Bug 10265: Keep punctuation for 8xx series added entry fields (MARC21)
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-overdrive-search.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>OverDrive search for '[% q | html %]' &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 [% BLOCK cssinclude %]
8 [% END %]
9 </head>
10 [% INCLUDE 'bodytag.inc' bodyid='overdrive-results-page' bodyclass='scrollto' %]
11 [% INCLUDE 'masthead.inc' %]
12
13     <div class="main">
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>
18                 </li>
19                 <li class="breadcrumb-item active" aria-current="page">
20                     <a href="#">OverDrive search for '[% q | html %]'</a>
21                 </li>
22             </ul>
23         </nav>
24
25         <div class="container-fluid">
26             <div class="row">
27                 <div class="col-lg-2">
28                     [% IF ( OpacNav || OpacNavBottom ) %]
29                         [% INCLUDE 'navigation.inc' %]
30                     [% END %]
31                 </div>
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">
36                                 <p></p>
37                             </div>
38
39                             <div id="top-pages">
40                                 <nav class="pagination pagination-sm noprint" aria-label="Search results pagination">
41                                 </nav>
42                             </div>
43
44                             <table id="overdrive-results-list" class="table table-striped">
45                                 <tbody>
46                                 </tbody>
47                             </table>
48
49                             <div id="bottom-pages">
50                                 <nav class="pagination pagination-sm noprint" aria-label="Search results pagination">
51                                 </nav>
52                             </div>
53
54                     </div> <!-- / #overdrive-results-content -->
55                 </div> <!-- / .span10 -->
56             </div> <!-- / .row -->
57         </div> <!-- / .container-fluid -->
58     </div> <!-- / .main -->
59
60 [% IF ( Koha.Preference('OverDriveCirculation') ) %]
61     [% INCLUDE 'overdrive-checkout.inc' %]
62     [% IF ( Koha.Preference('OverDrivePasswordRequired') ) %]
63         [% INCLUDE 'overdrive-login.inc' %]
64     [% END %]
65 [% END %]
66
67 [% INCLUDE 'opac-bottom.inc' %]
68 [% BLOCK jsinclude %]
69     [% Asset.js("js/overdrive.js") | $raw %]
70     <script>
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 %];
74
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...") );
79
80             KOHA.OverDrive.Get(
81                 prod.links.availability.href,
82                 {},
83                 function ( data ) {
84                     if ( data.error ) return;
85
86                     if( data.availabilityType == 'AlwaysAvailable' ){
87                         $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + '<span class="available"><b>' + _("Always available") + '</b></span>' );
88                      } else {
89                         $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + '<span class="available"><b>' + _("Items available:") + ' </b>' +  data.copiesAvailable + " " + _("out of") + ' ' + data.copiesOwned + '</span>' );
90                     }
91
92                     if ( data.numberOfHolds ) {
93                         $availability_summary.find( '.available' ).append( ', ' + _("waiting holds:") + ' <strong>' + data.numberOfHolds + '</strong>' );
94                     }
95
96                     $tr.find( '.info' ).each(function() {
97                         KOHA.OverDriveCirculation.add_actions(this, data.id, data.copiesAvailable);
98                     });
99                 }
100             );
101         }
102
103         function search( offset ) {
104             $( '#overdrive-status' ).html( _("Searching OverDrive...") + ' <img class="throbber" src="[% interface | html %]/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
105
106             KOHA.OverDrive.Search( "[% Koha.Preference('OverDriveLibraryID') | html %]", querystring, results_per_page, offset, function( data ) {
107                 if ( data.error ) {
108                     $( '#overdrive-status' ).html( '<strong class="unavailable">' + _("Error searching OverDrive collection.") + '</strong>' );
109                     return;
110                 }
111
112                 if ( !data.totalItems ) {
113                     $( '#overdrive-status' ).html( '<strong>' + _("No results found in the library's OverDrive collection.") + '</strong>' );
114                     return;
115                 }
116
117                 $( '#overdrive-results-list tbody' ).empty();
118
119                 $( '#overdrive-status' ).html( '<strong>' + _("Found") + ' ' + data.totalItems + ' ' + _("results in the library's OverDrive collection.") + '</strong>' );
120
121                 for ( var i = 0; data.products[i]; i++ ) {
122                     var prod = data.products[i];
123                     var results = [];
124
125                     results.push( '<tr>' );
126
127                     results.push( '<td class="info"><a class="title" href="', prod.contentDetails[0].href, '">' );
128                     results.push( prod.title );
129                     if ( prod.subtitle ) results.push( ', ', prod.subtitle );
130                     results.push( '</a>' );
131                     if ( prod.primaryCreator ) results.push( '<p>' + _("by") + ' ', prod.primaryCreator.name, '</p>' );
132                     results.push( '<span class="results_summary mediatype"><span class="label">' + _("Type:") + ' </span>', prod.mediaType, '</span>' );
133
134                     if ( prod.starRating ) {
135                         var rating_value = Math.round( prod.starRating );
136                         results.push( '<div class="results_summary ratings">' );
137                         results.push( '<div class="br-wrapper br-theme-fontawesome-stars">');
138                         results.push( '<div class="br-widget br-readonly">');
139                         for ( var rating = 1; rating <= 5; rating++ ) {
140
141                             results.push( '<a href="#"' );
142                             if( rating == rating_value ){
143                                 results.push( ' class="br-selected br-current"></a>' );
144                             } else if( rating_value > rating ){
145                                 results.push( ' class="br-selected"></a>' );
146                             } else {
147                                 results.push( '></a>');
148                             }
149                         }
150                         results.push( '</div>' );
151                         results.push( '</div>' );
152                         results.push( '</div>' );
153                     }
154
155                     results.push( '</td>' );
156
157                     results.push( '<td>' );
158                     if ( prod.images.thumbnail ) {
159                         results.push( '<a href="', prod.contentDetails[0].href, '">' );
160                         results.push( '<img class="thumbnail" src="', prod.images.thumbnail.href, '" />' );
161                         results.push( '</a>' );
162                     }
163                     results.push( '</td>' );
164
165                     results.push( '</tr>' );
166                     var $tr = $( results.join( '' ));
167                     $( '#overdrive-results-list tbody' ).append( $tr );
168
169                     fetch_availability( prod, $tr );
170                 }
171
172                 $( '#overdrive-results-list tr:odd' ).addClass( 'highlight' );
173
174                 var pages = [];
175                 var cur_page = offset / results_per_page;
176                 var max_page = Math.floor( data.totalItems / results_per_page );
177
178                 if ( cur_page != 0 ) {
179                     pages.push( '<li class="page-item"><a class="page-link od-nav" href="#" data-offset="' + (offset - results_per_page) + '">&laquo; ' + _("Previous") + '</a></li>' );
180                 }
181
182                 for ( var page = Math.max( 0, cur_page - 9 ); page <= Math.min( max_page, cur_page + 9 ); page++ ) {
183                     if ( page == cur_page ) {
184                         pages.push( ' <li class="page-item disabled"><a class="page-link" href="#">' + ( page + 1 ) + '</a></li>' );
185                     } else {
186                         pages.push( ' <li class="page-item"><a class="page-link od-nav" href="#" data-offset="' + ( page * results_per_page ) + '">' + ( page + 1 ) + '</a></li>' );
187                     }
188                 }
189
190                 if ( cur_page < max_page ) {
191                     pages.push( ' <li class="page-item"><a class="page-link od-nav" href="#" data-offset="' + (offset + results_per_page) + '">' + _("Next") + ' &raquo;</a></li>' );
192                 }
193
194                 if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pagination' ).html( '<ul class="pagination">' + pages.join( '' ) + '</ul>');
195
196             } );
197         }
198
199         $( document ).ready( function() {
200             $( '#breadcrumbs p' )
201                 .append( ' ' )
202                 .append( '<span id="overdrive-status"></span>' );
203
204             $( document ).on( 'click', 'a.od-nav', function() {
205                 search( $( this ).data( 'offset' ) );
206                 return false;
207             });
208
209             [% IF ( overdrive_error ) %]
210                 KOHA.OverDriveCirculation.display_error("#breadcrumbs", "[% overdrive_error.dquote | html %]");
211             [% END %]
212             [% IF ( loggedinusername and Koha.Preference('OverDriveCirculation') ) %]
213                 KOHA.OverDriveCirculation.with_account_details("#breadcrumbs", function() {
214                     search( 0 );
215                 });
216             [% ELSE %]
217                 search( 0 );
218             [% END %]
219         });
220     </script>
221 [% END %]