Explorar o código

Added support for onInit and onSwitchChange event

pauloortins %!s(int64=11) %!d(string=hai) anos
pai
achega
c2c7ce675f

+ 22 - 0
dist/js/bootstrap-switch.js

@@ -283,6 +283,28 @@
         return this.$element;
       };
 
+      BootstrapSwitch.prototype.onInit = function(value) {
+        if (typeof value === "undefined") {
+          return this.options.onInit;
+        }
+        if (!value) {
+          value = $.fn.bootstrapSwitch.defaults.onInit;
+        }
+        this.options.onInit = value;
+        return this.$element;
+      };
+
+      BootstrapSwitch.prototype.onSwitchChange = function(value) {
+        if (typeof value === "undefined") {
+          return this.options.onSwitchChange;
+        }
+        if (!value) {
+          value = $.fn.bootstrapSwitch.defaults.onSwitchChange;
+        }
+        this.options.onSwitchChange = value;
+        return this.$element;
+      };
+
       BootstrapSwitch.prototype.destroy = function() {
         var $form;
         $form = this.$element.closest("form");

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
dist/js/bootstrap-switch.min.js


+ 16 - 0
src/coffee/bootstrap-switch.coffee

@@ -203,6 +203,22 @@ do ($ = window.jQuery, window) ->
       @options.wrapperClass = value
       @$element
 
+    onInit: (value) ->
+      return @options.onInit if typeof value is "undefined"
+
+      value = $.fn.bootstrapSwitch.defaults.onInit unless value
+
+      @options.onInit = value
+      @$element
+
+    onSwitchChange: (value) ->
+      return @options.onSwitchChange if typeof value is "undefined"
+
+      value = $.fn.bootstrapSwitch.defaults.onSwitchChange unless value
+
+      @options.onSwitchChange = value
+      @$element
+
     destroy: ->
       $form = @$element.closest "form"
 

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio