From e5e669e8d7be891219ee4c1d712d8969008a6e34 Mon Sep 17 00:00:00 2001 From: superRaytin Date: Sat, 17 Jan 2015 15:14:37 +0800 Subject: [PATCH] Update copyright. --- Gruntfile.js | 4 ++-- dist/pagination-with-styles.js | 4 ++-- dist/pagination-with-styles.min.js | 4 ++-- dist/pagination.js | 4 ++-- dist/pagination.min.js | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 2a902a6..33e0af3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,9 +8,9 @@ module.exports = function(grunt){ ' * pagination.js <%= pkg.version %>\n' + ' * <%= pkg.description %>\n' + ' * https://github.com/superRaytin/paginationjs\n\n' + - ' * Homepage: https://paginationjs.com\n' + + ' * Homepage: http://paginationjs.com\n' + ' *\n' + - ' * Copyright 2014, superRaytin\n' + + ' * Copyright 2014-2100, superRaytin\n' + ' * Released under the MIT license.\n' + '*/\n' }, diff --git a/dist/pagination-with-styles.js b/dist/pagination-with-styles.js index 8483d07..73b9c64 100644 --- a/dist/pagination-with-styles.js +++ b/dist/pagination-with-styles.js @@ -3,9 +3,9 @@ * A jQuery plugin to provide simple yet fully customisable pagination. * https://github.com/superRaytin/paginationjs * - * Homepage: https://paginationjs.com + * Homepage: http://paginationjs.com * - * Copyright 2014, superRaytin + * Copyright 2014-2100, superRaytin * Released under the MIT license. */ diff --git a/dist/pagination-with-styles.min.js b/dist/pagination-with-styles.min.js index 8566867..9edb2a0 100644 --- a/dist/pagination-with-styles.min.js +++ b/dist/pagination-with-styles.min.js @@ -3,9 +3,9 @@ * A jQuery plugin to provide simple yet fully customisable pagination * https://github.com/superRaytin/paginationjs - * Homepage: https://paginationjs.com + * Homepage: http://paginationjs.com * - * Copyright 2014, superRaytin + * Copyright 2014-2100, superRaytin * Released under the MIT license. */ !function(a,b){function c(a){throw new Error("Pagination: "+a)}function d(a){a.dataSource||c('"dataSource" is required.'),"string"==typeof a.dataSource?"undefined"==typeof a.totalNumber?c('"totalNumber" is required.'):b.isNumeric(a.totalNumber)||c('"totalNumber" is incorrect. (Number)'):i.isObject(a.dataSource)&&("undefined"==typeof a.locator?c('"dataSource" is a Object, please specify "locator".'):"string"==typeof a.locator||b.isFunction(a.locator)||c(""+a.locator+" is incorrect. (String | Function)"))}function e(){var a=b("#paginationjs-style");if(!a.length){var c='.paginationjs:not(.custom-paginationjs){line-height: 1.6; font-family: "Marmelad", "Lucida Grande", "Arial", "Hiragino Sans GB", Georgia, sans-serif; font-size: 14px; box-sizing: initial;}.paginationjs:not(.custom-paginationjs):after{display: table; content: " "; clear: both;}.paginationjs:not(.custom-paginationjs) .paginationjs-pages{float: left;}.paginationjs:not(.custom-paginationjs) .paginationjs-pages ul{float: left; margin: 0; padding: 0;}.paginationjs:not(.custom-paginationjs) .paginationjs-pages li{float: left; border: 1px solid #aaaaaa; border-right: none; list-style: none;}.paginationjs:not(.custom-paginationjs) .paginationjs-pages li > a{min-width: 30px; height: 28px; line-height: 28px; display: block; background: #fff; font-size: 14px; color: #333; text-decoration: none; text-align: center;}.paginationjs:not(.custom-paginationjs) .paginationjs-pages li > a:hover{background: #eee;}.paginationjs:not(.custom-paginationjs) .paginationjs-pages li.active{border: none;}.paginationjs:not(.custom-paginationjs) .paginationjs-pages li.active > a{height: 30px; line-height: 30px; background: #aaaaaa; color: #fff;}.paginationjs:not(.custom-paginationjs) .paginationjs-pages li.disabled > a{opacity: .3;}.paginationjs:not(.custom-paginationjs) .paginationjs-pages li.disabled > a:hover{background: none;}.paginationjs:not(.custom-paginationjs) .paginationjs-pages li:first-child{border-radius: 3px 0 0 3px;}.paginationjs:not(.custom-paginationjs) .paginationjs-pages li:first-child > a{border-radius: 3px 0 0 3px;}.paginationjs:not(.custom-paginationjs) .paginationjs-pages li:last-child{border-right: 1px solid #aaaaaa; border-radius: 0 3px 3px 0;}.paginationjs:not(.custom-paginationjs) .paginationjs-pages li:last-child > a{border-radius: 0 3px 3px 0;}.paginationjs:not(.custom-paginationjs) .paginationjs-go-input{float: left; margin-left: 10px; font-size: 14px;}.paginationjs:not(.custom-paginationjs) .paginationjs-go-input > input[type="text"]{width: 30px; height: 28px; background: #fff; border-radius: 3px; border: 1px solid #aaaaaa; padding: 0; font-size: 14px; text-align: center; vertical-align: baseline; outline: none; box-shadow: none; box-sizing: initial;}.paginationjs:not(.custom-paginationjs) .paginationjs-go-button{float: left; margin-left: 10px; font-size: 14px;}.paginationjs:not(.custom-paginationjs) .paginationjs-go-button > input[type="button"]{min-width: 40px; height: 30px; line-height: 28px; background: #fff; border-radius: 3px; border: 1px solid #aaaaaa; text-align: center; padding: 0 8px; font-size: 14px; vertical-align: baseline; outline: none; box-shadow: none; color: #333; cursor: pointer;}.paginationjs:not(.custom-paginationjs) .paginationjs-go-button > input[type="button"]:hover{background-color: #f8f8f8;}.paginationjs:not(.custom-paginationjs) .paginationjs-nav{float: left; height: 30px; line-height: 30px; margin-left: 10px; font-size: 14px;}.paginationjs:not(.custom-paginationjs).paginationjs-small{font-size: 12px;}.paginationjs:not(.custom-paginationjs).paginationjs-small li > a{min-width: 26px; height: 24px; line-height: 24px; font-size: 12px;}.paginationjs:not(.custom-paginationjs).paginationjs-small li.active > a{height: 26px; line-height: 26px;}.paginationjs:not(.custom-paginationjs).paginationjs-small .paginationjs-go-input{font-size: 12px;}.paginationjs:not(.custom-paginationjs).paginationjs-small .paginationjs-go-input > input[type="text"]{width: 26px; height: 24px; font-size: 12px;}.paginationjs:not(.custom-paginationjs).paginationjs-small .paginationjs-go-button{font-size: 12px;}.paginationjs:not(.custom-paginationjs).paginationjs-small .paginationjs-go-button > input[type="button"]{min-width: 30px; height: 26px; line-height: 24px; padding: 0 6px; font-size: 12px;}.paginationjs:not(.custom-paginationjs).paginationjs-small .paginationjs-nav{height: 26px; line-height: 26px; font-size: 12px;}.paginationjs:not(.custom-paginationjs).paginationjs-big{font-size: 16px;}.paginationjs:not(.custom-paginationjs).paginationjs-big li > a{min-width: 36px; height: 34px; line-height: 34px; font-size: 16px;}.paginationjs:not(.custom-paginationjs).paginationjs-big li.active > a{height: 36px; line-height: 36px;}.paginationjs:not(.custom-paginationjs).paginationjs-big .paginationjs-go-input{font-size: 16px;}.paginationjs:not(.custom-paginationjs).paginationjs-big .paginationjs-go-input > input[type="text"]{width: 36px; height: 34px; font-size: 16px;}.paginationjs:not(.custom-paginationjs).paginationjs-big .paginationjs-go-button{font-size: 16px;}.paginationjs:not(.custom-paginationjs).paginationjs-big .paginationjs-go-button > input[type="button"]{min-width: 50px; height: 36px; line-height: 34px; padding: 0 12px; font-size: 16px;}.paginationjs:not(.custom-paginationjs).paginationjs-big .paginationjs-nav{height: 36px; line-height: 36px; font-size: 16px;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-blue .paginationjs-pages li{border-color: #289de9;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-blue .paginationjs-pages li > a{color: #289de9;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-blue .paginationjs-pages li > a:hover{background: #e9f4fc;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-blue .paginationjs-pages li.active > a{background: #289de9; color: #fff;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-blue .paginationjs-pages li.disabled > a:hover{background: none;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-blue .paginationjs-go-input > input[type="text"]{border-color: #289de9;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-blue .paginationjs-go-button > input[type="button"]{background: #289de9; border-color: #289de9; color: #fff;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-blue .paginationjs-go-button > input[type="button"]:hover{background-color: #3ca5ea;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-green .paginationjs-pages li{border-color: #449d44;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-green .paginationjs-pages li > a{color: #449d44;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-green .paginationjs-pages li > a:hover{background: #ebf4eb;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-green .paginationjs-pages li.active > a{background: #449d44; color: #fff;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-green .paginationjs-pages li.disabled > a:hover{background: none;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-green .paginationjs-go-input > input[type="text"]{border-color: #449d44;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-green .paginationjs-go-button > input[type="button"]{background: #449d44; border-color: #449d44; color: #fff;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-green .paginationjs-go-button > input[type="button"]:hover{background-color: #55a555;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-yellow .paginationjs-pages li{border-color: #ec971f;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-yellow .paginationjs-pages li > a{color: #ec971f;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-yellow .paginationjs-pages li > a:hover{background: #fdf5e9;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-yellow .paginationjs-pages li.active > a{background: #ec971f; color: #fff;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-yellow .paginationjs-pages li.disabled > a:hover{background: none;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-yellow .paginationjs-go-input > input[type="text"]{border-color: #ec971f;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-yellow .paginationjs-go-button > input[type="button"]{background: #ec971f; border-color: #ec971f; color: #fff;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-yellow .paginationjs-go-button > input[type="button"]:hover{background-color: #eea135;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-red .paginationjs-pages li{border-color: #c9302c;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-red .paginationjs-pages li > a{color: #c9302c;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-red .paginationjs-pages li > a:hover{background: #faeaea;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-red .paginationjs-pages li.active > a{background: #c9302c; color: #fff;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-red .paginationjs-pages li.disabled > a:hover{background: none;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-red .paginationjs-go-input > input[type="text"]{border-color: #c9302c;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-red .paginationjs-go-button > input[type="button"]{background: #c9302c; border-color: #c9302c; color: #fff;}.paginationjs:not(.custom-paginationjs).paginationjs-theme-red .paginationjs-go-button > input[type="button"]:hover{background-color: #ce4541;}';b("head").append('")}}"undefined"==typeof b&&c("Pagination requires jQuery.");var f="pagination",g="addHook",h="__pagination-";b.fn.pagination&&(f="pagination2"),b.fn[f]=function(f){if("undefined"==typeof f)return this;var g=b(this),j={initialize:function(){var a=this;if(g.data("pagination")||g.data("pagination",{}),a.callHook("beforeInit")!==!1){g.data("pagination").initialized&&b(".paginationjs",g).remove(),l.inlineStyle===!0&&e();var c=a.model={pageRange:l.pageRange,pageSize:l.pageSize};a.parseDataSource(l.dataSource,function(b){if(a.sync=i.isArray(b),a.sync&&(c.totalNumber=l.totalNumber=b.length),c.totalPage=a.getTotalPage(),!(l.hideWhenLessThanOnePage&&c.totalPage<=1)){var d=a.render(!0);l.className&&d.addClass(l.className),c.el=d,g["bottom"===l.position?"append":"prepend"](d),a.observer(),g.data("pagination").initialized=!0,a.callHook("afterInit",d)}})}},render:function(a){var c=this,d=c.model,e=d.el||b('
'),f=a!==!0;c.callHook("beforeRender",f);var g=d.pageNumber||l.pageNumber,h=l.pageRange,i=d.totalPage,j=g-h,k=g+h;return k>i&&(k=i,j=i-2*h,j=1>j?1:j),1>=j&&(j=1,k=Math.min(2*h+1,i)),e.html(c.createTemplate({currentPage:g,pageRange:h,totalPage:i,rangeStart:j,rangeEnd:k})),c.callHook("afterRender",f),e},createTemplate:function(a){var c,d,e=this,f=a.currentPage,g=a.totalPage,h=a.rangeStart,i=a.rangeEnd,j=l.totalNumber,k=l.showPrevious,m=l.showNext,n=l.showPageNumbers,o=l.showNavigator,p=l.showGoInput,q=l.showGoButton,r=l.pageLink,s=l.prevText,t=l.nextText,u=l.ellipsisText,v=l.goButtonText,w=l.classPrefix,x=l.activeClassName,y=l.disableClassName,z=l.ulClassName,A=b.isFunction(l.formatNavigator)?l.formatNavigator():l.formatNavigator,B=b.isFunction(l.formatGoInput)?l.formatGoInput():l.formatGoInput,C=b.isFunction(l.formatGoButton)?l.formatGoButton():l.formatGoButton,D=b.isFunction(l.autoHidePrevious)?l.autoHidePrevious():l.autoHidePrevious,E=b.isFunction(l.autoHideNext)?l.autoHideNext():l.autoHideNext,F=b.isFunction(l.header)?l.header():l.header,G=b.isFunction(l.footer)?l.footer():l.footer,H="",I='',J='';if(F&&(c=e.replaceVariables(F,{currentPage:f,totalPage:g,totalNumber:j}),H+=c),k||n||m){if(H+='
',H+=z?'
"}return o&&A&&(c=e.replaceVariables(A,{currentPage:f,totalPage:g,totalNumber:j}),H+='
'+c+"
"),p&&B&&(c=e.replaceVariables(B,{currentPage:f,totalPage:g,totalNumber:j,input:I}),H+='
'+c+"
"),q&&C&&(c=e.replaceVariables(C,{currentPage:f,totalPage:g,totalNumber:j,button:J}),H+='
'+c+"
"),G&&(c=e.replaceVariables(G,{currentPage:f,totalPage:g,totalNumber:j}),H+=c),H},go:function(a,c){function d(a){if(f.direction="undefined"==typeof f.pageNumber?0:h>f.pageNumber?1:-1,f.pageNumber=h,e.render(),e.disabled&&!e.sync&&e.enable(),g.data("pagination").model=f,b.isFunction(l.formatResult)){var d=b.extend(!0,[],a);i.isArray(a=l.formatResult(d))||(a=d)}g.data("pagination").currentPageData=a,e.callHook("beforePaging"),e.doCallback(a,c),e.callHook("afterPaging"),1==h&&e.callHook("afterIsFirstPage"),h==f.totalPage&&e.callHook("afterIsLastPage")}var e=this,f=e.model;if(!e.disabled){var h=a,j=l.pageSize,k=f.totalPage;if(h=parseInt(h),!(!h||1>h||h>k)){if(e.sync)return void d(e.getDataSegment(h));var m={},n=l.alias||{};m[n.pageSize?n.pageSize:"pageSize"]=j,m[n.pageNumber?n.pageNumber:"pageNumber"]=h;var o={type:"get",cache:!1,data:{},contentType:"application/x-www-form-urlencoded; charset=UTF-8",dataType:"json",async:!0};b.extend(!0,o,l.ajax),b.extend(o.data||{},m),o.url=l.dataSource,o.success=function(a){d(e.filterDataByLocator(a))},o.error=function(a,b,c){l.formatAjaxError&&l.formatAjaxError(a,b,c),e.enable()},e.disable(),b.ajax(o)}}},doCallback:function(a,c){var d=this,e=d.model;b.isFunction(c)?c(a,e):b.isFunction(l.callback)&&l.callback(a,e)},destroy:function(){this.callHook("beforeDestroy")!==!1&&(this.model.el.remove(),g.off(),b("#paginationjs-style").remove(),this.callHook("afterDestroy"))},previous:function(a){this.go(this.model.pageNumber-1,a)},next:function(a){this.go(this.model.pageNumber+1,a)},disable:function(){var a=this,b=a.sync?"sync":"async";a.callHook("beforeDisable",b)!==!1&&(a.disabled=!0,a.model.disabled=!0,a.callHook("afterDisable",b))},enable:function(){var a=this,b=a.sync?"sync":"async";a.callHook("beforeEnable",b)!==!1&&(a.disabled=!1,a.model.disabled=!1,a.callHook("afterEnable",b))},show:function(){var a=this;a.model.el.is(":visible")||a.model.el.show()},hide:function(){var a=this;a.model.el.is(":visible")&&a.model.el.hide()},replaceVariables:function(a,b){var c;for(var d in b){var e=b[d],f=new RegExp("<%=\\s*"+d+"\\s*%>","img");c=(c||a).replace(f,e)}return c},getDataSegment:function(a){var b=l.pageSize,c=l.dataSource,d=l.totalNumber,e=b*(a-1)+1,f=Math.min(a*b,d);return c.slice(e-1,f)},getTotalPage:function(){return Math.ceil(l.totalNumber/l.pageSize)},getLocator:function(a){var d;return"string"==typeof a?d=a:b.isFunction(a)?d=a():c('"locator" is incorrect. (String | Function)'),d},filterDataByLocator:function(a){var d,e=this.getLocator(l.locator);if(i.isObject(a)){try{b.each(e.split("."),function(b,c){d=(d?d:a)[c]})}catch(f){}d?i.isArray(d)||c("dataSource."+e+" must be an Array."):c("dataSource."+e+" is undefined.")}return d||a},parseDataSource:function(a,d){var e=this,f=arguments;i.isObject(a)?d(l.dataSource=e.filterDataByLocator(a)):i.isArray(a)?d(l.dataSource=a):b.isFunction(a)?l.dataSource(function(a){b.isFunction(a)&&c('Unexpect parameter of the "done" Function.'),f.callee.call(e,a,d)}):"string"==typeof a?(/^https?|file:/.test(a)&&(l.ajaxDataType="jsonp"),d(a)):c('Unexpect data type of the "dataSource".')},callHook:function(c){var d,e=g.data("pagination"),f=Array.prototype.slice.apply(arguments);return f.shift(),l[c]&&b.isFunction(l[c])&&l[c].apply(a,f)===!1&&(d=!1),e.hooks&&e.hooks[c]&&b.each(e.hooks[c],function(b,c){c.apply(a,f)===!1&&(d=!1)}),d!==!1},observer:function(){var a=this,d=a.model.el;g.on(h+"go",function(d,e,f){e=parseInt(b.trim(e)),e&&(b.isNumeric(e)||c('"pageNumber" is incorrect. (Number)'),a.go(e,f))}),d.delegate(".J-paginationjs-page","click",function(c){var d=b(c.currentTarget),e=b.trim(d.attr("data-num"));return!e||d.hasClass(l.disableClassName)||d.hasClass(l.activeClassName)?void 0:a.callHook("beforePageOnClick",c)===!1?!1:(a.go(e),a.callHook("afterPageOnClick",c),l.pageLink?void 0:!1)}),d.delegate(".J-paginationjs-previous","click",function(c){var d=b(c.currentTarget),e=b.trim(d.attr("data-num"));return e&&!d.hasClass(l.disableClassName)?a.callHook("beforePreviousOnClick",c)===!1?!1:(a.go(e),a.callHook("afterPreviousOnClick",c),l.pageLink?void 0:!1):void 0}),d.delegate(".J-paginationjs-next","click",function(c){var d=b(c.currentTarget),e=b.trim(d.attr("data-num"));return e&&!d.hasClass(l.disableClassName)?a.callHook("beforeNextOnClick",c)===!1?!1:(a.go(e),a.callHook("afterNextOnClick",c),l.pageLink?void 0:!1):void 0}),d.delegate(".J-paginationjs-go-button","click",function(){var c=b(".J-paginationjs-go-pagenumber",d).val();return a.callHook("beforeGoButtonOnClick",event,c)===!1?!1:(g.trigger(h+"go",c),void a.callHook("afterGoButtonOnClick",event,c))}),d.delegate(".J-paginationjs-go-pagenumber","keyup",function(c){if(13===c.which){var e=b(c.currentTarget).val();if(a.callHook("beforeGoInputOnEnter",c,e)===!1)return!1;g.trigger(h+"go",e),b(".J-paginationjs-go-pagenumber",d).focus(),a.callHook("afterGoInputOnEnter",c,e)}}),g.on(h+"previous",function(b,c){a.previous(c)}),g.on(h+"next",function(b,c){a.next(c)}),g.on(h+"disable",function(){a.disable()}),g.on(h+"enable",function(){a.enable()}),g.on(h+"show",function(){a.show()}),g.on(h+"hide",function(){a.hide()}),g.on(h+"destroy",function(){a.destroy()}),(j.sync||l.triggerPagingOnInit)&&g.trigger(h+"go",Math.min(l.pageNumber,a.model.totalPage))}};if(g.data("pagination")&&g.data("pagination").initialized===!0){if(b.isNumeric(f))return g.trigger.call(this,h+"go",f,arguments[1]),this;if("string"==typeof f){var k=Array.prototype.slice.apply(arguments);switch(k[0]=h+k[0],f){case"previous":case"next":case"go":case"disable":case"enable":case"show":case"hide":case"destroy":g.trigger.apply(this,k);break;case"getSelectedPageNum":return g.data("pagination").model?g.data("pagination").model.pageNumber:g.data("pagination").attributes.pageNumber;case"getTotalPage":return g.data("pagination").model.totalPage;case"getSelectedPageData":return g.data("pagination").currentPageData;case"isDisabled":return g.data("pagination").model.disabled===!0;default:c("Pagination do not provide action: "+f)}return this}}else i.isObject(f)||c("options is illegal");var l=b.extend({},arguments.callee.defaults,f);return d(l),j.initialize(),this},b.fn[f].defaults={totalNumber:1,pageNumber:1,pageSize:10,pageRange:2,showPrevious:!0,showNext:!0,showPageNumbers:!0,showNavigator:!1,showGoInput:!1,showGoButton:!1,pageLink:"",prevText:"«",nextText:"»",ellipsisText:"...",goButtonText:"Go",classPrefix:"paginationjs",activeClassName:"active",disableClassName:"disabled",inlineStyle:!0,formatNavigator:"<%= currentPage %> / <%= totalPage %>",formatGoInput:"<%= input %>",formatGoButton:"<%= button %>",position:"bottom",autoHidePrevious:!1,autoHideNext:!1,triggerPagingOnInit:!0,hideWhenLessThanOnePage:!1,showFirstOnEllipsisShow:!0,showLastOnEllipsisShow:!0,callback:function(){}},b.fn[g]=function(a,d){arguments.length<2&&c("Missing argument."),b.isFunction(d)||c("callback must be a function.");var e=b(this),f=e.data("pagination");f||(e.data("pagination",{}),f=e.data("pagination")),!f.hooks&&(f.hooks={}),f.hooks[a]=f.hooks[a]||[],f.hooks[a].push(d)},b[f]=function(a,d){arguments.length<2&&c("Requires two parameters.");var e;return e="string"!=typeof a&&a instanceof jQuery?a:b(a),e.length?(e.pagination(d),e):void 0};var i={};b.each(["Object","Array"],function(a,b){i["is"+b]=function(a){return toString.call(a)==="[object "+b+"]"}}),"function"==typeof define&&(define.amd||define.cmd)&&define(function(){return b})}(this,window.jQuery); \ No newline at end of file diff --git a/dist/pagination.js b/dist/pagination.js index 3f20964..3a9b55d 100644 --- a/dist/pagination.js +++ b/dist/pagination.js @@ -3,9 +3,9 @@ * A jQuery plugin to provide simple yet fully customisable pagination. * https://github.com/superRaytin/paginationjs * - * Homepage: https://paginationjs.com + * Homepage: http://paginationjs.com * - * Copyright 2014, superRaytin + * Copyright 2014-2100, superRaytin * Released under the MIT license. */ diff --git a/dist/pagination.min.js b/dist/pagination.min.js index f6295be..86b1d8a 100644 --- a/dist/pagination.min.js +++ b/dist/pagination.min.js @@ -3,9 +3,9 @@ * A jQuery plugin to provide simple yet fully customisable pagination * https://github.com/superRaytin/paginationjs - * Homepage: https://paginationjs.com + * Homepage: http://paginationjs.com * - * Copyright 2014, superRaytin + * Copyright 2014-2100, superRaytin * Released under the MIT license. */ !function(a,b){function c(a){throw new Error("Pagination: "+a)}function d(a){a.dataSource||c('"dataSource" is required.'),"string"==typeof a.dataSource?"undefined"==typeof a.totalNumber?c('"totalNumber" is required.'):b.isNumeric(a.totalNumber)||c('"totalNumber" is incorrect. (Number)'):h.isObject(a.dataSource)&&("undefined"==typeof a.locator?c('"dataSource" is a Object, please specify "locator".'):"string"==typeof a.locator||b.isFunction(a.locator)||c(""+a.locator+" is incorrect. (String | Function)"))}"undefined"==typeof b&&c("Pagination requires jQuery.");var e="pagination",f="addHook",g="__pagination-";b.fn.pagination&&(e="pagination2"),b.fn[e]=function(e){if("undefined"==typeof e)return this;var f=b(this),i={initialize:function(){var a=this;if(f.data("pagination")||f.data("pagination",{}),a.callHook("beforeInit")!==!1){f.data("pagination").initialized&&b(".paginationjs",f).remove();var c=a.model={pageRange:k.pageRange,pageSize:k.pageSize};a.parseDataSource(k.dataSource,function(b){if(a.sync=h.isArray(b),a.sync&&(c.totalNumber=k.totalNumber=b.length),c.totalPage=a.getTotalPage(),!(k.hideWhenLessThanOnePage&&c.totalPage<=1)){var d=a.render(!0);k.className&&d.addClass(k.className),c.el=d,f["bottom"===k.position?"append":"prepend"](d),a.observer(),f.data("pagination").initialized=!0,a.callHook("afterInit",d)}})}},render:function(a){var c=this,d=c.model,e=d.el||b('
'),f=a!==!0;c.callHook("beforeRender",f);var g=d.pageNumber||k.pageNumber,h=k.pageRange,i=d.totalPage,j=g-h,l=g+h;return l>i&&(l=i,j=i-2*h,j=1>j?1:j),1>=j&&(j=1,l=Math.min(2*h+1,i)),e.html(c.createTemplate({currentPage:g,pageRange:h,totalPage:i,rangeStart:j,rangeEnd:l})),c.callHook("afterRender",f),e},createTemplate:function(a){var c,d,e=this,f=a.currentPage,g=a.totalPage,h=a.rangeStart,i=a.rangeEnd,j=k.totalNumber,l=k.showPrevious,m=k.showNext,n=k.showPageNumbers,o=k.showNavigator,p=k.showGoInput,q=k.showGoButton,r=k.pageLink,s=k.prevText,t=k.nextText,u=k.ellipsisText,v=k.goButtonText,w=k.classPrefix,x=k.activeClassName,y=k.disableClassName,z=k.ulClassName,A=b.isFunction(k.formatNavigator)?k.formatNavigator():k.formatNavigator,B=b.isFunction(k.formatGoInput)?k.formatGoInput():k.formatGoInput,C=b.isFunction(k.formatGoButton)?k.formatGoButton():k.formatGoButton,D=b.isFunction(k.autoHidePrevious)?k.autoHidePrevious():k.autoHidePrevious,E=b.isFunction(k.autoHideNext)?k.autoHideNext():k.autoHideNext,F=b.isFunction(k.header)?k.header():k.header,G=b.isFunction(k.footer)?k.footer():k.footer,H="",I='',J='';if(F&&(c=e.replaceVariables(F,{currentPage:f,totalPage:g,totalNumber:j}),H+=c),l||n||m){if(H+='
',H+=z?'
"}return o&&A&&(c=e.replaceVariables(A,{currentPage:f,totalPage:g,totalNumber:j}),H+='
'+c+"
"),p&&B&&(c=e.replaceVariables(B,{currentPage:f,totalPage:g,totalNumber:j,input:I}),H+='
'+c+"
"),q&&C&&(c=e.replaceVariables(C,{currentPage:f,totalPage:g,totalNumber:j,button:J}),H+='
'+c+"
"),G&&(c=e.replaceVariables(G,{currentPage:f,totalPage:g,totalNumber:j}),H+=c),H},go:function(a,c){function d(a){if(g.direction="undefined"==typeof g.pageNumber?0:i>g.pageNumber?1:-1,g.pageNumber=i,e.render(),e.disabled&&!e.sync&&e.enable(),f.data("pagination").model=g,b.isFunction(k.formatResult)){var d=b.extend(!0,[],a);h.isArray(a=k.formatResult(d))||(a=d)}f.data("pagination").currentPageData=a,e.callHook("beforePaging"),e.doCallback(a,c),e.callHook("afterPaging"),1==i&&e.callHook("afterIsFirstPage"),i==g.totalPage&&e.callHook("afterIsLastPage")}var e=this,g=e.model;if(!e.disabled){var i=a,j=k.pageSize,l=g.totalPage;if(i=parseInt(i),!(!i||1>i||i>l)){if(e.sync)return void d(e.getDataSegment(i));var m={},n=k.alias||{};m[n.pageSize?n.pageSize:"pageSize"]=j,m[n.pageNumber?n.pageNumber:"pageNumber"]=i;var o={type:"get",cache:!1,data:{},contentType:"application/x-www-form-urlencoded; charset=UTF-8",dataType:"json",async:!0};b.extend(!0,o,k.ajax),b.extend(o.data||{},m),o.url=k.dataSource,o.success=function(a){d(e.filterDataByLocator(a))},o.error=function(a,b,c){k.formatAjaxError&&k.formatAjaxError(a,b,c),e.enable()},e.disable(),b.ajax(o)}}},doCallback:function(a,c){var d=this,e=d.model;b.isFunction(c)?c(a,e):b.isFunction(k.callback)&&k.callback(a,e)},destroy:function(){this.callHook("beforeDestroy")!==!1&&(this.model.el.remove(),f.off(),b("#paginationjs-style").remove(),this.callHook("afterDestroy"))},previous:function(a){this.go(this.model.pageNumber-1,a)},next:function(a){this.go(this.model.pageNumber+1,a)},disable:function(){var a=this,b=a.sync?"sync":"async";a.callHook("beforeDisable",b)!==!1&&(a.disabled=!0,a.model.disabled=!0,a.callHook("afterDisable",b))},enable:function(){var a=this,b=a.sync?"sync":"async";a.callHook("beforeEnable",b)!==!1&&(a.disabled=!1,a.model.disabled=!1,a.callHook("afterEnable",b))},show:function(){var a=this;a.model.el.is(":visible")||a.model.el.show()},hide:function(){var a=this;a.model.el.is(":visible")&&a.model.el.hide()},replaceVariables:function(a,b){var c;for(var d in b){var e=b[d],f=new RegExp("<%=\\s*"+d+"\\s*%>","img");c=(c||a).replace(f,e)}return c},getDataSegment:function(a){var b=k.pageSize,c=k.dataSource,d=k.totalNumber,e=b*(a-1)+1,f=Math.min(a*b,d);return c.slice(e-1,f)},getTotalPage:function(){return Math.ceil(k.totalNumber/k.pageSize)},getLocator:function(a){var d;return"string"==typeof a?d=a:b.isFunction(a)?d=a():c('"locator" is incorrect. (String | Function)'),d},filterDataByLocator:function(a){var d,e=this.getLocator(k.locator);if(h.isObject(a)){try{b.each(e.split("."),function(b,c){d=(d?d:a)[c]})}catch(f){}d?h.isArray(d)||c("dataSource."+e+" must be an Array."):c("dataSource."+e+" is undefined.")}return d||a},parseDataSource:function(a,d){var e=this,f=arguments;h.isObject(a)?d(k.dataSource=e.filterDataByLocator(a)):h.isArray(a)?d(k.dataSource=a):b.isFunction(a)?k.dataSource(function(a){b.isFunction(a)&&c('Unexpect parameter of the "done" Function.'),f.callee.call(e,a,d)}):"string"==typeof a?(/^https?|file:/.test(a)&&(k.ajaxDataType="jsonp"),d(a)):c('Unexpect data type of the "dataSource".')},callHook:function(c){var d,e=f.data("pagination"),g=Array.prototype.slice.apply(arguments);return g.shift(),k[c]&&b.isFunction(k[c])&&k[c].apply(a,g)===!1&&(d=!1),e.hooks&&e.hooks[c]&&b.each(e.hooks[c],function(b,c){c.apply(a,g)===!1&&(d=!1)}),d!==!1},observer:function(){var a=this,d=a.model.el;f.on(g+"go",function(d,e,f){e=parseInt(b.trim(e)),e&&(b.isNumeric(e)||c('"pageNumber" is incorrect. (Number)'),a.go(e,f))}),d.delegate(".J-paginationjs-page","click",function(c){var d=b(c.currentTarget),e=b.trim(d.attr("data-num"));return!e||d.hasClass(k.disableClassName)||d.hasClass(k.activeClassName)?void 0:a.callHook("beforePageOnClick",c)===!1?!1:(a.go(e),a.callHook("afterPageOnClick",c),k.pageLink?void 0:!1)}),d.delegate(".J-paginationjs-previous","click",function(c){var d=b(c.currentTarget),e=b.trim(d.attr("data-num"));return e&&!d.hasClass(k.disableClassName)?a.callHook("beforePreviousOnClick",c)===!1?!1:(a.go(e),a.callHook("afterPreviousOnClick",c),k.pageLink?void 0:!1):void 0}),d.delegate(".J-paginationjs-next","click",function(c){var d=b(c.currentTarget),e=b.trim(d.attr("data-num"));return e&&!d.hasClass(k.disableClassName)?a.callHook("beforeNextOnClick",c)===!1?!1:(a.go(e),a.callHook("afterNextOnClick",c),k.pageLink?void 0:!1):void 0}),d.delegate(".J-paginationjs-go-button","click",function(){var c=b(".J-paginationjs-go-pagenumber",d).val();return a.callHook("beforeGoButtonOnClick",event,c)===!1?!1:(f.trigger(g+"go",c),void a.callHook("afterGoButtonOnClick",event,c))}),d.delegate(".J-paginationjs-go-pagenumber","keyup",function(c){if(13===c.which){var e=b(c.currentTarget).val();if(a.callHook("beforeGoInputOnEnter",c,e)===!1)return!1;f.trigger(g+"go",e),b(".J-paginationjs-go-pagenumber",d).focus(),a.callHook("afterGoInputOnEnter",c,e)}}),f.on(g+"previous",function(b,c){a.previous(c)}),f.on(g+"next",function(b,c){a.next(c)}),f.on(g+"disable",function(){a.disable()}),f.on(g+"enable",function(){a.enable()}),f.on(g+"show",function(){a.show()}),f.on(g+"hide",function(){a.hide()}),f.on(g+"destroy",function(){a.destroy()}),(i.sync||k.triggerPagingOnInit)&&f.trigger(g+"go",Math.min(k.pageNumber,a.model.totalPage))}};if(f.data("pagination")&&f.data("pagination").initialized===!0){if(b.isNumeric(e))return f.trigger.call(this,g+"go",e,arguments[1]),this;if("string"==typeof e){var j=Array.prototype.slice.apply(arguments);switch(j[0]=g+j[0],e){case"previous":case"next":case"go":case"disable":case"enable":case"show":case"hide":case"destroy":f.trigger.apply(this,j);break;case"getSelectedPageNum":return f.data("pagination").model?f.data("pagination").model.pageNumber:f.data("pagination").attributes.pageNumber;case"getTotalPage":return f.data("pagination").model.totalPage;case"getSelectedPageData":return f.data("pagination").currentPageData;case"isDisabled":return f.data("pagination").model.disabled===!0;default:c("Pagination do not provide action: "+e)}return this}}else h.isObject(e)||c("options is illegal");var k=b.extend({},arguments.callee.defaults,e);return d(k),i.initialize(),this},b.fn[e].defaults={totalNumber:1,pageNumber:1,pageSize:10,pageRange:2,showPrevious:!0,showNext:!0,showPageNumbers:!0,showNavigator:!1,showGoInput:!1,showGoButton:!1,pageLink:"",prevText:"«",nextText:"»",ellipsisText:"...",goButtonText:"Go",classPrefix:"paginationjs",activeClassName:"active",disableClassName:"disabled",inlineStyle:!0,formatNavigator:"<%= currentPage %> / <%= totalPage %>",formatGoInput:"<%= input %>",formatGoButton:"<%= button %>",position:"bottom",autoHidePrevious:!1,autoHideNext:!1,triggerPagingOnInit:!0,hideWhenLessThanOnePage:!1,showFirstOnEllipsisShow:!0,showLastOnEllipsisShow:!0,callback:function(){}},b.fn[f]=function(a,d){arguments.length<2&&c("Missing argument."),b.isFunction(d)||c("callback must be a function.");var e=b(this),f=e.data("pagination");f||(e.data("pagination",{}),f=e.data("pagination")),!f.hooks&&(f.hooks={}),f.hooks[a]=f.hooks[a]||[],f.hooks[a].push(d)},b[e]=function(a,d){arguments.length<2&&c("Requires two parameters.");var e;return e="string"!=typeof a&&a instanceof jQuery?a:b(a),e.length?(e.pagination(d),e):void 0};var h={};b.each(["Object","Array"],function(a,b){h["is"+b]=function(a){return toString.call(a)==="[object "+b+"]"}}),"function"==typeof define&&(define.amd||define.cmd)&&define(function(){return b})}(this,window.jQuery); \ No newline at end of file