/*
* Kendo UI Complete v2013.3.1119 (http://kendoui.com)
* Copyright 2013 Telerik AD. All rights reserved.
*
* Kendo UI Complete commercial licenses may be obtained at
* https://www.kendoui.com/purchase/license-agreement/kendo-ui-complete-commercial.aspx
* If you do not own a commercial license, this file shall be governed by the trial license terms.
*/
!function(define){return define(["./kendo.data.min","./kendo.mobile.application.min","./kendo.userevents.min"],function(){!function(t){function e(){return this.nodeType===g.TEXT_NODE&&this.nodeValue.match(q)}function i(t,e){e&&!t[0].querySelector(".km-icon")&&t.prepend('')}function s(t){i(t,x(t,"icon")),i(t,x(t.children(y),"icon"))}function n(t){var s=t.parent(),n=t.add(s.children(m.roleSelector("detailbutton"))),o=s.contents().not(n).not(e);o.length||(t.addClass("km-listview-link").attr(m.attr("role"),"listview-link"),i(t,x(s,"icon")),i(t,x(t,"icon")))}function o(t){if(t[0].querySelector("input[type=checkbox],input[type=radio]")){var e=t.parent();e.contents().not(t).not(function(){return 3==this.nodeType})[0]||(t.addClass("km-listview-label"),t.children("[type=checkbox],[type=radio]").addClass("km-widget km-icon km-check"))}}function r(e,i){t(e).css("transform","translate3d(0px, "+i+"px, 0px)")}var l,a,h,d,c,u,f,p,m=window.kendo,g=window.Node,v=m.mobile,b=v.ui,_=m.data.DataSource,w=b.Widget,k=".km-list > li, > li:not(.km-group-container)",S=".km-listview-link, .km-listview-label",y="["+m.attr("icon")+"]",T=t.proxy,x=m.attrValue,C="km-group-title",H="km-state-active",D='
',B=m.template('#= this.headerTemplate(data) #
#= kendo.render(this.template, data.items)#
'),I='',z=m.template(''),V=".kendoMobileListView",F="styled",R="dataBound",L="dataBinding",M="itemChange",E="click",O="change",A="progress",P="function",q=/^\s+$/,U=/button/,G=m.Class.extend({init:function(t){var e,i,s=t.scroller();s&&(this.options=t.options,this.element=t.element,this.scroller=t.scroller(),this._shouldFixHeaders(),e=this,i=function(){e._cacheHeaders()},t.bind("resize",i),t.bind(F,i),t.bind(R,i),s.bind("scroll",function(t){e._fixHeader(t)}))},_fixHeader:function(e){if(this.fixedHeaders){var i,s,n,o=0,r=this.scroller,l=this.headers,a=e.scrollTop;do{if(i=l[o++],!i){n=t("");break}s=i.offset,n=i.header}while(s+1>a);this.currentHeader!=o&&(r.fixedContainer.html(n.clone()),this.currentHeader=o)}},_shouldFixHeaders:function(){this.fixedHeaders="group"===this.options.type&&this.options.fixedHeaders},_cacheHeaders:function(){if(this._shouldFixHeaders(),this.fixedHeaders){var e=[],i=this.scroller.scrollTop;this.element.find("."+C).each(function(s,n){n=t(n),e.unshift({offset:n.position().top+i,header:n})}),this.headers=e,this._fixHeader({scrollTop:i})}}}),j=function(){return{page:1}},N=m.Class.extend({init:function(t){var e=this,i=t.options,s=t.scroller(),n=i.pullParameters||j;this.listView=t,this.scroller=s,t.bind("_dataSource",function(t){e.setDataSource(t.dataSource)}),s.setOptions({pullToRefresh:!0,pull:function(){e._pulled=!0,e.dataSource.read(n.call(t,e._first))},pullTemplate:i.pullTemplate,releaseTemplate:i.releaseTemplate,refreshTemplate:i.refreshTemplate})},setDataSource:function(t){var e=this;this._first=t.view()[0],this.dataSource=t,t.bind("change",function(){e._change()})},_change:function(){var t,e=this.scroller,i=this.dataSource;this._pulled&&e.pullHandled(),(this._pulled||!this._first)&&(t=i.view(),t[0]&&(this._first=t[0])),this._pulled=!1}}),W=m.Observable.extend({init:function(t){var e=this;m.Observable.fn.init.call(e),e.buffer=t.buffer,e.height=t.height,e.item=t.item,e.items=[],e.footer=t.footer,e.buffer.bind("reset",function(){e.refresh()})},refresh:function(){for(var t,e,i,s,n=this.buffer,o=this.items,r=!1;o.length;)o.pop().destroy();for(this.offset=n.offset,i=this.item,s=0;st+2*s&&0!==this.offset;)this.offset--,e=n.pop(),e.update(this.content(this.offset)),e.above(n[0]),n.unshift(e);else for(;n[0].topt,c=t-h,u=t+l+h;this.lastTop=t,this.lastDirection=d,d?r[0].top>c&&r[r.length-1].bottom>u+h&&this.offset>0&&(this.offset--,e=r.pop(),i=r[0],e.update(this.content(this.offset)),r.unshift(e),m.queueAnimation(function(){e.above(i),o._resize()})):r[r.length-1].bottom',h=m.Class.extend({init:function(e){this.element=t('').appendTo(e.element),this._loadIcon=t(a).appendTo(this.element)},enable:function(){this.element.show(),this.height=this.element.outerHeight(!0)},disable:function(){this.element.hide(),this.height=0},below:function(t){t&&(this.top=t.bottom,this.bottom=this.height+this.top,r(this.element,this.top))}}),d=h.extend({init:function(e,i){this._loadIcon=t(a).hide(),this._loadButton=t(''+e.options.loadMoreText+"").hide(),this.element=t('').append(this._loadIcon).append(this._loadButton).appendTo(e.element);var s=this;this._loadButton.kendoMobileButton().data("kendoMobileButton").bind("click",function(){s._hideShowButton(),i.next()}),i.bind("resize",function(){s._showLoadButton()}),this.height=this.element.outerHeight(!0),this.disable()},_hideShowButton:function(){this._loadButton.hide(),this.element.addClass("km-scroller-refresh"),this._loadIcon.css("display","block")},_showLoadButton:function(){this._loadButton.show(),this.element.removeClass("km-scroller-refresh"),this._loadIcon.hide()}}),c=m.Class.extend({init:function(t){var e=this;this.chromeHeight=t.wrapper.children().not(t.element).outerHeight()||0,this.listView=t,this.scroller=t.scroller(),this.options=t.options,t.bind("_dataSource",function(t){e.setDataSource(t.dataSource)}),t.bind("resize",function(){e.list.items.length&&(e.scroller.reset(),e.buffer.range(0),e.list.refresh())}),this.scroller.makeVirtual(),this.scroller.bind("scroll",function(t){e.list.update(t.scrollTop)}),this.scroller.bind("scrollEnd",function(t){e.list.batchUpdate(t.scrollTop)})},destroy:function(){this.list.unbind(),this.buffer.unbind()},setDataSource:function(e){var i,s,n,o,r=this,a=this.options,c=this.listView,u=c.scroller(),f=a.loadMore;if(this.dataSource&&this._unbindDataSource(),this.dataSource=e,i=e.pageSize()||a.virtualViewSize,!i)throw Error("the DataSource does not have page size configured. Page Size setting is mandatory for the mobile listview virtual scrolling to work as expected.");this.buffer&&this.buffer.destroy(),s=new m.data.Buffer(e,Math.floor(i/2),f),n=f?new d(c,s):new h(c),this.list&&this.list.destroy(),o=new W({buffer:s,footer:n,item:function(t){return new l(c,t)},height:function(){return u.height()}}),o.bind("resize",function(){r.updateScrollerSize()}),o.bind("reset",function(){r.footer.enable()}),o.bind("endReached",function(){n.disable(),r.updateScrollerSize()}),s.bind("expand",function(){o.lastDirection=!1,o.batchUpdate(u.scrollTop)}),t.extend(this,{buffer:s,scroller:u,list:o,footer:n})},updateScrollerSize:function(){this.scroller.virtualSize(0,this.list.totalHeight()+this.chromeHeight)},refresh:function(){this.list.refresh()},reset:function(){this.buffer.range(0),this.list.refresh()},_unbindDataSource:function(){}}),u=m.Class.extend({init:function(t){var e,i=this;this.listView=t,this.options=t.options,e=this,this._refreshHandler=function(t){e.refresh(t)},this._progressHandler=function(){t.showLoading()},t.bind("_dataSource",function(t){i.setDataSource(t.dataSource)})},destroy:function(){},reset:function(){},refresh:function(t){var e,i,s=t&&t.action,n=t&&t.items,o=this.listView,r=this.dataSource,l=this.options.appendOnRefresh,a=r.view(),h=r.group(),d=h&&h[0];return"itemchange"===s?(e=o.findByDataItem(n)[0],e&&o.setDataItem(e,n[0]),undefined):(o.trigger(L),"add"!==s||d?"remove"!==s||d?d?o.replaceGrouped(a):l&&!o._filter?o.prepend(a):o.replace(a):o.remove(n):(i=a.indexOf(n[0]),i>-1&&o.insertAt(n,i)),this._shouldShowLoading()&&o.hideLoading(),o.trigger(R,{ns:b}),undefined)},setDataSource:function(t){this.dataSource&&this._unbindDataSource(),this.dataSource=t,t.bind(O,this._refreshHandler),this._shouldShowLoading()&&this.dataSource.bind(A,this._progressHandler)},_unbindDataSource:function(){this.dataSource.unbind(O,this._refreshHandler).unbind(A,this._progressHandler)},_shouldShowLoading:function(){var t=this.options;return!t.pullToRefresh&&!t.loadMore&&!t.endlessScroll}}),f=m.Class.extend({init:function(t){var e=this,i=t.options.filterable,s="change paste";this.listView=t,this.options=i,t.element.before(z({placeholder:i.placeholder||"Search..."})),i.autoFilter!==!1&&(s+=" keyup"),this.element=t.wrapper.find(".km-search-form"),this.searchInput=t.wrapper.find("input[type=search]").closest("form").on("submit"+V,function(t){t.preventDefault()}).end().on("focus"+V,function(){e._oldFilter=e.searchInput.val()}).on(s.split(" ").join(V+" ")+V,T(this._filterChange,this)),this.clearButton=t.wrapper.find(".km-filter-reset").on(E,T(this,"_clearFilter")).hide()},_search:function(t){this._filter=!0,this.clearButton[t?"show":"hide"](),this.listView.dataSource.filter(t)},_filterChange:function(t){var e=this;"paste"==t.type&&this.options.autoFilter!==!1?setTimeout(function(){e._applyFilter()},1):this._applyFilter()},_applyFilter:function(){var t=this.options,e=this.searchInput.val(),i=e.length?{field:t.field,operator:t.operator||"startsWith",ignoreCase:t.ignoreCase,value:e}:null;e!==this._oldFilter&&(this._oldFilter=e,this._search(i))},_clearFilter:function(t){this.searchInput.val(""),this._search(null),t.preventDefault()}}),p=w.extend({init:function(t,e){var i=this;w.fn.init.call(this,t,e),t=this.element,e=this.options,e.scrollTreshold&&(e.scrollThreshold=e.scrollTreshold),t.on("down",S,"_highlight").on("move up cancel",S,"_dim"),this._userEvents=new m.UserEvents(t,{filter:k,allowSelection:!0,tap:function(t){i._click(t)},end:function(t){m.mobile.application.options.useNativeScrolling&&t.preventDefault()}}),t.css("-ms-touch-action","auto"),t.wrap(I),this.wrapper=this.element.parent(),this._headerFixer=new G(this),this._itemsCache={},this._templates(),this.virtual=e.endlessScroll||e.loadMore,this._style(),this.options.pullToRefresh&&(this._pullToRefreshHandler=new N(this)),this.options.filterable&&(this._filter=new f(this)),this._itemBinder=this.virtual?new c(this):new u(this),this.setDataSource(e.dataSource),this._enhanceItems(this.items()),m.notify(this,b)},events:[E,L,R,M],options:{name:"ListView",style:"",type:"flat",autoBind:!0,fixedHeaders:!1,template:"#:data#",headerTemplate:'#:value#',appendOnRefresh:!1,loadMore:!1,loadMoreText:"Press to load more",endlessScroll:!1,scrollThreshold:30,pullToRefresh:!1,pullTemplate:"Pull to refresh",releaseTemplate:"Release to refresh",refreshTemplate:"Refreshing",pullOffset:140,filterable:!1,virtualViewSize:null},refresh:function(){this._itemBinder.refresh()},reset:function(){this._itemBinder.reset()},setDataSource:function(t){var e=!t;this.dataSource=_.create(t),this.trigger("_dataSource",{dataSource:this.dataSource}),this.options.autoBind&&!e&&(this.items().remove(),this.dataSource.fetch())},destroy:function(){w.fn.destroy.call(this),m.destroy(this.element),this._userEvents.destroy(),this._itemBinder&&this._itemBinder.destroy(),this.element.unwrap(),delete this.element,delete this.wrapper,delete this._userEvents},items:function(){return"group"===this.options.type?this.element.find(".km-list").children():this.element.children().not(".km-load-more")},scroller:function(){return this._scrollerInstance||(this._scrollerInstance=this.element.closest(".km-scroll-wrapper").data("kendoMobileScroller")),this._scrollerInstance},showLoading:function(){var t=this.view();t&&t.loader&&t.loader.show()},hideLoading:function(){var t=this.view();t&&t.loader&&t.loader.hide()},insertAt:function(t,e){var i=this;return this._renderItems(t,function(s){0===e?i.element.prepend(s):-1===e?i.element.append(s):i.items().eq(e-1).after(s);for(var n=0;ne;e++)s[e]="[data-"+m.ns+"uid="+t[e].uid+"]";return this.element.find(s.join(","))},setDataItem:function(e,i){var s=this,n=function(n){var o=t(n[0]);t(e).replaceWith(o),s.trigger(M,{item:o,data:i,ns:b})};return this._renderItems([i],n)[0]},_renderItems:function(e,i){var s=t(m.render(this.template,e));return i(s),v.init(s),this._enhanceItems(s),s},_dim:function(t){this._toggle(t,!1)},_highlight:function(t){this._toggle(t,!0)},_toggle:function(e,i){if(!(e.which>1)){var s=t(e.currentTarget),n=s.parent(),o=x(s,"role")||"",r=!o.match(U),l=e.isDefaultPrevented();r&&n.toggleClass(H,i&&!l)}},_templates:function(){var t=this.options.template,e=this.options.headerTemplate,i=' data-uid="#=arguments[0].uid || ""#"',s={},n={};typeof t===P&&(s.template=t,t="#=this.template(data)#"),this.template=T(m.template(""+t+""),s),n.template=this.template,typeof e===P&&(n._headerTemplate=e,e="#=this._headerTemplate(data)#"),n.headerTemplate=m.template(e),this.groupTemplate=T(B,n)},_click:function(e){if(!(e.event.which>1||e.event.isDefaultPrevented())){var i,s=e.target,n=t(e.event.target),o=n.closest(m.roleSelector("button","detailbutton","backbutton")),r=m.widgetInstance(o,b),l=s.attr(m.attr("uid"));l&&(i=this.dataSource.getByUid(l)),this.trigger(E,{target:n,item:s,dataItem:i,button:r})&&e.preventDefault()}},_styleGroups:function(){var e=this.element.children();e.children("ul").addClass("km-list"),e.each(function(){var e=t(this),i=e.contents().first();e.addClass("km-group-container"),i.is("ul")||i.is("div."+C)||i.wrap(D)})},_style:function(){var t=this.options,e="group"===t.type,i=this.element,s="inset"===t.style;i.addClass("km-listview").toggleClass("km-list",!e).toggleClass("km-virtual-list",this.virtual).toggleClass("km-listinset",!e&&s).toggleClass("km-listgroup",e&&!s).toggleClass("km-listgroupinset",e&&s),i.parents(".km-listview")[0]||i.closest(".km-content").toggleClass("km-insetcontent",s),e&&this._styleGroups(),this.trigger(F)},_enhanceItems:function(e){e.each(function(){var e,i=t(this),r=!1;i.children().each(function(){e=t(this),e.is("a")?(n(e),r=!0):e.is("label")&&(o(e),r=!0)}),r||s(i)})}}),b.plugin(p)}(window.kendo.jQuery)})}("function"==typeof define&&define.amd?define:function(t,e){return e()});
//@ sourceMappingURL=kendo.mobile.listview.min.js.map