aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/assets/javascript
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2012-07-05 00:30:02 +0200
committerJoas Schilling <nickvergessen@gmx.de>2012-07-05 01:03:19 +0200
commitf1056a9b2fd6e4ff7bc107372e9210bae9e077f0 (patch)
tree59b77442e1cfb1cd74ebb176fb84e21ea0f9e467 /phpBB/assets/javascript
parentfc3a19567f1852389dfa78472cca4b1d01387bfa (diff)
downloadforums-f1056a9b2fd6e4ff7bc107372e9210bae9e077f0.tar
forums-f1056a9b2fd6e4ff7bc107372e9210bae9e077f0.tar.gz
forums-f1056a9b2fd6e4ff7bc107372e9210bae9e077f0.tar.bz2
forums-f1056a9b2fd6e4ff7bc107372e9210bae9e077f0.tar.xz
forums-f1056a9b2fd6e4ff7bc107372e9210bae9e077f0.zip
[ticket/10811] Make toogle_subscribe more generic so it can toogle all links
PHPBB3-10811
Diffstat (limited to 'phpBB/assets/javascript')
-rw-r--r--phpBB/assets/javascript/core.js39
1 files changed, 23 insertions, 16 deletions
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js
index 3c1e39fca6..76615eb051 100644
--- a/phpBB/assets/javascript/core.js
+++ b/phpBB/assets/javascript/core.js
@@ -452,24 +452,31 @@ phpbb.add_ajax_callback('alt_text', function() {
* 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.
+ * Additionally it replaces the class of the link's parent
+ * and changes the link itself.
*/
-phpbb.add_ajax_callback('toggle_subscribe', function() {
+phpbb.add_ajax_callback('toggle_link', 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');
- }
+ 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