4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog › OverDrive search for '[% q | html %]'</title>
6 [% INCLUDE 'doc-head-close.inc' %]
10 [% INCLUDE 'bodytag.inc' bodyid='overdrive-results-page' bodyclass='scrollto' %]
11 [% INCLUDE 'masthead.inc' %]
14 <nav aria-label="breadcrumb">
15 <ul class="breadcrumb">
16 <li class="breadcrumb-item">
17 <a href="/cgi-bin/koha/opac-main.pl">Home</a>
19 <li class="breadcrumb-item active" aria-current="page">
20 <a href="#">OverDrive search for '[% q | html %]'</a>
25 <div class="container-fluid">
27 <div class="col-lg-2">
28 [% IF ( OpacNav || OpacNavBottom ) %]
29 [% INCLUDE 'navigation.inc' %]
32 <div class="col-lg-10 order-first order-md-first order-lg-2">
33 <div id="overdrive-results-content" class="maincontent searchresults">
34 <h1>OverDrive search for '[% q | html %]'</h1>
35 <div id="breadcrumbs">
40 <nav class="pagination pagination-sm noprint" aria-label="Search results pagination">
44 <table id="overdrive-results-list" class="table table-striped">
49 <div id="bottom-pages">
50 <nav class="pagination pagination-sm noprint" aria-label="Search results pagination">
54 </div> <!-- / #overdrive-results-content -->
55 </div> <!-- / .span10 -->
56 </div> <!-- / .row -->
57 </div> <!-- / .container-fluid -->
58 </div> <!-- / .main -->
60 [% IF ( Koha.Preference('OverDriveCirculation') ) %]
61 [% INCLUDE 'overdrive-checkout.inc' %]
62 [% IF ( Koha.Preference('OverDrivePasswordRequired') ) %]
63 [% INCLUDE 'overdrive-login.inc' %]
67 [% INCLUDE 'opac-bottom.inc' %]
69 [% Asset.js("js/overdrive.js") | $raw %]
71 var OD_password_required = [% IF Koha.Preference('OverDrivePasswordRequired') %]1[% ELSE %]0[% END %];
72 var querystring = "[% q |replace( "'", "\'" ) |replace( '\n', '\\n' ) |replace( '\r', '\\r' ) | html %]";
73 var results_per_page = [% OPACnumSearchResults | html %];
75 function fetch_availability( prod, $tr ) {
76 var $availability_summary = $( '<span class="results_summary availability"></span>' );
77 $tr.find( '.mediatype' ).after( $availability_summary );
78 $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + _("Loading...") );
81 prod.links.availability.href,
84 if ( data.error ) return;
86 $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + '<span class="available"><b>' + _("Items available:") + ' </b>' + data.copiesAvailable + " " + _("out of") + ' ' + data.copiesOwned + '</span>' );
88 if ( data.numberOfHolds ) {
89 $availability_summary.find( '.available' ).append( ', ' + _("waiting holds:") + ' <strong>' + data.numberOfHolds + '</strong>' );
92 $tr.find( '.info' ).each(function() {
93 KOHA.OverDriveCirculation.add_actions(this, data.id, data.copiesAvailable);
99 function search( offset ) {
100 $( '#overdrive-status' ).html( _("Searching OverDrive...") + ' <img class="throbber" src="[% interface | html %]/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
102 KOHA.OverDrive.Search( "[% Koha.Preference('OverDriveLibraryID') | html %]", querystring, results_per_page, offset, function( data ) {
104 $( '#overdrive-status' ).html( '<strong class="unavailable">' + _("Error searching OverDrive collection.") + '</strong>' );
108 if ( !data.totalItems ) {
109 $( '#overdrive-status' ).html( '<strong>' + _("No results found in the library's OverDrive collection.") + '</strong>' );
113 $( '#overdrive-results-list tbody' ).empty();
115 $( '#overdrive-status' ).html( '<strong>' + _("Found") + ' ' + data.totalItems + ' ' + _("results in the library's OverDrive collection.") + '</strong>' );
117 for ( var i = 0; data.products[i]; i++ ) {
118 var prod = data.products[i];
121 results.push( '<tr>' );
123 results.push( '<td class="info"><a class="title" href="', prod.contentDetails[0].href, '">' );
124 results.push( prod.title );
125 if ( prod.subtitle ) results.push( ', ', prod.subtitle );
126 results.push( '</a>' );
127 if ( prod.primaryCreator ) results.push( '<p>' + _("by") + ' ', prod.primaryCreator.name, '</p>' );
128 results.push( '<span class="results_summary mediatype"><span class="label">' + _("Type:") + ' </span>', prod.mediaType, '</span>' );
130 if ( prod.starRating ) {
131 var rating_value = Math.round( prod.starRating );
132 results.push( '<div class="results_summary ratings">' );
133 results.push( '<div class="br-wrapper br-theme-fontawesome-stars">');
134 results.push( '<div class="br-widget br-readonly">');
135 for ( var rating = 1; rating <= 5; rating++ ) {
137 results.push( '<a href="#"' );
138 if( rating == rating_value ){
139 results.push( ' class="br-selected br-current"></a>' );
140 } else if( rating_value > rating ){
141 results.push( ' class="br-selected"></a>' );
143 results.push( '></a>');
146 results.push( '</div>' );
147 results.push( '</div>' );
148 results.push( '</div>' );
151 results.push( '</td>' );
153 results.push( '<td>' );
154 if ( prod.images.thumbnail ) {
155 results.push( '<a href="', prod.contentDetails[0].href, '">' );
156 results.push( '<img class="thumbnail" src="', prod.images.thumbnail.href, '" />' );
157 results.push( '</a>' );
159 results.push( '</td>' );
161 results.push( '</tr>' );
162 var $tr = $( results.join( '' ));
163 $( '#overdrive-results-list tbody' ).append( $tr );
165 fetch_availability( prod, $tr );
168 $( '#overdrive-results-list tr:odd' ).addClass( 'highlight' );
171 var cur_page = offset / results_per_page;
172 var max_page = Math.floor( data.totalItems / results_per_page );
174 if ( cur_page != 0 ) {
175 pages.push( '<li class="page-item"><a class="page-link od-nav" href="#" data-offset="' + (offset - results_per_page) + '">« ' + _("Previous") + '</a></li>' );
178 for ( var page = Math.max( 0, cur_page - 9 ); page <= Math.min( max_page, cur_page + 9 ); page++ ) {
179 if ( page == cur_page ) {
180 pages.push( ' <li class="page-item disabled"><a class="page-link" href="#">' + ( page + 1 ) + '</a></li>' );
182 pages.push( ' <li class="page-item"><a class="page-link od-nav" href="#" data-offset="' + ( page * results_per_page ) + '">' + ( page + 1 ) + '</a></li>' );
186 if ( cur_page < max_page ) {
187 pages.push( ' <li class="page-item"><a class="page-link od-nav" href="#" data-offset="' + (offset + results_per_page) + '">' + _("Next") + ' »</a></li>' );
190 if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pagination' ).html( '<ul class="pagination">' + pages.join( '' ) + '</ul>');
195 $( document ).ready( function() {
196 $( '#breadcrumbs p' )
198 .append( '<span id="overdrive-status"></span>' );
200 $( document ).on( 'click', 'a.od-nav', function() {
201 search( $( this ).data( 'offset' ) );
205 [% IF ( overdrive_error ) %]
206 KOHA.OverDriveCirculation.display_error("#breadcrumbs", "[% overdrive_error.dquote | html %]");
208 [% IF ( loggedinusername and Koha.Preference('OverDriveCirculation') ) %]
209 KOHA.OverDriveCirculation.with_account_details("#breadcrumbs", function() {