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}']); |
| 7 | % my $pages = (stash('search.totalResults') / (stash('search.itemsPerPage') || 1)); |
| 8 | % $pages = $pages < 0 ? 0 : $pages; |
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 |
| 11 | <span id="total-results"><%= commify(stash('search.totalResults')) %> matches</span> |
Nils Diewald | 2ef057e | 2014-11-04 16:04:17 +0000 | [diff] [blame^] | 12 | <% if (stash 'search.benchmark') { %> in <%= stash 'search.benchmark' %><% } %> |
Nils Diewald | 2329e1d | 2014-06-12 16:07:57 +0000 | [diff] [blame] | 13 | </p> |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 14 | </div> |
Nils Diewald | 02df991 | 2014-06-03 16:08:07 +0000 | [diff] [blame] | 15 | %= include 'query' |
Nils Diewald | 1d2903f | 2014-11-03 22:31:20 +0000 | [diff] [blame] | 16 | %= include 'api-communication' |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 17 | % }; |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 18 | |
Nils Diewald | 7cad840 | 2014-07-08 17:06:56 +0000 | [diff] [blame] | 19 | % unless (stash('search.totalResults') == 0) { |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 20 | <div id="search"> |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 21 | <ol class="left-aligned"> |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 22 | %= search_hits begin |
| 23 | %= include 'match', match => $_ |
| 24 | % end |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 25 | </ol> |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 26 | </div> |
Nils Diewald | 7cad840 | 2014-07-08 17:06:56 +0000 | [diff] [blame] | 27 | % }; |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 28 | % end |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 29 | % end |
Nils Diewald | 44a7278 | 2014-06-20 16:03:21 +0000 | [diff] [blame] | 30 | |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 31 | % 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 Diewald | 1eba657 | 2014-06-17 19:49:53 +0000 | [diff] [blame] | 46 | % }; |