|
@@ -20,7 +20,7 @@
|
|
|
*/
|
|
|
|
|
|
(function() {
|
|
|
- var __slice = [].slice;
|
|
|
+ var slice = [].slice;
|
|
|
|
|
|
(function($, window) {
|
|
|
"use strict";
|
|
@@ -55,43 +55,43 @@
|
|
|
return function() {
|
|
|
var classes;
|
|
|
classes = ["" + _this.options.baseClass].concat(_this._getClasses(_this.options.wrapperClass));
|
|
|
- classes.push(_this.options.state ? "" + _this.options.baseClass + "-on" : "" + _this.options.baseClass + "-off");
|
|
|
+ classes.push(_this.options.state ? _this.options.baseClass + "-on" : _this.options.baseClass + "-off");
|
|
|
if (_this.options.size != null) {
|
|
|
- classes.push("" + _this.options.baseClass + "-" + _this.options.size);
|
|
|
+ classes.push(_this.options.baseClass + "-" + _this.options.size);
|
|
|
}
|
|
|
if (_this.options.disabled) {
|
|
|
- classes.push("" + _this.options.baseClass + "-disabled");
|
|
|
+ classes.push(_this.options.baseClass + "-disabled");
|
|
|
}
|
|
|
if (_this.options.readonly) {
|
|
|
- classes.push("" + _this.options.baseClass + "-readonly");
|
|
|
+ classes.push(_this.options.baseClass + "-readonly");
|
|
|
}
|
|
|
if (_this.options.indeterminate) {
|
|
|
- classes.push("" + _this.options.baseClass + "-indeterminate");
|
|
|
+ classes.push(_this.options.baseClass + "-indeterminate");
|
|
|
}
|
|
|
if (_this.options.inverse) {
|
|
|
- classes.push("" + _this.options.baseClass + "-inverse");
|
|
|
+ classes.push(_this.options.baseClass + "-inverse");
|
|
|
}
|
|
|
if (_this.$element.attr("id")) {
|
|
|
- classes.push("" + _this.options.baseClass + "-id-" + (_this.$element.attr("id")));
|
|
|
+ classes.push(_this.options.baseClass + "-id-" + (_this.$element.attr("id")));
|
|
|
}
|
|
|
return classes.join(" ");
|
|
|
};
|
|
|
})(this)()
|
|
|
});
|
|
|
this.$container = $("<div>", {
|
|
|
- "class": "" + this.options.baseClass + "-container"
|
|
|
+ "class": this.options.baseClass + "-container"
|
|
|
});
|
|
|
this.$on = $("<span>", {
|
|
|
html: this.options.onText,
|
|
|
- "class": "" + this.options.baseClass + "-handle-on " + this.options.baseClass + "-" + this.options.onColor
|
|
|
+ "class": this.options.baseClass + "-handle-on " + this.options.baseClass + "-" + this.options.onColor
|
|
|
});
|
|
|
this.$off = $("<span>", {
|
|
|
html: this.options.offText,
|
|
|
- "class": "" + this.options.baseClass + "-handle-off " + this.options.baseClass + "-" + this.options.offColor
|
|
|
+ "class": this.options.baseClass + "-handle-off " + this.options.baseClass + "-" + this.options.offColor
|
|
|
});
|
|
|
this.$label = $("<span>", {
|
|
|
html: this.options.labelText,
|
|
|
- "class": "" + this.options.baseClass + "-label"
|
|
|
+ "class": this.options.baseClass + "-label"
|
|
|
});
|
|
|
this.$element.on("init.bootstrapSwitch", (function(_this) {
|
|
|
return function() {
|
|
@@ -155,10 +155,10 @@
|
|
|
return this.options.size;
|
|
|
}
|
|
|
if (this.options.size != null) {
|
|
|
- this.$wrapper.removeClass("" + this.options.baseClass + "-" + this.options.size);
|
|
|
+ this.$wrapper.removeClass(this.options.baseClass + "-" + this.options.size);
|
|
|
}
|
|
|
if (value) {
|
|
|
- this.$wrapper.addClass("" + this.options.baseClass + "-" + value);
|
|
|
+ this.$wrapper.addClass(this.options.baseClass + "-" + value);
|
|
|
}
|
|
|
this._width();
|
|
|
this._containerPosition();
|
|
@@ -179,7 +179,7 @@
|
|
|
|
|
|
BootstrapSwitch.prototype.toggleAnimate = function() {
|
|
|
this.options.animate = !this.options.animate;
|
|
|
- this.$wrapper.toggleClass("" + this.options.baseClass + "-animate");
|
|
|
+ this.$wrapper.toggleClass(this.options.baseClass + "-animate");
|
|
|
return this.$element;
|
|
|
};
|
|
|
|
|
@@ -197,7 +197,7 @@
|
|
|
BootstrapSwitch.prototype.toggleDisabled = function() {
|
|
|
this.options.disabled = !this.options.disabled;
|
|
|
this.$element.prop("disabled", this.options.disabled);
|
|
|
- this.$wrapper.toggleClass("" + this.options.baseClass + "-disabled");
|
|
|
+ this.$wrapper.toggleClass(this.options.baseClass + "-disabled");
|
|
|
return this.$element;
|
|
|
};
|
|
|
|
|
@@ -215,7 +215,7 @@
|
|
|
BootstrapSwitch.prototype.toggleReadonly = function() {
|
|
|
this.options.readonly = !this.options.readonly;
|
|
|
this.$element.prop("readonly", this.options.readonly);
|
|
|
- this.$wrapper.toggleClass("" + this.options.baseClass + "-readonly");
|
|
|
+ this.$wrapper.toggleClass(this.options.baseClass + "-readonly");
|
|
|
return this.$element;
|
|
|
};
|
|
|
|
|
@@ -233,7 +233,7 @@
|
|
|
BootstrapSwitch.prototype.toggleIndeterminate = function() {
|
|
|
this.options.indeterminate = !this.options.indeterminate;
|
|
|
this.$element.prop("indeterminate", this.options.indeterminate);
|
|
|
- this.$wrapper.toggleClass("" + this.options.baseClass + "-indeterminate");
|
|
|
+ this.$wrapper.toggleClass(this.options.baseClass + "-indeterminate");
|
|
|
this._containerPosition();
|
|
|
return this.$element;
|
|
|
};
|
|
@@ -251,7 +251,7 @@
|
|
|
|
|
|
BootstrapSwitch.prototype.toggleInverse = function() {
|
|
|
var $off, $on;
|
|
|
- this.$wrapper.toggleClass("" + this.options.baseClass + "-inverse");
|
|
|
+ this.$wrapper.toggleClass(this.options.baseClass + "-inverse");
|
|
|
$on = this.$on.clone(true);
|
|
|
$off = this.$off.clone(true);
|
|
|
this.$on.replaceWith($off);
|
|
@@ -269,9 +269,9 @@
|
|
|
return color;
|
|
|
}
|
|
|
if (color != null) {
|
|
|
- this.$on.removeClass("" + this.options.baseClass + "-" + color);
|
|
|
+ this.$on.removeClass(this.options.baseClass + "-" + color);
|
|
|
}
|
|
|
- this.$on.addClass("" + this.options.baseClass + "-" + value);
|
|
|
+ this.$on.addClass(this.options.baseClass + "-" + value);
|
|
|
this.options.onColor = value;
|
|
|
return this.$element;
|
|
|
};
|
|
@@ -283,9 +283,9 @@
|
|
|
return color;
|
|
|
}
|
|
|
if (color != null) {
|
|
|
- this.$off.removeClass("" + this.options.baseClass + "-" + color);
|
|
|
+ this.$off.removeClass(this.options.baseClass + "-" + color);
|
|
|
}
|
|
|
- this.$off.addClass("" + this.options.baseClass + "-" + value);
|
|
|
+ this.$off.addClass(this.options.baseClass + "-" + value);
|
|
|
this.options.offColor = value;
|
|
|
return this.$element;
|
|
|
};
|
|
@@ -459,7 +459,7 @@
|
|
|
}
|
|
|
return setTimeout(function() {
|
|
|
return callback();
|
|
|
- }, 50);
|
|
|
+ }, 25);
|
|
|
};
|
|
|
|
|
|
BootstrapSwitch.prototype._init = function() {
|
|
@@ -469,7 +469,7 @@
|
|
|
_this._width();
|
|
|
return _this._containerPosition(null, function() {
|
|
|
if (_this.options.animate) {
|
|
|
- return _this.$wrapper.addClass("" + _this.options.baseClass + "-animate");
|
|
|
+ return _this.$wrapper.addClass(_this.options.baseClass + "-animate");
|
|
|
}
|
|
|
});
|
|
|
};
|
|
@@ -484,7 +484,7 @@
|
|
|
return window.clearInterval(initInterval);
|
|
|
}
|
|
|
};
|
|
|
- })(this), 50);
|
|
|
+ })(this), 25);
|
|
|
};
|
|
|
|
|
|
BootstrapSwitch.prototype._elementHandlers = function() {
|
|
@@ -500,7 +500,7 @@
|
|
|
return;
|
|
|
}
|
|
|
_this.options.state = state;
|
|
|
- _this.$wrapper.toggleClass("" + _this.options.baseClass + "-off").toggleClass("" + _this.options.baseClass + "-on");
|
|
|
+ _this.$wrapper.toggleClass(_this.options.baseClass + "-off").toggleClass(_this.options.baseClass + "-on");
|
|
|
if (!skip) {
|
|
|
if (_this.$element.is(":radio")) {
|
|
|
$("[name='" + (_this.$element.attr('name')) + "']").not(_this.$element).prop("checked", false).trigger("change.bootstrapSwitch", true);
|
|
@@ -512,13 +512,13 @@
|
|
|
"focus.bootstrapSwitch": (function(_this) {
|
|
|
return function(e) {
|
|
|
e.preventDefault();
|
|
|
- return _this.$wrapper.addClass("" + _this.options.baseClass + "-focused");
|
|
|
+ return _this.$wrapper.addClass(_this.options.baseClass + "-focused");
|
|
|
};
|
|
|
})(this),
|
|
|
"blur.bootstrapSwitch": (function(_this) {
|
|
|
return function(e) {
|
|
|
e.preventDefault();
|
|
|
- return _this.$wrapper.removeClass("" + _this.options.baseClass + "-focused");
|
|
|
+ return _this.$wrapper.removeClass(_this.options.baseClass + "-focused");
|
|
|
};
|
|
|
})(this),
|
|
|
"keydown.bootstrapSwitch": (function(_this) {
|
|
@@ -571,7 +571,7 @@
|
|
|
e.stopPropagation();
|
|
|
_this._dragStart = (e.pageX || e.originalEvent.touches[0].pageX) - parseInt(_this.$container.css("margin-left"), 10);
|
|
|
if (_this.options.animate) {
|
|
|
- _this.$wrapper.removeClass("" + _this.options.baseClass + "-animate");
|
|
|
+ _this.$wrapper.removeClass(_this.options.baseClass + "-animate");
|
|
|
}
|
|
|
return _this.$element.trigger("focus.bootstrapSwitch");
|
|
|
};
|
|
@@ -588,7 +588,7 @@
|
|
|
return;
|
|
|
}
|
|
|
_this._dragEnd = difference;
|
|
|
- return _this.$container.css("margin-left", "" + _this._dragEnd + "px");
|
|
|
+ return _this.$container.css("margin-left", _this._dragEnd + "px");
|
|
|
};
|
|
|
})(this),
|
|
|
"mouseup.bootstrapSwitch touchend.bootstrapSwitch": (function(_this) {
|
|
@@ -599,7 +599,7 @@
|
|
|
}
|
|
|
e.preventDefault();
|
|
|
if (_this.options.animate) {
|
|
|
- _this.$wrapper.addClass("" + _this.options.baseClass + "-animate");
|
|
|
+ _this.$wrapper.addClass(_this.options.baseClass + "-animate");
|
|
|
}
|
|
|
if (_this._dragEnd) {
|
|
|
state = _this._dragEnd > -(_this._handleWidth / 2);
|
|
@@ -651,14 +651,14 @@
|
|
|
};
|
|
|
|
|
|
BootstrapSwitch.prototype._getClasses = function(classes) {
|
|
|
- var c, cls, _i, _len;
|
|
|
+ var c, cls, i, len;
|
|
|
if (!$.isArray(classes)) {
|
|
|
- return ["" + this.options.baseClass + "-" + classes];
|
|
|
+ return [this.options.baseClass + "-" + classes];
|
|
|
}
|
|
|
cls = [];
|
|
|
- for (_i = 0, _len = classes.length; _i < _len; _i++) {
|
|
|
- c = classes[_i];
|
|
|
- cls.push("" + this.options.baseClass + "-" + c);
|
|
|
+ for (i = 0, len = classes.length; i < len; i++) {
|
|
|
+ c = classes[i];
|
|
|
+ cls.push(this.options.baseClass + "-" + c);
|
|
|
}
|
|
|
return cls;
|
|
|
};
|
|
@@ -668,7 +668,7 @@
|
|
|
})();
|
|
|
$.fn.bootstrapSwitch = function() {
|
|
|
var args, option, ret;
|
|
|
- option = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
|
|
+ option = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
|
|
ret = this;
|
|
|
this.each(function() {
|
|
|
var $this, data;
|