16 lines
12 KiB
JavaScript
16 lines
12 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.fx.min","./kendo.data.min","./kendo.draganddrop.min"],e)}(function(){return function(e,t){var n,i,r,o,a,s,l,d,c=window.kendo,u=c.mobile,h=u.ui,p=e.proxy,f=c.effects.Transition,g=c.ui.Pane,m=c.ui.PaneDimensions,v=h.DataBoundWidget,_=c.data.DataSource,w=c.data.Buffer,y=c.data.BatchBuffer,b=Math,k=b.abs,x=b.ceil,C=b.round,T=b.max,S=b.min,D=b.floor,A="change",E="changing",I="refresh",P="km-current-page",M="km-virtual-page",z="function",F="itemChange",R="cleanup",L=3,H=-1,B=0,N=1,O=-1,V=0,U=1,W=c.Class.extend({init:function(t){var n=this,i=e("<ol class='km-pages'/>");t.element.append(i),this._changeProxy=p(n,"_change"),this._refreshProxy=p(n,"_refresh"),t.bind(A,this._changeProxy),t.bind(I,this._refreshProxy),e.extend(n,{element:i,scrollView:t})},items:function(){return this.element.children()},_refresh:function(e){var t,n="";for(t=0;e.pageCount>t;t++)n+="<li/>";this.element.html(n),this.items().eq(e.page).addClass(P)},_change:function(e){this.items().removeClass(P).eq(e.page).addClass(P)},destroy:function(){this.scrollView.unbind(A,this._changeProxy),this.scrollView.unbind(I,this._refreshProxy),this.element.remove()}});c.mobile.ui.ScrollViewPager=W,n="transitionEnd",i="dragStart",r="dragEnd",o=c.Observable.extend({init:function(t,o){var a,s,l,d,u,h,p=this;c.Observable.fn.init.call(this),this.element=t,this.container=t.parent(),a=new c.ui.Movable(p.element),s=new f({axis:"x",movable:a,onEnd:function(){p.trigger(n)}}),l=new c.UserEvents(t,{start:function(e){2*k(e.x.velocity)>=k(e.y.velocity)?l.capture():l.cancel(),p.trigger(i,e),s.cancel()},allowSelection:!0,end:function(e){p.trigger(r,e)}}),d=new m({element:p.element,container:p.container}),u=d.x,u.bind(A,function(){p.trigger(A)}),h=new g({dimensions:d,userEvents:l,movable:a,elastic:!0}),e.extend(p,{duration:o&&o.duration||1,movable:a,transition:s,userEvents:l,dimensions:d,dimension:u,pane:h}),this.bind([n,i,r,A],o)},size:function(){return{width:this.dimensions.x.getSize(),height:this.dimensions.y.getSize()}},total:function(){return this.dimension.getTotal()},offset:function(){return-this.movable.x},updateDimension:function(){this.dimension.update(!0)},refresh:function(){this.dimensions.refresh()},moveTo:function(e){this.movable.moveAxis("x",-e)},transitionTo:function(e,t,n){n?this.moveTo(-e):this.transition.moveTo({location:e,duration:this.duration,ease:t})}}),c.mobile.ui.ScrollViewElasticPane=o,a=c.Observable.extend({init:function(e,t,n){var i=this;c.Observable.fn.init.call(this),i.element=e,i.pane=t,i._getPages(),this.page=0,this.pageSize=n.pageSize||1,this.contentHeight=n.contentHeight,this.enablePager=n.enablePager},scrollTo:function(e,t){this.page=e,this.pane.transitionTo(-e*this.pane.size().width,f.easeOutExpo,t)},paneMoved:function(e,t,n,i){var r,o,a=this,s=a.pane,l=s.size().width*a.pageSize,d=C,c=t?f.easeOutBack:f.easeOutExpo;e===O?d=x:e===U&&(d=D),o=d(s.offset()/l),r=T(a.minSnap,S(-o*l,a.maxSnap)),o!=a.page&&n&&n({currentPage:a.page,nextPage:o})&&(r=-a.page*s.size().width),s.transitionTo(r,c,i)},updatePage:function(){var e=this.pane,t=C(e.offset()/e.size().width);return t!=this.page?(this.page=t,!0):!1},forcePageUpdate:function(){return this.updatePage()},resizeTo:function(e){var t,n,i=this.pane,r=e.width;this.pageElements.width(r),"100%"===this.contentHeight&&(t=this.element.parent().height(),this.enablePager===!0&&(n=this.element.parent().find("ol.km-pages"),n.length&&(t-=n.outerHeight(!0))),this.element.css("height",t),this.pageElements.css("height",t)),i.updateDimension(),this._paged||(this.page=D(i.offset()/r)),this.scrollTo(this.page,!0),this.pageCount=x(i.total()/r),this.minSnap=-(this.pageCount-1)*r,this.maxSnap=0},_getPages:function(){this.pageElements=this.element.find("[data-role=page]"),this._paged=this.pageElements.length>0}}),c.mobile.ui.ScrollViewContent=a,s=c.Observable.extend({init:function(e,t,n){var i=this;c.Observable.fn.init.call(this),i.element=e,i.pane=t,i.options=n,i._templates(),i.page=n.page||0,i.pages=[],i._initPages(),i.resizeTo(i.pane.size()),i.pane.dimension.forceEnabled()},setDataSource:function(e)
|