blob: 3fe630259d0841c72932dcb62182ed58e1a71f1d [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}']);
Nils Diewald2fef6c62014-11-11 17:48:59 +00007% my $pages;
8% $pages = stash('search.totalResults') == -1 ? -1 : (stash('search.totalResults') / (stash('search.itemsPerPage') || 1));
Nils Diewald44a72782014-06-20 16:03:21 +00009 <div id="pagination"><%= pagination(stash('search.startPage'), $pages, $url) =%></div>
10 <p class="found">Found
Nils Diewald432356a2014-11-11 12:52:13 +000011% my $found = stash('search.totalResults');
12% if ($found == -1) {
13% $found = 'unknown amount of';
14% } elsif (stash('search.timeExceeded')) {
15% $found = 'more than ' . $found;
16% };
17 <span id="total-results"><%= $found %> matches</span>
Nils Diewald2ef057e2014-11-04 16:04:17 +000018 <% if (stash 'search.benchmark') { %> in <%= stash 'search.benchmark' %><% } %>
Nils Diewald2329e1d2014-06-12 16:07:57 +000019 </p>
Nils Diewald5d1ffb42014-05-21 17:45:34 +000020</div>
Nils Diewald02df9912014-06-03 16:08:07 +000021%= include 'query'
Nils Diewald1d2903f2014-11-03 22:31:20 +000022%= include 'api-communication'
Nils Diewald4af3f0b2014-06-25 01:43:17 +000023% };
Nils Diewald5d1ffb42014-05-21 17:45:34 +000024
Nils Diewald432356a2014-11-11 12:52:13 +000025% if (stash('search.totalResults') != 0 && scalar @{stash('search.hits')}) {
Nils Diewald4af3f0b2014-06-25 01:43:17 +000026<div id="search">
Nils Diewald5d1ffb42014-05-21 17:45:34 +000027<ol class="left-aligned">
Nils Diewald4af3f0b2014-06-25 01:43:17 +000028%= search_hits begin
29%= include 'match', match => $_
30% end
Nils Diewald5d1ffb42014-05-21 17:45:34 +000031</ol>
Nils Diewald4af3f0b2014-06-25 01:43:17 +000032</div>
Nils Diewald7cad8402014-07-08 17:06:56 +000033% };
Nils Diewald4af3f0b2014-06-25 01:43:17 +000034% end
Nils Diewald5d1ffb42014-05-21 17:45:34 +000035% end
Nils Diewald44a72782014-06-20 16:03:21 +000036
Nils Diewald4af3f0b2014-06-25 01:43:17 +000037% content 'javascript' => begin
38%= javascript begin
39
40$("#search > ol > li:not(.active)").on("click", function (e) {
41 $(this).addClass('active');
42 e.stopPropagation();
43});
44
45$("#search > ol > li:not(.active) > ul > li.close").on("click", function (e) {
46 $(this.parentNode.parentNode).removeClass('active');
47 e.stopPropagation();
48});
49
50% end
51% end
Nils Diewald1eba6572014-06-17 19:49:53 +000052% };