From 784e4685de0934c939f7047bcea191088169d824 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 23 Jul 2020 19:49:33 +0000 Subject: [PATCH] Bug 25031: (QA follow-up) Avoid displaying extra navigation This patch reworks the construction of the navigation links in such a way that they are built during a loop over an updated jQuery object. Previously the stored variable might not reflect that some elements had been removed. Signed-off-by: Jonathan Druart --- .../prog/en/modules/catalogue/detail.tt | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) 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 c09ccdbfb2..d2376ab098 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -164,6 +164,7 @@
Image from Adlibris
[% END %] + [% IF ( AmazonCoverImages && normalized_isbn) %] [% END %] + [% IF ( IntranetCoce && CoceProviders && normalized_isbn ) %] [% coce_id = normalized_ean || normalized_isbn %]
@@ -936,8 +938,7 @@ Note that permanent location is a code, and location may be an authval. // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html function verify_images() { // Loop over each container in the template which contains covers - var coverSlides = $(".cover-image"); - coverSlides.each( function( index ){ + $(".cover-image").each( function( index ){ var div = $(this); // Find the image in the container var img = div.find("img")[0]; @@ -977,24 +978,26 @@ Note that permanent location is a code, and location may be an authval. div.find(".hint").html(_("Coce image from Open Library")); } } - // If more that one slide is present, add a navigation link - // for activating the slide - if( coverSlides.length > 1 ){ - var covernav = $(""); - if( index == 0 ){ - // Set the first navigation link as active - $(covernav).addClass("nav-active"); - } - $(covernav).html(""); - $("#cover-slides").addClass("cover-slides").append( covernav ); - } } } }); - if( $(".cover-image").length < 2 ){ - /* Don't show controls for switching between covers if there is only 1 */ - $(".cover-nav").remove(); + + var coverSlides = $(".cover-image"); + if( coverSlides.length > 1 ){ + coverSlides.each(function( index ){ + // If more that one slide is present, add a navigation link + // for activating the slide + var covernav = $(""); + if( index == 0 ){ + // Set the first navigation link as active + $(covernav).addClass("nav-active"); + } + $(covernav).html(""); + $("#cover-slides").addClass("cover-slides").append( covernav ); + + }); } + if( $(".cover-image:visible").length < 1 ){ $("#cover-slides").remove(); } -- 2.39.5