16 lines
17 KiB
JavaScript
16 lines
17 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.data.min","./kendo.userevents.min","./kendo.mobile.button.min"],e)}(function(){return function(e,t){function n(){return this.nodeType===v.TEXT_NODE&&this.nodeValue.match(U)}function i(e,t){t&&!e[0].querySelector(".km-icon")&&e.prepend('<span class="km-icon km-'+t+'"/>')}function r(e){i(e,S(e,"icon")),i(e,S(e.children(C),"icon"))}function o(e){var t=e.parent(),r=e.add(t.children(m.roleSelector("detailbutton"))),o=t.contents().not(r).not(n);o.length||(e.addClass("km-listview-link").attr(m.attr("role"),"listview-link"),i(e,S(t,"icon")),i(e,S(e,"icon")))}function a(e){if(e[0].querySelector("input[type=checkbox],input[type=radio]")){var t=e.parent();t.contents().not(e).not(function(){return 3==this.nodeType})[0]||(e.addClass("km-listview-label"),e.children("[type=checkbox],[type=radio]").addClass("km-widget km-icon km-check"))}}function s(t,n){e(t).css("transform","translate3d(0px, "+n+"px, 0px)")}var l,d,c,u,h,p,f,g,m=window.kendo,v=window.Node,_=m.mobile,w=_.ui,y=m.data.DataSource,k=w.DataBoundWidget,b=".km-list > li, > li:not(.km-group-container)",x=".km-listview-link, .km-listview-label",C="["+m.attr("icon")+"]",T=e.proxy,S=m.attrValue,D="km-group-title",A="km-state-active",E='<div class="'+D+'"><div class="km-text"></div></div>',I=m.template('<li><div class="'+D+'"><div class="km-text">#= this.headerTemplate(data) #</div></div><ul>#= kendo.render(this.template, data.items)#</ul></li>'),P='<div class="km-listview-wrapper" />',M=m.template('<form class="km-filter-form"><div class="km-filter-wrap"><input type="search" placeholder="#=placeholder#"/><a href="\\#" class="km-filter-reset" title="Clear"><span class="km-icon km-clear"></span><span class="km-text">Clear</span></a></div></form>'),z=".kendoMobileListView",F="styled",L="dataBound",R="dataBinding",H="itemChange",B="click",N="change",O="progress",V="function",U=/^\s+$/,W=/button/,j=m.Class.extend({init:function(e){var t,n,i=e.scroller();i&&(this.options=e.options,this.element=e.element,this.scroller=e.scroller(),this._shouldFixHeaders(),t=this,n=function(){t._cacheHeaders()},e.bind("resize",n),e.bind(F,n),e.bind(L,n),i.bind("scroll",function(e){t._fixHeader(e)}))},_fixHeader:function(t){if(this.fixedHeaders){var n,i,r,o=0,a=this.scroller,s=this.headers,l=t.scrollTop;do{if(n=s[o++],!n){r=e("<div />");break}i=n.offset,r=n.header}while(i+1>l);this.currentHeader!=o&&(a.fixedContainer.html(r.clone()),this.currentHeader=o)}},_shouldFixHeaders:function(){this.fixedHeaders="group"===this.options.type&&this.options.fixedHeaders},_cacheHeaders:function(){if(this._shouldFixHeaders(),this.fixedHeaders){var t=[],n=this.scroller.scrollTop;this.element.find("."+D).each(function(i,r){r=e(r),t.unshift({offset:r.position().top+n,header:r})}),this.headers=t,this._fixHeader({scrollTop:n})}}}),q=function(){return{page:1}},G=m.Class.extend({init:function(e){var t=this,n=e.options,i=e.scroller(),r=n.pullParameters||q;this.listView=e,this.scroller=i,e.bind("_dataSource",function(e){t.setDataSource(e.dataSource)}),i.setOptions({pullToRefresh:!0,pull:function(){t._pulled||(t._pulled=!0,t.dataSource.read(r.call(e,t._first)))},pullTemplate:n.pullTemplate,releaseTemplate:n.releaseTemplate,refreshTemplate:n.refreshTemplate})},setDataSource:function(e){var t=this;this._first=e.view()[0],this.dataSource=e,e.bind("change",function(){t._change()}),e.bind("error",function(){t._change()})},_change:function(){var e,t=this.scroller,n=this.dataSource;this._pulled&&t.pullHandled(),(this._pulled||!this._first)&&(e=n.view(),e[0]&&(this._first=e[0])),this._pulled=!1}}),Y=m.Observable.extend({init:function(e){var t=this;m.Observable.fn.init.call(t),t.buffer=e.buffer,t.height=e.height,t.item=e.item,t.items=[],t.footer=e.footer,t.buffer.bind("reset",function(){t.refresh()})},refresh:function(){for(var e,t,n,i,r=this.buffer,o=this.items,a=!1;o.length;)o.pop().destroy();for(this.offset=r.offset,e=this.item,i=0;r.viewSize>i;i++){if(i===r.total()){a=!0;break}n=e(this.content(this.offset+o.length)),n.below(t),t=n,o.push(n)}this.itemCount=o.length,this.trigger("reset"),this._resize(
|