blob: 7c96a6858be6221630c46b63a87f30ff30e9178b [file] [log] [blame]
Nils Diewald2329e1d2014-06-12 16:07:57 +00001% if (param 'q') {
Nils Diewald4af3f0b2014-06-25 01:43:17 +00002% content 'main' => begin
3%= search begin
4% unless (param 'snippet') {
Nils Diewald5d1ffb42014-05-21 17:45:34 +00005<div style="clear: both">
Nils Diewald4af3f0b2014-06-25 01:43:17 +00006% my $url = url_with->query(['p' => '{page}']);
7% my $pages = (stash('search.totalResults') / (stash('search.itemsPerPage') || 1));
8% $pages = $pages < 0 ? 0 : $pages;
Nils Diewald44a72782014-06-20 16:03:21 +00009 <div id="pagination"><%= pagination(stash('search.startPage'), $pages, $url) =%></div>
10 <p class="found">Found
11 <span id="total-results"><%= commify(stash('search.totalResults')) %> matches</span>
12 <% if (stash 'search.bm.hit') { %> in <%= stash 'search.bm.hit' %> (<%= stash 'search.bm.result' %>)<% } %>
Nils Diewald2329e1d2014-06-12 16:07:57 +000013 </p>
Nils Diewald5d1ffb42014-05-21 17:45:34 +000014</div>
Nils Diewald02df9912014-06-03 16:08:07 +000015%= include 'query'
Nils Diewald1d2903f2014-11-03 22:31:20 +000016%= include 'api-communication'
Nils Diewald4af3f0b2014-06-25 01:43:17 +000017% };
Nils Diewald5d1ffb42014-05-21 17:45:34 +000018
Nils Diewald7cad8402014-07-08 17:06:56 +000019% unless (stash('search.totalResults') == 0) {
Nils Diewald4af3f0b2014-06-25 01:43:17 +000020<div id="search">
Nils Diewald5d1ffb42014-05-21 17:45:34 +000021<ol class="left-aligned">
Nils Diewald4af3f0b2014-06-25 01:43:17 +000022%= search_hits begin
23%= include 'match', match => $_
24% end
Nils Diewald5d1ffb42014-05-21 17:45:34 +000025</ol>
Nils Diewald4af3f0b2014-06-25 01:43:17 +000026</div>
Nils Diewald7cad8402014-07-08 17:06:56 +000027% };
Nils Diewald4af3f0b2014-06-25 01:43:17 +000028% end
Nils Diewald5d1ffb42014-05-21 17:45:34 +000029% end
Nils Diewald44a72782014-06-20 16:03:21 +000030
Nils Diewald4af3f0b2014-06-25 01:43:17 +000031% content 'javascript' => begin
32%= javascript begin
33
34$("#search > ol > li:not(.active)").on("click", function (e) {
35 $(this).addClass('active');
36 e.stopPropagation();
37});
38
39$("#search > ol > li:not(.active) > ul > li.close").on("click", function (e) {
40 $(this.parentNode.parentNode).removeClass('active');
41 e.stopPropagation();
42});
43
44% end
45% end
Nils Diewald1eba6572014-06-17 19:49:53 +000046% };