diff --git a/README.md b/README.md index ce390a0..a734a2d 100644 --- a/README.md +++ b/README.md @@ -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'. diff --git a/angular-tree-control.js b/angular-tree-control.js index c0c3212..1a96c1c 100644 --- a/angular-tree-control.js +++ b/angular-tree-control.js @@ -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'] ) @@ -114,6 +115,7 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex onNodeToggle: "&", onRightClick: "&", menuId: "@", + selectOnRightClick: "=?", options: "=?", orderBy: "=?", reverseOrder: "@", @@ -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); } diff --git a/context-menu.js b/context-menu.js index 12b8ddb..2599c86 100644 --- a/context-menu.js +++ b/context-menu.js @@ -46,7 +46,7 @@ }); var ulDim = { height: ul.prop("clientHeight"), - width: ul.prop("cientWidth") + width: ul.prop("clientWidth") }; var pgDim = getPageDimensions();