12345678910111213141516 |
- /**
- * @preserve
- * bootpag - jQuery plugin for dynamic pagination
- *
- * Copyright (c) 2015 botmonster@7items.com
- *
- * Licensed under the MIT license:
- * http://www.opensource.org/licenses/mit-license.php
- *
- * Project home:
- * http://botmonster.com/jquery-bootpag/
- *
- * Version: 1.0.7
- *
- */
- !function(a,t){a.fn.bootpag=function(t){function s(t,s){s=parseInt(s,10);var r,n=0==i.maxVisible?1:i.maxVisible,d=1==i.maxVisible?0:1,o=Math.floor((s-1)/n)*n,f=t.find("li");i.page=s=0>s?0:s>i.total?i.total:s,f.removeClass(i.activeClass),r=1>s-1?1:i.leaps&&s-1>=i.maxVisible?Math.floor((s-1)/n)*n:s-1,i.firstLastUse&&(f.first().toggleClass(i.disabledClass,1===s),f.hasClass(i.disabledClass)?f.attr("tabIndex","-1"):f.removeAttr("tabIndex"));var p=f.first();i.firstLastUse&&(p=p.next()),p.toggleClass(i.disabledClass,1===s).attr("data-lp",r).find("a").attr("href",l(r)),p.hasClass(i.disabledClass)?p.find("a").attr("tabIndex","-1"):p.find("a").removeAttr("tabIndex");var d=1==i.maxVisible?0:1;r=s+1>i.total?i.total:i.leaps&&s+1<i.total-i.maxVisible?o+i.maxVisible+d:s+1;var b=f.last();i.firstLastUse&&(b=b.prev()),b.toggleClass(i.disabledClass,s===i.total).attr("data-lp",r).find("a").attr("href",l(r)),b.hasClass(i.disabledClass)?b.find("a").attr("tabIndex","-1"):b.find("a").removeAttr("tabIndex"),f.last().toggleClass(i.disabledClass,s===i.total),f.hasClass(i.disabledClass)?f.attr("tabIndex","-1"):f.removeAttr("tabIndex");var C=f.filter("[data-lp="+s+"]"),h="."+[i.nextClass,i.prevClass,i.firstClass,i.lastClass].join(",.");if(!C.not(h).length){var c=o>=s?-i.maxVisible:0;f.not(h).each(function(t){r=t+1+o+c,a(this).attr("data-lp",r).toggle(r<=i.total).find("a").html(r).attr("href",l(r))}),C=f.filter("[data-lp="+s+"]")}C.not(h).addClass(i.activeClass),e.data("settings",i)}function l(a){return i.href.replace(i.hrefVariable,a)}var e=this,i=a.extend({total:0,page:1,maxVisible:null,leaps:!0,href:"javascript:void(0);",hrefVariable:"{{number}}",next:"»",prev:"«",firstLastUse:!1,first:'<span aria-hidden="true">←</span>',last:'<span aria-hidden="true">→</span>',wrapClass:"pagination",activeClass:"active",disabledClass:"disabled",nextClass:"next",prevClass:"prev",lastClass:"last",firstClass:"first"},e.data("settings")||{},t||{});return i.total<=0?this:(a.isNumeric(i.maxVisible)||i.maxVisible||(i.maxVisible=parseInt(i.total,10)),e.data("settings",i),this.each(function(){var t,r,n=a(this),d=['<ul class="',i.wrapClass,' bootpag">'];i.firstLastUse&&(d=d.concat(['<li data-lp="1" class="',i.firstClass,'"><a href="',l(1),'">',i.first,"</a></li>"])),i.prev&&(d=d.concat(['<li data-lp="1" class="',i.prevClass,'"><a href="',l(1),'">',i.prev,"</a></li>"]));for(var o=1;o<=Math.min(i.total,i.maxVisible);o++)d=d.concat(['<li data-lp="',o,'"><a href="',l(o),'">',o,"</a></li>"]);i.next&&(r=i.leaps&&i.total>i.maxVisible?Math.min(i.maxVisible+1,i.total):2,d=d.concat(['<li data-lp="',r,'" class="',i.nextClass,'"><a href="',l(r),'">',i.next,"</a></li>"])),i.firstLastUse&&(d=d.concat(['<li data-lp="',i.total,'" class="last"><a href="',l(i.total),'">',i.last,"</a></li>"])),d.push("</ul>"),n.find("ul.bootpag").remove(),n.append(d.join("")),t=n.find("ul.bootpag"),n.find("li").click(function(){var t=a(this);if(!t.hasClass(i.disabledClass)&&!t.hasClass(i.activeClass)){var l=parseInt(t.attr("data-lp"),10);e.find("ul.bootpag").each(function(){s(a(this),l)}),e.trigger("page",l)}}),s(t,i.page)}))}}(jQuery,window);
|