Jonathan Ouellette 580e90f6a2 initial add
2022-09-27 14:10:30 -07:00

10 lines
3.9 KiB
JavaScript

/*
* Kendo UI Complete v2013.3.1119 (http://kendoui.com)
* Copyright 2013 Telerik AD. All rights reserved.
*
* Kendo UI Complete commercial licenses may be obtained at
* https://www.kendoui.com/purchase/license-agreement/kendo-ui-complete-commercial.aspx
* If you do not own a commercial license, this file shall be governed by the trial license terms.
*/
!function(define){return define(["./kendo.mobile.application.min"],function(){!function(e,n){function t(e,n,t){return Math.max(n,Math.min(t,e))}var a=window.kendo,i=a.mobile.ui,s=i.Widget,o=a.support,r="change",c="km-switch-on",l="km-switch-off",d="margin-left",p="km-state-active",h="km-state-disabled",u="disabled",f=o.transitions.css+"transform",k=e.proxy,m=s.extend({init:function(e,n){var t,i=this;s.fn.init.call(i,e,n),i._wrapper(),i._drag(),i._background(),i.origin=parseInt(i.background.css(d),10),i._handle(),i.constrain=0,i.snapPoint=0,e=i.element[0],e.type="checkbox",i._animateBackground=!0,t=i.options.checked,null===t&&(t=e.checked),i.check(t),i.options.enable=i.options.enable&&!i.element.attr(u),i.enable(i.options.enable),i.refresh(),a.notify(i,a.mobile.ui)},refresh:function(){var e=this;e.width=e.wrapper.width(),e.handleWidth=e.handle.outerWidth(!0),e.constrain=e.width-e.handleWidth,e.snapPoint=e.width/2-e.handleWidth/2,"number"!=typeof e.origin&&(e.origin=parseInt(e.background.css(d),10)),e.background.data("origin",e.origin),e.check(e.element[0].checked)},events:[r],options:{name:"Switch",onLabel:"on",offLabel:"off",checked:null,enable:!0},check:function(e){var t=this,a=t.element[0];return e===n?a.checked:(t._position(e?t.constrain:0),a.checked=e,t.wrapper.toggleClass(c,e).toggleClass(l,!e),n)},destroy:function(){s.fn.destroy.call(this),this.userEvents.destroy()},toggle:function(){var e=this;e.check(!e.element[0].checked)},enable:function(e){var t=this.element,a=this.wrapper;n===e&&(e=!0),this.options.enable=e,e?t.removeAttr(u):t.attr(u,u),a.toggleClass(h,!e)},_resize:function(){this.refresh()},_move:function(e){var n=this;e.preventDefault(),n._position(t(n.position+e.x.delta,0,n.width-n.handle.outerWidth(!0)))},_position:function(e){var n=this;n.position=e,n.handle.css(f,"translatex("+e+"px)"),n._animateBackground&&n.background.css(d,n.origin+e)},_start:function(){this.options.enable?(this.userEvents.capture(),this.handle.addClass(p)):this.userEvents.cancel()},_stop:function(){var e=this;e.handle.removeClass(p),e._toggle(e.position>e.snapPoint)},_toggle:function(e){var n,t=this,i=t.handle,s=t.element[0],o=s.checked,d=a.mobile.application&&a.mobile.application.os.wp?100:200;t.wrapper.toggleClass(c,e).toggleClass(l,!e),t.position=n=e*t.constrain,t._animateBackground&&t.background.kendoStop(!0,!0).kendoAnimate({effects:"slideMargin",offset:n,reset:!0,reverse:!e,axis:"left",duration:d}),i.kendoStop(!0,!0).kendoAnimate({effects:"slideTo",duration:d,offset:n+"px,0",reset:!0,complete:function(){o!==e&&(s.checked=e,t.trigger(r,{checked:e}))}})},_background:function(){var n,t=this;n=e("<span class='km-switch-wrapper'><span class='km-switch-background'></span></span>").appendTo(t.wrapper).children(".km-switch-background"),t.background=n},_handle:function(){var n=this,t=n.options;n.handle=e("<span class='km-switch-container'><span class='km-switch-handle' /></span>").appendTo(n.wrapper).children(".km-switch-handle"),n.handle.append('<span class="km-switch-label-on">'+t.onLabel+'</span><span class="km-switch-label-off">'+t.offLabel+"</span>")},_wrapper:function(){var e=this,n=e.element,t=n.parent("span.km-switch");t[0]||(t=n.wrap('<span class="km-switch"/>').parent()),e.wrapper=t.addClass("km-widget")},_drag:function(){var e=this;e.userEvents=new a.UserEvents(e.wrapper,{tap:function(){e.options.enable&&e._toggle(!e.element[0].checked)},start:k(e._start,e),move:k(e._move,e),end:k(e._stop,e)})}});i.plugin(m)}(window.kendo.jQuery)})}("function"==typeof define&&define.amd?define:function(e,n){return n()});
//@ sourceMappingURL=kendo.mobile.switch.min.js.map