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 'opac-bottom.inc' %]
60 <script type="text/javascript" src="[% interface %]/[% theme %]/js/overdrive.js"></script>
61 <script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.rating.js"></script>
62 <script type="text/javascript">
63 var querystring = "[% q |replace( "'", "\'" ) |replace( '\n', '\\n' ) |replace( '\r', '\\r' ) |html %]";
64 var results_per_page = [% OPACnumSearchResults %];
66 function fetch_availability( prod, $tr ) {
67 var $availability_summary = $( '<span class="results_summary availability"></span>' );
68 $tr.find( '.mediatype' ).after( $availability_summary );
69 $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + _("Loading...") );
72 prod.links.availability.href,
75 if ( data.error ) return;
77 $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + '<span class="available"><b>' + _("Items available:") + ' </b>' + data.copiesAvailable + " " + _("out of") + ' ' + data.copiesOwned + '</span>' );
79 if ( data.numberOfHolds ) {
80 $availability_summary.find( '.available' ).append( ', ' + _("waiting holds:") + ' <strong>' + data.numberOfHolds + '</strong>' );
83 $tr.find( '.info' ).append( '<div class="actions-menu"><span class="actions"><a href="' + prod.contentDetails[0].href + '" ' + ( data.copiesAvailable ? ( ' class="addtocart">' + _("Check out") ) : ( ' class="hold">' + _("Place hold") ) ) + '</a></span></div>' );
88 function search( offset ) {
89 $( '#overdrive-status' ).html( _("Searching OverDrive...") + ' <img class="throbber" src="[% interface %]/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
91 KOHA.OverDrive.Search( "[% OverDriveLibraryID %]", querystring, results_per_page, offset, function( data ) {
93 $( '#overdrive-status' ).html( '<strong class="unavailable">' + _("Error searching OverDrive collection.") + '</strong>' );
97 if ( !data.totalItems ) {
98 $( '#overdrive-status' ).html( '<strong>' + _("No results found in the library's OverDrive collection.") + '</strong>' );
102 $( '#overdrive-results-list tbody' ).empty();
104 $( '#overdrive-status' ).html( '<strong>' + _("Found") + ' ' + data.totalItems + ' ' + _("results in the library's OverDrive collection.") + '</strong>' );
106 for ( var i = 0; data.products[i]; i++ ) {
107 var prod = data.products[i];
110 results.push( '<tr>' );
112 results.push( '<td class="info"><a class="title" href="', prod.contentDetails[0].href, '">' );
113 results.push( prod.title );
114 if ( prod.subtitle ) results.push( ', ', prod.subtitle );
115 results.push( '</a>' );
116 results.push( '<p>' + _("by") + ' ', prod.primaryCreator.name, '</p>' );
117 results.push( '<span class="results_summary mediatype"><span class="label">' + _("Type:") + ' </span>', prod.mediaType, '</span>' );
119 if ( prod.starRating ) {
120 results.push( '<div class="results_summary ratings">' );
121 for ( var rating = 1; rating <= 5; rating++ ) {
122 results.push( '<input class="star" type="radio" name="rating-' + i + '" value="' + rating + '"' + ( rating == Math.round( prod.starRating ) ? ' checked="checked"' : '' ) + ' disabled="disabled" />' );
124 results.push( '</div>' );
127 results.push( '</td>' );
129 results.push( '<td>' );
130 if ( prod.images.thumbnail ) {
131 results.push( '<a href="', prod.contentDetails[0].href, '">' );
132 results.push( '<img class="thumbnail" src="', prod.images.thumbnail.href, '" />' );
133 results.push( '</a>' );
135 results.push( '</td>' );
137 results.push( '</tr>' );
138 var $tr = $( results.join( '' ));
139 $( '#overdrive-results-list tbody' ).append( $tr );
141 fetch_availability( prod, $tr );
144 $( '#overdrive-results-list tr:odd' ).addClass( 'highlight' );
147 var cur_page = offset / results_per_page;
148 var max_page = Math.floor( data.totalItems / results_per_page );
150 if ( cur_page != 0 ) {
151 pages.push( '<li><a class="od-nav" href="#" data-offset="' + (offset - results_per_page) + '">« ' + _("Previous") + '</a></li>' );
154 for ( var page = Math.max( 0, cur_page - 9 ); page <= Math.min( max_page, cur_page + 9 ); page++ ) {
155 if ( page == cur_page ) {
156 pages.push( ' <li class="active"><a href="#">' + ( page + 1 ) + '</a></li>' );
158 pages.push( ' <li><a class="od-nav" href="#" data-offset="' + ( page * results_per_page ) + '">' + ( page + 1 ) + '</a></li>' );
162 if ( cur_page < max_page ) {
163 pages.push( ' <li><a class="od-nav" href="#" data-offset="' + (offset + results_per_page) + '">' + _("Next") + ' »</a></li>' );
166 if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pagination' ).html( '<ul>' + pages.join( '' ) + '</ul>');
168 $( '#overdrive-results-list input.star' ).rating();
172 $( document ).ready( function() {
173 $( '#breadcrumbs p' )
175 .append( '<span id="overdrive-status"></span>' );
177 $( document ).on( 'click', 'a.od-nav', function() {
178 search( $( this ).data( 'offset' ) );