1 [% INCLUDE 'doc-head-open.inc' %]
2 [% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › OverDrive search for '[% q | html %]'
3 [% INCLUDE 'doc-head-close.inc' %]
5 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/jquery.rating.css" />
13 <body id="overdrive-results-page" class="scrollto">
14 [% INCLUDE 'masthead.inc' %]
17 <ul class="breadcrumb">
18 <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">›</span></li>
19 <li><a href="#">OverDrive search for '[% q | html %]'</a></li>
22 <div class="container-fluid">
23 <div class="row-fluid">
25 [% IF ( OpacNav || OpacNavBottom ) %]
26 [% INCLUDE 'navigation.inc' %]
30 <div id="overdrive-results-content" class="maincontent searchresults">
31 <h1>OverDrive search for '[% q | html %]'</h1>
32 <div id="breadcrumbs">
37 <div class="pagination pagination-small">
41 <table id="overdrive-results-list" class="table table-striped">
46 <div id="bottom-pages">
47 <div class="pagination pagination-small">
51 </div> <!-- / #overdrive-results-content -->
52 </div> <!-- / .span10 -->
53 </div> <!-- / .row-fluid -->
54 </div> <!-- / .container-fluid -->
55 </div> <!-- / .main -->
57 [% INCLUDE 'opac-bottom.inc' %]
59 <script type="text/javascript" src="[% interface %]/[% theme %]/js/overdrive.js"></script>
60 <script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.rating.js"></script>
61 <script type="text/javascript">
62 var querystring = "[% q |replace( "'", "\'" ) |replace( '\n', '\\n' ) |replace( '\r', '\\r' ) |html %]";
63 var results_per_page = [% OPACnumSearchResults %];
65 function fetch_availability( prod, $tr ) {
66 var $availability_summary = $( '<span class="results_summary availability"></span>' );
67 $tr.find( '.mediatype' ).after( $availability_summary );
68 $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + _("Loading...") );
71 prod.links.availability.href,
74 if ( data.error ) return;
76 $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + '<span class="available"><b>' + _("Copies available:") + ' </b>' + data.copiesAvailable + " " + _("out of") + ' ' + data.copiesOwned + '</span>' );
78 if ( data.numberOfHolds ) {
79 $availability_summary.find( '.available' ).append( ', ' + _("waiting holds:") + ' <strong>' + data.numberOfHolds + '</strong>' );
82 $tr.find( '.info' ).append( '<div class="actions-menu"><span class="actions"><a href="http://' + prod.contentDetails[0].href + '" ' + ( data.copiesAvailable ? ( ' class="addtocart">' + _("Check out") ) : ( ' class="hold">' + _("Place hold") ) ) + '</a></span></div>' );
87 function search( offset ) {
88 $( '#overdrive-status' ).html( _("Searching OverDrive...") + ' <img class="throbber" src="[% interface %]/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
90 KOHA.OverDrive.Search( "[% OverDriveLibraryID %]", querystring, results_per_page, offset, function( data ) {
92 $( '#overdrive-status' ).html( '<strong class="unavailable">' + _("Error searching OverDrive collection.") + '</strong>' );
96 if ( !data.totalItems ) {
97 $( '#overdrive-status' ).html( '<strong>' + _("No results found in the library's OverDrive collection.") + '</strong>' );
101 $( '#overdrive-results-list tbody' ).empty();
103 $( '#overdrive-status' ).html( '<strong>' + _("Found") + ' ' + data.totalItems + ' ' + _("results in the library's OverDrive collection.") + '</strong>' );
105 for ( var i = 0; data.products[i]; i++ ) {
106 var prod = data.products[i];
109 results.push( '<tr>' );
111 results.push( '<td class="info"><a class="title" href="http://', prod.contentDetails[0].href, '">' );
112 results.push( prod.title );
113 if ( prod.subtitle ) results.push( ', ', prod.subtitle );
114 results.push( '</a>' );
115 results.push( '<p>' + _("by") + ' ', prod.primaryCreator.name, '</p>' );
116 results.push( '<span class="results_summary mediatype"><span class="label">' + _("Type:") + ' </span>', prod.mediaType, '</span>' );
118 if ( prod.starRating ) {
119 results.push( '<div class="results_summary ratings">' );
120 for ( var rating = 1; rating <= 5; rating++ ) {
121 results.push( '<input class="star" type="radio" name="rating-' + i + '" value="' + rating + '"' + ( rating == Math.round( prod.starRating ) ? ' checked="checked"' : '' ) + ' disabled="disabled" />' );
123 results.push( '</div>' );
126 results.push( '</td>' );
128 results.push( '<td>' );
129 if ( prod.images.thumbnail ) {
130 results.push( '<a href="http://', prod.contentDetails[0].href, '">' );
131 results.push( '<img class="thumbnail" src="', prod.images.thumbnail.href, '" />' );
132 results.push( '</a>' );
134 results.push( '</td>' );
136 results.push( '</tr>' );
137 var $tr = $( results.join( '' ));
138 $( '#overdrive-results-list tbody' ).append( $tr );
140 fetch_availability( prod, $tr );
143 $( '#overdrive-results-list tr:odd' ).addClass( 'highlight' );
146 var cur_page = offset / results_per_page;
147 var max_page = Math.floor( data.totalItems / results_per_page );
149 if ( cur_page != 0 ) {
150 pages.push( '<li><a class="od-nav" href="#" data-offset="' + (offset - results_per_page) + '">« ' + _("Previous") + '</a></li>' );
153 for ( var page = Math.max( 0, cur_page - 9 ); page <= Math.min( max_page, cur_page + 9 ); page++ ) {
154 if ( page == cur_page ) {
155 pages.push( ' <li class="active"><a href="#">' + ( page + 1 ) + '</a></li>' );
157 pages.push( ' <li><a class="od-nav" href="#" data-offset="' + ( page * results_per_page ) + '">' + ( page + 1 ) + '</a></li>' );
161 if ( cur_page < max_page ) {
162 pages.push( ' <li><a class="od-nav" href="#" data-offset="' + (offset + results_per_page) + '">' + _("Next") + ' »</a></li>' );
165 if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pagination' ).html( '<ul>' + pages.join( '' ) + '</ul>');
167 $( '#overdrive-results-list input.star' ).rating();
171 $( document ).ready( function() {
172 $( '#breadcrumbs p' )
174 .append( '<span id="overdrive-status"></span>' );
176 $( document ).on( 'click', 'a.od-nav', function() {
177 search( $( this ).data( 'offset' ) );