11 lines
14 KiB
JavaScript
11 lines
14 KiB
JavaScript
|
/**
|
||
|
* bootstrap-switch - Turn checkboxes and radio buttons into toggle switches.
|
||
|
*
|
||
|
* @version v3.4.0
|
||
|
* @homepage https://bttstrp.github.io/bootstrap-switch
|
||
|
* @author Mattia Larentis <mattia@larentis.eu> (http://larentis.eu)
|
||
|
* @license MIT
|
||
|
*/
|
||
|
|
||
|
(function(a,b){if('function'==typeof define&&define.amd)define(['jquery'],b);else if('undefined'!=typeof exports)b(require('jquery'));else{b(a.jquery),a.bootstrapSwitch={exports:{}}.exports}})(this,function(a){'use strict';function c(x,y){if(!(x instanceof y))throw new TypeError('Cannot call a class as a function')}function d(x,y){var z=x.state,A=x.size,B=x.disabled,C=x.readonly,D=x.indeterminate,E=x.inverse;return[z?'on':'off',A,B?'disabled':void 0,C?'readonly':void 0,D?'indeterminate':void 0,E?'inverse':void 0,y?'id-'+y:void 0].filter(function(F){return null==F})}function e(){return{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]'),indeterminate:this.$element.data('indeterminate'),inverse:this.$element.data('inverse'),radioAllOff:this.$element.data('radio-all-off'),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'),handleWidth:this.$element.data('handle-width'),labelWidth:this.$element.data('label-width'),baseClass:this.$element.data('base-class'),wrapperClass:this.$element.data('wrapper-class')}}function f(){var x=this,y=this.$on.add(this.$off).add(this.$label).css('width',''),z='auto'===this.options.handleWidth?Math.round(Math.max(this.$on.width(),this.$off.width())):this.options.handleWidth;return y.width(z),this.$label.width(function(A,B){return'auto'===x.options.labelWidth?B<z?z:B:x.options.labelWidth}),this.privateHandleWidth=this.$on.outerWidth(),this.privateLabelWidth=this.$label.outerWidth(),this.$container.width(2*this.privateHandleWidth+this.privateLabelWidth),this.$wrapper.width(this.privateHandleWidth+this.privateLabelWidth)}function g(){var x=this,y=0<arguments.length&&arguments[0]!==void 0?arguments[0]:this.ope;this.$container.css('margin-left',function(){var z=[0,'-'+x.privateHandleWidth+'px'];return x.options.indeterminate?'-'+x.privateHandleWidth/2+'px':y?x.options.inverse?z[1]:z[0]:x.options.inverse?z[0]:z[1]})}function h(x){return this.options.baseClass+'-'+x}function j(){var x=this,y=function(){x.setPrevOptions(),f.call(x),g.call(x),setTimeout(function(){return x.options.animate&&x.$wrapper.addClass(h.call(x,'animate'))},50)};if(this.$wrapper.is(':visible'))return void y();var z=window.setInterval(function(){return x.$wrapper.is(':visible')&&(y()||!0)&&window.clearInterval(z)},50)}function k(){var x=this;return this.$element.on({'setPreviousOptions.bootstrapSwitch':function(){return x.setPrevOptions()},'previousState.bootstrapSwitch':function(){x.options=x.prevOptions,x.options.indeterminate&&x.$wrapper.addClass(h.call(x,'indeterminate')),x.$element.prop('checked',x.options.state).trigger('change.bootstrapSwitch',!0)},'change.bootstrapSwitch':function(z,A){z.preventDefault(),z.stopImmediatePropagation();var B=x.$element.is(':checked');g.call(x,B);B===x.options.state||(x.options.state=B,x.$wrapper.toggleClass(h.call(x,'off')).toggleClass(h.call(x,'on')),!A&&(x.$element.is(':radio')&&u('[name="'+x.$element.attr('name')+'"]').not(x.$element).prop('checked',!1).trigger('change.bootstrapSwitch',!0),x.$element.trigger('switchChange.bootstrapSwitch',[B])))},'focus.bootstrapSwitch':function(z){z.preventDefault(),x.$wrapper.addClass(h.call(x,'focused'))},'blur.bootstrapSwitch':function(z){z.preventDefault(),x.$wrapper.removeClass(h.call(x,'focused'))},'keydown.bootstrapSwitch':function(z){!z.which||x.options.disabled||x.options.readonly||(37===z.which||39===z.which)&&(z.preventDefault(),z.stopImmediatePropagation(),x.state(39===z.which))}})}function l(){var x=this;return this.$on.on('click.bootstrapSwitch',function(y){return y.preventDefault(),y.stopPropagation(),x.state(!1),x.$element.trigger('focus.bootstrapSwitch')}),this.$off.on('click.bootstrapSwitch',function(y){return y.preventDefault(),y.stopPropagation(),x.state(!0),x.$element.trigger('focus.bootstrapSwitch')})}function m(){var x=this,y=void 0,z=void 0;this.$label.on({cl
|