| % if (param 'q') { |
| % content 'main' => begin |
| %= search begin |
| % unless (param 'snippet') { |
| <div style="clear: both"> |
| % my $url = url_with->query(['p' => '{page}']); |
| % my $pages = (stash('search.totalResults') / (stash('search.itemsPerPage') || 1)); |
| % $pages = $pages < 0 ? 0 : $pages; |
| <div id="pagination"><%= pagination(stash('search.startPage'), $pages, $url) =%></div> |
| <p class="found">Found |
| <span id="total-results"><%= commify(stash('search.totalResults')) %> matches</span> |
| <% if (stash 'search.bm.hit') { %> in <%= stash 'search.bm.hit' %> (<%= stash 'search.bm.result' %>)<% } %> |
| </p> |
| </div> |
| %= include 'query' |
| %= include 'api-communication' |
| % }; |
| |
| % unless (stash('search.totalResults') == 0) { |
| <div id="search"> |
| <ol class="left-aligned"> |
| %= search_hits begin |
| %= include 'match', match => $_ |
| % end |
| </ol> |
| </div> |
| % }; |
| % end |
| % end |
| |
| % content 'javascript' => begin |
| %= javascript begin |
| |
| $("#search > ol > li:not(.active)").on("click", function (e) { |
| $(this).addClass('active'); |
| e.stopPropagation(); |
| }); |
| |
| $("#search > ol > li:not(.active) > ul > li.close").on("click", function (e) { |
| $(this.parentNode.parentNode).removeClass('active'); |
| e.stopPropagation(); |
| }); |
| |
| % end |
| % end |
| % }; |