From 47b8ca6d64964816a1242c2a14f7982e7937875f Mon Sep 17 00:00:00 2001 From: Leigh Metzroth Date: Thu, 8 Mar 2018 16:16:14 +1000 Subject: [PATCH 1/2] Added an option to prevent selection on right click. Defaults to true in order to maintain compatibility with previous version. --- README.md | 1 + angular-tree-control.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) 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); } From 871fa157bb00d842b0ca14cdf5716e154238a2fb Mon Sep 17 00:00:00 2001 From: Leigh Metzroth Date: Thu, 8 Mar 2018 17:39:04 +1000 Subject: [PATCH 2/2] Fixed the typo in client width --- context-menu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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();