diff --git a/README.md b/README.md index 0ea4e53..df92f4d 100644 --- a/README.md +++ b/README.md @@ -111,8 +111,8 @@ Attributes of angular treecontrol - `selected-node` : [Node], used when `multiSelection=false`. 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. - `selected-nodes` : [Array[Node]], used when `multiSelection=true`. Binding for the selected nodes 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-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-selection` : `(node, selected,$event)` callback called whenever selecting a node in the tree. The callback expression can use the selected node (`node`), a boolean which indicates if the node was selected or deselected (`selected`) and the mouse event generated from the selection (`$event`). +- `on-node-toggle` : `(node, expanded, $event)` callback called whenever a node expands or collapses in the tree. The callback expression can use the toggled node (`node`), a boolean which indicates expansion or collapse (`expanded`) and the mouse event generated from the click (`$event`). - `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 3043027..59559fb 100644 --- a/angular-tree-control.js +++ b/angular-tree-control.js @@ -172,7 +172,7 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex return !!$scope.expandedNodesMap[this.$id]; }; - $scope.selectNodeHead = function() { + $scope.selectNodeHead = function(node,$event) { var transcludedScope = this; var expanding = $scope.expandedNodesMap[transcludedScope.$id] === undefined; $scope.expandedNodesMap[transcludedScope.$id] = (expanding ? transcludedScope.node : undefined); @@ -192,18 +192,18 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex if ($scope.onNodeToggle) { var parentNode = (transcludedScope.$parent.node === transcludedScope.synteticRoot)?null:transcludedScope.$parent.node; var path = createPath(transcludedScope); - $scope.onNodeToggle({node: transcludedScope.node, $parentNode: parentNode, $path: path, + $scope.onNodeToggle({node: transcludedScope.node, $event: $event, $parentNode: parentNode, $path: path, $index: transcludedScope.$index, $first: transcludedScope.$first, $middle: transcludedScope.$middle, $last: transcludedScope.$last, $odd: transcludedScope.$odd, $even: transcludedScope.$even, expanded: expanding}); } }; - $scope.selectNodeLabel = function( selectedNode){ + $scope.selectNodeLabel = function( selectedNode, $event){ var transcludedScope = this; if(!$scope.options.isLeaf(selectedNode, $scope) && (!$scope.options.dirSelectable || !$scope.options.isSelectable(selectedNode))) { // Branch node is not selectable, expand - this.selectNodeHead(); + this.selectNodeHead(selectedNode,$event); } else if($scope.options.isLeaf(selectedNode, $scope) && (!$scope.options.isSelectable(selectedNode))) { // Leaf node is not selectable @@ -242,7 +242,7 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex if ($scope.onSelection) { var parentNode = (transcludedScope.$parent.node === transcludedScope.synteticRoot)?null:transcludedScope.$parent.node; var path = createPath(transcludedScope) - $scope.onSelection({node: selectedNode, selected: selected, $parentNode: parentNode, $path: path, + $scope.onSelection({node: selectedNode, $event: $event, selected: selected, $parentNode: parentNode, $path: path, $index: transcludedScope.$index, $first: transcludedScope.$first, $middle: transcludedScope.$middle, $last: transcludedScope.$last, $odd: transcludedScope.$odd, $even: transcludedScope.$even}); } @@ -296,9 +296,9 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex ''; diff --git a/bower.json b/bower.json index 75de363..3339ec0 100644 --- a/bower.json +++ b/bower.json @@ -3,7 +3,8 @@ "version": "0.2.28", "author": "Yoav Abrahami", "contributors": [ - "Benjamin Orozco " + "Benjamin Orozco ", + "José M. Fernández " ], "main": [ "./angular-tree-control.js", @@ -16,13 +17,13 @@ "karma.conf.js" ], "dependencies": { - "angular": "~1.4.4" + "angular": "~1.4.4 || ~1.5.4" }, "devDependencies": { - "angular-mocks": "~1.4.4", + "angular-mocks": "~1.4.4 || ~1.5.4", "jquery": "~2.2.2", - "bootstrap": "~3.1.1", - "angular-bootstrap": "~0.11.0", + "bootstrap": "~3.3.6", + "angular-bootstrap": "~1.2.5", "google-code-prettify": "1.0.1" } } diff --git a/package.json b/package.json index 250b130..f16e55b 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ }, "author": "Yoav Abrahami", "contributors": [ - "Benjamin Orozco " + "Benjamin Orozco ", + "José M. Fernández " ], "license": "MIT", "bugs": {