mirror of
https://codeberg.org/nobody/LocalCDN.git
synced 2025-01-13 02:23:09 +01:00
11 lines
15 KiB
JavaScript
11 lines
15 KiB
JavaScript
|
/*
|
||
|
* pagination.js 2.5.0
|
||
|
* A jQuery plugin to provide simple yet fully customisable pagination
|
||
|
* https://github.com/superRaytin/paginationjs
|
||
|
|
||
|
* Homepage: http://pagination.js.org
|
||
|
*
|
||
|
* Copyright 2014-2100, superRaytin
|
||
|
* Released under the MIT license.
|
||
|
*/
|
||
|
!function(n,c){void 0===c&&l("Pagination requires jQuery.");var r="pagination",s="__pagination-",I=(c.fn.pagination&&l('plugin conflicted, the name "pagination" has been taken by another jQuery plugin.'),c.fn[r]=function(a){if(void 0!==a){var t,u=c(this),D=c.extend({},c.fn[r].defaults,a),e={initialize:function(){var e,t=this;u.data("pagination")||u.data("pagination",{}),!1!==t.callHook("beforeInit")&&(u.data("pagination").initialized&&c(".paginationjs",u).remove(),t.disabled=!!D.disabled,e=t.model={pageRange:D.pageRange,pageSize:D.pageSize},t.parseDataSource(D.dataSource,function(a){t.isAsync=I.isString(a),I.isArray(a)&&(e.totalNumber=D.totalNumber=a.length),t.isDynamicTotalNumber=t.isAsync&&D.totalNumberLocator;a=t.render(!0);D.className&&a.addClass(D.className),e.el=a,u["bottom"===D.position?"append":"prepend"](a),t.observer(),u.data("pagination").initialized=!0,t.callHook("afterInit",a)}))},render:function(a){var e=this,t=e.model,o=t.el||c('<div class="paginationjs"></div>'),a=!0!==a,t=(e.callHook("beforeRender",a),t.pageNumber||D.pageNumber),i=D.pageRange||0,n=e.getTotalPage(),r=t-i,s=t+i;return(r=n<s?(r=(s=n)-2*i)<1?1:r:r)<=1&&(r=1,s=Math.min(2*i+1,n)),o.html(e.generateHTML({currentPage:t,pageRange:i,rangeStart:r,rangeEnd:s})),D.hideOnlyOnePage&&o[n<=1?"hide":"show"](),e.callHook("afterRender",a),o},getPageLinkTag:function(a){var e=D.pageLink;return e?`<a href="${e}">${a}</a>`:`<a>${a}</a>`},generatePageNumbersHTML:function(a){var e,t=a.currentPage,o=this.getTotalPage(),i=this.getPageLinkTag,n=a.rangeStart,r=a.rangeEnd,s="",a=D.ellipsisText,l=D.classPrefix,u=D.pageClassName||"",c=D.activeClassName||"",g=D.disableClassName||"";if(null===D.pageRange)for(e=1;e<=o;e++)s+=e==t?`<li class="${l}-page J-paginationjs-page ${u} ${c}" data-num="${e}"><a>${e}</a></li>`:`<li class="${l}-page J-paginationjs-page ${u}" data-num="${e}">${i(e)}</li>`;else{if(n<=3)for(e=1;e<n;e++)s+=e==t?`<li class="${l}-page J-paginationjs-page ${u} ${c}" data-num="${e}"><a>${e}</a></li>`:`<li class="${l}-page J-paginationjs-page ${u}" data-num="${e}">${i(e)}</li>`;else D.hideFirstOnEllipsisShow||(s+=`<li class="${l}-page ${l}-first J-paginationjs-page ${u}" data-num="1">${i(1)}</li>`),s+=`<li class="${l}-ellipsis ${g}"><a>${a}</a></li>`;for(e=n;e<=r;e++)s+=e==t?`<li class="${l}-page J-paginationjs-page ${u} ${c}" data-num="${e}"><a>${e}</a></li>`:`<li class="${l}-page J-paginationjs-page ${u}" data-num="${e}">${i(e)}</li>`;if(o-2<=r)for(e=r+1;e<=o;e++)s+=`<li class="${l}-page J-paginationjs-page ${u}" data-num="${e}">${i(e)}</li>`;else s+=`<li class="${l}-ellipsis ${g}"><a>${a}</a></li>`,D.hideLastOnEllipsisShow||(s+=`<li class="${l}-page ${l}-last J-paginationjs-page ${u}" data-num="${o}">${i(o)}</li>`)}return s},generateHTML:function(a){var e,t=this,o=a.currentPage,i=t.getTotalPage(),n=t.getPageLinkTag,r=t.getTotalNumber(),s=D.pageSize,l=D.showPrevious,u=D.showNext,c=D.showPageNumbers,g=D.showNavigator,p=D.showSizeChanger,f=D.sizeChangerOptions,d=D.showGoInput,m=D.showGoButton,b=D.prevText,h=D.nextText,v=D.goButtonText,N=D.classPrefix,y=D.disableClassName||"",$=D.ulClassName||"",k=D.prevClassName||"",P=D.nextClassName||"",x="",j='<select class="J-paginationjs-size-select">',S='<input type="text" class="J-paginationjs-go-pagenumber">',v=`<input type="button" class="J-paginationjs-go-button" value="${v}">`,T="function"==typeof D.formatSizeChanger?D.formatSizeChanger(o,i,r):D.formatSizeChanger,C="function"==typeof D.formatNavigator?D.formatNavigator(o,i,r):D.formatNavigator,H="function"==typeof D.formatGoInput?D.formatGoInput(S,o,i,r):D.formatGoInput,w="function"==typeof D.formatGoButton?D.formatGoButton(v,o,i,r):D.formatGoButton,O="function"==typeof D.autoHidePrevious?D.autoHidePrevious():D.autoHidePrevious,z="function"==typeof D.autoHideNext?D.autoHideNext():D.autoHideNext,L="function"==typeof D.header?D.header(o,i,r):D.header,J="function"==typeof D.footer?D.footer(o,i,r):D.footer;if(L&&(x+=e=t.replaceVariables(L,{currentPage:o,totalPage:i,totalNumber:r})),g&&C&&(x+=`<div class="${N}-nav J-paginationjs-nav">${e=t.replaceVariables(C,{currentPage:o
|