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

Commit

Permalink
Handle clicking on the label too
Browse files Browse the repository at this point in the history
  • Loading branch information
zaggino committed Mar 20, 2014
1 parent 04e0ec0 commit 151f3c1
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,20 @@ define(function (require, exports, module) {
// install scroller shadows
ViewUtils.addScrollerShadow(_projectTree.get(0));

_projectTree
.off("click.jstree", "li > ins")
.on("click.jstree", "li > ins", function (event) {
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) {
Expand All @@ -692,8 +703,17 @@ define(function (require, exports, module) {
}
}
// original behaviour
_projectTree.jstree("toggle_node", $node);
})
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");
Expand Down

0 comments on commit 151f3c1

Please sign in to comment.