Lines 1-17
Link Here
|
1 |
/* global KOHA biblionumber new_results_browser addMultiple vShelfAdd openWindow search_result SEARCH_RESULTS PREF_AmazonCoverImages PREF_LocalCoverImages PREF_IntranetCoce PREF_CoceProviders CoceHost CoceProviders addRecord delSingleRecord PREF_BrowseResultSelection resetSearchContext addBibToContext delBibToContext getContextBiblioNumbers MSG_NO_ITEM_SELECTED MSG_NO_ITEM_SELECTED holdfor_cardnumber holdforclub strQuery MSG_NON_RESERVES_SELECTED PREF_NotHighlightedWords PLACE_HOLD __ */ |
1 |
/* global KOHA biblionumber new_results_browser addMultiple vShelfAdd openWindow search_result SEARCH_RESULTS PREF_LocalCoverImages PREF_IntranetCoce PREF_CoceProviders CoceHost CoceProviders addRecord delSingleRecord PREF_BrowseResultSelection resetSearchContext addBibToContext delBibToContext getContextBiblioNumbers MSG_NO_ITEM_SELECTED MSG_NO_ITEM_SELECTED holdfor_cardnumber holdforclub strQuery MSG_NON_RESERVES_SELECTED PREF_NotHighlightedWords PLACE_HOLD __ */ |
2 |
|
2 |
|
3 |
if( PREF_AmazonCoverImages ){ |
3 |
function verify_images() { |
4 |
$(window).load(function() { |
4 |
/* Loop over each container in the template which contains covers */ |
5 |
verify_images(); |
5 |
var coverSlides = $(".cover-slides"); /* One coverSlides for each search result */ |
|
|
6 |
coverSlides.each( function( index ){ |
7 |
var slide = $(this); |
8 |
var biblionumber = $(this).data("biblionumber"); |
9 |
var coverImages = $(".cover-image", slide ); /* Multiple coverImages for each coverSlides */ |
10 |
var blanks = []; |
11 |
coverImages.each( function( index ){ |
12 |
var div = $(this); |
13 |
var coverId = div.attr("id"); |
14 |
/* Find the image in the container */ |
15 |
var img = div.find("img")[0]; |
16 |
if( $(img).length > 0 ){ |
17 |
if( (img.complete != null) && (!img.complete) || img.naturalHeight == 0 ){ |
18 |
/* No image loaded in the container. Remove the slide */ |
19 |
blanks.push( coverId ); |
20 |
div.remove(); |
21 |
} else { |
22 |
/* Check if Amazon image is present */ |
23 |
if ( div.hasClass("amazon-bookcoverimg") ) { |
24 |
w = img.width; |
25 |
h = img.height; |
26 |
if ((w == 1) || (h == 1)) { |
27 |
/* Amazon returned single-pixel placeholder */ |
28 |
/* Remove the container */ |
29 |
blanks.push( coverId ); |
30 |
div.remove(); |
31 |
} |
32 |
} |
33 |
/* Check if Local image is present */ |
34 |
if ( div.hasClass("local-coverimg" ) ) { |
35 |
w = img.width; |
36 |
h = img.height; |
37 |
if ((w == 1) || (h == 1)) { |
38 |
/* Local cover image returned single-pixel placeholder */ |
39 |
/* Remove the container */ |
40 |
blanks.push( coverId ); |
41 |
div.remove(); |
42 |
} |
43 |
} |
44 |
if( div.hasClass("custom-img") ){ |
45 |
/* Check for image from CustomCoverImages system preference */ |
46 |
if ( (img.complete != null) && (!img.complete) || img.naturalHeight == 0 ) { |
47 |
/* No image was loaded via the CustomCoverImages system preference */ |
48 |
/* Remove the container */ |
49 |
blanks.push( coverId ); |
50 |
div.remove(); |
51 |
} |
52 |
} |
53 |
|
54 |
if( div.hasClass("coce-coverimg") ){ |
55 |
/* Identify which service's image is being loaded by IntranetCoce system pref */ |
56 |
if( $(img).attr("src").indexOf('amazon.com') >= 0 ){ |
57 |
div.find(".hint").html(_("Coce image from Amazon.com")); |
58 |
} else if( $(img).attr("src").indexOf('google.com') >= 0 ){ |
59 |
div.find(".hint").html(_("Coce image from Google Books")); |
60 |
} else if( $(img).attr("src").indexOf('openlibrary.org') >= 0 ){ |
61 |
div.find(".hint").html(_("Coce image from Open Library")); |
62 |
} else { |
63 |
blanks.push( coverId ); |
64 |
div.remove(); |
65 |
} |
66 |
} |
67 |
if( coverImages.length > 1 ){ |
68 |
if( blanks.includes( coverId ) ){ |
69 |
/* Don't add covernav link */ |
70 |
} else { |
71 |
var covernav = $("<a href=\"#\" data-coverid=\"" + coverId + "\" data-biblionumber=\"" + biblionumber + "\" class=\"cover-nav\"></a>"); |
72 |
$(covernav).html("<i class=\"fa fa-circle\"></i>"); |
73 |
slide.addClass("cover-slides").append( covernav ); |
74 |
} |
75 |
} |
76 |
} /* /IF image loaded */ |
77 |
} else { |
78 |
blanks.push( coverId ); |
79 |
div.remove(); |
80 |
} /* /IF there is an image tag */ |
81 |
/* console.log( coverImages ); */ |
82 |
}); |
83 |
|
84 |
/* Show the first cover image slide after empty ones have been removed */ |
85 |
$(".cover-image", slide).eq(0).show(); |
86 |
/* Remove "loading" background gif */ |
87 |
$(".bookcoverimg").css("background","unset"); |
88 |
|
89 |
if( $(".cover-image", slide).length < 2 ){ |
90 |
/* Don't show controls for switching between covers if there is only 1 */ |
91 |
$(".cover-nav", slide).remove(); |
92 |
} |
93 |
/* Set the first navigation link as active */ |
94 |
$(".cover-nav", slide).eq(0).addClass("nav-active"); |
95 |
|
96 |
/* If no slides contain any cover images, remove the container */ |
97 |
if( $(".cover-image:visible", slide).length < 1 ){ |
98 |
slide.remove(); |
99 |
} |
6 |
}); |
100 |
}); |
7 |
} |
101 |
} |
8 |
|
102 |
|
|
|
103 |
$(window).load(function() { |
104 |
verify_images(); |
105 |
}); |
106 |
|
9 |
var Sticky; |
107 |
var Sticky; |
10 |
var toHighlight = {}; |
108 |
var toHighlight = {}; |
11 |
var q_array; |
109 |
var q_array; |
12 |
|
110 |
|
13 |
$(document).ready(function() { |
111 |
$(document).ready(function() { |
14 |
|
112 |
|
|
|
113 |
$("#searchresults").on("click",".cover-nav", function(e){ |
114 |
e.preventDefault(); |
115 |
/* Adding click handler for cover image navigation links */ |
116 |
var coverid = $(this).data("coverid"); |
117 |
var biblionumber = $(this).data("biblionumber"); |
118 |
var slides = $("#cover-slides-" + biblionumber ); |
119 |
|
120 |
$(".cover-nav", slides).removeClass("nav-active"); |
121 |
$(this).addClass("nav-active"); |
122 |
$(".cover-image", slides).hide(); |
123 |
$( "#" + coverid ).show(); |
124 |
}); |
125 |
|
15 |
$(".moretoggle").click(function(e) { |
126 |
$(".moretoggle").click(function(e) { |
16 |
e.preventDefault(); |
127 |
e.preventDefault(); |
17 |
$(this).siblings(".collapsible-facet").toggle(); |
128 |
$(this).siblings(".collapsible-facet").toggle(); |
Lines 86-93
$(document).ready(function() {
Link Here
|
86 |
if( search_result.query_desc ){ |
197 |
if( search_result.query_desc ){ |
87 |
toHighlight = $("p,span.results_summary,a.title"); |
198 |
toHighlight = $("p,span.results_summary,a.title"); |
88 |
q_array = search_result.query_desc.split(" "); |
199 |
q_array = search_result.query_desc.split(" "); |
89 |
// ensure that we don't have "" at the end of the array, which can |
200 |
/* ensure that we don't have "" at the end of the array, which can */ |
90 |
// break the highlighter |
201 |
/* break the highlighter */ |
91 |
while ( q_array.length > 0 && q_array[q_array.length-1] == "") { |
202 |
while ( q_array.length > 0 && q_array[q_array.length-1] == "") { |
92 |
q_array = q_array.splice(0,-1); |
203 |
q_array = q_array.splice(0,-1); |
93 |
} |
204 |
} |
Lines 307-327
function holdForClub() {
Link Here
|
307 |
placeHold(); |
418 |
placeHold(); |
308 |
} |
419 |
} |
309 |
|
420 |
|
310 |
// http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html |
|
|
311 |
function verify_images() { |
312 |
$("img").each(function(){ |
313 |
if ((this.src.indexOf('images-amazon.com') >= 0) || (this.src.indexOf('images.amazon.com') >=0)) { |
314 |
var w = this.width; |
315 |
var h = this.height; |
316 |
if ((w == 1) || (h == 1)) { |
317 |
$(this).parent().html('<span class="no-image">'+__("No cover image available")+'</span>'); |
318 |
} else if ((this.complete != null) && (!this.complete)) { |
319 |
$(this).parent().html('<span class="no-image">'+__("No cover image available")+'</span>'); |
320 |
} |
321 |
} |
322 |
}); |
323 |
} |
324 |
|
325 |
function toggleBatchOp( b ){ |
421 |
function toggleBatchOp( b ){ |
326 |
var results_batch_ops = $("#results_batch_ops"); |
422 |
var results_batch_ops = $("#results_batch_ops"); |
327 |
if( b ){ |
423 |
if( b ){ |
Lines 336-342
function resultsBatchProcess( op ){
Link Here
|
336 |
var params = []; |
432 |
var params = []; |
337 |
var url = ""; |
433 |
var url = ""; |
338 |
if( op == "edit" ){ |
434 |
if( op == "edit" ){ |
339 |
// batch edit selected records |
435 |
/* batch edit selected records */ |
340 |
if ( selected.length < 1 ){ |
436 |
if ( selected.length < 1 ){ |
341 |
alert( __("You must select at least one record") ); |
437 |
alert( __("You must select at least one record") ); |
342 |
} else { |
438 |
} else { |
Lines 347-353
function resultsBatchProcess( op ){
Link Here
|
347 |
location.href = url; |
443 |
location.href = url; |
348 |
} |
444 |
} |
349 |
} else if( op == "delete" ){ |
445 |
} else if( op == "delete" ){ |
350 |
// batch delete selected records |
446 |
/* batch delete selected records */ |
351 |
if ( selected.length < 1) { |
447 |
if ( selected.length < 1) { |
352 |
alert( __("You must select at least one record") ); |
448 |
alert( __("You must select at least one record") ); |
353 |
} else { |
449 |
} else { |
Lines 358-364
function resultsBatchProcess( op ){
Link Here
|
358 |
location.href = url; |
454 |
location.href = url; |
359 |
} |
455 |
} |
360 |
} else if( op == "merge" ){ |
456 |
} else if( op == "merge" ){ |
361 |
// merge selected records |
457 |
/* merge selected records */ |
362 |
if ( selected.length < 2) { |
458 |
if ( selected.length < 2) { |
363 |
alert( __("At least two records must be selected for merging") ); |
459 |
alert( __("At least two records must be selected for merging") ); |
364 |
} else { |
460 |
} else { |
365 |
- |
|
|