Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an option to prevent selection on right click. #287

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Attributes of angular treecontrol
- `on-selection` : `(node, selected)` callback called whenever selecting a node in the tree. The callback expression can use the selected node (`node`) and a boolean which indicates if the node was selected or deselected (`selected`).
- `on-node-toggle` : `(node, expanded)` callback called whenever a node expands or collapses in the tree. The callback expression can use the toggled node (`node`) and a boolean which indicates expansion or collapse (`expanded`).
- `on-right-click` : `(node)` callback called whenever a node is right-clicked.
- `select-on-right-click` : Should the right click propagate to a node selected? If `false` it will not fire the `on-selection` callback. Defaults to `true`.
- `options` : different options to customize the tree control.
- `multiSelection` : [Boolean] enable multiple nodes selection in the tree.
- `nodeChildren` : the name of the property of each node that holds the node children. Defaults to 'children'.
Expand Down
4 changes: 3 additions & 1 deletion angular-tree-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex
ensureDefault($scope.options, "isLeaf", defaultIsLeaf);
ensureDefault($scope.options, "allowDeselect", true);
ensureDefault($scope.options, "isSelectable", defaultIsSelectable);
ensureDefault($scope, "selectOnRightClick", true);
}

angular.module( 'treeControl', ['contextMenu'] )
Expand Down Expand Up @@ -114,6 +115,7 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex
onNodeToggle: "&",
onRightClick: "&",
menuId: "@",
selectOnRightClick: "=?",
options: "=?",
orderBy: "=?",
reverseOrder: "@",
Expand Down Expand Up @@ -259,7 +261,7 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex
$event.preventDefault();

// Are are we changing the 'selected' node (as well)?
if ($scope.selectedNode != targetNode) {
if ($scope.selectedNode != targetNode && $scope.selectOnRightClick) {
this.selectNodeLabel(targetNode);
}

Expand Down
2 changes: 1 addition & 1 deletion context-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
});

var ulDim = { height: ul.prop("clientHeight"),
width: ul.prop("cientWidth")
width: ul.prop("clientWidth")
};

var pgDim = getPageDimensions();
Expand Down