Koha/koha-tmpl/opac-tmpl/bootstrap/js/localcovers.js
Frédérick bbb6cf94de Bug 11982 - Show local cover image in the intranet biblio details page
Also, fix useless "No cover image" block when using Amazon and local
cover images at the same time.

http://bugs.koha-community.org/show_bug.cgi?id=11982
Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2015-03-30 13:45:20 -03:00

52 lines
2 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],span[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/opac-image.pl?thumbnail=1&biblionumber=' + $(mydiv).attr("class"))
.load(function () {
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
//IE HACK
try {
$(mydiv).append(img);
$(mydiv).children('.no-image').remove();
}
catch(err){
};
} else {
if (uselink) {
var a = $("<a />").attr('href', '/cgi-bin/koha/opac-imageviewer.pl?biblionumber=' + $(mydiv).attr("class"));
$(a).append(img);
$(mydiv).empty().append(a);
} else {
$(mydiv).empty().append(img);
}
$(mydiv).children('.no-image').remove();
}
})
});
}
};