Koha/koha-tmpl/opac-tmpl/prog/en/js/localcovers.js
Owen Leonard e1ebabf3ec Bug 7127 - Follow-up - Templates must be valid XHTML
Corrections to OPAC search results and lists pages for validity
errors: duplicate ids, invalidly placed elements, unescaped
ampersands.

The change to localcovers.js adds a check for <span> in addition
to <div> so that the results template can use a <span>

The <form> tag has been removed from the inline tag entry
markup in order to correct a display error in Internet Explorer 8.
Removing it doesn't affect functionality or validity.

To test: Validate the HTML of the OPAC results page and an OPAC
list contents page (/cgi-bin/koha/opac-shelves.pl?viewshelf=XX).
Verify the functinality of adding tags on both pages with the
TagsInputOnList system preference enabled. Verify that local
cover images are display on search results and detail pages.

Includes fixes for errors spotted by QA

Revisions

Signed-off-by: Ian Walls <koha.sekjal@gmail.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
2012-02-06 21:38:32 +01: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();
}
})
});
}
};