grand finale v...i hope fixed show page connection to prev next button

This commit is contained in:
JoBCB 2021-05-14 14:10:57 +01:00
parent b5e9ca37ba
commit 688030d85b
2 changed files with 66 additions and 84 deletions

View File

@ -1361,7 +1361,7 @@ div#browsethearchive-pagination, div#zinesindex-pagination, div#selfpublishedind
text-align: center; text-align: center;
} }
/*temptative pagination*/ /* new pagination*/
ul.browsethearchive-pagination { ul.browsethearchive-pagination {
width: 100%; width: 100%;
@ -1442,7 +1442,6 @@ ul.browsethearchive-pagination li a.current {
cursor: pointer; cursor: pointer;
} }
/************ BROWSE BY CATEGORY ************/ /************ BROWSE BY CATEGORY ************/
div#browsebycategory-listcategories{ div#browsebycategory-listcategories{

View File

@ -46,115 +46,98 @@
<script type="text/javascript"> <script type="text/javascript">
pageSize = 24; // pagination script w/ support from @biberman on stackoverflow - big thanks!
incremSlide = 5;
startPage = 0;
numberPage = 0;
//pagination slider ref https://www.javaer101.com/en/article/123201810.html
var pageCount = $(".browsethearchive-items").length / pageSize; let startPage;
var totalSlidepPage = Math.floor(pageCount / incremSlide); const pageSize = 24;
const totalSlidePage = 5;
const pageCount = Math.ceil($(".browsethearchive-items").length / pageSize);
const slideRange = Math.floor(totalSlidePage / 2);
for(var i = 0 ; i<pageCount;i++){ slide = function() {
$("#pagin").append('<li><a href="#">'+(i+1)+'</a></li> '); startPage = $("#pagin li a.current").parent().index();
if(i>pageSize){ let paginationStart = (startPage - slideRange) < 0 ? 0 :
$("#pagin li").eq(i).hide(); (startPage >= (pageCount - slideRange) ? (pageCount - totalSlidePage) :
} (startPage - slideRange));
$("#pagin li").hide();
for (let t = paginationStart; t < (paginationStart + totalSlidePage); t++) {
$("#pagin li").eq(t + 1).show();
} }
var prev = $("<li/>").addClass("prev").html("Prev").click(function(){ next.show();
startPage-=1; prev.show();
incremSlide-=1;
numberPage--;
slide();
});
if (startPage == 1) {
prev.hide(); prev.hide();
}
else if (startPage == pageCount ) {
next.hide();
}
}
var next = $("<li/>").addClass("next").html("Next").click(function(){ showPage = function() {
startPage+=1; console.log(startPage);
incremSlide+=1; $(".browsethearchive-items").hide();
numberPage++; $(".browsethearchive-items").each(function(n) {
slide(); if (n >= pageSize * (startPage - 1) && n < pageSize * startPage)
$(this).show();
}); });
}
for (let i = 0 ; i < pageCount; i++) {
$("#pagin").append('<li><a href="#">' + (i + 1) + '</a></li> ');
$("#pagin").prepend(prev).append(next); if (i > pageSize) {
$("#pagin li").eq(i).hide();
}
}
$("#pagin li").first().find("a").addClass("current"); let prev = $("<li/>").addClass("prev").html("Prev").click(function() {
let prevLi = $("#pagin li a.current").parent().prev().find("a");
slide = function(sens){ if (prevLi[0]) {
$("#pagin li").hide(); $("#pagin li a.current").removeClass("current");
prevLi.addClass("current");
for(t=startPage;t<incremSlide;t++){
$("#pagin li").eq(t+1).show();
}
if(startPage == 0){
next.show();
prev.hide();
}else if(numberPage == totalSlidepPage ){
next.hide();
prev.show();
}else{
next.show();
prev.show();
}
} }
slide(); slide();
showPage = function(page) { if (startPage != 0) {
$(".browsethearchive-items").hide(); showPage();
$(".browsethearchive-items").each(function(n) {
if (n >= pageSize * (page - 1) && n < pageSize * page)
$(this).show();
});
} }
});
showPage(1);
$("#pagin li a").eq(0).addClass("current");
let next = $("<li/>").addClass("next").html("Next").click(function() {
let nextLi = $("#pagin li a.current").parent().next().find("a");
var $listItems = $('#pagin li a'); if (nextLi[0]) {
var activeLink; $("#pagin li a.current").removeClass("current");
nextLi.addClass("current");
}
slide();
if (startPage <= pageCount) {
showPage();
}
});
$("#pagin").prepend(prev).append(next);
$("#pagin li a").click(function() { $("#pagin li a").click(function() {
$('#pagin li a').removeClass('current');
$(this).addClass('current');
$listItems.removeClass('current'); slide();
$(this).addClass('current'); showPage();
var activeLink=$(this);
showPage(parseInt($(this).text()));
}); });
$("#pagin li a").eq(0).addClass("current");
var i = 1; slide();
showPage();
$(".prev").click(function() {
let prevLi = $("#pagin li a.current").parent().prev().find("a");
$("#pagin li a.current").removeClass("current");
prevLi.addClass("current");
if (i != 1) {
showPage(--i);
}
});
$(".next").click(function() {
let nextLi = $("#pagin li a.current").parent().next().find("a");
$("#pagin li a.current").removeClass("current");
nextLi.addClass("current");
if (i < ($('.browsethearchive-items').length)/ pageSize) {
showPage(++i);
}
});
</script> </script>