Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #6640 from sathyamoorthi/Find-In-Files2
Browse files Browse the repository at this point in the history
Expand / Collapse All for "Find In Files" result - clean commit
  • Loading branch information
TomMalbran committed Jan 25, 2014
2 parents 68e793a + dcea7fd commit f1061fa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/htmlContent/search-results.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
<tbody>
{{#searchList}}
<tr class="file-section" data-file="{{file}}">
<td colspan="2"><span class="disclosure-triangle expanded"></span>{{{filename}}}</td>
<td colspan="2">
<span class="disclosure-triangle expanded" title="{{Strings.FIND_IN_FILES_EXPAND_COLLAPSE}}"></span>
{{{filename}}}
</td>
</tr>
{{#items}}
<tr data-file="{{file}}" data-item="{{item}}">
Expand Down
1 change: 1 addition & 0 deletions src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ define({
"FIND_IN_FILES_MORE_THAN" : "Over ",
"FIND_IN_FILES_PAGING" : "{0}&mdash;{1}",
"FIND_IN_FILES_FILE_PATH" : "<span class='dialog-filename'>{0}</span> {2} <span class='dialog-path'>{1}</span>", // We shoudl use normal dashes on Windows instead of em dash eventually
"FIND_IN_FILES_EXPAND_COLLAPSE" : "Ctrl/Cmd click to expand/collapse all",
"ERROR_FETCHING_UPDATE_INFO_TITLE" : "Error getting update info",
"ERROR_FETCHING_UPDATE_INFO_MSG" : "There was a problem getting the latest update information from the server. Please make sure you are connected to the internet and try again.",

Expand Down
33 changes: 26 additions & 7 deletions src/search/FindInFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ define(function (require, exports, module) {
// Insert the search results
$searchContent
.empty()
.append(Mustache.render(searchResultsTemplate, {searchList: searchList}))
.append(Mustache.render(searchResultsTemplate, {searchList: searchList, Strings: Strings}))
.scrollTop(0) // Otherwise scroll pos from previous contents is remembered
.off(".searchList") // Remove the old events

Expand All @@ -437,14 +437,33 @@ define(function (require, exports, module) {

// This is a file title row, expand/collapse on click
if ($row.hasClass("file-section")) {
// Clicking the file section header collapses/expands result rows for that file
$row.nextUntil(".file-section").toggle();
var $titleRows,
collapsed = !searchResults[fullPath].collapsed;

var $triangle = $(".disclosure-triangle", $row);
$triangle.toggleClass("expanded").toggleClass("collapsed");
if (e.metaKey || e.ctrlKey) { //Expand all / Collapse all
$titleRows = $(e.target).closest("table").find(".file-section");
} else {
// Clicking the file section header collapses/expands result rows for that file
$titleRows = $row;
}

searchResults[fullPath].collapsed = !searchResults[fullPath].collapsed;

$titleRows.each(function () {
fullPath = searchList[$(this).data("file")].fullPath;
searchItem = searchResults[fullPath];

if (searchItem.collapsed !== collapsed) {
searchItem.collapsed = collapsed;
$(this).nextUntil(".file-section").toggle();
$(this).find(".disclosure-triangle").toggleClass("expanded").toggleClass("collapsed");
}
});

//In Expand/Collapse all, reset all search results 'collapsed' flag to same value(true/false).
if (e.metaKey || e.ctrlKey) {
_.forEach(searchResults, function (item) {
item.collapsed = collapsed;
});
}
// This is a file row, show the result on click
} else {
// Grab the required item data
Expand Down

0 comments on commit f1061fa

Please sign in to comment.