LocalCDN-Firefox-Chrome-Brave/resources/paginationjs/2.6.0/pagination.min.jsm

11 lines
15 KiB
JavaScript
Raw Normal View History

2023-03-17 06:22:19 +01:00
/*
* pagination.js 2.6.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,u){void 0===u&&l("Pagination requires jQuery.");var r="pagination",s="__pagination-",D=(u.fn.pagination&&l('plugin conflicted, the name "pagination" has been taken by another jQuery plugin.'),u.fn[r]=function(a){if(void 0!==a){var t,c=u(this),J=u.extend({},u.fn[r].defaults,a),e={initialize:function(){var e,t=this;c.data("pagination")||c.data("pagination",{}),!1!==t.callHook("beforeInit")&&(c.data("pagination").initialized&&u(".paginationjs",c).remove(),t.disabled=!!J.disabled,e=t.model={pageRange:J.pageRange,pageSize:J.pageSize},t.parseDataSource(J.dataSource,function(a){t.isAsync=D.isString(a),D.isArray(a)&&(e.totalNumber=J.totalNumber=a.length),t.isDynamicTotalNumber=t.isAsync&&J.totalNumberLocator;a=t.render(!0);J.className&&a.addClass(J.className),e.el=a,c["bottom"===J.position?"append":"prepend"](a),t.observer(),c.data("pagination").initialized=!0,t.callHook("afterInit",a)}))},render:function(a){var e=this,t=e.model,o=t.el||u('<div class="paginationjs"></div>'),a=!0!==a,t=(e.callHook("beforeRender",a),t.pageNumber||J.pageNumber),i=J.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})),J.hideOnlyOnePage&&o[n<=1?"hide":"show"](),e.callHook("afterRender",a),o},getPageLinkTag:function(a){var e=J.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=J.ellipsisText,l=J.classPrefix,c=J.pageClassName||"",u=J.activeClassName||"",g=J.disableClassName||"";if(null===J.pageRange)for(e=1;e<=o;e++)s+=e==t?`<li class="${l}-page J-paginationjs-page ${c} ${u}" data-num="${e}"><a>${e}</a></li>`:`<li class="${l}-page J-paginationjs-page ${c}" 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 ${c} ${u}" data-num="${e}"><a>${e}</a></li>`:`<li class="${l}-page J-paginationjs-page ${c}" data-num="${e}">${i(e)}</li>`;else J.hideFirstOnEllipsisShow||(s+=`<li class="${l}-page ${l}-first J-paginationjs-page ${c}" 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 ${c} ${u}" data-num="${e}"><a>${e}</a></li>`:`<li class="${l}-page J-paginationjs-page ${c}" 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 ${c}" data-num="${e}">${i(e)}</li>`;else s+=`<li class="${l}-ellipsis ${g}"><a>${a}</a></li>`,J.hideLastOnEllipsisShow||(s+=`<li class="${l}-page ${l}-last J-paginationjs-page ${c}" 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=J.pageSize,l=J.showPrevious,c=J.showNext,u=J.showPageNumbers,g=J.showNavigator,p=J.showSizeChanger,f=J.sizeChangerOptions,d=J.showGoInput,m=J.showGoButton,b=J.prevText,h=J.nextText,v=J.goButtonText,y=J.classPrefix,N=J.disableClassName||"",$=J.ulClassName||"",k=J.prevClassName||"",P=J.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 J.formatSizeChanger?J.formatSizeChanger(o,i,r):J.formatSizeChanger,C="function"==typeof J.formatNavigator?J.formatNavigator(o,i,r):J.formatNavigator,H="function"==typeof J.formatGoInput?J.formatGoInput(S,o,i,r):J.formatGoInput,w="function"==typeof J.formatGoButton?J.formatGoButton(v,o,i,r):J.formatGoButton,O="function"==typeof J.autoHidePrevious?J.autoHidePrevious():J.autoHidePrevious,z="function"==typeof J.autoHideNext?J.autoHideNext():J.autoHideNext,L="function"==typeof J.header?J.header(o,i,r):J.header,E="function"==typeof J.footer?J.footer(o,i,r):J.footer;if(L&&(x+=e=t.replaceVariables(L,{currentPage:o,totalPage:i,totalNumber:r})),g&&C&&(x+=`<div class="${y}-nav J-paginationjs-nav">${e=t.replaceVariables(C,{currentPage:o