-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Expand / Collapse All for "Find In Files" result. #5757
Changes from 3 commits
39d9c90
7ccde5f
57b9957
ba3e47c
ecd1e80
939b643
79dea63
409ed84
524e8d6
0df4912
5e88b67
6e9723b
7c14fe9
fe7fe93
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -431,13 +431,30 @@ 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 $triangle = $(".disclosure-triangle", $row); | ||
$triangle.toggleClass("expanded").toggleClass("collapsed"); | ||
|
||
searchResults[fullPath].collapsed = !searchResults[fullPath].collapsed; | ||
if (e.metaKey || e.ctrlKey) { //Expand all / Collapse all | ||
var $titleRows = $(e.target).closest("table").find(".file-section"), | ||
collapsed = !searchResults[fullPath].collapsed; | ||
|
||
$titleRows.each(function () { | ||
searchItem = searchList[$(this).data("file")]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will look nicer to do here |
||
fullPath = searchItem.fullPath; | ||
|
||
if (searchResults[fullPath].collapsed !== collapsed) { | ||
$(this).nextUntil(".file-section").toggle(); | ||
$(this).find(".disclosure-triangle").toggleClass("expanded").toggleClass("collapsed"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 2 lines are almost the sames as lines (454-455), only the element changes. So I was thinking that maybe we could have a function: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it should change the internal state too, so the function can be |
||
} | ||
}); | ||
|
||
_.forEach(searchResults, function (item) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to have a comment here to mention that this is required to collapse/uncollapse all the files and not just the ones in the current page. |
||
item.collapsed = collapsed; | ||
}); | ||
} else { | ||
// Clicking the file section header collapses/expands result rows for that file | ||
$row.nextUntil(".file-section").toggle(); | ||
$row.find(".disclosure-triangle").toggleClass("expanded").toggleClass("collapsed"); | ||
searchResults[fullPath].collapsed = !searchResults[fullPath].collapsed; | ||
} | ||
|
||
// This is a file row, show the result on click | ||
} else { | ||
|
@@ -467,6 +484,8 @@ define(function (require, exports, module) { | |
} | ||
}); | ||
|
||
$searchContent.find(".disclosure-triangle").attr("title", Strings.FIND_IN_FILES_EXPAND_COLLAPSE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be added to the html template. |
||
|
||
if ($selectedRow) { | ||
$selectedRow.removeClass("selected"); | ||
$selectedRow = null; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this variable was declared before the if, then we could also use it in line 456.