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> |
| 12 | <% if (stash 'search.bm.hit') { %> in <%= stash 'search.bm.hit' %> (<%= stash 'search.bm.result' %>)<% } %> |
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 | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 16 | % }; |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 17 | |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 18 | <div id="search"> |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 19 | <ol class="left-aligned"> |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 20 | %= search_hits begin |
| 21 | %= include 'match', match => $_ |
| 22 | % end |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 23 | </ol> |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 24 | </div> |
Nils Diewald | 44a7278 | 2014-06-20 16:03:21 +0000 | [diff] [blame] | 25 | |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 26 | % end |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 27 | % end |
Nils Diewald | 44a7278 | 2014-06-20 16:03:21 +0000 | [diff] [blame] | 28 | |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 29 | % content 'javascript' => begin |
| 30 | %= javascript begin |
| 31 | |
| 32 | $("#search > ol > li:not(.active)").on("click", function (e) { |
| 33 | $(this).addClass('active'); |
| 34 | e.stopPropagation(); |
| 35 | }); |
| 36 | |
| 37 | $("#search > ol > li:not(.active) > ul > li.close").on("click", function (e) { |
| 38 | $(this.parentNode.parentNode).removeClass('active'); |
| 39 | e.stopPropagation(); |
| 40 | }); |
| 41 | |
| 42 | % end |
| 43 | % end |
Nils Diewald | 1eba657 | 2014-06-17 19:49:53 +0000 | [diff] [blame] | 44 | % }; |