diff --git a/README.md b/README.md index 7a280a3..ce97dd4 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ Attributes of angular treecontrol - `tree-model` : [Node|Array[Node]] the tree data on the `$scope`. This can be an array of nodes or a single node. - `selected-node` : [Node] binding for the selected node in the tree. Updating this value updates the selection displayed in the tree. Selecting a node in the tree will update this value. - `expanded-nodes` : [Array[Node]] binding for the expanded nodes in the tree. Updating this value updates the nodes that are expanded in the tree. +- `on-right-click` : [Array[Node]] binding for the expanded nodes in the tree. Updating this value updates the nodes that are expanded in the tree. - `on-selection` : callback called whenever selecting a node in the tree. The callback argument is the selected node. - `on-node-toggle` : callback called whenever a node expands or collapses in the tree. The function arguments are the toggled node and a boolean which is true for expansion, false for collapse. - `options` : different options to customize the tree control. diff --git a/angular-tree-control.js b/angular-tree-control.js index dc004a8..c98834c 100644 --- a/angular-tree-control.js +++ b/angular-tree-control.js @@ -32,6 +32,7 @@ selectedNode: "=?", expandedNodes: "=?", onSelection: "&", + onRightClick: "&", onNodeToggle: "&", options: "=?", orderBy: "@", @@ -79,7 +80,7 @@ $scope.headClass = function(node) { var liSelectionClass = classIfDefined($scope.options.injectClasses.liSelected, false); var injectSelectionClass = ""; - if (liSelectionClass && ($scope.options.equality(this.node, $scope.selectedNode))) + if (liSelectionClass && (this.node == $scope.selectedNode)) injectSelectionClass = " " + liSelectionClass; if ($scope.options.isLeaf(node)) return "tree-leaf" + injectSelectionClass; @@ -134,6 +135,20 @@ } }; + $scope.rightClickNodeLabel = function( selectedNode ){ + if (selectedNode[$scope.options.nodeChildren] && selectedNode[$scope.options.nodeChildren].length > 0 && + !$scope.options.dirSelectable) { + this.selectNodeHead(); + } + else { + if ($scope.selectedNode != selectedNode) { + $scope.selectedNode = selectedNode; + if ($scope.onRightClick) + $scope.onRightClick({node: selectedNode}); + } + } + }; + $scope.selectedClass = function() { var labelSelectionClass = classIfDefined($scope.options.injectClasses.labelSelected, false); var injectSelectionClass = ""; @@ -149,7 +164,7 @@ '