You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
11 KiB
22 lines
11 KiB
11 years ago
|
/* ========================================================================
|
||
|
* 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 t=[].slice;!function(o,e){"use strict";var s;return s=function(){function t(t,e){var s;null==e&&(e={}),this.$element=o(t),this.options=o.extend({},o.fn.bootstrapSwitch.defaults,e,{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")}),this.$wrapper=o("<div>"),this.$container=o("<div>"),this.$on=o("<span>",{html:this.options.onText}),this.$off=o("<span>",{html:this.options.offText}),this.$label=o("<label>",{"for":this.$element.attr("id"),html:this.options.labelText}),s=function(t){return function(e){var s,i,n,a;if(!o.isArray(e))return""+t.options.baseClass+"-"+e;for(i=[],n=0,a=e.length;a>n;n++)s=e[n],i.push(""+t.options.baseClass+"-"+s);return i.join(" ")}}(this),this.$wrapper.addClass(function(t){return function(){var o;return o=[""+t.options.baseClass,""+t.options.baseClass+"-"+t.options.wrapperClass],o.push(t.options.state?""+t.options.baseClass+"-"+t.options.onModifierClass:""+t.options.baseClass+"-"+t.options.offModifierClass),null!=t.options.size&&o.push(""+t.options.baseClass+"-"+t.options.size),t.options.animate&&o.push(""+t.options.baseClass+"-"+t.options.animateModifierClass),t.options.disabled&&o.push(""+t.options.baseClass+"-"+t.options.disabledModifierClass),t.options.readonly&&o.push(""+t.options.baseClass+"-"+t.options.readonlyModifierClass),t.$element.attr("id")&&o.push(""+t.options.baseClass+"-id-"+t.$element.attr("id")),o.join(" ")}}(this)),this.$container.addClass(s(this.options.containerClass)),this.$on.addClass(""+s(this.options.handleOnClass)+" "+this.options.baseClass+"-"+this.options.onColor),this.$off.addClass(""+s(this.options.handleOffClass)+" "+this.options.baseClass+"-"+this.options.offColor),this.$label.addClass(s(this.options.labelClass)),this.$element.on("init.bootstrapSwitch",function(o){return function(){return o.options.onInit.apply(t,arguments)}}(this)),this.$element.on("switchChange.bootstrapSwitch",function(o){return function(){return o.options.onSwitchChange.apply(t,arguments)}}(this)),this.$container=this.$element.wrap(this.$container).parent(),this.$wrapper=this.$container.wrap(this.$wrapper).parent(),this.$element.before(this.$on).before(this.$label).before(this.$off).trigger("init.bootstrapSwitch"),this._elementHandlers(),this._handleHandlers(),this._labelHandlers(),this._formHandler()}return t.prototype.name="bootstrap-switch",t.prototype._constructor=t,t.prototype.state=function(t,o){return"undefined"==typeof t?this.options.state:this.options.disabled||this.options.readonly?this.$element:(t=!!t,this.$element.prop("checked",t).trigger("change.bootstrapSwitch",o),this.$element)},t.prototype.toggleState=function(t){return this.options.disabled||this.options.readonly?this.$element:this.$element.prop("checked",!this.options.state).trigger("change.bootstrapSwitch",t)},t.prototype.size=function(t){return"undefined"==typeof t?this.options.size:(null!=this.options.size&&this.$wrapper.removeClass(""+this.options.baseClass+"-"+this.options.size),this.$wrapper.addClass(""+this.options.baseClass+"-"+t),this.options.size=t,this.$element)},t.prototype.animate=function(t){return"undefined"==typeof t?this.options.animate:(t=!!t,this.$wrapper[t?"addClass":"removeClass"](""+this.options.baseClass+"-"+this.options.animateModifierClass),this.options.animate=t,this.$element)},t.prototype.disabled=function(t){return"undefined"==typeof t?this.options.disabled:(t=!!t,this.$wrapper[t?"addClass":"removeClass"](""+this.options.baseClass+"-"+this.options.disabledModifierClass),this.$element.prop("disabled",t),this.options.disabled=t,this.$element)},t.prototype.toggleDisabled=function(){return this.$element.prop("disabled",!this.options.disabled),this.$wrapper.toggleClass(""+this.options.baseClass+"-"+this.options.disabledModifierClass),this.options.disabled=!this.op
|