|
27 | 27 | var BootstrapSwitch; |
28 | 28 | BootstrapSwitch = (function() { |
29 | 29 | function BootstrapSwitch(element, options) { |
30 | | - var initInterval; |
31 | 30 | if (options == null) { |
32 | 31 | options = {}; |
33 | 32 | } |
|
110 | 109 | if (this.options.indeterminate) { |
111 | 110 | this.$element.prop("indeterminate", true); |
112 | 111 | } |
113 | | - initInterval = window.setInterval((function(_this) { |
114 | | - return function() { |
115 | | - if (_this.$wrapper.is(":visible")) { |
116 | | - _this._width(); |
117 | | - _this._containerPosition(null, function() { |
118 | | - if (_this.options.animate) { |
119 | | - return _this.$wrapper.addClass("" + _this.options.baseClass + "-animate"); |
120 | | - } |
121 | | - }); |
122 | | - return window.clearInterval(initInterval); |
123 | | - } |
124 | | - }; |
125 | | - })(this), 50); |
| 112 | + this._init(); |
126 | 113 | this._elementHandlers(); |
127 | 114 | this._handleHandlers(); |
128 | 115 | this._labelHandlers(); |
|
475 | 462 | }, 50); |
476 | 463 | }; |
477 | 464 |
|
| 465 | + BootstrapSwitch.prototype._init = function() { |
| 466 | + var init, initInterval; |
| 467 | + init = (function(_this) { |
| 468 | + return function() { |
| 469 | + _this._width(); |
| 470 | + return _this._containerPosition(null, function() { |
| 471 | + if (_this.options.animate) { |
| 472 | + return _this.$wrapper.addClass("" + _this.options.baseClass + "-animate"); |
| 473 | + } |
| 474 | + }); |
| 475 | + }; |
| 476 | + })(this); |
| 477 | + if (this.$wrapper.is(":visible")) { |
| 478 | + return init(); |
| 479 | + } |
| 480 | + return initInterval = window.setInterval((function(_this) { |
| 481 | + return function() { |
| 482 | + if (_this.$wrapper.is(":visible")) { |
| 483 | + init(); |
| 484 | + return window.clearInterval(initInterval); |
| 485 | + } |
| 486 | + }; |
| 487 | + })(this), 50); |
| 488 | + }; |
| 489 | + |
478 | 490 | BootstrapSwitch.prototype._elementHandlers = function() { |
479 | 491 | return this.$element.on({ |
480 | 492 | "change.bootstrapSwitch": (function(_this) { |
|
0 commit comments