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

Commit 04e0ec0

Browse files
committed
Added 'Collapse file tree' feature and 'Toggle siblings' feature
1 parent 4c18488 commit 04e0ec0

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/project/ProjectManager.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,29 @@ define(function (require, exports, module) {
671671
ViewUtils.addScrollerShadow(_projectTree.get(0));
672672

673673
_projectTree
674+
.off("click.jstree", "li > ins")
675+
.on("click.jstree", "li > ins", function (event) {
676+
var $node = $(event.target).parent("li");
677+
if (event.ctrlKey || event.metaKey) {
678+
if (event.altKey) {
679+
// collapse subtree
680+
// note: expanding using open_all is a bad idea due to poor performance
681+
if ($node.is(".jstree-open")) {
682+
_projectTree.jstree("close_all", $node);
683+
return;
684+
}
685+
} else {
686+
// toggle siblings
687+
var methodName = $node.is(".jstree-open") ? "close_node" : "open_node";
688+
$node.parent().children("li").each(function () {
689+
_projectTree.jstree(methodName, $(this));
690+
});
691+
return;
692+
}
693+
}
694+
// original behaviour
695+
_projectTree.jstree("toggle_node", $node);
696+
})
674697
.unbind("dblclick.jstree")
675698
.bind("dblclick.jstree", function (event) {
676699
var entry = $(event.target).closest("li").data("entry");

0 commit comments

Comments
 (0)