2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › OverDrive search for '[% q | html %]'</title>
4 [% INCLUDE 'doc-head-close.inc' %]
6 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/jquery.rating.css" />
14 [% INCLUDE 'bodytag.inc' bodyid='overdrive-results-page' bodyclass='scrollto' %]
15 [% INCLUDE 'masthead.inc' %]
18 <ul class="breadcrumb">
19 <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">›</span></li>
20 <li><a href="#">OverDrive search for '[% q | html %]'</a></li>
23 <div class="container-fluid">
24 <div class="row-fluid">
26 [% IF ( OpacNav || OpacNavBottom ) %]
27 [% INCLUDE 'navigation.inc' %]
31 <div id="overdrive-results-content" class="maincontent searchresults">
32 <h1>OverDrive search for '[% q | html %]'</h1>
33 <div id="breadcrumbs">
38 <div class="pagination pagination-small">
42 <table id="overdrive-results-list" class="table table-striped">
47 <div id="bottom-pages">
48 <div class="pagination pagination-small">
52 </div> <!-- / #overdrive-results-content -->
53 </div> <!-- / .span10 -->
54 </div> <!-- / .row-fluid -->
55 </div> <!-- / .container-fluid -->
56 </div> <!-- / .main -->
58 [% INCLUDE 'overdrive-checkout.inc' %]
60 [% INCLUDE 'opac-bottom.inc' %]
62 <script type="text/javascript" src="[% interface %]/[% theme %]/js/overdrive.js"></script>
63 <script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.rating.js"></script>
64 <script type="text/javascript">
65 var querystring = "[% q |replace( "'", "\'" ) |replace( '\n', '\\n' ) |replace( '\r', '\\r' ) |html %]";
66 var results_per_page = [% OPACnumSearchResults %];
68 function fetch_availability( prod, $tr ) {
69 var $availability_summary = $( '<span class="results_summary availability"></span>' );
70 $tr.find( '.mediatype' ).after( $availability_summary );
71 $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + _("Loading...") );
74 prod.links.availability.href,
77 if ( data.error ) return;
79 $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + '<span class="available"><b>' + _("Items available:") + ' </b>' + data.copiesAvailable + " " + _("out of") + ' ' + data.copiesOwned + '</span>' );
81 if ( data.numberOfHolds ) {
82 $availability_summary.find( '.available' ).append( ', ' + _("waiting holds:") + ' <strong>' + data.numberOfHolds + '</strong>' );
85 $tr.find( '.info' ).each(function() {
86 KOHA.OverDriveCirculation.add_actions(this, data.id, data.copiesAvailable);
92 function search( offset ) {
93 $( '#overdrive-status' ).html( _("Searching OverDrive...") + ' <img class="throbber" src="[% interface %]/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
95 KOHA.OverDrive.Search( "[% OverDriveLibraryID %]", querystring, results_per_page, offset, function( data ) {
97 $( '#overdrive-status' ).html( '<strong class="unavailable">' + _("Error searching OverDrive collection.") + '</strong>' );
101 if ( !data.totalItems ) {
102 $( '#overdrive-status' ).html( '<strong>' + _("No results found in the library's OverDrive collection.") + '</strong>' );
106 $( '#overdrive-results-list tbody' ).empty();
108 $( '#overdrive-status' ).html( '<strong>' + _("Found") + ' ' + data.totalItems + ' ' + _("results in the library's OverDrive collection.") + '</strong>' );
110 for ( var i = 0; data.products[i]; i++ ) {
111 var prod = data.products[i];
114 results.push( '<tr>' );
116 results.push( '<td class="info"><a class="title" href="', prod.contentDetails[0].href, '">' );
117 results.push( prod.title );
118 if ( prod.subtitle ) results.push( ', ', prod.subtitle );
119 results.push( '</a>' );
120 results.push( '<p>' + _("by") + ' ', prod.primaryCreator.name, '</p>' );
121 results.push( '<span class="results_summary mediatype"><span class="label">' + _("Type:") + ' </span>', prod.mediaType, '</span>' );
123 if ( prod.starRating ) {
124 results.push( '<div class="results_summary ratings">' );
125 for ( var rating = 1; rating <= 5; rating++ ) {
126 results.push( '<input class="star" type="radio" name="rating-' + i + '" value="' + rating + '"' + ( rating == Math.round( prod.starRating ) ? ' checked="checked"' : '' ) + ' disabled="disabled" />' );
128 results.push( '</div>' );
131 results.push( '</td>' );
133 results.push( '<td>' );
134 if ( prod.images.thumbnail ) {
135 results.push( '<a href="', prod.contentDetails[0].href, '">' );
136 results.push( '<img class="thumbnail" src="', prod.images.thumbnail.href, '" />' );
137 results.push( '</a>' );
139 results.push( '</td>' );
141 results.push( '</tr>' );
142 var $tr = $( results.join( '' ));
143 $( '#overdrive-results-list tbody' ).append( $tr );
145 fetch_availability( prod, $tr );
148 $( '#overdrive-results-list tr:odd' ).addClass( 'highlight' );
151 var cur_page = offset / results_per_page;
152 var max_page = Math.floor( data.totalItems / results_per_page );
154 if ( cur_page != 0 ) {
155 pages.push( '<li><a class="od-nav" href="#" data-offset="' + (offset - results_per_page) + '">« ' + _("Previous") + '</a></li>' );
158 for ( var page = Math.max( 0, cur_page - 9 ); page <= Math.min( max_page, cur_page + 9 ); page++ ) {
159 if ( page == cur_page ) {
160 pages.push( ' <li class="active"><a href="#">' + ( page + 1 ) + '</a></li>' );
162 pages.push( ' <li><a class="od-nav" href="#" data-offset="' + ( page * results_per_page ) + '">' + ( page + 1 ) + '</a></li>' );
166 if ( cur_page < max_page ) {
167 pages.push( ' <li><a class="od-nav" href="#" data-offset="' + (offset + results_per_page) + '">' + _("Next") + ' »</a></li>' );
170 if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pagination' ).html( '<ul>' + pages.join( '' ) + '</ul>');
172 $( '#overdrive-results-list input.star' ).rating();
176 $( document ).ready( function() {
177 $( '#breadcrumbs p' )
179 .append( '<span id="overdrive-status"></span>' );
181 $( document ).on( 'click', 'a.od-nav', function() {
182 search( $( this ).data( 'offset' ) );
186 [% IF ( overdrive_error ) %]
187 KOHA.OverDriveCirculation.display_error("#breadcrumbs", "[% overdrive_error.dquote %]");
189 [% IF ( loggedinusername ) %]
190 KOHA.OverDriveCirculation.with_account_details("#breadcrumbs", function() {