From 2668cbdc419fa550968d3a63dec4ac1d09749a17 Mon Sep 17 00:00:00 2001 From: mbeaulieu Date: Fri, 8 Aug 2014 08:38:20 -0400 Subject: [PATCH] Bug 11982 - Fixed the amazon no image icon. A no image icon will only be displayed if both the amazon and local images are missing. Added hyperlink to details on the local image in the search result page. modified: koha-tmpl/intranet-tmpl/prog/en/js/localcovers.js modified: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt modified: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt Signed-off-by: Owen Leonard Signed-off-by: Katrin Fischer Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- .../intranet-tmpl/prog/en/js/localcovers.js | 39 ++++++++++++++++++- .../prog/en/modules/catalogue/detail.tt | 6 +-- .../prog/en/modules/catalogue/results.tt | 15 +++++-- 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/localcovers.js b/koha-tmpl/intranet-tmpl/prog/en/js/localcovers.js index 58e13cf2f4..253d7a6082 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/localcovers.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/localcovers.js @@ -46,7 +46,44 @@ KOHA.LocalCover = { } $(mydiv).children('.no-image').remove(); } - }) + }); + }); + }, + LoadResultsCovers: function(){ + $("div [id^=local-thumbnail]").each(function(i) { + var mydiv = this; + var message = document.createElement("span"); + $(message).attr("class","no-image thumbnail"); + $(message).html(NO_LOCAL_JACKET); + $(mydiv).append(message); + var img = $(""); + img.attr('src','/cgi-bin/koha/catalogue/image.pl?thumbnail=1&biblionumber=' + $(mydiv).attr("class")); + img.load(function () { + if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth <= 1) { + //IE HACK + try { + var otherCovers = $(mydiv).closest('td').find('img'); + var nbCovers = otherCovers.length; + if(nbCovers > 0){ + var badCovers = 0; + otherCovers.each(function(){ + if(this.naturalWidth <= 1){ + $(this).parent().remove(); + badCovers++; + } + }); + if(badCovers < nbCovers){ + $(mydiv).parent().remove(); + } + } + } + catch(err){ + } + } else { + $(mydiv).append(img); + $(mydiv).children('.no-image').remove(); + } + }); }); } }; 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 c3ea895480..48bc90b259 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -174,6 +174,9 @@ function verify_images() { [%# inject no images message %] [% IF ( LocalCoverImages && ! localimages.0 ) %] showNoImageMessage(); + [% END %] + [% IF LocalCoverImages %] + KOHA.LocalCover.GetCoverFromBibnumber(true); [% END %] $("body").on("click",".previewMARC", function(e){ e.preventDefault(); @@ -184,9 +187,6 @@ function verify_images() { $("#marcPreview").on("hidden", function(){ $("#marcPreview .modal-body").html("
\"\" "+_("Loading")+"
"); }); - [% IF LocalCoverImages %] - KOHA.LocalCover.GetCoverFromBibnumber(true); - [% END %] }); [% IF ( AmazonCoverImages ) %]$(window).load(function() { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt index ef6da75b44..933453c561 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -151,7 +151,7 @@ $('#sort_by').change(function() { [% END %] [% END %] -[% IF LocalCoverImages %]KOHA.LocalCover.GetCoverFromBibnumber(false);[% END %] +[% IF LocalCoverImages %]KOHA.LocalCover.LoadResultsCovers();[% END %] }); @@ -446,12 +446,19 @@ var holdForPatron = function () { [% IF ( loop.odd ) %][% ELSE %][% END %] [% IF ( AmazonCoverImages || LocalCoverImages ) %] - [% IF ( LocalCoverImages ) %] + [% IF ( LocalCoverImages) %] + + [% END %] [% IF ( AmazonCoverImages ) %] - - + [% IF ( SEARCH_RESULT.normalized_isbn ) %] + + + [% ELSIF ( !LocalCoverImages ) %] + + + [% END %] [% END %] -- 2.39.5