Owen Leonard
fa8c57e55d
This patch addresses a few issues raised during QA: 1. If there are no images, avoid the momentary appearance of an empty borered box. The class controlling the appearance of the box is now added after initialization. 2. If there is only one image, remove the control for switching between covers. 3. Add "preventDefault" to cover naviation click handler. 4. Correct translation function in localcovers.js. This patch modifies SCSS, so rebuilding the staff client CSS is necessary for testing. Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
79 lines
3.1 KiB
JavaScript
79 lines
3.1 KiB
JavaScript
/* global __ */
|
|
|
|
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) {
|
|
var mydiv = $("#local-thumbnail-preview");
|
|
var biblionumber = mydiv.data("biblionumber");
|
|
var img = document.createElement("img");
|
|
img.src = "/cgi-bin/koha/catalogue/image.pl?thumbnail=1&biblionumber=" + biblionumber;
|
|
img.onload = function() {
|
|
// image dimensions can't be known until image has loaded
|
|
if ( (img.complete != null) && (!img.complete) ) {
|
|
mydiv.remove();
|
|
}
|
|
};
|
|
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);
|
|
}
|
|
},
|
|
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 cover image available") );
|
|
$(mydiv).append(message);
|
|
var img = $("<img />");
|
|
img.attr('src','/cgi-bin/koha/catalogue/image.pl?thumbnail=1&biblionumber=' + $(mydiv).attr("class"))
|
|
.addClass("thumbnail")
|
|
.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();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
};
|