Add callback param to WCF.ToggleOptions
authorDaniel Rudolf <daniel.rudolf@eifel-online.com>
Tue, 26 Feb 2013 17:58:09 +0000 (18:58 +0100)
committerDaniel Rudolf <daniel.rudolf@eifel-online.com>
Tue, 26 Feb 2013 17:58:09 +0000 (18:58 +0100)
wcfsetup/install/files/js/WCF.js

index 01c3667e6d5f2e25e75e468875291e9131a8794d..1e172b1f0f2395c0cc920c7254b644c9f5fca478 100755 (executable)
@@ -3331,6 +3331,7 @@ WCF.Template.Compiled = Class.extend({
  * @param      string          element
  * @param      array           showItems
  * @param      array           hideItems
+ * @param      function        callback
  */
 WCF.ToggleOptions = Class.extend({
        /**
@@ -3353,6 +3354,13 @@ WCF.ToggleOptions = Class.extend({
         * @var array
         */
        _hideItems: [],
+               
+       /**
+        * callback after options were toggled
+        * 
+        * @var function
+        */
+        _callback: null,
        
        /**
         * Initializes option toggle.
@@ -3360,11 +3368,15 @@ WCF.ToggleOptions = Class.extend({
         * @param       string          element
         * @param       array           showItems
         * @param       array           hideItems
+        * @param       function        callback
         */
-       init: function(element, showItems, hideItems) {
+       init: function(element, showItems, hideItems, callback) {
                this._element = $('#' + element);
                this._showItems = showItems;
                this._hideItems = hideItems;
+               if (callback !== undefined) {
+                       this._callback = callback;
+               }
                
                // bind event
                this._element.click($.proxy(this._toggle, this));
@@ -3390,6 +3402,10 @@ WCF.ToggleOptions = Class.extend({
                        
                        $('#' + $item).hide();
                }
+               
+               if (this._callback !== null) {
+                       $.proxy(this._callback, this);
+               }
        }
 });