Skip to content
Snippets Groups Projects
Commit 76c00a28 authored by Demian Katz's avatar Demian Katz
Browse files

Link thumbnails to previews when applicable.

- Resolves VUFIND-923
- Thanks to Chris Hallberg for elegant JS solutions!
parent f37611ab
No related merge requests found
...@@ -27,6 +27,13 @@ function getHTPreviews(skeys) { ...@@ -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) { function processBookInfo(booksInfo, previewClass) {
// assign the correct rights string depending on source // assign the correct rights string depending on source
var viewOptions = (previewClass == 'previewGBS') var viewOptions = (previewClass == 'previewGBS')
...@@ -35,8 +42,9 @@ function processBookInfo(booksInfo, previewClass) { ...@@ -35,8 +42,9 @@ function processBookInfo(booksInfo, previewClass) {
var bookInfo = booksInfo[bibkey]; var bookInfo = booksInfo[bibkey];
if (bookInfo) { if (bookInfo) {
if (viewOptions.indexOf(bookInfo.preview)>= 0) { if (viewOptions.indexOf(bookInfo.preview)>= 0) {
var $link = $('.' + previewClass + '.' + bibkey); applyPreviewUrl(
$link.attr('href', bookInfo.preview_url).show(); $('.' + previewClass + '.' + bibkey), bookInfo.preview_url
);
} }
} }
} }
...@@ -58,7 +66,7 @@ function processHTBookInfo(booksInfo) { ...@@ -58,7 +66,7 @@ function processHTBookInfo(booksInfo) {
for (var i = 0; i < items.length; i++) { for (var i = 0; i < items.length; i++) {
// check if items possess an eligible rights code // check if items possess an eligible rights code
if (getHathiOptions().indexOf(items[i].rightsCode) >= 0) { if (getHathiOptions().indexOf(items[i].rightsCode) >= 0) {
$link.attr('href', items[i].itemURL).show(); applyPreviewUrl($link, items[i].itemURL);
} }
} }
} }
......
<div class="result source<?=$this->escapeHtml($this->driver->getResourceSource())?> recordId<?=$this->driver->supportsAjaxStatus()?' ajaxItemId':''?>"> <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" /> <input type="hidden" value="<?=$this->escapeHtml($this->driver->getUniqueID())?>" class="hiddenId" />
<div class="span-2"> <div class="span-2">
<? if ($summThumb = $this->record($this->driver)->getThumbnail()): ?> <a href="<?=$this->recordLink()->getUrl($this->driver)?>">
<img src="<?=$this->escapeHtml($summThumb)?>" class="summcover" alt="<?=$this->transEsc('Cover Image')?>"/> <? if ($summThumb = $this->record($this->driver)->getThumbnail()): ?>
<? else: ?> <img src="<?=$this->escapeHtml($summThumb)?>" class="summcover" alt="<?=$this->transEsc('Cover Image')?>"/>
<img src="<?=$this->url('cover-unavailable')?>" class="summcover" alt="<?=$this->transEsc('No Cover Image')?>"/> <? else: ?>
<? endif; ?> <img src="<?=$this->url('cover-unavailable')?>" class="summcover" alt="<?=$this->transEsc('No Cover Image')?>"/>
<? endif; ?>
</a>
</div> </div>
<div class="span-9"> <div class="span-9">
<div class="resultItemLine1"> <div class="resultItemLine1">
......
...@@ -27,6 +27,13 @@ function getHTPreviews(skeys) { ...@@ -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) { function processBookInfo(booksInfo, previewClass) {
// assign the correct rights string depending on source // assign the correct rights string depending on source
var viewOptions = (previewClass == 'previewGBS') var viewOptions = (previewClass == 'previewGBS')
...@@ -35,8 +42,9 @@ function processBookInfo(booksInfo, previewClass) { ...@@ -35,8 +42,9 @@ function processBookInfo(booksInfo, previewClass) {
var bookInfo = booksInfo[bibkey]; var bookInfo = booksInfo[bibkey];
if (bookInfo) { if (bookInfo) {
if (viewOptions.indexOf(bookInfo.preview)>= 0) { if (viewOptions.indexOf(bookInfo.preview)>= 0) {
var $link = $('.' + previewClass + '.' + bibkey); applyPreviewUrl(
$link.attr('href', bookInfo.preview_url).show(); $('.' + previewClass + '.' + bibkey), bookInfo.preview_url
);
} }
} }
} }
...@@ -58,7 +66,7 @@ function processHTBookInfo(booksInfo) { ...@@ -58,7 +66,7 @@ function processHTBookInfo(booksInfo) {
for (var i = 0; i < items.length; i++) { for (var i = 0; i < items.length; i++) {
// check if items possess an eligible rights code // check if items possess an eligible rights code
if (getHathiOptions().indexOf(items[i].rightsCode) >= 0) { if (getHathiOptions().indexOf(items[i].rightsCode) >= 0) {
$link.attr('href', items[i].itemURL).show(); applyPreviewUrl($link, items[i].itemURL);
} }
} }
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment