Added _toggleButton to allow custom toggeling effects
authorMagnus Kühn <magnus.khn@gmail.com>
Sun, 30 Dec 2012 10:34:02 +0000 (11:34 +0100)
committerMagnus Kühn <magnus.khn@gmail.com>
Sun, 30 Dec 2012 10:34:02 +0000 (11:34 +0100)
wcfsetup/install/files/js/WCF.js

index 4c1af8576e59ffbfb420581de32e027df61b1c2f..0462009fa5a3826383b0becf68adb2afbf77ab83 100755 (executable)
@@ -1887,42 +1887,52 @@ WCF.Action.Toggle = Class.extend({
         */
        triggerEffect: function(objectIDs) {
                this.containerList.each($.proxy(function(index, container) {
-                       var $toggleButton = $(container).find(this.toggleButtonSelector);
+                       var $container = $(container);
+                       var $toggleButton = $container.find(this.toggleButtonSelector);
                        if (WCF.inArray($toggleButton.data('objectID'), objectIDs)) {
-                               $(container).wcfHighlight();
-                               
-                               // toggle icon source
-                               $toggleButton.attr('src', function() {
-                                       if (this.src.match(/disabled\.svg$/)) {
-                                               return this.src.replace(/disabled\.svg$/, 'enabled.svg');
-                                       }
-                                       else {
-                                               return this.src.replace(/enabled\.svg$/, 'disabled.svg');
-                                       }
-                               });
-                               
-                               // toogle icon title
-                               $toggleButton.attr('title', function() {
-                                       if (this.src.match(/enabled\.svg$/)) {
-                                               if ($(this).data('disableTitle')) {
-                                                       return $(this).data('disableTitle');
-                                               }
-                                               
-                                               return WCF.Language.get('wcf.global.button.disable');
-                                       }
-                                       else {
-                                               if ($(this).data('enableTitle')) {
-                                                       return $(this).data('enableTitle');
-                                               }
-                                               
-                                               return WCF.Language.get('wcf.global.button.enable');
-                                       }
-                               });
-                               
-                               // toggle css class
-                               $(container).toggleClass('disabled');
+                               $container.wcfHighlight();
+                               this._toggleButton($container, $toggleButton);
                        }
                }, this));
+       },
+       
+       /**
+        * Tiggers the toggle effect on a button
+        * 
+        * @param       jQuery  $container
+        * @param       jQuery  $toggleButton
+        */
+       _toggleButton: function($container, $toggleButton) {
+               // toggle icon source
+               $toggleButton.attr('src', function() {
+                       if (this.src.match(/disabled\.svg$/)) {
+                               return this.src.replace(/disabled\.svg$/, 'enabled.svg');
+                       }
+                       else {
+                               return this.src.replace(/enabled\.svg$/, 'disabled.svg');
+                       }
+               });
+
+               // toogle icon title
+               $toggleButton.attr('title', function() {
+                       if (this.src.match(/enabled\.svg$/)) {
+                               if ($(this).data('disableTitle')) {
+                                       return $(this).data('disableTitle');
+                               }
+
+                               return WCF.Language.get('wcf.global.button.disable');
+                       }
+                       else {
+                               if ($(this).data('enableTitle')) {
+                                       return $(this).data('enableTitle');
+                               }
+
+                               return WCF.Language.get('wcf.global.button.enable');
+                       }
+               });
+
+               // toggle css class
+               $container.toggleClass('disabled');
        }
 });