Koha/koha-tmpl/opac-tmpl/ccsr/en/js/localcovers.js
Jared Camins-Esakov 2ab4398fcf Bug 8597: Add CSS, JS, and images to ccsr theme
In order for themes to work, they must include all CSS, Javascript, and
image assets that they use. This patch adds all CSS, Javascript, and
images from the prog theme to ccsr, EXCEPT for the famfamfam image set,
which needs to be moved outside of the theme directories, per bug 8624.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
2012-09-18 13:41:51 +02:00

44 lines
1.7 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).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) {
} else {
if (uselink) {
var a = $("<a />").attr('href', '/cgi-bin/koha/opac-imageviewer.pl?biblionumber=' + $(mydiv).attr("class"));
$(a).append(img);
$(mydiv).append(a);
} else {
$(mydiv).append(img);
}
$(mydiv).children('.no-image').remove();
}
})
});
}
};