From cedfa90d766194a6c07f6b4289d55d712b499040 Mon Sep 17 00:00:00 2001 From: Ghighi Eftimie Date: Sat, 10 Oct 2020 17:51:46 +0300 Subject: [PATCH 1/5] fix for #981 --- cps/static/css/caliBlur.css | 6 +++--- cps/static/js/main.js | 13 +++++++++++++ cps/templates/layout.html | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/cps/static/css/caliBlur.css b/cps/static/css/caliBlur.css index 3bf07110..b7d86519 100644 --- a/cps/static/css/caliBlur.css +++ b/cps/static/css/caliBlur.css @@ -637,18 +637,18 @@ div[aria-label="Edit/Delete book"] > .btn > span:hover { color: var(--color-primary) } -.book { +/* .book { width: 225px; max-width: 225px; position: relative !important; - left: auto !important; + left: auto !important; top: auto !important; -webkit-transform: none !important; -ms-transform: none !important; transform: none !important; min-width: 225px; display: block -} +} */ #infscr-loading img, body > div.container-fluid > div > div.col-sm-10 > div.discover > div.isotope:after, body > div.container-fluid > div > div.col-sm-10 > div.discover > div.isotope:before { display: none diff --git a/cps/static/js/main.js b/cps/static/js/main.js index 7312f08d..c04ec65e 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -187,6 +187,19 @@ $(function() { $(".load-more .row").isotope( "appended", $(data), null ); }); + // fix for infinite scroll on CaliBlur Theme (#981) + if ($(".load-more .row").length && $("body").hasClass("blur")) { + $(".col-sm-10").bind("scroll", function () { + if ( + $(this).scrollTop() + $(this).innerHeight() >= + $(this)[0].scrollHeight + ) { + $loadMore.infiniteScroll("loadNextPage"); + window.history.replaceState({}, null, $loadMore.infiniteScroll('getAbsolutePath')+1) + } + }); + } + $("#restart").click(function() { $.ajax({ dataType: "json", diff --git a/cps/templates/layout.html b/cps/templates/layout.html index c555f556..65867fe7 100644 --- a/cps/templates/layout.html +++ b/cps/templates/layout.html @@ -166,7 +166,7 @@ {% endif %} {% endfor %} {% if pagination.has_next %} -
  • {% endif %} From f574f8faf00342da222f38040a94e59d8764aa5a Mon Sep 17 00:00:00 2001 From: Ghighi Eftimie Date: Sat, 10 Oct 2020 18:34:55 +0300 Subject: [PATCH 2/5] better js check --- cps/static/js/main.js | 51 ++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/cps/static/js/main.js b/cps/static/js/main.js index c04ec65e..ff9cac08 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -172,32 +172,33 @@ $(function() { layoutMode : "fitColumns" }); - - var $loadMore = $(".load-more .row").infiniteScroll({ - debug: false, - // selector for the paged navigation (it will be hidden) - path : ".next", - // selector for the NEXT link (to page 2) - append : ".load-more .book" - //animate : true, # ToDo: Reenable function - //extraScrollPx: 300 - }); - $loadMore.on( "append.infiniteScroll", function( event, response, path, data ) { - $(".pagination").addClass("hidden"); - $(".load-more .row").isotope( "appended", $(data), null ); - }); - - // fix for infinite scroll on CaliBlur Theme (#981) - if ($(".load-more .row").length && $("body").hasClass("blur")) { - $(".col-sm-10").bind("scroll", function () { - if ( - $(this).scrollTop() + $(this).innerHeight() >= - $(this)[0].scrollHeight - ) { - $loadMore.infiniteScroll("loadNextPage"); - window.history.replaceState({}, null, $loadMore.infiniteScroll('getAbsolutePath')+1) - } + if ($('.next').length) { + var $loadMore = $(".load-more .row").infiniteScroll({ + debug: false, + // selector for the paged navigation (it will be hidden) + path : ".next", + // selector for the NEXT link (to page 2) + append : ".load-more .book" + //animate : true, # ToDo: Reenable function + //extraScrollPx: 300 }); + $loadMore.on( "append.infiniteScroll", function( event, response, path, data ) { + $(".pagination").addClass("hidden"); + $(".load-more .row").isotope( "appended", $(data), null ); + }); + + // fix for infinite scroll on CaliBlur Theme (#981) + if ($("body").hasClass("blur")) { + $(".col-sm-10").bind("scroll", function () { + if ( + $(this).scrollTop() + $(this).innerHeight() >= + $(this)[0].scrollHeight + ) { + $loadMore.infiniteScroll("loadNextPage"); + window.history.replaceState({}, null, $loadMore.infiniteScroll('getAbsolutePath')+1) + } + }); + } } $("#restart").click(function() { From e723aaa5f6715dffa36c8a5b3ff7434c502fefd2 Mon Sep 17 00:00:00 2001 From: Ghighi Eftimie Date: Sun, 11 Oct 2020 21:56:49 +0300 Subject: [PATCH 3/5] fix for history state (+1 not needed) --- cps/static/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/static/js/main.js b/cps/static/js/main.js index ff9cac08..44a72b06 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -195,7 +195,7 @@ $(function() { $(this)[0].scrollHeight ) { $loadMore.infiniteScroll("loadNextPage"); - window.history.replaceState({}, null, $loadMore.infiniteScroll('getAbsolutePath')+1) + window.history.replaceState({}, null, $loadMore.infiniteScroll("getAbsolutePath")); } }); } From 9adcfa99f429245ea9d88751c8b2370622e8ca08 Mon Sep 17 00:00:00 2001 From: Ghighi Eftimie Date: Sun, 11 Oct 2020 22:35:56 +0300 Subject: [PATCH 4/5] trigger infinite scroll script only on templates where .load-more class is present --- cps/static/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/static/js/main.js b/cps/static/js/main.js index 44a72b06..c1f58b7f 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -172,7 +172,7 @@ $(function() { layoutMode : "fitColumns" }); - if ($('.next').length) { + if ($(".load-more").length && $(".next").length) { var $loadMore = $(".load-more .row").infiniteScroll({ debug: false, // selector for the paged navigation (it will be hidden) From 2ff286b672f7f3e04a1bfdd6a677ed8906d3d1cf Mon Sep 17 00:00:00 2001 From: Ghighi Date: Fri, 16 Oct 2020 00:43:57 +0300 Subject: [PATCH 5/5] natural solution, pagination is changing on new page --- cps/static/js/main.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cps/static/js/main.js b/cps/static/js/main.js index c1f58b7f..f2d7b929 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -183,7 +183,9 @@ $(function() { //extraScrollPx: 300 }); $loadMore.on( "append.infiniteScroll", function( event, response, path, data ) { - $(".pagination").addClass("hidden"); + if ($("body").hasClass("blur")) { + $(".pagination").addClass("hidden").html(() => $(response).find(".pagination").html()); + } $(".load-more .row").isotope( "appended", $(data), null ); });