diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2012-04-18 17:03:24 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2012-04-29 12:33:55 +0200 |
commit | 53a47fdcc323a5d7dc3696215cc47285a0c99042 (patch) | |
tree | 1991f0352796f78abdf0d38257c230407ab5f8e8 /phpBB/assets | |
parent | 286aebd93bd49eac2ff80c3a6930f7f692a4c3ef (diff) | |
download | forums-53a47fdcc323a5d7dc3696215cc47285a0c99042.tar forums-53a47fdcc323a5d7dc3696215cc47285a0c99042.tar.gz forums-53a47fdcc323a5d7dc3696215cc47285a0c99042.tar.bz2 forums-53a47fdcc323a5d7dc3696215cc47285a0c99042.tar.xz forums-53a47fdcc323a5d7dc3696215cc47285a0c99042.zip |
[ticket/10811] Make subscribe/unsubscribe repeatable with AJAX
PHPBB3-10811
Diffstat (limited to 'phpBB/assets')
-rw-r--r-- | phpBB/assets/javascript/core.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 74c71fca79..3c1e39fca6 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -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 |