From 708d4de228659103d8a74b949c13a0f02a9d4006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Marchal?= Date: Sun, 14 Feb 2021 10:32:39 +0100 Subject: [PATCH] Fix for page number with fancybox It is far from perfect. Should be investigated by reading fancybox code if there's a better way later on --- scripts/exposition.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/exposition.js b/scripts/exposition.js index 58dcfb1..95f3731 100644 --- a/scripts/exposition.js +++ b/scripts/exposition.js @@ -38,7 +38,7 @@ jQuery(document).ready(function($) if (urlParams.get('page') != "") targetPage = urlParams.get('page'); - + var currentPage = 0; var previousArray = [] var options = { @@ -48,9 +48,8 @@ jQuery(document).ready(function($) className: 'paginationjs-theme-blue', callback: function (response, pagination) { - console.log(window.location.pathname); - console.log(window.location.hash); - window.history.replaceState('', '', window.location.pathname + '?page=' + pagination.pageNumber + window.location.hash); // careful, back button is broken with that + currentPage = pagination.pageNumber; + window.history.replaceState('', '', window.location.pathname + '?page=' + currentPage + window.location.hash); if (previousArray.length > 0) { @@ -87,7 +86,6 @@ jQuery(document).ready(function($) mobile: { preventCaptionOverlap: true, }, - hash: false, caption: function(instance, item) { @@ -126,7 +124,12 @@ jQuery(document).ready(function($) $('#pagination').pagination('previous'); }, - + afterClose : function(instance) + { + // 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); + } }); });