2a4a91aef3
If the a cover image exists, it will be displayed on the details page. Nothing is displayed of there is no cover available. modified: koha-tmpl/intranet-tmpl/prog/en/js/localcovers.js modified: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Works as described, passes tests and QA script. Checked Amazon covers and local covers display correctly in staff on results and detail pages. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
88 lines
3.6 KiB
JavaScript
88 lines
3.6 KiB
JavaScript
if (typeof KOHA == "undefined" || !KOHA) {
|
|
var KOHA = {};
|
|
}
|
|
|
|
/**
|
|
* A namespace for local cover related functions.
|
|
*/
|
|
KOHA.LocalCover = {
|
|
|
|
|
|
/**
|
|
* Search all:
|
|
* <div title="biblionumber" id="isbn" class="openlibrary-thumbnail"></div>
|
|
* or
|
|
* <div title="biblionumber" id="isbn" class="openlibrary-thumbnail-preview"></div>
|
|
* and run a search with all collected isbns to Open Library Book Search.
|
|
* The result is asynchronously returned by OpenLibrary and catched by
|
|
* olCallBack().
|
|
*/
|
|
GetCoverFromBibnumber: function(uselink) {
|
|
$("div [id^=local-thumbnail]").each(function(i) {
|
|
var mydiv = this;
|
|
var message = document.createElement("span");
|
|
$(message).attr("class","no-image");
|
|
$(message).html(NO_LOCAL_JACKET);
|
|
$(mydiv).parent().find('.no-image').remove();
|
|
$(mydiv).append(message);
|
|
var img = $("<img />").attr('src',
|
|
'/cgi-bin/koha/catalogue/image.pl?thumbnail=1&biblionumber=' + $(mydiv).attr("class"))
|
|
.load(function () {
|
|
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth <= 1) {
|
|
//IE HACK
|
|
try {
|
|
$(mydiv).remove();
|
|
}
|
|
catch(err){
|
|
}
|
|
} else {
|
|
if (uselink) {
|
|
var a = $("<a />").attr('href', '/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=' + $(mydiv).attr("class"));
|
|
$(a).append(img);
|
|
$(mydiv).append(a);
|
|
} else {
|
|
$(mydiv).append(img);
|
|
}
|
|
$(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 />");
|
|
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();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
};
|