Skip to content

Commit

Permalink
New attribute for empty region #153
Browse files Browse the repository at this point in the history
  • Loading branch information
JimLiu committed Jun 2, 2014
1 parent de79651 commit 0d567c1
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 12 deletions.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -144,6 +144,11 @@ If you write your own [$callbacks.accept](#accept) method, you have to check `da
##### data-drag-delay
Number of milliseconds a click must be held to start a drag. (default 0)

##### data-empty-place-holder-enabled
If a tree is empty, there will be an empty place hoder which is used to drop node from other trees by default.
- `true` (default): display an empty place holder if the tree is empty
- `false`: do not display an empty place hoder

##### Example
- turn on/off drag and drop.
- Limit depth to 5
Expand Down
2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "angular-ui-tree",
"version": "2.1.3",
"version": "2.1.4",
"homepage": "https://github.com/JimLiu/angular-ui-tree",
"authors": [
"Jim Liu <https://github.com/JimLiu>",
Expand Down
13 changes: 11 additions & 2 deletions demo/dist/angular-ui-tree.js
@@ -1,5 +1,5 @@
/**
* @license Angular UI Tree v2.1.3
* @license Angular UI Tree v2.1.4
* (c) 2010-2014. https://github.com/JimLiu/angular-ui-tree
* License: MIT
*/
Expand Down Expand Up @@ -303,6 +303,7 @@
$scope.$callbacks = null;

$scope.dragEnabled = true;
$scope.emptyPlaceHolderEnabled = true;
$scope.maxDepth = 0;
$scope.dragDelay = 0;

Expand All @@ -319,7 +320,8 @@
};

$scope.resetEmptyElement = function() {
if ($scope.$nodesScope.$modelValue.length === 0) {
if ($scope.$nodesScope.$modelValue.length === 0 &&
$scope.emptyPlaceHolderEnabled) {
$element.append($scope.$emptyElm);
} else {
$scope.$emptyElm.remove();
Expand Down Expand Up @@ -639,6 +641,13 @@
}
});

attrs.$observe('emptyPlaceHolderEnabled', function(val) {
var ep = scope.$eval(val);
if((typeof ep) == "boolean") {
scope.emptyPlaceHolderEnabled = ep;
}
});

attrs.$observe('maxDepth', function(val) {
var md = scope.$eval(val);
if((typeof md) == "number") {
Expand Down
4 changes: 2 additions & 2 deletions demo/dist/angular-ui-tree.min.js

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions dist/angular-ui-tree.js
@@ -1,5 +1,5 @@
/**
* @license Angular UI Tree v2.1.3
* @license Angular UI Tree v2.1.4
* (c) 2010-2014. https://github.com/JimLiu/angular-ui-tree
* License: MIT
*/
Expand Down Expand Up @@ -303,6 +303,7 @@
$scope.$callbacks = null;

$scope.dragEnabled = true;
$scope.emptyPlaceHolderEnabled = true;
$scope.maxDepth = 0;
$scope.dragDelay = 0;

Expand All @@ -319,7 +320,8 @@
};

$scope.resetEmptyElement = function() {
if ($scope.$nodesScope.$modelValue.length === 0) {
if ($scope.$nodesScope.$modelValue.length === 0 &&
$scope.emptyPlaceHolderEnabled) {
$element.append($scope.$emptyElm);
} else {
$scope.$emptyElm.remove();
Expand Down Expand Up @@ -639,6 +641,13 @@
}
});

attrs.$observe('emptyPlaceHolderEnabled', function(val) {
var ep = scope.$eval(val);
if((typeof ep) == "boolean") {
scope.emptyPlaceHolderEnabled = ep;
}
});

attrs.$observe('maxDepth', function(val) {
var md = scope.$eval(val);
if((typeof md) == "number") {
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-ui-tree.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "Angular-NestedSortable",
"version": "2.1.3",
"version": "2.1.4",
"dependencies": {
"grunt": "~0.4.2",
"grunt-contrib-jshint": "~0.8.0",
Expand Down
4 changes: 3 additions & 1 deletion source/controllers/treeCtrl.js
Expand Up @@ -14,6 +14,7 @@
$scope.$callbacks = null;

$scope.dragEnabled = true;
$scope.emptyPlaceHolderEnabled = true;
$scope.maxDepth = 0;
$scope.dragDelay = 0;

Expand All @@ -30,7 +31,8 @@
};

$scope.resetEmptyElement = function() {
if ($scope.$nodesScope.$modelValue.length === 0) {
if ($scope.$nodesScope.$modelValue.length === 0 &&
$scope.emptyPlaceHolderEnabled) {
$element.append($scope.$emptyElm);
} else {
$scope.$emptyElm.remove();
Expand Down
7 changes: 7 additions & 0 deletions source/directives/uiTree.js
Expand Up @@ -37,6 +37,13 @@
}
});

attrs.$observe('emptyPlaceHolderEnabled', function(val) {
var ep = scope.$eval(val);
if((typeof ep) == "boolean") {
scope.emptyPlaceHolderEnabled = ep;
}
});

attrs.$observe('maxDepth', function(val) {
var md = scope.$eval(val);
if((typeof md) == "number") {
Expand Down
2 changes: 1 addition & 1 deletion source/main.js
@@ -1,5 +1,5 @@
/**
* @license Angular UI Tree v2.1.3
* @license Angular UI Tree v2.1.4
* (c) 2010-2014. https://github.com/JimLiu/angular-ui-tree
* License: MIT
*/
Expand Down

0 comments on commit 0d567c1

Please sign in to comment.