diff options
author | Oleg Pudeyev <oleg@bsdpower.com> | 2012-07-05 10:44:48 -0400 |
---|---|---|
committer | Oleg Pudeyev <oleg@bsdpower.com> | 2012-07-05 10:44:48 -0400 |
commit | d9fd0cce0a5b323bff785af401e90370a3d73972 (patch) | |
tree | fad7e45e42186efaef6365dcb83c6dca87d8ae57 /phpBB/assets/javascript/core.js | |
parent | c54d74ec0ed24a9ee7c0d722eb185f1c8a58aab9 (diff) | |
parent | f1056a9b2fd6e4ff7bc107372e9210bae9e077f0 (diff) | |
download | forums-d9fd0cce0a5b323bff785af401e90370a3d73972.tar forums-d9fd0cce0a5b323bff785af401e90370a3d73972.tar.gz forums-d9fd0cce0a5b323bff785af401e90370a3d73972.tar.bz2 forums-d9fd0cce0a5b323bff785af401e90370a3d73972.tar.xz forums-d9fd0cce0a5b323bff785af401e90370a3d73972.zip |
Merge PR #759 branch 'nickvergessen/ticket/10811' into develop
* nickvergessen/ticket/10811:
[ticket/10811] Make toogle_subscribe more generic so it can toogle all links
[ticket/10811] Make it easier for MODs/Extensions to define the alt-text
[ticket/10811] Make subscribe/unsubscribe repeatable with AJAX
[ticket/10811] Fix AJAX callback alt_text so it can be repeated.
Diffstat (limited to 'phpBB/assets/javascript/core.js')
-rw-r--r-- | phpBB/assets/javascript/core.js | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 958b6c9ff6..76615eb051 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -436,14 +436,47 @@ phpbb.add_ajax_callback = function(id, callback) * the alt-text data attribute, and replaces the text in the attribute with the * current text so that the process can be repeated. */ -phpbb.add_ajax_callback('alt_text', function(data) { +phpbb.add_ajax_callback('alt_text', function() { var el = $(this), alt_text; alt_text = el.attr('data-alt-text'); + el.attr('data-alt-text', el.text()); el.attr('title', alt_text); 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 class of the link's parent + * and changes the link itself. + */ +phpbb.add_ajax_callback('toggle_link', function() { + var el = $(this), + toggle_text, + toggle_url, + toggle_class; + + // Toggle link text + + toggle_text = el.attr('data-toggle-text'); + el.attr('data-toggle-text', el.text()); + el.attr('title', toggle_text); + el.text(toggle_text); + + // Toggle link url + toggle_url = el.attr('data-toggle-url'); + el.attr('data-toggle-url', el.attr('href')); + el.attr('href', toggle_url); + + // Toggle class of link parent + toggle_class = el.attr('data-toggle-class'); + el.attr('data-toggle-class', el.parent().attr('class')); + el.parent().attr('class', toggle_class); +}); })(jQuery); // Avoid conflicts with other libraries |