3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › OverDrive search for '[% q | html %]'</title>
5 [% INCLUDE 'doc-head-close.inc' %]
7 [% Asset.css("css/jquery.rating.css") %]
15 [% INCLUDE 'bodytag.inc' bodyid='overdrive-results-page' bodyclass='scrollto' %]
16 [% INCLUDE 'masthead.inc' %]
19 <ul class="breadcrumb">
20 <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">›</span></li>
21 <li><a href="#">OverDrive search for '[% q | html %]'</a></li>
24 <div class="container-fluid">
25 <div class="row-fluid">
27 [% IF ( OpacNav || OpacNavBottom ) %]
28 [% INCLUDE 'navigation.inc' %]
32 <div id="overdrive-results-content" class="maincontent searchresults">
33 <h1>OverDrive search for '[% q | html %]'</h1>
34 <div id="breadcrumbs">
39 <div class="pagination pagination-small">
43 <table id="overdrive-results-list" class="table table-striped">
48 <div id="bottom-pages">
49 <div class="pagination pagination-small">
53 </div> <!-- / #overdrive-results-content -->
54 </div> <!-- / .span10 -->
55 </div> <!-- / .row-fluid -->
56 </div> <!-- / .container-fluid -->
57 </div> <!-- / .main -->
59 [% INCLUDE 'overdrive-checkout.inc' %]
61 [% INCLUDE 'opac-bottom.inc' %]
63 [% Asset.js("js/overdrive.js") %]
64 [% Asset.js("lib/jquery/plugins/jquery.rating.js") %]
66 var OD_password_required = [% IF Koha.Preference('OverDrivePasswordRequired') %]1[% ELSE %]0[% END %];
67 var querystring = "[% q |replace( "'", "\'" ) |replace( '\n', '\\n' ) |replace( '\r', '\\r' ) | html %]";
68 var results_per_page = [% OPACnumSearchResults | html %];
70 function fetch_availability( prod, $tr ) {
71 var $availability_summary = $( '<span class="results_summary availability"></span>' );
72 $tr.find( '.mediatype' ).after( $availability_summary );
73 $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + _("Loading...") );
76 prod.links.availability.href,
79 if ( data.error ) return;
81 $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + '<span class="available"><b>' + _("Items available:") + ' </b>' + data.copiesAvailable + " " + _("out of") + ' ' + data.copiesOwned + '</span>' );
83 if ( data.numberOfHolds ) {
84 $availability_summary.find( '.available' ).append( ', ' + _("waiting holds:") + ' <strong>' + data.numberOfHolds + '</strong>' );
87 $tr.find( '.info' ).each(function() {
88 KOHA.OverDriveCirculation.add_actions(this, data.id, data.copiesAvailable);
94 function search( offset ) {
95 $( '#overdrive-status' ).html( _("Searching OverDrive...") + ' <img class="throbber" src="[% interface %]/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
97 KOHA.OverDrive.Search( "[% OverDriveLibraryID %]", querystring, results_per_page, offset, function( data ) {
99 $( '#overdrive-status' ).html( '<strong class="unavailable">' + _("Error searching OverDrive collection.") + '</strong>' );
103 if ( !data.totalItems ) {
104 $( '#overdrive-status' ).html( '<strong>' + _("No results found in the library's OverDrive collection.") + '</strong>' );
108 $( '#overdrive-results-list tbody' ).empty();
110 $( '#overdrive-status' ).html( '<strong>' + _("Found") + ' ' + data.totalItems + ' ' + _("results in the library's OverDrive collection.") + '</strong>' );
112 for ( var i = 0; data.products[i]; i++ ) {
113 var prod = data.products[i];
116 results.push( '<tr>' );
118 results.push( '<td class="info"><a class="title" href="', prod.contentDetails[0].href, '">' );
119 results.push( prod.title );
120 if ( prod.subtitle ) results.push( ', ', prod.subtitle );
121 results.push( '</a>' );
122 results.push( '<p>' + _("by") + ' ', prod.primaryCreator.name, '</p>' );
123 results.push( '<span class="results_summary mediatype"><span class="label">' + _("Type:") + ' </span>', prod.mediaType, '</span>' );
125 if ( prod.starRating ) {
126 results.push( '<div class="results_summary ratings">' );
127 for ( var rating = 1; rating <= 5; rating++ ) {
128 results.push( '<input class="star" type="radio" name="rating-' + i + '" value="' + rating + '"' + ( rating == Math.round( prod.starRating ) ? ' checked="checked"' : '' ) + ' disabled="disabled" />' );
130 results.push( '</div>' );
133 results.push( '</td>' );
135 results.push( '<td>' );
136 if ( prod.images.thumbnail ) {
137 results.push( '<a href="', prod.contentDetails[0].href, '">' );
138 results.push( '<img class="thumbnail" src="', prod.images.thumbnail.href, '" />' );
139 results.push( '</a>' );
141 results.push( '</td>' );
143 results.push( '</tr>' );
144 var $tr = $( results.join( '' ));
145 $( '#overdrive-results-list tbody' ).append( $tr );
147 fetch_availability( prod, $tr );
150 $( '#overdrive-results-list tr:odd' ).addClass( 'highlight' );
153 var cur_page = offset / results_per_page;
154 var max_page = Math.floor( data.totalItems / results_per_page );
156 if ( cur_page != 0 ) {
157 pages.push( '<li><a class="od-nav" href="#" data-offset="' + (offset - results_per_page) + '">« ' + _("Previous") + '</a></li>' );
160 for ( var page = Math.max( 0, cur_page - 9 ); page <= Math.min( max_page, cur_page + 9 ); page++ ) {
161 if ( page == cur_page ) {
162 pages.push( ' <li class="active"><a href="#">' + ( page + 1 ) + '</a></li>' );
164 pages.push( ' <li><a class="od-nav" href="#" data-offset="' + ( page * results_per_page ) + '">' + ( page + 1 ) + '</a></li>' );
168 if ( cur_page < max_page ) {
169 pages.push( ' <li><a class="od-nav" href="#" data-offset="' + (offset + results_per_page) + '">' + _("Next") + ' »</a></li>' );
172 if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pagination' ).html( '<ul>' + pages.join( '' ) + '</ul>');
174 $( '#overdrive-results-list input.star' ).rating();
178 $( document ).ready( function() {
179 $( '#breadcrumbs p' )
181 .append( '<span id="overdrive-status"></span>' );
183 $( document ).on( 'click', 'a.od-nav', function() {
184 search( $( this ).data( 'offset' ) );
188 [% IF ( overdrive_error ) %]
189 KOHA.OverDriveCirculation.display_error("#breadcrumbs", "[% overdrive_error.dquote %]");
191 [% IF ( loggedinusername and Koha.Preference('OverDriveCirculation') ) %]
192 KOHA.OverDriveCirculation.with_account_details("#breadcrumbs", function() {