Bug 17602: Use Asset TT plugin and fix indentation
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-recordedbooks-search.tt
1 [% USE Koha %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; RecordedBooks search for '[% q | html %]'</title>
4 [% INCLUDE 'doc-head-close.inc' %]
5 [% BLOCK cssinclude %]
6 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/jquery.rating.css" />
7 <style>
8 .actions a.addtocart {
9     display: inline;
10 }
11 </style>
12 [% END %]
13 </head>
14 [% INCLUDE 'bodytag.inc' bodyid='recordedbooks-results-page' bodyclass='scrollto' %]
15 [% INCLUDE 'masthead.inc' %]
16
17     <div class="main">
18         <ul class="breadcrumb">
19             <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
20             <li><a href="#">RecordedBooks search for '[% q | html %]'</a></li>
21         </ul>
22
23         <div class="container-fluid">
24             <div class="row-fluid">
25                 <div class="span2">
26                     [% IF ( OpacNav || OpacNavBottom ) %]
27                         [% INCLUDE 'navigation.inc' %]
28                     [% END %]
29                 </div>
30                 <div class="span10">
31                     <div id="recordedbooks-results-content" class="maincontent searchresults">
32                         <h1>RecordedBooks search for '[% q | html %]'</h1>
33                             <div id="breadcrumbs">
34                                 <p></p>
35                             </div>
36
37                             <div id="top-pages">
38                                 <div class="pagination pagination-small">
39                                 </div>
40                             </div>
41
42                             <table id="recordedbooks-results-list" class="table table-striped">
43                                 <tbody>
44                                 </tbody>
45                             </table>
46
47                             <div id="bottom-pages">
48                                 <div class="pagination pagination-small">
49                                 </div>
50                             </div>
51
52                     </div> <!-- / #recordedbooks-results-content -->
53                 </div> <!-- / .span10 -->
54             </div> <!-- / .row-fluid -->
55         </div> <!-- / .container-fluid -->
56     </div> <!-- / .main -->
57
58 [% INCLUDE 'recordedbooks-checkout.inc' %]
59
60 [% INCLUDE 'opac-bottom.inc' %]
61 [% BLOCK jsinclude %]
62 [% Asset.js("js/recordedbooks.js") %]
63 [% Asset.js("lib/jquery/plugins/jquery.rating.js") %]
64 <script type="text/javascript">
65 var querystring = "[% q |replace( "'", "\'" ) |replace( '\n', '\\n' ) |replace( '\r', '\\r' ) |html %]";
66 var results_per_page = [% OPACnumSearchResults || 20 %];
67
68 function search( page ) {
69     $( '#recordedbooks-status' ).html( MSG_SEARCHING.format("RecordedBooks") + ' <img class="throbber" src="[% interface %]/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
70
71     KOHA.RecordedBooks.search( querystring, results_per_page, page, function( data ) {
72         if ( data.error ) {
73             $( '#recordedbooks-status' ).html( '<strong class="unavailable">' + MSG_ERROR_SEARCHING_COLLECTION.format("RecordedBooks") + ': ' + data.error + '</strong>' );
74             return;
75         }
76
77         if ( !data.total ) {
78             $( '#recordedbooks-status' ).html( '<strong>' + MSG_NO_RESULTS_FOUND_IN_COLLECTION.format("RecordedBooks") + '</strong>' );
79             return;
80         }
81
82         $( '#recordedbooks-results-list tbody' ).empty();
83
84         $( '#recordedbooks-status' ).html( '<strong>' + MSG_RESULTS_FOUND_IN_COLLECTION.format(data.total, "RecordedBooks") + '</strong>' );
85
86         for ( var i = 0; data.items[i]; i++ ) {
87             var prod = data.items[i];
88             var results = [];
89
90             results.push( '<tr>' );
91
92             results.push( '<td class="info"><span class="title">' );
93             if (prod.url) results.push( '<a href="', prod.url, '" target="recordedbooks">' );
94             results.push( prod.title );
95             if (prod.url) results.push( '</a>' );
96             results.push( '</span>' );
97             results.push( '<p>' + MSG_BY + ' ', prod.author, '</p>' );
98             if (prod.description) results.push( '<p>' + prod.description, '</p>' );
99             results.push( '<span class="results_summary mediatype"><span class="label">' + MSG_TYPE + ': </span>', prod.media, '</span>' );
100
101             results.push( '</td>' );
102
103             results.push( '<td>' );
104             if ( prod.images && prod.images.medium ) {
105                 if (prod.url) results.push( '<a href="', prod.url, '" target="recordedbooks">' );
106                 results.push( '<img class="thumbnail" src="', prod.images.medium, '" />' );
107                 if (prod.url) results.push( '</a>' );
108             }
109             results.push( '</td>' );
110
111             results.push( '</tr>' );
112             var $tr = $( results.join( '' ));
113             $( '#recordedbooks-results-list tbody' ).append( $tr );
114
115             $tr.find( '.info' ).each(function() {
116                 KOHA.RecordedBooks.add_actions(this, prod.isbn);
117             });
118         }
119
120         $( '#recordedbooks-results-list tr:odd' ).addClass( 'highlight' );
121
122         var pages = [];
123
124         var max_page = Math.floor( data.total / results_per_page );
125         if (data.total == page*results_per_page) max_page++;
126
127         if ( page != 1 ) {
128             pages.push( '<li><a class="od-nav" href="#" data-page="' + (page - 1) + '">&laquo; ' + MSG_PREVIOUS + '</a></li>' );
129         }
130
131         for ( var p = Math.max( 0, page - 9 ); p <= Math.min( max_page, p + 9 ); p++ ) {
132             if ( p == page ) {
133                 pages.push( ' <li class="active"><a href="#">' + ( p + 1 ) + '</a></li>' );
134             } else {
135                 pages.push( ' <li><a class="od-nav" href="#" data-page="' +  p + '">' + p + '</a></li>' );
136             }
137         }
138
139         if ( page < max_page ) {
140             pages.push( ' <li><a class="od-nav" href="#" data-page="' + (page + 1) + '">' + MSG_NEXT + ' &raquo;</a></li>' );
141         }
142
143         if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pagination' ).html( '<ul>' + pages.join( '' ) + '</ul>');
144
145         $( '#recordedbooks-results-list input.star' ).rating();
146     } );
147 }
148
149 $( document ).ready( function() {
150     $( '#breadcrumbs p' )
151         .append( ' ' )
152         .append( '<span id="recordedbooks-status"></span>' );
153
154     $( document ).on( 'click', 'a.od-nav', function() {
155         search( $( this ).data( 'page' ) );
156         return false;
157     });
158
159     [% IF ( loggedinusername ) %]
160     KOHA.RecordedBooks.with_account_details("#breadcrumbs", function() {
161         search( 1 );
162     });
163     [% ELSE %]
164         search( 1 );
165     [% END %]
166 } );
167 </script>
168 [% END %]