From a9a4d71f75760a1ed8709f7270ac54f7701aa4ca Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 16 Apr 2020 12:10:52 +0000 Subject: [PATCH] Bug 25031: (QA follow-up) Improve handling of one or fewer images This patch addresses a few issues raised during QA: 1. If there are no images, avoid the momentary appearance of an empty borered box. The class controlling the appearance of the box is now added after initialization. 2. If there is only one image, remove the control for switching between covers. 3. Add "preventDefault" to cover naviation click handler. 4. Correct translation function in localcovers.js. This patch modifies SCSS, so rebuilding the staff client CSS is necessary for testing. --- .../intranet-tmpl/prog/css/src/staff-global.scss | 2 +- .../prog/en/modules/catalogue/detail.tt | 22 +++++++++++++--------- koha-tmpl/intranet-tmpl/prog/js/localcovers.js | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index 50ff01e905..3bd6ae4e00 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -2091,7 +2091,7 @@ li { } } -#cover-slides { +.cover-slides { background: #FFF url("[% interface | html %]/[% theme | html %]/img/spinner-small.gif") center center no-repeat; border: 1px solid #b9d8d9; border-radius: 3px; 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 38d1a612ee..6ded2d3308 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -972,20 +972,23 @@ Note that permanent location is a code, and location may be an authval. } // 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").append( covernav ); + var covernav = $(""); + if( index == 0 ){ + // Set the first navigation link as active + $(covernav).addClass("nav-active"); } + $(covernav).html(""); + $("#cover-slides").append( covernav ); } } }); if( $(".cover-image:visible").length < 1 ){ $("#cover-slides").remove(); + } else if( $(".cover-image:visible").length == 1 ){ + $(".cover-nav").remove(); + $("#cover-slides").addClass("cover-slides"); + } else { + $("#cover-slides").addClass("cover-slides"); } $("#editions img").each(function(i){ @@ -1159,8 +1162,9 @@ Note that permanent location is a code, and location may be an authval. link = $(this).attr("href"); openWindow(link,"Print spine label",400,400); }); - $("#cover-slides").on("click",".cover-nav", function(){ + $("#cover-slides").on("click",".cover-nav", function(e){ // Adding click handler for cover image navigation links + e.preventDefault(); var num = $(this).data("num"); $(".cover-nav").removeClass("nav-active"); $(this).addClass("nav-active"); diff --git a/koha-tmpl/intranet-tmpl/prog/js/localcovers.js b/koha-tmpl/intranet-tmpl/prog/js/localcovers.js index a25d7c73f4..9f3303f694 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/localcovers.js +++ b/koha-tmpl/intranet-tmpl/prog/js/localcovers.js @@ -43,7 +43,7 @@ KOHA.LocalCover = { var mydiv = this; var message = document.createElement("span"); $(message).attr("class","no-image thumbnail"); - $(message).html( _("No cover image available") ); + $(message).html( __("No cover image available") ); $(mydiv).append(message); var img = $(""); img.attr('src','/cgi-bin/koha/catalogue/image.pl?thumbnail=1&biblionumber=' + $(mydiv).attr("class")) -- 2.11.0