From 0604580c6d3200fb3543a88b3c3ccb57e9b02b36 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 20 Jul 2023 08:52:33 +0200 Subject: [PATCH] Bug 33568: Fix local cover images MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We need to reprocess the images when the table is refreshed, to do that we teach verify_cover_images to go through a given container instead of the whole document, and pass a call back function to build_items_table that will be called when DataTables will have redrawn the table (drawCallback). Signed-off-by: Owen Leonard Signed-off-by: Laurence Rault Signed-off-by: Emily Lamancusa Signed-off-by: Tomás Cohen Arazi Signed-off-by: Katrin Fischer --- .../html_helpers/tables/items/catalogue_detail.inc | 8 +++++--- .../prog/en/modules/catalogue/detail.tt | 14 ++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc index 94f8e91dc8..5e9daedd7b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc @@ -145,7 +145,7 @@ tab.find(".show_filters").hide(); tab.find(".hide_filters").show(); $("#"+tab_id+"_table thead tr:eq(1)").remove(); - build_items_table(tab_id, true, { destroy: true } ); + build_items_table(tab_id, true, { destroy: true }, build_items_table_drawncallback ); }); $(".hide_filters").on("click",function(e){ @@ -155,7 +155,7 @@ tab.find(".hide_filters").hide(); tab.find(".show_filters").show(); $("#"+tab_id+"_table thead tr:eq(1)").remove(); - build_items_table(tab_id, false, { destroy: true } ); + build_items_table(tab_id, false, { destroy: true }, build_items_table_drawncallback ); }); }); [% END %] @@ -218,7 +218,7 @@ holdings: '[% PROCESS 'build_table' tab="holdings" | collapse %]', otherholdings: '[% PROCESS 'build_table' tab="otherholdings" | collapse %]', }; - function build_items_table (tab_id, add_filters, dt_options) { + function build_items_table (tab_id, add_filters, dt_options, drawcallback) { if ( dt_options && dt_options.hasOwnProperty('destroy') ) { let table_id = "#"+tab_id+"_table"; @@ -753,6 +753,8 @@ container.find(".top.pager").remove(); container.find(".bottom.pager").remove(); } + + if ( drawcallback ) { drawcallback(this); } }, [% END %] ...dt_options, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index ff690d3cb1..8055d18ca7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -1122,9 +1122,10 @@ var interface = "[% interface | html %]"; var theme = "[% theme | html %]"; // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html - function verify_cover_images() { + function verify_cover_images(container) { // Loop over each container in the template which contains covers - $(".cover-slider").each(function(){ + let cover_sliders = container ? container.find('.cover-slider') : $(".cover-slider"); + cover_sliders.each(function(){ var lightbox_descriptions = []; var first_shown = 0; $(this).find(".cover-image").each( function( index ){ @@ -1189,7 +1190,7 @@ }); - $(".cover-slider").each(function(){ + cover_sliders.each(function(){ var coverSlide = this; var coverImages = $(this).find(".cover-image"); if( coverImages.length > 1 ){ @@ -1231,6 +1232,11 @@ }); } + let build_items_table_drawncallback = function (table) { + let tab_id = table.parents('.tab-pane').attr('id'); + verify_cover_images($("#" + tab_id + '_table')); + }; + function removeLocalImage(imagenumber) { var thumbnail = $("#imagenumber-" + imagenumber ); var copy = thumbnail.html(); @@ -1710,7 +1716,7 @@ let items_tab_ids = [ 'holdings', 'otherholdings' ]; items_tab_ids.forEach( function( tab_id, index ) { - build_items_table(tab_id, false); + build_items_table(tab_id, false, {}, build_items_table_drawncallback); [% IF bundlesEnabled %] // Add event listener for opening and closing bundle details -- 2.39.5