Browse Source

Added support for onInit and onSwitchChange event

pauloortins 11 years ago
parent
commit
c2c7ce675f

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

@@ -283,6 +283,28 @@
         return this.$element;
         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() {
       BootstrapSwitch.prototype.destroy = function() {
         var $form;
         var $form;
         $form = this.$element.closest("form");
         $form = this.$element.closest("form");

File diff suppressed because it is too large
+ 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
       @options.wrapperClass = value
       @$element
       @$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: ->
     destroy: ->
       $form = @$element.closest "form"
       $form = @$element.closest "form"
 
 

Some files were not shown because too many files changed in this diff