Bug 24223: Convert OpacNav system preference to additional content
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-recordedbooks-search.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE AdditionalContents %]
5 [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode, blocktitle => 0 ) %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>RecordedBooks search for '[% q | html %]' &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 [% BLOCK cssinclude %]
10 [% END %]
11 </head>
12 [% INCLUDE 'bodytag.inc' bodyid='recordedbooks-results-page' bodyclass='scrollto' %]
13 [% INCLUDE 'masthead.inc' %]
14
15     <div class="main">
16         <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumbs">
17             <ol class="breadcrumb">
18                 <li class="breadcrumb-item">
19                     <a href="/cgi-bin/koha/opac-main.pl">Home</a>
20                 </li>
21                 <li class="breadcrumb-item active">
22                     <a href="#" aria-current="page">RecordedBooks search for '[% q | html %]'</a>
23                 </li>
24             </ol>
25         </nav> <!-- /#breadcrumbs -->
26
27         <div class="container-fluid">
28             <div class="row">
29                 <div class="col-lg-2">
30                     [% IF ( OpacNav || OpacNavBottom ) %]
31                         [% INCLUDE 'navigation.inc' %]
32                     [% END %]
33                 </div>
34                 <div class="col-lg-10 order-first order-md-first order-lg-2">
35                     <div id="recordedbooks-results-content" class="maincontent searchresults">
36                         <h1>RecordedBooks search for '[% q | html %]'</h1>
37                             [% UNLESS ( logged_in_user ) %]
38                                  <h2 class="rb_login">Sign in to view availability and checkout items or place holds</h2>
39                             [% END %]
40
41                             <div id="breadcrumbs">
42                                 <p></p>
43                             </div>
44
45                             <div id="top-pages">
46                                 <nav class="pagination pagination-sm noprint" aria-label="Search results pagination">
47                                 </nav>
48                             </div>
49
50                             <table id="recordedbooks-results-list" class="table table-striped">
51                                 <tbody>
52                                 </tbody>
53                             </table>
54
55                             <div id="bottom-pages">
56                                 <nav class="pagination pagination-sm noprint" aria-label="Search results pagination">
57                                 </nav>
58                             </div>
59
60                     </div> <!-- / #recordedbooks-results-content -->
61                 </div> <!-- / .col-lg-10 -->
62             </div> <!-- / .row -->
63         </div> <!-- / .container-fluid -->
64     </div> <!-- / .main -->
65
66 [% INCLUDE 'recordedbooks-checkout.inc' %]
67
68 [% INCLUDE 'opac-bottom.inc' %]
69 [% BLOCK jsinclude %]
70     [% Asset.js("js/recordedbooks.js") | $raw %]
71     <script>
72         var querystring = "[% q |replace( "'", "\'" ) |replace( '\n', '\\n' ) |replace( '\r', '\\r' ) |html %]";
73         var results_per_page = [% OPACnumSearchResults || 20 | html %];
74
75         function search( page ) {
76             $( '#recordedbooks-status' ).html( MSG_SEARCHING.format("RecordedBooks") + ' <img class="throbber" src="[% interface | html %]/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
77
78             KOHA.RecordedBooks.search( querystring, results_per_page, page, function( data ) {
79                 if ( data.error ) {
80                     $( '#recordedbooks-status' ).html( '<strong class="unavailable">' + MSG_ERROR_SEARCHING_COLLECTION.format("RecordedBooks") + ': ' + data.error + '</strong>' );
81                     return;
82                 }
83
84                 if ( !data.total ) {
85                     $( '#recordedbooks-status' ).html( '<strong>' + MSG_NO_RESULTS_FOUND_IN_COLLECTION.format("RecordedBooks") + '</strong>' );
86                     return;
87                 }
88
89                 $( '#recordedbooks-results-list tbody' ).empty();
90
91                 $( '#recordedbooks-status' ).html( '<strong>' + MSG_RESULTS_FOUND_IN_COLLECTION.format(data.total, "RecordedBooks") + '</strong>' );
92
93                 for ( var i = 0; data.items[i]; i++ ) {
94                     var prod = data.items[i];
95                     var results = [];
96                     results.push( '<tr>' );
97
98                     results.push( '<td class="info"><span class="title">' );
99                     if (prod.url) results.push( '<a href="', prod.url, '" target="recordedbooks">' );
100                     results.push( prod.title );
101                     if (prod.url) results.push( '</a>' );
102                     results.push( '</span>' );
103                     results.push( '<p>' + MSG_BY + ' ', prod.author, '</p>' );
104                     if (prod.description) results.push( '<p>' + prod.description, '</p>' );
105                     results.push( '<span class="results_summary mediatype"><span class="label">' + MSG_TYPE + ': </span>', prod.media, '</span>' );
106
107                     results.push( '</td>' );
108
109                     results.push( '<td>' );
110                     if ( prod.images && prod.images.medium ) {
111                         if (prod.url) results.push( '<a href="', prod.url, '" target="recordedbooks">' );
112                         results.push( '<img class="thumbnail" src="', prod.images.medium, '" />' );
113                         if (prod.url) results.push( '</a>' );
114                     }
115                     results.push( '</td>' );
116
117                     results.push( '</tr>' );
118                     var $tr = $( results.join( '' ));
119                     $( '#recordedbooks-results-list tbody' ).append( $tr );
120
121                     $tr.find( '.info' ).each(function() {
122                         KOHA.RecordedBooks.add_actions(this, prod.isbn);
123                     });
124                 }
125
126                 $( '#recordedbooks-results-list tr:odd' ).addClass( 'highlight' );
127
128                 var pages = [];
129
130                 var max_page = Math.floor( data.total / results_per_page );
131                 if (data.total == page*results_per_page) max_page++;
132
133                 if ( page != 1 ) {
134                     pages.push( '<li class="page-item"><a class="page-link od-nav" href="#" data-page="' + (page - 1) + '">&laquo; ' + MSG_PREVIOUS + '</a></li>' );
135                 }
136
137                 for ( var p = Math.max( 0, page - 9 ); p <= Math.min( max_page, p + 9 ); p++ ) {
138                     if ( p == page ) {
139                         pages.push( ' <li class="page-item disabled"><a class="page-link" href="#">' + ( p + 1 ) + '</a></li>' );
140                     } else {
141                         pages.push( ' <li class="page-item"><a class="page-link od-nav" href="#" data-page="' +  p + '">' + p + '</a></li>' );
142                     }
143                 }
144
145                 if ( page < max_page ) {
146                     pages.push( ' <li class="page-item"><a class="page-link od-nav" href="#" data-page="' + (page + 1) + '">' + MSG_NEXT + ' &raquo;</a></li>' );
147                 }
148
149                 if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pagination' ).html( '<ul class="pagination">' + pages.join( '' ) + '</ul>');
150
151                 if( KOHA.RecordedBooks.is_identified() == false ){
152                     $("#breadcrumbs").before('<h3 class="rb_register"><a href="https://[% Koha.Preference('RecordedBooksDomain') | uri %]">To see availability you must register for RecordedBooks using your cardnumber and the email associated with your Koha account</a></h3>');
153                 }
154
155             } );
156         }
157
158         $( document ).ready( function() {
159             $( '#breadcrumbs p' )
160                 .append( ' ' )
161                 .append( '<span id="recordedbooks-status"></span>' );
162
163             $( document ).on( 'click', 'a.od-nav', function() {
164                 search( $( this ).data( 'page' ) );
165                 return false;
166             });
167
168             [% IF ( logged_in_user ) %]
169             KOHA.RecordedBooks.with_account_details("#breadcrumbs", function() {
170                 search( 1 );
171             });
172             [% ELSE %]
173                 search( 1 );
174             [% END %]
175         } );
176     </script>
177 [% END %]