//>>built
define("dgrid/extensions/Pagination",["../_StoreMixin","dojo/_base/declare","dojo/_base/lang","dojo/_base/Deferred","dojo/on","dojo/query","dojo/string","dojo/has","put-selector/put","dojo/i18n!./nls/pagination","dojo/_base/sniff","xstyle/css!../css/extensions/Pagination.css"],function(_1,_2,_3,_4,on,_5,_6,_7,_8,_9){return _2("dgrid.extensions.Pagination",_1,{rowsPerPage:10,pagingTextBox:false,previousNextArrows:true,firstLastArrows:false,pagingLinks:2,pageSizeOptions:[],i18nPagination:_9,showFooter:true,_currentPage:1,_total:0,buildRendering:function(){this.inherited(arguments);var _a=this,_b=this.paginationNode=_8(this.footerNode,"div.dgrid-pagination"),_c=this.paginationStatusNode=_8(_b,"div.dgrid-status"),_d=this.pageSizeOptions,_9=this.i18nPagination,_e,_f;_c.tabIndex=0;if(_d.length){var _10=_8(_b,"select.dgrid-page-size"),i;for(i=0;i<_d.length;i++){_8(_10,"option",_d[i],{value:_d[i]});}on(_10,"change",function(){_a.rowsPerPage=+_10.value;_a.gotoPage(1);});}_c.innerHTML=_6.substitute(_9.status,{start:1,end:1,total:0});_e=this.paginationNavigationNode=_8(_b,"div.dgrid-navigation");if(this.firstLastArrows){_f=_8(_e,"a[href=javascript:].dgrid-first","«");_f.setAttribute("aria-label",_9.gotoFirst);}if(this.previousNextArrows){_f=_8(_e,"a[href=javascript:].dgrid-previous","‹");_f.setAttribute("aria-label",_9.gotoPrev);}this.paginationLinksNode=_8(_e,"span.dgrid-pagination-links");if(this.previousNextArrows){_f=_8(_e,"a[href=javascript:].dgrid-next","›");_f.setAttribute("aria-label",_9.gotoNext);}if(this.firstLastArrows){_f=_8(_e,"a[href=javascript:].dgrid-last","»");_f.setAttribute("aria-label",_9.gotoLast);}on(_e,"a:click",function(){var cls=this.className,_11,max;if(_a._isLoading||cls.indexOf("dgrid-page-disabled")>-1){return;}_11=_a._currentPage;max=Math.ceil(_a._total/_a.rowsPerPage);if(cls=="dgrid-page-link"){_a.gotoPage(+this.innerHTML,true);}else{if(cls=="dgrid-first"){_a.gotoPage(1);}else{if(cls=="dgrid-last"){_a.gotoPage(max);}else{if(cls=="dgrid-previous"){_a.gotoPage(_11-1);}else{if(cls=="dgrid-next"){_a.gotoPage(_11+1);}}}}}});},_updateNavigation:function(_12){var _13=this,_9=this.i18nPagination,_14=this.paginationLinksNode,_15=this._currentPage,_16=this.pagingLinks,_17=this.paginationNavigationNode,end=Math.ceil(this._total/this.rowsPerPage),_18=this._pagingTextBoxHandle;function _19(_1a){var _1b;if(_13.pagingTextBox&&_1a==_15){_1b=_8(_14,"input.dgrid-page-input[type=text][value=$]",_15);_1b.setAttribute("aria-label",_9.jumpPage);_13._pagingTextBoxHandle=on(_1b,"change",function(){var _1c=+this.value;if(!isNaN(_1c)&&_1c>0&&_1c<=end){_13.gotoPage(+this.value,true);}});}else{_1b=_8(_14,"a[href=javascript:]"+(_1a==_15?".dgrid-page-disabled":"")+".dgrid-page-link",_1a);_1b.setAttribute("aria-label",_9.gotoPage);}if(_1a==_15&&_12){_1b.focus();}};if(_18){_18.remove();}_14.innerHTML="";_5(".dgrid-first, .dgrid-previous",_17).forEach(function(_1d){_8(_1d,(_15==1?".":"!")+"dgrid-page-disabled");});_5(".dgrid-last, .dgrid-next",_17).forEach(function(_1e){_8(_1e,(_15>=end?".":"!")+"dgrid-page-disabled");});if(_16&&end>0){_19(1);var _1f=_15-_16;if(_1f>2){_8(_14,"span.dgrid-page-skip","...");}else{_1f=2;}for(var i=_1f;i<Math.min(_15+_16+1,end);i++){_19(i);}if(_15+_16+1<end){_8(_14,"span.dgrid-page-skip","...");}_19(end);}else{if(_13.pagingTextBox){_19(_15);}}},refresh:function(){if(!this.store){throw new Error("Pagination requires a store to operate.");}this.inherited(arguments);this.gotoPage(1);},gotoPage:function(_20,_21){var _22=this;this._trackError(function(){var _23=_22.rowsPerPage,_24=(_20-1)*_23,_25=_3.mixin(_22.get("queryOptions"),{start:_24,count:_23}),_26,_27=_22.contentNode,_28=_22._rowIdToObject,_29=5+_22.id.length,r,_2a;for(r in _28){_22.row(r.substr(_29)).remove();}_22._rowIdToObject={};_27.innerHTML="";_2a=_8(_27,"div.dgrid-loading");_2a.innerHTML=_22.loadingMessage;_22._isLoading=true;_26=_22.store.query(_22.query,_25);return _4.when(_22.renderArray(_26,_2a,_25),function(){_8(_2a,"!");delete _22._isLoading;_22.scrollTo({y:0});_4.when(_26.total,function(_2b){if(!_2b){_22.noDataNode=_8(_22.contentNode,"div.dgrid-no-data");_22.noDataNode.innerHTML=_22.noDataMessage;}_22.paginationStatusNode.innerHTML=_6.substitute(_22.i18nPagination.status,{start:Math.min(_24+1,_2b),end:Math.min(_2b,_24+_23),total:_2b});_22._total=_2b;_22._currentPage=_20;_22._updateNavigation(_21);});if(_7("ie")<7||(_7("ie")&&_7("quirks"))){_22.resize();}},function(_2c){delete _22._isLoading;throw _2c;});});}});});