Bug 5522 - allow google preview to open in a new window
If the OPACURLOpenInNewWindow system is set, then google preview links will obey it. Signed-off-by: Nicole Engard <nengard@bywatersolutions.com> Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
parent
9693db7bff
commit
3775854158
3 changed files with 44 additions and 31 deletions
|
@ -17,13 +17,14 @@ KOHA.Google = {
|
|||
* The result is asynchronously returned by Google and catched by
|
||||
* gbsCallBack().
|
||||
*/
|
||||
GetCoverFromIsbn: function() {
|
||||
GetCoverFromIsbn: function(newWindow) {
|
||||
var bibkeys = [];
|
||||
$("div [id^=gbs-thumbnail]").each(function(i) {
|
||||
bibkeys.push($(this).attr("class")); // id=isbn
|
||||
});
|
||||
bibkeys = bibkeys.join(',');
|
||||
var scriptElement = document.createElement("script");
|
||||
this.openInNewWindow=newWindow;
|
||||
scriptElement.setAttribute("id", "jsonScript");
|
||||
scriptElement.setAttribute("src",
|
||||
"http://books.google.com/books?bibkeys=" + escape(bibkeys) +
|
||||
|
@ -38,33 +39,37 @@ KOHA.Google = {
|
|||
* and link to preview if div id is gbs-thumbnail-preview
|
||||
*/
|
||||
gbsCallBack: function(booksInfo) {
|
||||
for (id in booksInfo) {
|
||||
var book = booksInfo[id];
|
||||
$("."+book.bib_key).each(function() {
|
||||
var a = document.createElement("a");
|
||||
a.href = book.info_url;
|
||||
if (typeof(book.thumbnail_url) != "undefined") {
|
||||
var img = document.createElement("img");
|
||||
img.src = book.thumbnail_url;
|
||||
$(this).append(img);
|
||||
var re = /^gbs-thumbnail-preview/;
|
||||
if ( re.exec($(this).attr("id")) ) {
|
||||
$(this).append(
|
||||
'<div style="margin-bottom:5px; margin-top:-5px;font-size:9px">' +
|
||||
'<a href="' +
|
||||
book.info_url +
|
||||
'"><img src="' +
|
||||
'http://books.google.com/intl/en/googlebooks/images/gbs_preview_sticker1.gif' +
|
||||
'"></a></div>'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
var message = document.createElement("span");
|
||||
$(message).attr("class","no-image");
|
||||
$(message).html(NO_GOOGLE_JACKET);
|
||||
$(this).append(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
var target = '';
|
||||
if (this.openInNewWindow) {
|
||||
target = 'target="_blank" ';
|
||||
}
|
||||
for (id in booksInfo) {
|
||||
var book = booksInfo[id];
|
||||
$("."+book.bib_key).each(function() {
|
||||
var a = document.createElement("a");
|
||||
a.href = book.info_url;
|
||||
if (typeof(book.thumbnail_url) != "undefined") {
|
||||
var img = document.createElement("img");
|
||||
img.src = book.thumbnail_url;
|
||||
$(this).append(img);
|
||||
var re = /^gbs-thumbnail-preview/;
|
||||
if ( re.exec($(this).attr("id")) ) {
|
||||
$(this).append(
|
||||
'<div style="margin-bottom:5px; margin-top:-5px;font-size:9px">' +
|
||||
'<a '+target+'href="' +
|
||||
book.info_url +
|
||||
'"><img src="' +
|
||||
'http://books.google.com/intl/en/googlebooks/images/gbs_preview_sticker1.gif' +
|
||||
'"></a></div>'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
var message = document.createElement("span");
|
||||
$(message).attr("class","no-image");
|
||||
$(message).html(NO_GOOGLE_JACKET);
|
||||
$(this).append(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
widgets : ['zebra'],
|
||||
sortList: [[0,0]]
|
||||
});<!-- TMPL_IF NAME="GoogleJackets" -->
|
||||
KOHA.Google.GetCoverFromIsbn();<!-- /TMPL_IF --><!-- TMPL_IF NAME="TagsEnabled" -->
|
||||
KOHA.Google.GetCoverFromIsbn(<!-- TMPL_VAR name="covernewwindow" -->);<!-- /TMPL_IF --><!-- TMPL_IF NAME="TagsEnabled" -->
|
||||
$(".tagbutton").click(KOHA.Tags.add_tag_button);<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="opacbookbag" -->$("a.print").parent().after("<li><a class=\"addtocart\" href=\"#\" onclick=\"addRecord('"+$("input[name=bib]").val()+"'); return false;\">"+_("Add to Your Cart")+"<\/a><\/li>");
|
||||
<!-- /TMPL_IF -->});
|
||||
|
|
|
@ -582,6 +582,14 @@ if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->pref
|
|||
'sort'=>'-weight', limit=>$tag_quantity}));
|
||||
}
|
||||
|
||||
if (C4::Context->preference("OPACURLOpenInNewWindow")) {
|
||||
# These values are going to be read by Javascript, at least in the case
|
||||
# of the google covers
|
||||
$template->param(covernewwindow => 'true');
|
||||
} else {
|
||||
$template->param(covernewwindow => 'false');
|
||||
}
|
||||
|
||||
#Search for title in links
|
||||
my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
|
||||
|
||||
|
|
Loading…
Reference in a new issue