Lines 2-7
Link Here
|
2 |
[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › OverDrive search for '[% q | html %]' |
2 |
[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › OverDrive search for '[% q | html %]' |
3 |
[% INCLUDE 'doc-head-close.inc' %] |
3 |
[% INCLUDE 'doc-head-close.inc' %] |
4 |
<script type="text/javascript" src="[% themelang %]/js/overdrive.js"></script> |
4 |
<script type="text/javascript" src="[% themelang %]/js/overdrive.js"></script> |
|
|
5 |
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.rating.js"></script> |
6 |
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/jquery.rating.css" /> |
5 |
<script type="text/javascript"> |
7 |
<script type="text/javascript"> |
6 |
var querystring = "[% q |replace( "'", "\'" ) |replace( '\n', '\\n' ) |replace( '\r', '\\r' ) |html %]"; |
8 |
var querystring = "[% q |replace( "'", "\'" ) |replace( '\n', '\\n' ) |replace( '\r', '\\r' ) |html %]"; |
7 |
var results_per_page = [% OPACnumSearchResults %]; |
9 |
var results_per_page = [% OPACnumSearchResults %]; |
Lines 9-15
var results_per_page = [% OPACnumSearchResults %];
Link Here
|
9 |
function fetch_availability( prod, $tr ) { |
11 |
function fetch_availability( prod, $tr ) { |
10 |
var $availability_summary = $( '<span class="results_summary"></span>' ); |
12 |
var $availability_summary = $( '<span class="results_summary"></span>' ); |
11 |
$tr.find( '.info' ).append( $availability_summary ); |
13 |
$tr.find( '.info' ).append( $availability_summary ); |
12 |
$availability_summary.html( '<span class="label">Availability: </span> Loading...' ); |
14 |
$availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + _("Loading...") ); |
13 |
|
15 |
|
14 |
KOHA.OverDrive.Get( |
16 |
KOHA.OverDrive.Get( |
15 |
prod.links.availability.href, |
17 |
prod.links.availability.href, |
Lines 17-50
function fetch_availability( prod, $tr ) {
Link Here
|
17 |
function ( data ) { |
19 |
function ( data ) { |
18 |
if ( data.error ) return; |
20 |
if ( data.error ) return; |
19 |
|
21 |
|
20 |
$availability_summary.html( '<span class="label">Copies available: </span><span class="available"><strong>' + data.copiesAvailable + '</strong> out of ' + data.copiesOwned + '</span>' ); |
22 |
$availability_summary.html( '<span class="label">' + _("Copies available:") + ' </span><span class="available"><strong>' + data.copiesAvailable + '</strong> ' + _("out of") + ' ' + data.copiesOwned + '</span>' ); |
21 |
|
23 |
|
22 |
if ( data.numberOfHolds ) { |
24 |
if ( data.numberOfHolds ) { |
23 |
$availability_summary.find( '.available' ).append( ', waiting holds: <strong>' + data.numberOfHolds + '</strong>' ); |
25 |
$availability_summary.find( '.available' ).append( ', ' + _("waiting holds:") + ' <strong>' + data.numberOfHolds + '</strong>' ); |
24 |
} |
26 |
} |
25 |
|
27 |
|
26 |
$tr.find( '.info' ).append( '<span class="results_summary actions"><span class="label">Actions: </span><a href="http://' + prod.contentDetails[0].href + '" ' + ( data.copiesAvailable ? ' class="addtocart">Check out' : ' class="hold">Place hold' ) + '</a></span>' ); |
28 |
$tr.find( '.info' ).append( '<span class="results_summary actions"><span class="label">' + _("Actions:") + ' </span><a href="http://' + prod.contentDetails[0].href + '" ' + ( data.copiesAvailable ? ( ' class="addtocart">' + _("Check out") ) : ( ' class="hold">' + _("Place hold") ) ) + '</a></span>' ); |
27 |
} |
29 |
} |
28 |
); |
30 |
); |
29 |
} |
31 |
} |
30 |
|
32 |
|
31 |
function search( offset ) { |
33 |
function search( offset ) { |
32 |
$( '#overdrive-status' ).html( 'Searching OverDrive... <img class="throbber" src="/opac-tmpl/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' ); |
34 |
$( '#overdrive-status' ).html( _("Searching OverDrive...") + ' <img class="throbber" src="/opac-tmpl/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' ); |
33 |
|
35 |
|
34 |
KOHA.OverDrive.Search( "[% OverDriveLibraryID %]", querystring, results_per_page, offset, function( data ) { |
36 |
KOHA.OverDrive.Search( "[% OverDriveLibraryID %]", querystring, results_per_page, offset, function( data ) { |
35 |
if ( data.error ) { |
37 |
if ( data.error ) { |
36 |
$( '#overdrive-status' ).html( '<strong class="unavailable">Error searching OverDrive collection.</strong>' ); |
38 |
$( '#overdrive-status' ).html( '<strong class="unavailable">' + _("Error searching OverDrive collection.") + '</strong>' ); |
37 |
return; |
39 |
return; |
38 |
} |
40 |
} |
39 |
|
41 |
|
40 |
if ( !data.totalItems ) { |
42 |
if ( !data.totalItems ) { |
41 |
$( '#overdrive-status' ).html( '<strong>No results found in the library\'s OverDrive collection.</strong>' ); |
43 |
$( '#overdrive-status' ).html( '<strong>' + _("No results found in the library's OverDrive collection.") + '</strong>' ); |
42 |
return; |
44 |
return; |
43 |
} |
45 |
} |
44 |
|
46 |
|
45 |
$( '#results tbody' ).empty(); |
47 |
$( '#overdrive-results-list tbody' ).empty(); |
46 |
|
48 |
|
47 |
$( '#overdrive-status' ).html( '<strong>Found ' + data.totalItems + ' results in the library\'s OverDrive collection.</strong>' ); |
49 |
$( '#overdrive-status' ).html( '<strong>' + _("Found") + ' ' + data.totalItems + ' ' + _("results in the library's OverDrive collection.") + '</strong>' ); |
48 |
|
50 |
|
49 |
for ( var i = 0; data.products[i]; i++ ) { |
51 |
for ( var i = 0; data.products[i]; i++ ) { |
50 |
var prod = data.products[i]; |
52 |
var prod = data.products[i]; |
Lines 56-64
function search( offset ) {
Link Here
|
56 |
results.push( prod.title ); |
58 |
results.push( prod.title ); |
57 |
if ( prod.subtitle ) results.push( ', ', prod.subtitle ); |
59 |
if ( prod.subtitle ) results.push( ', ', prod.subtitle ); |
58 |
results.push( '</a>' ); |
60 |
results.push( '</a>' ); |
59 |
results.push( '<p>by ', prod.primaryCreator.name, '</p>' ); |
61 |
results.push( '<p>' + _("by") + ' ', prod.primaryCreator.name, '</p>' ); |
60 |
results.push( '<span class="results_summary"><span class="label">Type: </span>', prod.mediaType, '</span>' ); |
62 |
if ( prod.starRating ) { |
61 |
if ( prod.starRating ) results.push( '<span class="results_summary"><span class="label">Average rating: <img src="[% themelang %]/../images/Star', Math.round( parseInt( prod.starRating )), '.gif" title="" style="max-height: 15px; vertical-align: bottom"/></span>' ); |
63 |
results.push( '<span class="results_summary ratings">' ); |
|
|
64 |
for ( var rating = 1; rating <= 5; rating++ ) { |
65 |
results.push( '<input class="star" type="radio" name="rating-' + i + '" value="' + rating + '"' + ( rating == Math.round( prod.starRating ) ? ' checked="checked"' : '' ) + ' disabled="disabled" />' ); |
66 |
} |
67 |
results.push( '</span>' ); |
68 |
} |
69 |
results.push( '<span class="results_summary"><span class="label">' + _("Type:") + ' </span>', prod.mediaType, '</span>' ); |
62 |
results.push( '</td>' ); |
70 |
results.push( '</td>' ); |
63 |
|
71 |
|
64 |
results.push( '<td>' ); |
72 |
results.push( '<td>' ); |
Lines 71-89
function search( offset ) {
Link Here
|
71 |
|
79 |
|
72 |
results.push( '</tr>' ); |
80 |
results.push( '</tr>' ); |
73 |
var $tr = $( results.join( '' )); |
81 |
var $tr = $( results.join( '' )); |
74 |
$( '#results tbody' ).append( $tr ); |
82 |
$( '#overdrive-results-list tbody' ).append( $tr ); |
75 |
|
83 |
|
76 |
fetch_availability( prod, $tr ); |
84 |
fetch_availability( prod, $tr ); |
77 |
} |
85 |
} |
78 |
|
86 |
|
79 |
$( '#results tr:odd' ).addClass( 'highlight' ); |
87 |
$( '#overdrive-results-list tr:odd' ).addClass( 'highlight' ); |
80 |
|
88 |
|
81 |
var pages = []; |
89 |
var pages = []; |
82 |
var cur_page = offset / results_per_page; |
90 |
var cur_page = offset / results_per_page; |
83 |
var max_page = Math.floor( data.totalItems / results_per_page ); |
91 |
var max_page = Math.floor( data.totalItems / results_per_page ); |
84 |
|
92 |
|
85 |
if ( cur_page != 0 ) { |
93 |
if ( cur_page != 0 ) { |
86 |
pages.push( '<a class="nav" href="#" data-offset="' + (offset - results_per_page) + '"><< Previous</a>' ); |
94 |
pages.push( '<a class="nav" href="#" data-offset="' + (offset - results_per_page) + '"><< ' + _("Previous") + '</a>' ); |
87 |
} |
95 |
} |
88 |
|
96 |
|
89 |
for ( var page = Math.max( 0, cur_page - 9 ); page <= Math.min( max_page, cur_page + 9 ); page++ ) { |
97 |
for ( var page = Math.max( 0, cur_page - 9 ); page <= Math.min( max_page, cur_page + 9 ); page++ ) { |
Lines 95-104
function search( offset ) {
Link Here
|
95 |
} |
103 |
} |
96 |
|
104 |
|
97 |
if ( cur_page < max_page ) { |
105 |
if ( cur_page < max_page ) { |
98 |
pages.push( ' <a class="nav" href="#" data-offset="' + (offset + results_per_page) + '">Next >></a>' ); |
106 |
pages.push( ' <a class="nav" href="#" data-offset="' + (offset + results_per_page) + '">' + _("Next") + ' >></a>' ); |
99 |
} |
107 |
} |
100 |
|
108 |
|
101 |
if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pages' ).html( pages.join( '' ) ); |
109 |
if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pages' ).html( pages.join( '' ) ); |
|
|
110 |
|
111 |
$( '#overdrive-results-list input.star' ).rating(); |
102 |
} ); |
112 |
} ); |
103 |
} |
113 |
} |
104 |
|
114 |
|
Lines 140-146
$( document ).ready( function() {
Link Here
|
140 |
<div class="pages"> |
150 |
<div class="pages"> |
141 |
</div> |
151 |
</div> |
142 |
</div> |
152 |
</div> |
143 |
<table id="results"> |
153 |
<table id="overdrive-results-list"> |
144 |
<tbody> |
154 |
<tbody> |
145 |
</tbody> |
155 |
</tbody> |
146 |
</table> |
156 |
</table> |