Nils Diewald | 2329e1d | 2014-06-12 16:07:57 +0000 | [diff] [blame] | 1 | % if (param 'q') { |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 2 | % content 'main' => begin |
| 3 | %= search begin |
| 4 | % unless (param 'snippet') { |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 5 | <div style="clear: both"> |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 6 | % my $url = url_with->query(['p' => '{page}']); |
Nils Diewald | 2fef6c6 | 2014-11-11 17:48:59 +0000 | [diff] [blame^] | 7 | % my $pages; |
| 8 | % $pages = stash('search.totalResults') == -1 ? -1 : (stash('search.totalResults') / (stash('search.itemsPerPage') || 1)); |
Nils Diewald | 44a7278 | 2014-06-20 16:03:21 +0000 | [diff] [blame] | 9 | <div id="pagination"><%= pagination(stash('search.startPage'), $pages, $url) =%></div> |
| 10 | <p class="found">Found |
Nils Diewald | 432356a | 2014-11-11 12:52:13 +0000 | [diff] [blame] | 11 | % 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 Diewald | 2ef057e | 2014-11-04 16:04:17 +0000 | [diff] [blame] | 18 | <% if (stash 'search.benchmark') { %> in <%= stash 'search.benchmark' %><% } %> |
Nils Diewald | 2329e1d | 2014-06-12 16:07:57 +0000 | [diff] [blame] | 19 | </p> |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 20 | </div> |
Nils Diewald | 02df991 | 2014-06-03 16:08:07 +0000 | [diff] [blame] | 21 | %= include 'query' |
Nils Diewald | 1d2903f | 2014-11-03 22:31:20 +0000 | [diff] [blame] | 22 | %= include 'api-communication' |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 23 | % }; |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 24 | |
Nils Diewald | 432356a | 2014-11-11 12:52:13 +0000 | [diff] [blame] | 25 | % if (stash('search.totalResults') != 0 && scalar @{stash('search.hits')}) { |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 26 | <div id="search"> |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 27 | <ol class="left-aligned"> |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 28 | %= search_hits begin |
| 29 | %= include 'match', match => $_ |
| 30 | % end |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 31 | </ol> |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 32 | </div> |
Nils Diewald | 7cad840 | 2014-07-08 17:06:56 +0000 | [diff] [blame] | 33 | % }; |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 34 | % end |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 35 | % end |
Nils Diewald | 44a7278 | 2014-06-20 16:03:21 +0000 | [diff] [blame] | 36 | |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 37 | % 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 Diewald | 1eba657 | 2014-06-17 19:49:53 +0000 | [diff] [blame] | 52 | % }; |