1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-28 20:40:24 +02:00

[ticket/10811] Make subscribe/unsubscribe repeatable with AJAX

PHPBB3-10811
This commit is contained in:
Joas Schilling
2012-04-18 17:03:24 +02:00
parent 286aebd93b
commit 53a47fdcc3
2 changed files with 27 additions and 2 deletions

View File

@@ -446,5 +446,30 @@ phpbb.add_ajax_callback('alt_text', function() {
el.text(alt_text);
});
/**
* This callback is based on the alt_text callback.
*
* It replaces the current text with the text in the alt-text data attribute,
* and replaces the text in the attribute with the current text so that the
* process can be repeated.
* Additionally it replaces the icon of the link and changes the link itself.
*/
phpbb.add_ajax_callback('toggle_subscribe', function() {
var el = $(this),
alt_text;
phpbb.ajax_callbacks['alt_text'].call(this);
if (el.attr('href').indexOf('unwatch') !== -1)
{
el.attr('href', el.attr('href').replace('unwatch', 'watch'));
el.parent().attr('class', 'icon-subscribe');
}
else
{
el.attr('href', el.attr('href').replace('watch', 'unwatch'));
el.parent().attr('class', 'icon-unsubscribe');
}
});
})(jQuery); // Avoid conflicts with other libraries