From fa8c57e55d3f3cc027bc6e9d0fdf8dad81555453 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 17 Jun 2020 21:45:00 +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. Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss | 2 +- .../intranet-tmpl/prog/en/modules/catalogue/detail.tt | 9 +++++++-- koha-tmpl/intranet-tmpl/prog/js/localcovers.js | 4 ++-- 3 files changed, 10 insertions(+), 5 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 5390f25e58..bf57675f2f 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -2095,7 +2095,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 724ff28d85..c09ccdbfb2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -986,11 +986,15 @@ Note that permanent location is a code, and location may be an authval. $(covernav).addClass("nav-active"); } $(covernav).html(""); - $("#cover-slides").append( covernav ); + $("#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(); + } if( $(".cover-image:visible").length < 1 ){ $("#cover-slides").remove(); } @@ -1166,7 +1170,8 @@ 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){ + e.preventDefault(); // Adding click handler for cover image navigation links var num = $(this).data("num"); $(".cover-nav").removeClass("nav-active"); diff --git a/koha-tmpl/intranet-tmpl/prog/js/localcovers.js b/koha-tmpl/intranet-tmpl/prog/js/localcovers.js index a25d7c73f4..fe94760aa4 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/localcovers.js +++ b/koha-tmpl/intranet-tmpl/prog/js/localcovers.js @@ -1,4 +1,4 @@ -/* global _ */ +/* global __ */ if (typeof KOHA == "undefined" || !KOHA) { var KOHA = {}; @@ -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.39.5