-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Added 'Collapse File Tree' feature #7026
Changes from 2 commits
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 |
|---|---|---|
|
|
@@ -670,7 +670,50 @@ define(function (require, exports, module) { | |
| // install scroller shadows | ||
| ViewUtils.addScrollerShadow(_projectTree.get(0)); | ||
|
|
||
| var findEventHandler = function (type, namespace, selector) { | ||
| var events = $._data(_projectTree[0], "events"), | ||
| eventsForType = events ? events[type] : null, | ||
| event = eventsForType ? _.find(eventsForType, function (e) { | ||
| return e.namespace === namespace && e.selector === selector; | ||
| }) : null, | ||
| eventHandler = event ? event.handler : null; | ||
| if (!eventHandler) { | ||
| console.error(type + "." + namespace + " " + selector + " handler not found!"); | ||
| } | ||
| return eventHandler; | ||
| }; | ||
| var createCustomHandler = function(originalHandler) { | ||
| return function (event) { | ||
| var $node = $(event.target).parent("li"); | ||
| if (event.ctrlKey || event.metaKey) { | ||
| if (event.altKey) { | ||
| // collapse subtree | ||
| // note: expanding using open_all is a bad idea due to poor performance | ||
| if ($node.is(".jstree-open")) { | ||
| _projectTree.jstree("close_all", $node); | ||
| return; | ||
|
Contributor
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. I think we should return true 'cause we handled the event. Same below.
Contributor
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. Is not returning to anything, it is just used so that it doesn't drop into the original behavior case.
Contributor
Author
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. Original event is here: https://github.com/adobe/brackets/blob/master/src/thirdparty/jstree_pre1.0_fix_1/jquery.jstree.js#L357
Contributor
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.
Contributor
Author
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 is the intended behaviour: ctrl+click willl expand - collapse all siblings of the one that has been clicked ctrl+alt+click will collapse just the one tree clicked, and all of its children (it doesn't work reverse for expand because it's slow) point is if I have a tree open like clicking ctrl+alt on
Contributor
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. ahhh... I think I understand the problem now. You need to handle clicking on the label too not just the disclosure triangle. Alt+clicking on the label is handled by jstree and feels somewhat unpredictable. |
||
| } | ||
| } else { | ||
| // toggle siblings | ||
| var methodName = $node.is(".jstree-open") ? "close_node" : "open_node"; | ||
| $node.parent().children("li").each(function () { | ||
| _projectTree.jstree(methodName, $(this)); | ||
| }); | ||
| return; | ||
| } | ||
| } | ||
| // original behaviour | ||
| originalHandler.apply(this, arguments); | ||
| }; | ||
| }; | ||
| var originalHrefHandler = findEventHandler("click", "jstree", "a"); | ||
| var originalInsHandler = findEventHandler("click", "jstree", "li > ins"); | ||
|
|
||
| _projectTree | ||
| .off("click.jstree", "a") | ||
| .on("click.jstree", "a", createCustomHandler(originalHrefHandler)) | ||
| .off("click.jstree", "li > ins") | ||
| .on("click.jstree", "li > ins", createCustomHandler(originalInsHandler)) | ||
| .unbind("dblclick.jstree") | ||
| .bind("dblclick.jstree", function (event) { | ||
| var entry = $(event.target).closest("li").data("entry"); | ||
|
|
||
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.
I think the other part of my confusion was that cmd+alt doesn't open all. If there is a performance hit with open all then let's just open the node that was clicked on as if alt wasn't pressed.