forked from aloysious/pagination
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex-min.js
executable file
·3 lines (3 loc) · 2.74 KB
/
index-min.js
1
2
3
/*! pagination - v2.0.0 - 2013-06-18 3:01:15 PM
* Copyright (c) 2013 首作; Licensed */
KISSY.add("kg/pagination/2.0.0/index",function(a,b,c,d,e){"use strict";function f(b,c){if(!(this instanceof f))return new f(b,c);if(a.isObject(b))this.con=b;else if(/^#/i.test(b))this.con=a.one(b);else if(a.one("#"+b))this.con=a.one("#"+b);else{if(!a.one(b))throw new Error("Pagination Container Hooker not found");this.con=a.one(b)}f.superclass.constructor.call(this,c),this.init()}return f.ATTRS={totalPage:{value:10},currentPage:{value:1},preposePagesCount:{value:2},postposePagesCount:{value:1},firstPagesCount:{value:2},lastPagesCount:{value:0},render:{value:!0}},a.extend(f,a.Base,{init:function(){this.get("render")&&this.render()},render:function(){this.renderUI(),this.bindUI(),this.syncUI()},renderUI:function(){this._resetPagination()},bindUI:function(){var a=this;c.delegate(a.con,"click",".pagination-spec",function(b){var c=b.currentTarget,d=parseInt(e.attr(c,"data-page"));a._switchToPage(d)}),c.delegate(a.con,"click",".pagination-prev",function(){var b=a.get("currentPage")-1;a._switchToPage(b)}),c.delegate(a.con,"click",".pagination-next",function(){var b=a.get("currentPage")+1;a._switchToPage(b)})},syncUI:function(){},_resetPagination:function(){var a,b="",c=this.get("totalPage")>0?this.get("totalPage"):1,d=(this.get("currentPage")<=c&&this.get("currentPage"))>0?this.get("currentPage"):1,f=this.get("preposePagesCount")>=0?this.get("preposePagesCount"):2,g=this.get("postposePagesCount")>=0?this.get("postposePagesCount"):1,h=this.get("firstPagesCount")>=0?this.get("firstPagesCount"):2,i=this.get("lastPagesCount")>=0?this.get("lastPagesCount"):0;if(b+=1===d?'<span class="pagination-start"><span>\u4e0a\u4e00\u9875</span></span>':'<a class="pagination-prev"><span>\u4e0a\u4e00\u9875</span></a>',h+f+1>=d)for(var j=1;d>j;j++)b+=this._renderActivePage(j);else{for(var j=1;h>=j;j++)b+=this._renderActivePage(j);b+='<span class="pagination-break">...</span>';for(var j=d-f;d-1>=j;j++)b+=this._renderActivePage(j)}if(b+='<span class="pagination-curr">'+d+"</span>",d>=c-i-g){a=d+1;for(var j=d+1;c>=j;j++)b+=this._renderActivePage(j)}else{for(var j=d+1;d+g>=j;j++)b+=this._renderActivePage(j);b+='<span class="pagination-break">...</span>';for(var j=c-i+1;c>=j;j++)b+=this._renderActivePage(j)}b+=d===c?'<span class="pagination-end"><span>\u4e0b\u4e00\u9875</span></span>':'<a class="pagination-next"><span>\u4e0b\u4e00\u9875<span></a>',e.html(this.con,b)},_renderActivePage:function(a){return'<a class="pagination-spec" data-page="'+a+'">'+a+"</a>"},_switchToPage:function(a){this.set("currentPage",a),this._resetPagination(),this.fire("switch",{toPage:this.get("currentPage")})},show:function(){this.con.show()},hide:function(){this.con.hide()}}),f},{requires:["base","event","node","dom"]});