aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/assets/javascript/core.js
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2012-07-18 11:07:32 +0200
committerJoas Schilling <nickvergessen@gmx.de>2012-07-18 11:07:32 +0200
commitf4136eacdc319b2029692a9c19a845a115b94129 (patch)
treef610d14df9e80ee74e8b35e4e8b8183170555f02 /phpBB/assets/javascript/core.js
parent3637cd395e39c1fa5b7279222abe1da5d2abcd00 (diff)
parentb176b86f111a05338ed3c74026bcf19d42ec0ee3 (diff)
downloadforums-f4136eacdc319b2029692a9c19a845a115b94129.tar
forums-f4136eacdc319b2029692a9c19a845a115b94129.tar.gz
forums-f4136eacdc319b2029692a9c19a845a115b94129.tar.bz2
forums-f4136eacdc319b2029692a9c19a845a115b94129.tar.xz
forums-f4136eacdc319b2029692a9c19a845a115b94129.zip
Merge branch 'develop' of git://github.com/phpbb/phpbb3 into feature/new-tz-handling
Diffstat (limited to 'phpBB/assets/javascript/core.js')
-rw-r--r--phpBB/assets/javascript/core.js35
1 files changed, 34 insertions, 1 deletions
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js
index ab1aaa8505..f07a245307 100644
--- a/phpBB/assets/javascript/core.js
+++ b/phpBB/assets/javascript/core.js
@@ -521,14 +521,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