3 if (typeof KOHA == "undefined" || !KOHA) {
8 * A namespace for local cover related functions.
15 * <div title="biblionumber" id="isbn" class="openlibrary-thumbnail"></div>
17 * <div title="biblionumber" id="isbn" class="openlibrary-thumbnail-preview"></div>
18 * and run a search with all collected isbns to Open Library Book Search.
19 * The result is asynchronously returned by OpenLibrary and catched by
22 GetCoverFromBibnumber: function(uselink) {
23 var mydiv = $("#local-thumbnail-preview");
24 var biblionumber = mydiv.data("biblionumber");
25 var img = document.createElement("img");
26 img.src = "/cgi-bin/koha/catalogue/image.pl?thumbnail=1&biblionumber=" + biblionumber;
27 img.onload = function() {
28 // image dimensions can't be known until image has loaded
29 if ( (img.complete != null) && (!img.complete) ) {
34 var a = $("<a />").attr('href', '/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=' + $(mydiv).attr("class"));
41 LoadResultsCovers: function(){
42 $("div [id^=local-thumbnail]").each(function(i) {
44 var message = document.createElement("span");
45 $(message).attr("class","no-image thumbnail");
46 $(message).html( __("No cover image available") );
47 $(mydiv).append(message);
48 var img = $("<img />");
49 img.attr('src','/cgi-bin/koha/catalogue/image.pl?thumbnail=1&biblionumber=' + $(mydiv).attr("class"))
50 .addClass("thumbnail")
52 if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth <= 1) {
55 var otherCovers = $(mydiv).closest('td').find('img');
56 var nbCovers = otherCovers.length;
59 otherCovers.each(function(){
60 if(this.naturalWidth <= 1){
61 $(this).parent().remove();
65 if(badCovers < nbCovers){
66 $(mydiv).parent().remove();
74 $(mydiv).children('.no-image').remove();