From 76c00a28b499b961335643a73f35a42689758c29 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Thu, 24 Oct 2013 10:58:59 -0400 Subject: [PATCH] Link thumbnails to previews when applicable. - Resolves VUFIND-923 - Thanks to Chris Hallberg for elegant JS solutions! --- themes/blueprint/js/preview.js | 14 +++++++++++--- .../RecordDriver/SolrDefault/result-list.phtml | 12 +++++++----- themes/bootstrap/js/preview.js | 14 +++++++++++--- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/themes/blueprint/js/preview.js b/themes/blueprint/js/preview.js index 793d225bb4c..e2235077047 100644 --- a/themes/blueprint/js/preview.js +++ b/themes/blueprint/js/preview.js @@ -27,6 +27,13 @@ function getHTPreviews(skeys) { } } +function applyPreviewUrl($link, url) { + $link.attr('href', url).show(); + $link.parents('.result,.record') + .find('img.summcover,img.recordcover') + .parents('a').attr('href', url); +} + function processBookInfo(booksInfo, previewClass) { // assign the correct rights string depending on source var viewOptions = (previewClass == 'previewGBS') @@ -35,8 +42,9 @@ function processBookInfo(booksInfo, previewClass) { var bookInfo = booksInfo[bibkey]; if (bookInfo) { if (viewOptions.indexOf(bookInfo.preview)>= 0) { - var $link = $('.' + previewClass + '.' + bibkey); - $link.attr('href', bookInfo.preview_url).show(); + applyPreviewUrl( + $('.' + previewClass + '.' + bibkey), bookInfo.preview_url + ); } } } @@ -58,7 +66,7 @@ function processHTBookInfo(booksInfo) { for (var i = 0; i < items.length; i++) { // check if items possess an eligible rights code if (getHathiOptions().indexOf(items[i].rightsCode) >= 0) { - $link.attr('href', items[i].itemURL).show(); + applyPreviewUrl($link, items[i].itemURL); } } } diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/result-list.phtml b/themes/blueprint/templates/RecordDriver/SolrDefault/result-list.phtml index b8588b41752..8967ca6362d 100644 --- a/themes/blueprint/templates/RecordDriver/SolrDefault/result-list.phtml +++ b/themes/blueprint/templates/RecordDriver/SolrDefault/result-list.phtml @@ -1,11 +1,13 @@ <div class="result source<?=$this->escapeHtml($this->driver->getResourceSource())?> recordId<?=$this->driver->supportsAjaxStatus()?' ajaxItemId':''?>"> <input type="hidden" value="<?=$this->escapeHtml($this->driver->getUniqueID())?>" class="hiddenId" /> <div class="span-2"> - <? if ($summThumb = $this->record($this->driver)->getThumbnail()): ?> - <img src="<?=$this->escapeHtml($summThumb)?>" class="summcover" alt="<?=$this->transEsc('Cover Image')?>"/> - <? else: ?> - <img src="<?=$this->url('cover-unavailable')?>" class="summcover" alt="<?=$this->transEsc('No Cover Image')?>"/> - <? endif; ?> + <a href="<?=$this->recordLink()->getUrl($this->driver)?>"> + <? if ($summThumb = $this->record($this->driver)->getThumbnail()): ?> + <img src="<?=$this->escapeHtml($summThumb)?>" class="summcover" alt="<?=$this->transEsc('Cover Image')?>"/> + <? else: ?> + <img src="<?=$this->url('cover-unavailable')?>" class="summcover" alt="<?=$this->transEsc('No Cover Image')?>"/> + <? endif; ?> + </a> </div> <div class="span-9"> <div class="resultItemLine1"> diff --git a/themes/bootstrap/js/preview.js b/themes/bootstrap/js/preview.js index 793d225bb4c..c1eed9fd20e 100644 --- a/themes/bootstrap/js/preview.js +++ b/themes/bootstrap/js/preview.js @@ -27,6 +27,13 @@ function getHTPreviews(skeys) { } } +function applyPreviewUrl($link, url) { + $link.attr('href', url).show(); + $link.parents('.result,.record') + .find('img.img-polaroid') + .parents('a').attr('href', url); +} + function processBookInfo(booksInfo, previewClass) { // assign the correct rights string depending on source var viewOptions = (previewClass == 'previewGBS') @@ -35,8 +42,9 @@ function processBookInfo(booksInfo, previewClass) { var bookInfo = booksInfo[bibkey]; if (bookInfo) { if (viewOptions.indexOf(bookInfo.preview)>= 0) { - var $link = $('.' + previewClass + '.' + bibkey); - $link.attr('href', bookInfo.preview_url).show(); + applyPreviewUrl( + $('.' + previewClass + '.' + bibkey), bookInfo.preview_url + ); } } } @@ -58,7 +66,7 @@ function processHTBookInfo(booksInfo) { for (var i = 0; i < items.length; i++) { // check if items possess an eligible rights code if (getHathiOptions().indexOf(items[i].rightsCode) >= 0) { - $link.attr('href', items[i].itemURL).show(); + applyPreviewUrl($link, items[i].itemURL); } } } -- GitLab