diff options
author | Varun Agrawal <Varun@VarunAgw.com> | 2014-04-10 23:43:37 +0530 |
---|---|---|
committer | Varun Agrawal <Varun@VarunAgw.com> | 2014-04-11 10:12:35 +0530 |
commit | 285b7a1f4c8dc3685efb04818747465e91be22c9 (patch) | |
tree | 7617512ab46d7a23fe5284ef58001613f72f45cd /phpBB/assets/javascript | |
parent | 377fb770fb37f4fb797ab234e44c4d387d4f8a64 (diff) | |
download | forums-285b7a1f4c8dc3685efb04818747465e91be22c9.tar forums-285b7a1f4c8dc3685efb04818747465e91be22c9.tar.gz forums-285b7a1f4c8dc3685efb04818747465e91be22c9.tar.bz2 forums-285b7a1f4c8dc3685efb04818747465e91be22c9.tar.xz forums-285b7a1f4c8dc3685efb04818747465e91be22c9.zip |
[ticket/12355] Topic Tools not fully updated when subscribing/bookmarking
The Topic Tools menu appears at the top of a topic page and again at the
bottom of a topic page.
When you use the Topic Tools menu to Bookmark or Subscribe to a Topic, the
menu item you chose is updated to reflect that, by switching to say
Unsubscribe topic or Remove from Bookmarks.
However, this change is not mirrored in the other Topic Tools menu at the
other location on the page.
Both Topic Tools menus should be updated during the AJAX event, so that
they always show the same options to the user.
It is solved by creating a data-update-all attribute which contains all
the class/ID that will update when topic tool is clicked
PHPBB3-12355
Diffstat (limited to 'phpBB/assets/javascript')
-rw-r--r-- | phpBB/assets/javascript/core.js | 58 |
1 files changed, 39 insertions, 19 deletions
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index aa9dc9af82..ca62a5f649 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -549,13 +549,23 @@ phpbb.addAjaxCallback = function(id, callback) { * current text so that the process can be repeated. */ phpbb.addAjaxCallback('alt_text', function() { - var el = $(this), + var el, + updateAll = $(this).data('update-all'), altText; - altText = el.attr('data-alt-text'); - el.attr('data-alt-text', el.text()); - el.attr('title', altText); - el.text(altText); + if (updateAll !== undefined && updateAll.length) { + el = $(updateAll); + } else { + el = $(this); + } + + el.each(function() { + var el = $(this); + altText = el.attr('data-alt-text'); + el.attr('data-alt-text', el.text()); + el.attr('title', $.trim(altText)); + el.text(altText); + }); }); /** @@ -568,27 +578,37 @@ phpbb.addAjaxCallback('alt_text', function() { * and changes the link itself. */ phpbb.addAjaxCallback('toggle_link', function() { - var el = $(this), + var el, + updateAll = $(this).data('update-all') , toggleText, toggleUrl, toggleClass; - // Toggle link text + if (updateAll !== undefined && updateAll.length) { + el = $(updateAll); + } else { + el = $(this); + } - toggleText = el.attr('data-toggle-text'); - el.attr('data-toggle-text', el.text()); - el.attr('title', toggleText); - el.text(toggleText); + el.each(function() { + var el = $(this); - // Toggle link url - toggleUrl = el.attr('data-toggle-url'); - el.attr('data-toggle-url', el.attr('href')); - el.attr('href', toggleUrl); + // Toggle link text + toggleText = el.attr('data-toggle-text'); + el.attr('data-toggle-text', el.text()); + el.attr('title', $.trim(toggleText)); + el.text(toggleText); - // Toggle class of link parent - toggleClass = el.attr('data-toggle-class'); - el.attr('data-toggle-class', el.parent().attr('class')); - el.parent().attr('class', toggleClass); + // Toggle link url + toggleUrl = el.attr('data-toggle-url'); + el.attr('data-toggle-url', el.attr('href')); + el.attr('href', toggleUrl); + + // Toggle class of link parent + toggleClass = el.attr('data-toggle-class'); + el.attr('data-toggle-class', el.parent().attr('class')); + el.parent().attr('class', toggleClass); + }); }); /** |