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 holdfor_cardnumber holdforclub strQuery PREF_NotHighlightedWords __ */ |
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 holdfor_cardnumber holdforclub strQuery PREF_NotHighlightedWords __ */ |
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 303-323
function holdForClub() {
Link Here
|
303 |
placeHold(); |
414 |
placeHold(); |
304 |
} |
415 |
} |
305 |
|
416 |
|
306 |
// http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html |
|
|
307 |
function verify_images() { |
308 |
$("img").each(function(){ |
309 |
if ((this.src.indexOf('images-amazon.com') >= 0) || (this.src.indexOf('images.amazon.com') >=0)) { |
310 |
var w = this.width; |
311 |
var h = this.height; |
312 |
if ((w == 1) || (h == 1)) { |
313 |
$(this).parent().html('<span class="no-image">'+ __("No cover image available") +'</span>'); |
314 |
} else if ((this.complete != null) && (!this.complete)) { |
315 |
$(this).parent().html('<span class="no-image">'+ __("No cover image available") +'</span>'); |
316 |
} |
317 |
} |
318 |
}); |
319 |
} |
320 |
|
321 |
function toggleBatchOp( b ){ |
417 |
function toggleBatchOp( b ){ |
322 |
var results_batch_ops = $("#results_batch_ops"); |
418 |
var results_batch_ops = $("#results_batch_ops"); |
323 |
if( b ){ |
419 |
if( b ){ |
Lines 332-338
function resultsBatchProcess( op ){
Link Here
|
332 |
var params = []; |
428 |
var params = []; |
333 |
var url = ""; |
429 |
var url = ""; |
334 |
if( op == "edit" ){ |
430 |
if( op == "edit" ){ |
335 |
// batch edit selected records |
431 |
/* batch edit selected records */ |
336 |
if ( selected.length < 1 ){ |
432 |
if ( selected.length < 1 ){ |
337 |
alert( __("You must select at least one record") ); |
433 |
alert( __("You must select at least one record") ); |
338 |
} else { |
434 |
} else { |
Lines 343-349
function resultsBatchProcess( op ){
Link Here
|
343 |
location.href = url; |
439 |
location.href = url; |
344 |
} |
440 |
} |
345 |
} else if( op == "delete" ){ |
441 |
} else if( op == "delete" ){ |
346 |
// batch delete selected records |
442 |
/* batch delete selected records */ |
347 |
if ( selected.length < 1) { |
443 |
if ( selected.length < 1) { |
348 |
alert( __("You must select at least one record") ); |
444 |
alert( __("You must select at least one record") ); |
349 |
} else { |
445 |
} else { |
Lines 354-360
function resultsBatchProcess( op ){
Link Here
|
354 |
location.href = url; |
450 |
location.href = url; |
355 |
} |
451 |
} |
356 |
} else if( op == "merge" ){ |
452 |
} else if( op == "merge" ){ |
357 |
// merge selected records |
453 |
/* merge selected records */ |
358 |
if ( selected.length < 2) { |
454 |
if ( selected.length < 2) { |
359 |
alert( __("At least two records must be selected for merging") ); |
455 |
alert( __("At least two records must be selected for merging") ); |
360 |
} else { |
456 |
} else { |
361 |
- |
|
|