Bugzilla – Attachment 2885 Details for
Bug 5522
The 'open in new window' setting should apply to google preview and ebook links
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch
0001-Bug-5522-allow-google-preview-to-open-in-a-new-windo.patch (text/plain), 6.00 KB, created by
Robin Sheat
on 2010-12-20 02:03:14 UTC
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Robin Sheat
Created:
2010-12-20 02:03:14 UTC
Size:
6.00 KB
patch
obsolete
>From f39229e5fd2c5bae14f152d5a4d3f3a6d59603d2 Mon Sep 17 00:00:00 2001 >From: Robin Sheat <robin@catalyst.net.nz> >Date: Mon, 20 Dec 2010 14:59:21 +1300 >Subject: [PATCH] Bug 5522 - allow google preview to open in a new window > >If the OPACURLOpenInNewWindow system is set, then google preview links >will obey it. >--- > koha-tmpl/opac-tmpl/prog/en/js/google-jackets.js | 65 +++++++++++--------- > .../opac-tmpl/prog/en/modules/opac-detail.tmpl | 2 +- > opac/opac-detail.pl | 8 +++ > 3 files changed, 44 insertions(+), 31 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/prog/en/js/google-jackets.js b/koha-tmpl/opac-tmpl/prog/en/js/google-jackets.js >index 45a4bb8..f7aa897 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/js/google-jackets.js >+++ b/koha-tmpl/opac-tmpl/prog/en/js/google-jackets.js >@@ -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); >+ } >+ }); >+ } >+ } > }; >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl >index 084c484..1d04f62 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl >@@ -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 -->}); >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 0cd05f7..b8b3449 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -583,6 +583,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 > if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){ > $dat->{author} ? $search_for_title =~ s/{AUTHOR}/$dat->{author}/g : $search_for_title =~ s/{AUTHOR}//g; >-- >1.7.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5522
: 2885