/* ======================================================================== * bootstrap-switch - v3.0.0 * http://www.bootstrap-switch.org * ======================================================================== * Copyright 2012-2013 Mattia Larentis * * ======================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ======================================================================== */ (function() { var __slice = [].slice; (function($, window) { "use strict"; var BootstrapSwitch; BootstrapSwitch = (function() { BootstrapSwitch.prototype.name = "bootstrap-switch"; function BootstrapSwitch(element, options) { if (options == null) { options = {}; } this.$element = $(element); this.options = $.extend({}, $.fn.bootstrapSwitch.defaults, options, { state: this.$element.is(":checked"), size: this.$element.data("size"), animate: this.$element.data("animate"), disabled: this.$element.is(":disabled"), readonly: this.$element.is("[readonly]"), onColor: this.$element.data("on-color"), offColor: this.$element.data("off-color"), onText: this.$element.data("on-text"), offText: this.$element.data("off-text"), labelText: this.$element.data("label-text"), onModifierClass: "on", offModifierClass: "off", focusedModifierClass: "focused", animateModifierClass: "animate", disabledModifierClass: "disabled", readonlyModifierClass: "readonly" }); this.$wrapper = $("
", { "class": (function(_this) { return function() { var classes; classes = ["" + _this.options.baseClass]; classes.push((function() { var c, cls, _i, _len, _ref, _results; if (!$.isArray(_this.options.wrapperClass)) { return "" + _this.options.baseClass + "-" + _this.options.wrapperClass; } cls = []; _ref = _this.options.wrapperClass; _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { c = _ref[_i]; _results.push(cls.push("" + _this.options.baseClass + "-" + c)); } return _results; })()); classes.push(_this.options.state ? "" + _this.options.baseClass + "-" + _this.options.onModifierClass : "" + _this.options.baseClass + "-" + _this.options.offModifierClass); if (_this.options.size != null) { classes.push("" + _this.options.baseClass + "-" + _this.options.size); } if (_this.options.animate) { classes.push("" + _this.options.baseClass + "-" + _this.options.animateModifierClass); } if (_this.options.disabled) { classes.push("" + _this.options.baseClass + "-" + _this.options.disabledModifierClass); } if (_this.options.readonly) { classes.push("" + _this.options.baseClass + "-" + _this.options.readonlyModifierClass); } if (_this.$element.attr("id")) { classes.push("" + _this.options.baseClass + "-id-" + (_this.$element.attr("id"))); } return classes.join(" "); }; })(this)() }); this.$container = $("
", { "class": "" + this.options.baseClass + "-container" }); this.$on = $("", { html: this.options.onText, "class": "" + this.options.baseClass + "-handle-on " + this.options.baseClass + "-" + this.options.onColor }); this.$off = $("", { html: this.options.offText, "class": "" + this.options.baseClass + "-handle-off " + this.options.baseClass + "-" + this.options.offColor }); this.$label = $("