Bug 27742: Page titles have unique info first
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-recordedbooks-search.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>RecordedBooks 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='recordedbooks-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="#">RecordedBooks 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="recordedbooks-results-content" class="maincontent searchresults">
34                         <h1>RecordedBooks search for '[% q | html %]'</h1>
35                             [% UNLESS ( logged_in_user ) %]
36                                  <h3 class="rb_login">Sign in to view availability and checkout items or place holds</h3>
37                             [% END %]
38
39                             <div id="breadcrumbs">
40                                 <p></p>
41                             </div>
42
43                             <div id="top-pages">
44                                 <nav class="pagination pagination-sm noprint" aria-label="Search results pagination">
45                                 </nav>
46                             </div>
47
48                             <table id="recordedbooks-results-list" class="table table-striped">
49                                 <tbody>
50                                 </tbody>
51                             </table>
52
53                             <div id="bottom-pages">
54                                 <nav class="pagination pagination-sm noprint" aria-label="Search results pagination">
55                                 </nav>
56                             </div>
57
58                     </div> <!-- / #recordedbooks-results-content -->
59                 </div> <!-- / .col-lg-10 -->
60             </div> <!-- / .row -->
61         </div> <!-- / .container-fluid -->
62     </div> <!-- / .main -->
63
64 [% INCLUDE 'recordedbooks-checkout.inc' %]
65
66 [% INCLUDE 'opac-bottom.inc' %]
67 [% BLOCK jsinclude %]
68     [% Asset.js("js/recordedbooks.js") | $raw %]
69     <script>
70         var querystring = "[% q |replace( "'", "\'" ) |replace( '\n', '\\n' ) |replace( '\r', '\\r' ) |html %]";
71         var results_per_page = [% OPACnumSearchResults || 20 | html %];
72
73         function search( page ) {
74             $( '#recordedbooks-status' ).html( MSG_SEARCHING.format("RecordedBooks") + ' <img class="throbber" src="[% interface | html %]/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
75
76             KOHA.RecordedBooks.search( querystring, results_per_page, page, function( data ) {
77                 if ( data.error ) {
78                     $( '#recordedbooks-status' ).html( '<strong class="unavailable">' + MSG_ERROR_SEARCHING_COLLECTION.format("RecordedBooks") + ': ' + data.error + '</strong>' );
79                     return;
80                 }
81
82                 if ( !data.total ) {
83                     $( '#recordedbooks-status' ).html( '<strong>' + MSG_NO_RESULTS_FOUND_IN_COLLECTION.format("RecordedBooks") + '</strong>' );
84                     return;
85                 }
86
87                 $( '#recordedbooks-results-list tbody' ).empty();
88
89                 $( '#recordedbooks-status' ).html( '<strong>' + MSG_RESULTS_FOUND_IN_COLLECTION.format(data.total, "RecordedBooks") + '</strong>' );
90
91                 for ( var i = 0; data.items[i]; i++ ) {
92                     var prod = data.items[i];
93                     var results = [];
94                     results.push( '<tr>' );
95
96                     results.push( '<td class="info"><span class="title">' );
97                     if (prod.url) results.push( '<a href="', prod.url, '" target="recordedbooks">' );
98                     results.push( prod.title );
99                     if (prod.url) results.push( '</a>' );
100                     results.push( '</span>' );
101                     results.push( '<p>' + MSG_BY + ' ', prod.author, '</p>' );
102                     if (prod.description) results.push( '<p>' + prod.description, '</p>' );
103                     results.push( '<span class="results_summary mediatype"><span class="label">' + MSG_TYPE + ': </span>', prod.media, '</span>' );
104
105                     results.push( '</td>' );
106
107                     results.push( '<td>' );
108                     if ( prod.images && prod.images.medium ) {
109                         if (prod.url) results.push( '<a href="', prod.url, '" target="recordedbooks">' );
110                         results.push( '<img class="thumbnail" src="', prod.images.medium, '" />' );
111                         if (prod.url) results.push( '</a>' );
112                     }
113                     results.push( '</td>' );
114
115                     results.push( '</tr>' );
116                     var $tr = $( results.join( '' ));
117                     $( '#recordedbooks-results-list tbody' ).append( $tr );
118
119                     $tr.find( '.info' ).each(function() {
120                         KOHA.RecordedBooks.add_actions(this, prod.isbn);
121                     });
122                 }
123
124                 $( '#recordedbooks-results-list tr:odd' ).addClass( 'highlight' );
125
126                 var pages = [];
127
128                 var max_page = Math.floor( data.total / results_per_page );
129                 if (data.total == page*results_per_page) max_page++;
130
131                 if ( page != 1 ) {
132                     pages.push( '<li class="page-item"><a class="page-link od-nav" href="#" data-page="' + (page - 1) + '">&laquo; ' + MSG_PREVIOUS + '</a></li>' );
133                 }
134
135                 for ( var p = Math.max( 0, page - 9 ); p <= Math.min( max_page, p + 9 ); p++ ) {
136                     if ( p == page ) {
137                         pages.push( ' <li class="page-item disabled"><a class="page-link" href="#">' + ( p + 1 ) + '</a></li>' );
138                     } else {
139                         pages.push( ' <li class="page-item"><a class="page-link od-nav" href="#" data-page="' +  p + '">' + p + '</a></li>' );
140                     }
141                 }
142
143                 if ( page < max_page ) {
144                     pages.push( ' <li class="page-item"><a class="page-link od-nav" href="#" data-page="' + (page + 1) + '">' + MSG_NEXT + ' &raquo;</a></li>' );
145                 }
146
147                 if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pagination' ).html( '<ul class="pagination">' + pages.join( '' ) + '</ul>');
148
149                 if( KOHA.RecordedBooks.is_identified() == false ){
150                     $("#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>');
151                 }
152
153             } );
154         }
155
156         $( document ).ready( function() {
157             $( '#breadcrumbs p' )
158                 .append( ' ' )
159                 .append( '<span id="recordedbooks-status"></span>' );
160
161             $( document ).on( 'click', 'a.od-nav', function() {
162                 search( $( this ).data( 'page' ) );
163                 return false;
164             });
165
166             [% IF ( logged_in_user ) %]
167             KOHA.RecordedBooks.with_account_details("#breadcrumbs", function() {
168                 search( 1 );
169             });
170             [% ELSE %]
171                 search( 1 );
172             [% END %]
173         } );
174     </script>
175 [% END %]