text: angular.module("tm.pagination",[]).directive("tmPagination",[function(){return window.timeout=null,{restrict:"EA",template:'<div class="page-list"><ul class="pagination" ng-show="conf.totalItems > 0"><li ng-class="{disabled: conf.currentPage == 1}" ng-click="prevPage()"><span>&laquo;<\/span><\/li><li ng-repeat="item in pageList track by $index" ng-class="{active: item == conf.currentPage, separate: item == \'...\'}" ng-click="changeCurrentPage(item)"><span>{{ item }}<\/span><\/li><li ng-class="{disabled: conf.currentPage == conf.numberOfPages}" ng-click="nextPage()"><span>&raquo;<\/span><\/li><\/ul><div class="page-total" ng-show="conf.totalItems > 0">第<input type="text" ng-model="jumpPageNum"  ng-keyup="jumpToPage($event)"/>页 / 共<strong>{{ totalPage }}<\/strong>页，每页<select ng-model="conf.itemsPerPage" ng-options="option for option in conf.perPageOptions " ng-change="changeItemsPerPage()"><\/select>条，合计<strong>{{ conf.totalItems }}<\/strong>条<\/div><div class="no-items" ng-show="conf.totalItems <= 0">暂无数据<\/div><\/div>',replace:!0,scope:{conf:"="},link:function(n){function t(){var r,u,t,i;for(n.totalPage=Math.ceil(n.conf.totalItems/n.conf.itemsPerPage),n.conf.currentPage=parseInt(n.conf.currentPage)?parseInt(n.conf.currentPage):1,n.conf.totalItems=parseInt(n.conf.totalItems),n.conf.rememberPerPage?(parseInt(localStorage[n.conf.rememberPerPage])||(localStorage[n.conf.rememberPerPage]=parseInt(n.conf.itemsPerPage)?parseInt(n.conf.itemsPerPage):15),n.conf.itemsPerPage=parseInt(localStorage[n.conf.rememberPerPage])):n.conf.itemsPerPage=parseInt(n.conf.itemsPerPage)?parseInt(n.conf.itemsPerPage):15,n.conf.numberOfPages=Math.ceil(n.conf.totalItems/n.conf.itemsPerPage),n.conf.currentPage<1&&(n.conf.currentPage=1),n.conf.currentPage>n.conf.numberOfPages&&(n.conf.currentPage=n.conf.numberOfPages),n.jumpPageNum=n.conf.currentPage,r=n.conf.perPageOptions.length,t=0;t<r;t++)n.conf.perPageOptions[t]==n.conf.itemsPerPage&&(u=!0);if(u||n.conf.perPageOptions.push(n.conf.itemsPerPage),n.conf.perPageOptions.sort(function(n,t){return n-t}),n.pageList=[],n.conf.numberOfPages<=n.conf.pagesLength)for(t=1;t<=n.conf.numberOfPages;t++)n.pageList.push(t);else if(i=(n.conf.pagesLength-1)/2,n.conf.currentPage<=i){for(t=1;t<=i+1;t++)n.pageList.push(t);n.pageList.push("...");n.pageList.push(n.conf.numberOfPages)}else if(n.conf.currentPage>n.conf.numberOfPages-i){for(n.pageList.push(1),n.pageList.push("..."),t=i+1;t>=1;t--)n.pageList.push(n.conf.numberOfPages-t);n.pageList.push(n.conf.numberOfPages)}else{for(n.pageList.push(1),n.pageList.push("..."),t=Math.ceil(i/2);t>=1;t--)n.pageList.push(n.conf.currentPage-t);for(n.pageList.push(n.conf.currentPage),t=1;t<=i/2;t++)n.pageList.push(n.conf.currentPage+t);n.pageList.push("...");n.pageList.push(n.conf.numberOfPages)}n.conf.onChange&&(window.timeout&&clearTimeout(window.timeout),window.timeout=setTimeout(function(){n.conf.currentPage>0&&(n.conf.onChange(),window.timeout=null)},100));n.$parent.conf=n.conf}n.changeCurrentPage=function(t){t!="..."&&(n.conf.currentPage=t)};n.conf.pagesLength=parseInt(n.conf.pagesLength)?parseInt(n.conf.pagesLength):9;n.conf.pagesLength%2==0&&(n.conf.pagesLength=n.conf.pagesLength-1);n.conf.perPageOptions||(n.conf.perPageOptions=[10,15,20,30,50]);n.prevPage=function(){n.conf.currentPage>1&&(n.conf.currentPage-=1)};n.nextPage=function(){n.conf.currentPage<n.conf.numberOfPages&&(n.conf.currentPage+=1)};n.jumpToPage=function(){n.jumpPageNum=n.jumpPageNum.replace(/[^0-9]/g,"");n.jumpPageNum!==""&&(n.conf.currentPage=n.jumpPageNum)};n.changeItemsPerPage=function(){n.conf.rememberPerPage&&localStorage.removeItem(n.conf.rememberPerPage)};n.$watch(function(){var t=n.conf.currentPage+" "+n.conf.totalItems+" ";return t+(n.conf.rememberPerPage?localStorage[n.conf.rememberPerPage]?localStorage[n.conf.rememberPerPage]:n.conf.itemsPerPage:n.conf.itemsPerPage)},t)}}}]);