demo20230512/Scripts/kendo/2014.2.716/kendo.mobile.drawer.min.js
2023-05-12 10:20:28 +08:00

16 lines
4.7 KiB
JavaScript

/**
* Copyright 2014 Telerik AD
*
* 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(e,define){define(["./kendo.mobile.view.min","./kendo.userevents.min"],e)}(function(){return function(e,t){var n=window.kendo,i=n.mobile,r=n.support.mobileOS,o=n.effects.Transition,a=n.roleSelector,s="x",l=i.ui,d=!(r.ios&&7==r.majorVersion&&!r.appMode),c="beforeShow",u="init",h="show",p="hide",f="afterHide",g={enable:e.noop},m=l.View.extend({init:function(t,r){var o,s,l,c,h;if(e(t).parent().prepend(t),i.ui.Widget.fn.init.call(this,t,r),this._layout(),this._scroller(),this._model(),o=this.element.closest(a("pane")).data("kendoMobilePane"))this.pane=o,this.pane.bind("viewShow",function(e){c._viewShow(e)}),this.pane.bind("sameViewRequested",function(){c.hide()}),s=this.userEvents=new n.UserEvents(o.element,{filter:a("view splitview"),allowSelection:!0});else{if(this.currentView=g,l=e(this.options.container),!l)throw Error("The drawer needs a container configuration option set.");s=this.userEvents=new n.UserEvents(l,{allowSelection:!0}),this._attachTransition(l)}c=this,h=function(e){c.visible&&(c.hide(),e.preventDefault())},this.options.swipeToOpen&&d?(s.bind("press",function(){c.transition.cancel()}),s.bind("start",function(e){c._start(e)}),s.bind("move",function(e){c._update(e)}),s.bind("end",function(e){c._end(e)}),s.bind("tap",h)):s.bind("press",h),this.leftPositioned="left"===this.options.position,this.visible=!1,this.element.hide().addClass("km-drawer").addClass(this.leftPositioned?"km-left-drawer":"km-right-drawer"),this.trigger(u)},options:{name:"Drawer",position:"left",views:[],swipeToOpenViews:[],swipeToOpen:!0,title:"",container:null},events:[c,p,f,u,h],show:function(){this._activate()&&this._show()},hide:function(){this.currentView&&(this.currentView.enable(),m.current=null,this._moveViewTo(0),this.trigger(p,{view:this}))},openFor:function(){this.visible?this.hide():this.show()},destroy:function(){l.View.fn.destroy.call(this),this.userEvents.destroy()},_activate:function(){if(this.visible)return!0;var e=this._currentViewIncludedIn(this.options.views);return!e||this.trigger(c,{view:this})?!1:(this._setAsCurrent(),this.element.show(),this.trigger(h,{view:this}),!0)},_currentViewIncludedIn:function(t){if(!this.pane||!t.length)return!0;var n=this.pane.view();return e.inArray(n.id.replace("#",""),t)>-1||e.inArray(n.element.attr("id"),t)>-1},_show:function(){this.currentView.enable(!1),this.visible=!0;var e=this.element.width();this.leftPositioned||(e=-e),this._moveViewTo(e)},_setAsCurrent:function(){m.last!==this&&(m.last&&m.last.element.hide(),this.element.show()),m.last=this,m.current=this},_moveViewTo:function(e){this.userEvents.cancel(),this.transition.moveTo({location:e,duration:400,ease:o.easeOutExpo})},_viewShow:function(e){return this.currentView&&this.currentView.enable(),this.currentView===e.view?(this.hide(),t):(this.currentView=e.view,this._attachTransition(e.view.element),t)},_attachTransition:function(e){var t=this,i=this.movable,r=i&&i.x;this.transition&&(this.transition.cancel(),this.movable.moveAxis("x",0)),i=this.movable=new n.ui.Movable(e),this.transition=new o({axis:s,movable:this.movable,onEnd:function(){0===i[s]&&(e[0].style.cssText="",t.element.hide(),t.trigger(f),t.visible=!1)}}),r&&(e.addClass("k-fx-hidden"),n.animationFrame(function(){e.removeClass("k-fx-hidden"),t.movable.moveAxis(s,r),t.hide()}))},_start:function(e){var i,r,o,a,s,l=e.sender;return Math.abs(e.x.velocity)<Math.abs(e.y.velocity)||n.triggeredByInput(e.event)||!this._currentViewIncludedIn(this.options.swipeToOpenViews)?(l.cancel(),t):(i=this.leftPositioned,r=this.visible,o=i&&r||!i&&!m.current,a=!i&&r||i&&!m.current,s=0>e.x.velocity,(o&&s||a&&!s)&&this._activate()?(l.capture(),t):(l.cancel(),t))},_update:function(e){var t,n=this.movable,i=n.x+e.x.delta;t=this.leftPositioned?Math.min(Math.max(0,i),this.element.width()):Math.max(Math.min(0,i),-this.element.width()),this.movable.moveAxis(s,t),e.event.preventDefault(),e.event.stopPropagation()},_end:function(e){var t,n=e.x.velocity,i=Math.abs(this.movable.x)>this.element.width()/2,r=.8;t=this.leftPositioned?n>-r&&(n>r||i):r>n&&(-r>n||i),t?this._show():this.hide()}});l.plugin(m)}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()});