ソースを参照

moved 'preOoptions' outside the @options because of semantic stuff: the user should not set these values

Mattia Larentis 10 年 前
コミット
ae3c4eaad2

+ 4 - 6
dist/js/bootstrap-switch.js

@@ -32,7 +32,6 @@
         }
         this.$element = $(element);
         this.options = $.extend({}, $.fn.bootstrapSwitch.defaults, {
-          prevOption: {},
           state: this.$element.is(":checked"),
           size: this.$element.data("size"),
           animate: this.$element.data("animate"),
@@ -51,6 +50,7 @@
           baseClass: this.$element.data("base-class"),
           wrapperClass: this.$element.data("wrapper-class")
         }, options);
+        this.prevOptions = {};
         this.$wrapper = $("<div>", {
           "class": (function(_this) {
             return function() {
@@ -128,7 +128,7 @@
       BootstrapSwitch.prototype._constructor = BootstrapSwitch;
 
       BootstrapSwitch.prototype.setPrevOptions = function() {
-        return this.options.prevOption = $.extend(true, {}, this.options);
+        return this.prevOptions = $.extend(true, {}, this.options);
       };
 
       BootstrapSwitch.prototype.state = function(value, skip) {
@@ -513,7 +513,7 @@
           })(this),
           "previousState.bootstrapSwitch": (function(_this) {
             return function(e) {
-              _this.options = _this.options.prevOption;
+              _this.options = _this.prevOptions;
               if (_this.options.indeterminate) {
                 _this.$wrapper.addClass(_this.options.baseClass + "-indeterminate");
               }
@@ -718,8 +718,7 @@
       return ret;
     };
     $.fn.bootstrapSwitch.Constructor = BootstrapSwitch;
-    $.fn.bootstrapSwitch.defaults = {
-      prevOption: {},
+    return $.fn.bootstrapSwitch.defaults = {
       state: true,
       size: null,
       animate: true,
@@ -740,7 +739,6 @@
       onInit: function() {},
       onSwitchChange: function() {}
     };
-    return $.fn.bootstrapSwitch.defaults.prevOption = $.extend(true, {}, $.fn.bootstrapSwitch.defaults);
   })(window.jQuery, window);
 
 }).call(this);

ファイルの差分が大きいため隠しています
+ 0 - 0
dist/js/bootstrap-switch.min.js


+ 3 - 5
src/coffee/bootstrap-switch.coffee

@@ -5,7 +5,6 @@ do ($ = window.jQuery, window) ->
     constructor: (element, options = {}) ->
       @$element = $ element
       @options = $.extend {}, $.fn.bootstrapSwitch.defaults,
-        prevOption: {}
         state: @$element.is ":checked"
         size: @$element.data "size"
         animate: @$element.data "animate"
@@ -24,6 +23,7 @@ do ($ = window.jQuery, window) ->
         baseClass: @$element.data "base-class"
         wrapperClass: @$element.data "wrapper-class"
       , options
+      @prevOptions = {}
       @$wrapper = $ "<div>",
         class: do =>
           classes = ["#{@options.baseClass}"].concat @_getClasses @options.wrapperClass
@@ -86,7 +86,7 @@ do ($ = window.jQuery, window) ->
     _constructor: BootstrapSwitch
 
     setPrevOptions: ->
-      @options.prevOption = $.extend(true, {}, @options)
+      @prevOptions = $.extend(true, {}, @options)
 
     state: (value, skip) ->
       return @options.state  if typeof value is "undefined"
@@ -378,7 +378,7 @@ do ($ = window.jQuery, window) ->
           @setPrevOptions()
 
         "previousState.bootstrapSwitch": (e) =>
-          @options = @options.prevOption
+          @options = @prevOptions
 
           @$wrapper.addClass "#{@options.baseClass}-indeterminate"  if @options.indeterminate
           @$element.prop("checked", @options.state).trigger "change.bootstrapSwitch", true
@@ -532,7 +532,6 @@ do ($ = window.jQuery, window) ->
 
   $.fn.bootstrapSwitch.Constructor = BootstrapSwitch
   $.fn.bootstrapSwitch.defaults =
-    prevOption: {}
     state: true
     size: null
     animate: true
@@ -552,4 +551,3 @@ do ($ = window.jQuery, window) ->
     wrapperClass: "wrapper"
     onInit: ->
     onSwitchChange: ->
-  $.fn.bootstrapSwitch.defaults.prevOption = $.extend(true, {}, $.fn.bootstrapSwitch.defaults)

+ 4 - 6
test/bootstrap-switch.js

@@ -32,7 +32,6 @@
         }
         this.$element = $(element);
         this.options = $.extend({}, $.fn.bootstrapSwitch.defaults, {
-          prevOption: {},
           state: this.$element.is(":checked"),
           size: this.$element.data("size"),
           animate: this.$element.data("animate"),
@@ -51,6 +50,7 @@
           baseClass: this.$element.data("base-class"),
           wrapperClass: this.$element.data("wrapper-class")
         }, options);
+        this.prevOptions = {};
         this.$wrapper = $("<div>", {
           "class": (function(_this) {
             return function() {
@@ -128,7 +128,7 @@
       BootstrapSwitch.prototype._constructor = BootstrapSwitch;
 
       BootstrapSwitch.prototype.setPrevOptions = function() {
-        return this.options.prevOption = $.extend(true, {}, this.options);
+        return this.prevOptions = $.extend(true, {}, this.options);
       };
 
       BootstrapSwitch.prototype.state = function(value, skip) {
@@ -513,7 +513,7 @@
           })(this),
           "previousState.bootstrapSwitch": (function(_this) {
             return function(e) {
-              _this.options = _this.options.prevOption;
+              _this.options = _this.prevOptions;
               if (_this.options.indeterminate) {
                 _this.$wrapper.addClass(_this.options.baseClass + "-indeterminate");
               }
@@ -718,8 +718,7 @@
       return ret;
     };
     $.fn.bootstrapSwitch.Constructor = BootstrapSwitch;
-    $.fn.bootstrapSwitch.defaults = {
-      prevOption: {},
+    return $.fn.bootstrapSwitch.defaults = {
       state: true,
       size: null,
       animate: true,
@@ -740,7 +739,6 @@
       onInit: function() {},
       onSwitchChange: function() {}
     };
-    return $.fn.bootstrapSwitch.defaults.prevOption = $.extend(true, {}, $.fn.bootstrapSwitch.defaults);
   })(window.jQuery, window);
 
 }).call(this);

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません