Permalink
Browse files

Make search results more visible (#853)

* Move API promotion at the bottom of results
* Jump to filters to highlight search results
* Add component filters to entity results
* Don't focus search input when there's a hash
  • Loading branch information...
flodolo committed Feb 4, 2017
1 parent 7dcbfc0 commit 332472fcfe2ca14b92d686ec416651054f1508a4
Showing with 46 additions and 11 deletions.
  1. +4 −3 app/views/onestring.php
  2. +26 −4 app/views/results_entities.php
  3. +3 −3 app/views/results_strings.php
  4. +3 −1 web/js/base.js
  5. +10 −0 web/js/main_search.js
View
@@ -14,9 +14,6 @@
// We have no error, display results
$page_descr = $entity;
// Promote API view
include VIEWS . 'templates/api_promotion.php';
?>
<table>
@@ -44,3 +41,7 @@
}
?>
</table>
<?php
// Promote API view
include VIEWS . 'templates/api_promotion.php';
@@ -1,9 +1,6 @@
<?php
namespace Transvision;
// Promote API view
include VIEWS . 'templates/api_promotion.php';
$table = "
<table class='collapsable'>
<thead>
@@ -19,8 +16,11 @@
$current_repo = $search->getRepository();
$extra_locale = $url['path'] == '3locales';
$components = [];
// Display results
foreach ($entities as $entity) {
$component = explode('/', $entity)[0];
$components[] = $component;
if (in_array($current_repo, ['firefox_ios', 'mozilla_org'])) {
$path_locale1 = VersionControl::gitPath($source_locale, $current_repo, $entity);
$path_locale2 = VersionControl::gitPath($locale, $current_repo, $entity);
@@ -164,7 +164,7 @@
}
$table .= "
<tr>
<tr class='{$component}'>
<td>
<span class='celltitle'>Entity</span>
<a class='resultpermalink tag' id='{$anchor_name}' href='#{$anchor_name}' title='Permalink to this result'>#</a>
@@ -198,7 +198,29 @@
</tr>\n";
}
// Remove duplicated components
$components = array_unique($components);
if (Project::isDesktopRepository($search->getRepository())) {
// Build logic to filter components
$filter_block = '';
foreach ($components as $value) {
$filter_block .= " <a href='#{$value}' id='{$value}' class='filter'>{$value}</a>";
}
}
if (isset($filter_block)):
?>
<div id="filters">
<h4>Filter by folder:</h4>
<a href="#showall" id="showall" class="filter">Show all results</a>
<?=$filter_block;?>
</div>
<?php
endif;
$table .= "</tbody>\n</table>\n\n";
if ($entities) {
print $table;
}
// Promote API view
include VIEWS . 'templates/api_promotion.php';
@@ -9,9 +9,9 @@
<?php
endif;
// Promote API view
include VIEWS . 'templates/api_promotion.php';
foreach ($output as $results_table) {
print $results_table;
}
// Promote API view
include VIEWS . 'templates/api_promotion.php';
View
@@ -65,5 +65,7 @@ $(document).ready(function() {
}
// Focus on the main search field.
$('#recherche').focus();
if (window.location.hash === '') {
$('#recherche').focus();
}
});
View
@@ -197,4 +197,14 @@ $(document).ready(function() {
$(this).remove();
});
});
/*
Jump to filters if there's not an hash already defined, e.g. to
jump to a specific row.
*/
if (window.location.hash === '' && $('#filters').length) {
$('body,html').animate({
scrollTop: $('#filters').offset().top
}, 500);
}
});

0 comments on commit 332472f

Please sign in to comment.