From bcb0eec9f6096e7789a695a7f29ef66a28355b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Marchal?= Date: Tue, 16 Feb 2021 02:24:44 +0100 Subject: [PATCH] No pagination when number of element is insufficient fixes #17 Also fixes URL issue in explorer --- scripts/explorer.js | 6 ++++-- scripts/exposition.js | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/explorer.js b/scripts/explorer.js index 5f3ce1b..825b9c4 100644 --- a/scripts/explorer.js +++ b/scripts/explorer.js @@ -528,11 +528,11 @@ jQuery(document).ready(function($) pageSize: pageSize, pageRange: getPageRange(), className: 'paginationjs-theme-ginou', + hideWhenLessThanOnePage: true, callback: function (response, pagination) { currentPage = pagination.pageNumber; urlParams = new URLSearchParams(window.location.search) - console.log(urlParams.get('page')); if (urlParams.get('page') == undefined) { window.history.replaceState('', '', window.location.pathname + window.location.search + '&page=' + currentPage + window.location.hash); @@ -659,7 +659,9 @@ jQuery(document).ready(function($) { // after closing, changing the URL again. I guess there's no better way except by changing fancybox code... // (apparently fancybox changes back to the original url it had when starting) - //window.history.replaceState('', '', window.location.pathname + '?page=' + currentPage + window.location.hash); + urlParams = new URLSearchParams(window.location.search) + trimSearch = window.location.search.substr(0, window.location.search.lastIndexOf('&')); + window.history.replaceState('', '', window.location.pathname + trimSearch + '&page=' + currentPage + window.location.hash); } }); }); diff --git a/scripts/exposition.js b/scripts/exposition.js index 2f892e9..fb55a4c 100644 --- a/scripts/exposition.js +++ b/scripts/exposition.js @@ -56,6 +56,7 @@ jQuery(document).ready(function($) pageSize: pageSize, pageRange: getPageRange(), className: 'paginationjs-theme-ginou', + hideWhenLessThanOnePage: true, callback: function (response, pagination) { currentPage = pagination.pageNumber;