diff --git a/lib/jquery.bootpag.js b/lib/jquery.bootpag.js
index 9d89046..dd112b2 100644
--- a/lib/jquery.bootpag.js
+++ b/lib/jquery.bootpag.js
@@ -2,7 +2,7 @@
* @preserve
* bootpag - jQuery plugin for dynamic pagination
*
- * Copyright (c) 2015 botmonster@7items.com
+ * Copyright (c) 2013 botmonster@7items.com
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
@@ -10,7 +10,9 @@
* Project home:
* http://botmonster.com/jquery-bootpag/
*
- * Version: 1.0.7
+ * Version: 1.0.7.1
+ *
+ * Fixed:modify some code ,then can work in Bootstrap 4
*
*/
(function($, window) {
@@ -19,70 +21,49 @@
var $owner = this,
settings = $.extend({
- total: 0,
- page: 1,
- maxVisible: null,
- leaps: true,
- href: 'javascript:void(0);',
- hrefVariable: '{{number}}',
- next: '»',
- prev: '«',
- firstLastUse: false,
- first: '← ',
- last: '→ ',
- wrapClass: 'pagination',
- activeClass: 'active',
- disabledClass: 'disabled',
- nextClass: 'next',
- prevClass: 'prev',
- lastClass: 'last',
- firstClass: 'first'
- },
- $owner.data('settings') || {},
- options || {});
+ total: 0,
+ page: 1,
+ maxVisible: null,
+ leaps: true,
+ href: 'javascript:void(0);',
+ hrefVariable: '{{number}}',
+ next: '»',
+ prev: '«'
+ },
+ $owner.data('settings') || {},
+ options || {});
if(settings.total <= 0)
return this;
- if(!$.isNumeric(settings.maxVisible) && !settings.maxVisible){
- settings.maxVisible = parseInt(settings.total, 10);
+ if(!$.isNumeric(settings.maxVisible) && !settings.maxVisible){
+ settings.maxVisible = settings.total;
}
$owner.data('settings', settings);
function renderPage($bootpag, page){
- page = parseInt(page, 10);
var lp,
maxV = settings.maxVisible == 0 ? 1 : settings.maxVisible,
step = settings.maxVisible == 1 ? 0 : 1,
vis = Math.floor((page - 1) / maxV) * maxV,
$page = $bootpag.find('li');
settings.page = page = page < 0 ? 0 : page > settings.total ? settings.total : page;
- $page.removeClass(settings.activeClass);
+ $page.removeClass('disabled');
lp = page - 1 < 1 ? 1 :
- settings.leaps && page - 1 >= settings.maxVisible ?
- Math.floor((page - 1) / maxV) * maxV : page - 1;
-
- if(settings.firstLastUse) {
- $page
- .first()
- .toggleClass(settings.disabledClass, page === 1);
- }
-
- var lfirst = $page.first();
- if(settings.firstLastUse) {
- lfirst = lfirst.next();
- }
-
- lfirst
- .toggleClass(settings.disabledClass, page === 1)
+ settings.leaps && page - 1 >= settings.maxVisible ?
+ Math.floor((page - 1) / maxV) * maxV : page - 1;
+ $page
+ .first()
+ .toggleClass('disabled', page === 1)
.attr('data-lp', lp)
.find('a').attr('href', href(lp));
var step = settings.maxVisible == 1 ? 0 : 1;
lp = page + 1 > settings.total ? settings.total :
+
settings.leaps && page + 1 <= settings.total - settings.maxVisible ?
vis + settings.maxVisible + step: page + 1;
@@ -91,25 +72,16 @@
llast = llast.prev();
}
- llast
- .toggleClass(settings.disabledClass, page === settings.total)
+ $page
+ .last()
+ .toggleClass('disabled', page === settings.total)
.attr('data-lp', lp)
- .find('a').attr('href', href(lp));
-
- $page
- .last()
- .toggleClass(settings.disabledClass, page === settings.total);
-
+ .find('a').attr('href', href(lp));;
var $currPage = $page.filter('[data-lp='+page+']');
-
- var clist = "." + [settings.nextClass,
- settings.prevClass,
- settings.firstClass,
- settings.lastClass].join(",.");
- if(!$currPage.not(clist).length){
+ if(!$currPage.not('.next,.prev').length){
var d = page <= vis ? -settings.maxVisible : 0;
- $page.not(clist).each(function(index){
+ $page.not('.next,.prev').each(function(index){
lp = index + 1 + vis + d;
$(this)
.attr('data-lp', lp)
@@ -118,7 +90,8 @@
});
$currPage = $page.filter('[data-lp='+page+']');
}
- $currPage.not(clist).addClass(settings.activeClass);
+ $currPage.addClass('disabled');
+ $owner.trigger('page', page);
$owner.data('settings', settings);
}
@@ -130,50 +103,33 @@
return this.each(function(){
var $bootpag, lp, me = $(this),
- p = ['
'];
+ p = ['');
+ p.push(' ');
me.find('ul.bootpag').remove();
- me.append(p.join(''));
+ me.append(p.join('')).addClass('pagination');
$bootpag = me.find('ul.bootpag');
-
me.find('li').click(function paginationClick(){
var me = $(this);
- if(me.hasClass(settings.disabledClass) || me.hasClass(settings.activeClass)){
+ if(me.hasClass('disabled')){
return;
}
- var page = parseInt(me.attr('data-lp'), 10);
- $owner.find('ul.bootpag').each(function(){
- renderPage($(this), page);
- });
-
- $owner.trigger('page', page);
+ renderPage($bootpag, parseInt(me.attr('data-lp'), 10));
});
renderPage($bootpag, settings.page);
});
}
-})(jQuery, window);
+})(jQuery, window);
\ No newline at end of file
diff --git a/lib/jquery.bootpag.min.js b/lib/jquery.bootpag.min.js
index 324b1a3..74b763d 100644
--- a/lib/jquery.bootpag.min.js
+++ b/lib/jquery.bootpag.min.js
@@ -1,21 +1,18 @@
-/*
-
- 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(h,q){h.fn.bootpag=function(p){function m(c,b){b=parseInt(b,10);var d,e=0==a.maxVisible?1:a.maxVisible,k=1==a.maxVisible?0:1,n=Math.floor((b-1)/e)*e,f=c.find("li");a.page=b=0>b?0:b>a.total?a.total:b;f.removeClass(a.activeClass);d=1>b-1?1:a.leaps&&b-1>=a.maxVisible?Math.floor((b-1)/e)*e:b-1;a.firstLastUse&&f.first().toggleClass(a.disabledClass,1===b);e=f.first();a.firstLastUse&&(e=e.next());e.toggleClass(a.disabledClass,1===b).attr("data-lp",d).find("a").attr("href",g(d));k=1==a.maxVisible?
-0:1;d=b+1>a.total?a.total:a.leaps&&b+1←',last:'→ ',wrapClass:"pagination",activeClass:"active",disabledClass:"disabled",nextClass:"next",prevClass:"prev",
-lastClass:"last",firstClass:"first"},l.data("settings")||{},p||{});if(0>=a.total)return this;h.isNumeric(a.maxVisible)||a.maxVisible||(a.maxVisible=parseInt(a.total,10));l.data("settings",a);return this.each(function(){var c,b,d=h(this);c=[''];a.firstLastUse&&(c=c.concat(['',a.first," "]));a.prev&&(c=c.concat(['',a.prev," "]));for(b=
-1;b<=Math.min(a.total,a.maxVisible);b++)c=c.concat(['',b," "]);a.next&&(b=a.leaps&&a.total>a.maxVisible?Math.min(a.maxVisible+1,a.total):2,c=c.concat(['',a.next," "]));a.firstLastUse&&(c=c.concat(['',a.last," "]));c.push(" ");d.find("ul.bootpag").remove();d.append(c.join(""));c=d.find("ul.bootpag");d.find("li").click(function(){var b=
-h(this);if(!b.hasClass(a.disabledClass)&&!b.hasClass(a.activeClass)){var c=parseInt(b.attr("data-lp"),10);l.find("ul.bootpag").each(function(){m(h(this),c)});l.trigger("page",c)}});m(c,a.page)})}})(jQuery,window);
+/**
+ * @preserve
+ * bootpag - jQuery plugin for dynamic pagination
+ *
+ * Copyright (c) 2013 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.1
+ *
+ * Fixed:modify some code ,then can work in Bootstrap 4
+ *
+ */
+(function($,window){$.fn.bootpag=function(options){var $owner=this,settings=$.extend({total:0,page:1,maxVisible:null,leaps:true,href:"javascript:void(0);",hrefVariable:"{{number}}",next:"»",prev:"«"},$owner.data("settings")||{},options||{});if(settings.total<=0){return this}if(!$.isNumeric(settings.maxVisible)&&!settings.maxVisible){settings.maxVisible=settings.total}$owner.data("settings",settings);function renderPage($bootpag,page){var lp,maxV=settings.maxVisible==0?1:settings.maxVisible,step=settings.maxVisible==1?0:1,vis=Math.floor((page-1)/maxV)*maxV,$page=$bootpag.find("li");settings.page=page=page<0?0:page>settings.total?settings.total:page;$page.removeClass("disabled");lp=page-1<1?1:settings.leaps&&page-1>=settings.maxVisible?Math.floor((page-1)/maxV)*maxV:page-1;$page.first().toggleClass("disabled",page===1).attr("data-lp",lp).find("a").attr("href",href(lp));var step=settings.maxVisible==1?0:1;lp=page+1>settings.total?settings.total:settings.leaps&&page+1");me.find("ul.bootpag").remove();me.append(p.join("")).addClass("pagination");$bootpag=me.find("ul.bootpag");me.find("li").click(function paginationClick(){var me=$(this);if(me.hasClass("disabled")){return}renderPage($bootpag,parseInt(me.attr("data-lp"),10))});renderPage($bootpag,settings.page)})}})(jQuery,window);
\ No newline at end of file