UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

1 lines 4.11 kB
module.exports=function(e){function n(o){if(t[o])return t[o].exports;var s=t[o]={exports:{},id:o,loaded:!1};return e[o].call(s.exports,s,s.exports,n),s.loaded=!0,s.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}({0:function(e,n,t){e.exports=t(1255)},3:function(e,n){e.exports=function(){throw Error("define cannot be used indirect")}},1040:function(e,n){e.exports=require("./kendo.userevents")},1056:function(e,n){e.exports=require("./kendo.fx")},1255:function(e,n,t){var o,s,i;!function(a,define){s=[t(1056),t(1040)],o=a,i="function"==typeof o?o.apply(n,s):o,!(void 0!==i&&(e.exports=i))}(function(){return function(e,n){function t(e){return"km-"+e}function o(e,n,t){return Math.max(n,Math.min(t,e))}var s=window.kendo,i=s.mobile.ui,a=s._outerWidth,r=i.Widget,c=s.support,p="change",l="switch-on",d="switch-off",u="margin-left",h="state-active",f="state-disabled",g="disabled",k=c.transitions.css===n?"":c.transitions.css,m=k+"transform",w=e.proxy,b='<span class="'+t("switch")+" "+t("widget")+'">\t <span class="'+t("switch-wrapper")+'">\t <span class="'+t("switch-background")+'"></span>\t </span> \t <span class="'+t("switch-container")+'">\t <span class="'+t("switch-handle")+'"> \t <span class="'+t("switch-label-on")+'">{0}</span> \t <span class="'+t("switch-label-off")+'">{1}</span> \t </span> \t </span>\t </span>',v=r.extend({init:function(n,t){var o,i=this;r.fn.init.call(i,n,t),t=i.options,i.wrapper=e(s.format(b,t.onLabel,t.offLabel)),i.handle=i.wrapper.find(".km-switch-handle"),i.background=i.wrapper.find(".km-switch-background"),i.wrapper.insertBefore(i.element).prepend(i.element),i._drag(),i.origin=parseInt(i.background.css(u),10),i.constrain=0,i.snapPoint=0,n=i.element[0],n.type="checkbox",i._animateBackground=!0,o=i.options.checked,null===o&&(o=n.checked),i.check(o),i.options.enable=i.options.enable&&!i.element.attr(g),i.enable(i.options.enable),i.refresh(),s.notify(i,s.mobile.ui)},refresh:function(){var e=this,n=a(e.handle,!0);e.width=e.wrapper.width(),e.constrain=e.width-n,e.snapPoint=e.constrain/2,"number"!=typeof e.origin&&(e.origin=parseInt(e.background.css(u),10)),e.background.data("origin",e.origin),e.check(e.element[0].checked)},events:[p],options:{name:"Switch",onLabel:"on",offLabel:"off",checked:null,enable:!0},check:function(e){var o=this,s=o.element[0];return e===n?s.checked:(o._position(e?o.constrain:0),s.checked=e,o.wrapper.toggleClass(t(l),e).toggleClass(t(d),!e),n)},value:function(){return this.check.apply(this,arguments)},destroy:function(){r.fn.destroy.call(this),this.userEvents.destroy()},toggle:function(){var e=this;e.check(!e.element[0].checked)},enable:function(e){var o=this.element,s=this.wrapper;n===e&&(e=!0),this.options.enable=e,e?o.removeAttr(g):o.attr(g,g),s.toggleClass(t(f),!e)},_resize:function(){this.refresh()},_move:function(e){var n=this;e.preventDefault(),n._position(o(n.position+e.x.delta,0,n.width-a(n.handle,!0)))},_position:function(e){var n=this;n.position=e,n.handle.css(m,"translatex("+e+"px)"),n._animateBackground&&n.background.css(u,n.origin+e)},_start:function(){this.options.enable?(this.userEvents.capture(),this.handle.addClass(t(h))):this.userEvents.cancel()},_stop:function(){var e=this;e.handle.removeClass(t(h)),e._toggle(e.position>e.snapPoint)},_toggle:function(e){var n,o=this,i=o.handle,a=o.element[0],r=a.checked,c=s.mobile.application&&s.mobile.application.os.wp?100:200;o.wrapper.toggleClass(t(l),e).toggleClass(t(d),!e),o.position=n=e*o.constrain,o._animateBackground&&o.background.kendoStop(!0,!0).kendoAnimate({effects:"slideMargin",offset:n,reset:!0,reverse:!e,axis:"left",duration:c}),i.kendoStop(!0,!0).kendoAnimate({effects:"slideTo",duration:c,offset:n+"px,0",reset:!0,complete:function(){r!==e&&(a.checked=e,o.trigger(p,{checked:e}))}})},_drag:function(){var e=this;e.userEvents=new s.UserEvents(e.wrapper,{fastTap:!0,tap:function(){e.options.enable&&e._toggle(!e.element[0].checked)},start:w(e._start,e),move:w(e._move,e),end:w(e._stop,e)})}});i.plugin(v)}(window.kendo.jQuery),window.kendo},t(3))}});