UNPKG

@progress/kendo-ui

Version:

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

1 lines 5 kB
module.exports=function(t){var n={};function s(e){if(n[e])return n[e].exports;var i=n[e]={exports:{},id:e,loaded:!1};return t[e].call(i.exports,i,i.exports,s),i.loaded=!0,i.exports}return s.m=t,s.c=n,s.p="",s(0)}({0:function(e,i,t){e.exports=t(1358)},3:function(e,i){e.exports=function(){throw Error("define cannot be used indirect")}},1113:function(e,i){e.exports=require("./kendo.userevents")},1338:function(e,i){e.exports=require("./kendo.mobile.view")},1358:function(e,i,t){var n;t(3),t=[t(1338),t(1113)],void 0===(i="function"==typeof(n=function(){var n={id:"mobile.drawer",name:"Drawer",category:"mobile",description:"The Kendo Mobile Drawer widget provides slide to reveal global application toolbox",depends:["mobile.view","userevents"]},a=window.kendo.jQuery,r=void 0,h=window.kendo,l=h.mobile,e=h.support.mobileOS,s=h.effects.Transition,u=h.roleSelector,o="x",i=l.ui,c=!(e.ios&&e.majorVersion==7&&!e.appMode),t="beforeShow",f="init",v="show",w="hide",p="afterHide",m={enable:a.noop},d=i.View.extend({init:function(e,i){a(e).parent().prepend(e);l.ui.Widget.fn.init.call(this,e,i);if(!this.options.$angular){this._layout();this._scroller()}this._model();var t=this.element.closest(u("pane")).data("kendoMobilePane"),n;if(t){this.pane=t;this.pane.bind("viewShow",function(e){o._viewShow(e)});this.pane.bind("sameViewRequested",function(){o.hide()});n=this.userEvents=new h.UserEvents(t.element,{fastTap:true,filter:u("view splitview"),allowSelection:true})}else{this.currentView=m;var s=a(this.options.container);if(!s)throw new Error("The drawer needs a container configuration option set.");n=this.userEvents=new h.UserEvents(s,{fastTap:true,allowSelection:true});this._attachTransition(s)}var o=this;var r=function(e){if(o.visible){o.hide();e.preventDefault()}};if(this.options.swipeToOpen&&c){n.bind("press",function(){o.transition.cancel()});n.bind("start",function(e){o._start(e)});n.bind("move",function(e){o._update(e)});n.bind("end",function(e){o._end(e)});n.bind("tap",r)}else n.bind("press",r);this.leftPositioned=this.options.position==="left";this.visible=false;this.element.hide().addClass("km-drawer").addClass(this.leftPositioned?"km-left-drawer":"km-right-drawer");this.trigger(f)},options:{name:"Drawer",position:"left",views:[],swipeToOpenViews:[],swipeToOpen:true,title:"",container:null},events:[t,w,p,f,v],show:function(){if(this._activate())this._show()},hide:function(){if(!this.currentView)return;this.currentView.enable();d.current=null;this._moveViewTo(0);this.trigger(w,{view:this})},openFor:function(){if(this.visible)this.hide();else this.show()},destroy:function(){i.View.fn.destroy.call(this);this.userEvents.destroy()},_activate:function(){if(this.visible)return true;var e=this._currentViewIncludedIn(this.options.views);if(!e||this.trigger(t,{view:this}))return false;this._setAsCurrent();this.element.show();this.trigger(v,{view:this});this._invokeNgController();return true},_currentViewIncludedIn:function(e){if(!this.pane||!e.length)return true;var i=this.pane.view();return a.inArray(i.id.replace("#",""),e)>-1||a.inArray(i.element.attr("id"),e)>-1},_show:function(){this.currentView.enable(false);this.visible=true;var e=this.element.width();if(!this.leftPositioned)e=-e;this._moveViewTo(e)},_setAsCurrent:function(){if(d.last!==this){if(d.last)d.last.element.hide();this.element.show()}d.last=this;d.current=this},_moveViewTo:function(e){this.userEvents.cancel();this.transition.moveTo({location:e,duration:400,ease:s.easeOutExpo})},_viewShow:function(e){if(this.currentView)this.currentView.enable();if(this.currentView===e.view){this.hide();return}this.currentView=e.view;this._attachTransition(e.view.element)},_attachTransition:function(e){var i=this,t=this.movable,n=t&&t.x;if(this.transition){this.transition.cancel();this.movable.moveAxis("x",0)}t=this.movable=new h.ui.Movable(e);this.transition=new s({axis:o,movable:this.movable,onEnd:function(){if(t[o]===0){e[0].style.cssText="";i.element.hide();i.trigger(p);i.visible=false}}});if(n){e.addClass("k-fx-hidden");h.animationFrame(function(){e.removeClass("k-fx-hidden");i.movable.moveAxis(o,n);i.hide()})}},_start:function(e){var i=e.sender;if(Math.abs(e.x.velocity)<Math.abs(e.y.velocity)||h.triggeredByInput(e.event)||!this._currentViewIncludedIn(this.options.swipeToOpenViews)){i.cancel();return}var t=this.leftPositioned,n=this.visible,s=t&&n||!t&&!d.current,o=!t&&n||t&&!d.current,r=e.x.velocity<0;if(s&&r||o&&!r)if(this._activate()){i.capture();return}i.cancel()},_update:function(e){var i=this.movable,t=i.x+e.x.delta,n;if(this.leftPositioned)n=Math.min(Math.max(0,t),this.element.width());else n=Math.max(Math.min(0,t),-this.element.width());this.movable.moveAxis(o,n);e.event.preventDefault();e.event.stopPropagation()},_end:function(e){var i=e.x.velocity,t=Math.abs(this.movable.x)>this.element.width()/2,n=.8,s;if(this.leftPositioned)s=i>-n&&(i>n||t);else s=i<n&&(i<-n||t);if(s)this._show();else this.hide()}});return i.plugin(d),window.kendo})?n.apply(i,t):n)||(e.exports=i)}});