Skip to content

Commit 209b87a

Browse files
committed
- Docs.
1 parent ca5448d commit 209b87a

13 files changed

+1179
-451
lines changed

dist/ng-tree-dnd.debug.js

Lines changed: 390 additions & 149 deletions
Large diffs are not rendered by default.

dist/ng-tree-dnd.js

Lines changed: 390 additions & 149 deletions
Large diffs are not rendered by default.

dist/ng-tree-dnd.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ng-tree-dnd.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsdoc.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@
99
"plugins/markdown"
1010
],
1111
"templates": {
12-
"cleverLinks": false,
13-
"monospaceLinks": false,
12+
"cleverLinks": true,
13+
"monospaceLinks": true,
1414
"default": {
1515
"outputSourceFiles": true
1616
},
17+
"collapseSymbols": false,
18+
"outputSourceFiles": true,
19+
"outputSourcePath": true,
1720
"path": "ink-docstrap",
21+
"syntaxTheme": "default",
1822
"theme": "paper",
23+
"sort": true,
1924
"navType": "vertical",
2025
"linenums": true,
2126
"dateFormat": "MMMM Do YYYY, h:mm:ss a"

src/directive/angular-tree-dnd.js

Lines changed: 103 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ function fnInitTreeDnD($timeout, $http, $compile, $parse, $window, $document, $t
496496
$scope.dragging = undefined;
497497

498498
angular.extend(
499-
$scope.$callbacks, {
499+
$scope.$callbacks, /** @lends $scope.$callbacks */ {
500500
beforeDrag: function (/*scopeDrag*/) {
501501
return true;
502502
},
@@ -693,6 +693,11 @@ function fnInitTreeDnD($timeout, $http, $compile, $parse, $window, $document, $t
693693
}
694694
}
695695

696+
/**
697+
* Status targeting when drag & drop
698+
*
699+
* @type {boolean}
700+
*/
696701
$scope.targeting = false;
697702

698703
/**
@@ -730,6 +735,13 @@ function fnInitTreeDnD($timeout, $http, $compile, $parse, $window, $document, $t
730735
return $scope.tree_nodes[index];
731736
};
732737

738+
/**
739+
* Init element place
740+
*
741+
* @param {DOMElement} element
742+
* @param {DOMElement} dragElm
743+
* @returns {*}
744+
*/
733745
$scope.initPlace = function (element, dragElm) {
734746

735747
if (!$scope.placeElm) {
@@ -773,26 +785,48 @@ function fnInitTreeDnD($timeout, $http, $compile, $parse, $window, $document, $t
773785
return $scope.placeElm;
774786
};
775787

788+
/**
789+
* Hide element place
790+
*/
776791
$scope.hidePlace = function () {
777792
if ($scope.placeElm) {
778793
$scope.placeElm.addClass($scope.$class.hidden);
779794
}
780795
};
781796

797+
/**
798+
* Show element place
799+
*/
782800
$scope.showPlace = function () {
783801
if ($scope.placeElm) {
784802
$scope.placeElm.removeClass($scope.$class.hidden);
785803
}
786804
};
787805

806+
/**
807+
* Get scope tree
808+
* @returns {$scope}
809+
*/
788810
$scope.getScopeTree = function () {
789811
return $scope;
790812
};
791813

792814
}
793815

816+
/**
817+
* Function safe apply to avoid loop-depth
818+
*
819+
* @type {$safeApply}
820+
*/
794821
$scope.$safeApply = $safeApply;
795822

823+
/**
824+
* Hide children
825+
*
826+
* @param {Node} node
827+
* @param {Node} parent
828+
* @returns {boolean}
829+
*/
796830
$scope.hiddenChild = function fnHiddenChild(node, parent) {
797831
var nodeScope = $scope.getScope(node);
798832
if (nodeScope) {
@@ -805,11 +839,7 @@ function fnInitTreeDnD($timeout, $http, $compile, $parse, $window, $document, $t
805839
}
806840
} else {
807841
// show node & init scope
808-
if (parent && parent.__expanded__ && parent.__visible__) {
809-
node.__visible__ = true;
810-
} else {
811-
node.__visible__ = false;
812-
}
842+
node.__visible__ = !!(parent && parent.__expanded__ && parent.__visible__);
813843
}
814844

815845
// skip all child hiding... if not expaned
@@ -1023,19 +1053,38 @@ function fnInitTreeDnD($timeout, $http, $compile, $parse, $window, $document, $t
10231053
);
10241054
}
10251055

1056+
/**
1057+
* Reload data with timeout
1058+
* @callback timeLoadData
1059+
*/
10261060
function timeLoadData() {
10271061
$scope.treeData = tmpTreeData;
10281062
reload_data();
10291063
timeReloadData = undefined;
10301064
}
10311065

1066+
/**
1067+
* Update limit
1068+
*/
10321069
$scope.updateLimit = function updateLimit() {
1033-
//console.log('Call fn UpdateLimit');
10341070
$scope.$TreeLimit += 50;
10351071
};
10361072

1073+
/**
1074+
* Reload data
1075+
* @type {reload_data}
1076+
*/
10371077
$scope.reload_data = reload_data;
10381078

1079+
/**
1080+
* Check attribute exist
1081+
* @callback check_exist_attr
1082+
*
1083+
* @param {object|array} attrs - Array attributes
1084+
* @param {Array|string} existAttr - Criteria condition
1085+
* @param {boolean} isAnd - Is condition AND
1086+
* @returns {*}
1087+
*/
10391088
function check_exist_attr(attrs, existAttr, isAnd) {
10401089
if (angular.isUndefinedOrNull(existAttr)) {
10411090
return false;
@@ -1050,6 +1099,14 @@ function fnInitTreeDnD($timeout, $http, $compile, $parse, $window, $document, $t
10501099
}
10511100
}
10521101

1102+
/**
1103+
* Foreach attributes with criteria
1104+
* @callback for_each_attrs
1105+
* @param {Object|Array} attrs - Array attributes
1106+
* @param {Array|string} exist - Criteria condition
1107+
* @param {boolean} isAnd - Is condition AND
1108+
* @returns {boolean}
1109+
*/
10531110
function for_each_attrs(attrs, exist, isAnd) {
10541111
var i, len = exist.length, passed = false;
10551112

@@ -1073,8 +1130,19 @@ function fnInitTreeDnD($timeout, $http, $compile, $parse, $window, $document, $t
10731130
return passed;
10741131
}
10751132

1076-
function generateWatch(type, nameAttr, valDefault, nameScope, fnNotExist, fnAfter,
1077-
fnBefore) {
1133+
/**
1134+
* Function generate watch attribute by automatic
1135+
*
1136+
* @callback generateWatch
1137+
* @param {*} type
1138+
* @param {string} nameAttr - Name attribute
1139+
* @param {*} valDefault - Value default
1140+
* @param {string|undefined} nameScope - Name of attribute in $scope
1141+
* @param {function} fnNotExist - Callback when attribute not exist
1142+
* @param {function} fnAfter - Callback when attribute found
1143+
* @param {function} fnBefore - Callback before attribute found (to prepare data)
1144+
*/
1145+
function generateWatch(type, nameAttr, valDefault, nameScope, fnNotExist, fnAfter, fnBefore) {
10781146
nameScope = nameScope || nameAttr;
10791147
if (typeof type === 'string' || angular.isArray(type)) {
10801148
if (angular.isFunction(fnBefore) && fnBefore()) {
@@ -1112,6 +1180,12 @@ function fnInitTreeDnD($timeout, $http, $compile, $parse, $window, $document, $t
11121180
}
11131181
}
11141182

1183+
/**
1184+
* Call safeApply
1185+
*
1186+
* @param fn
1187+
* @callback $safeApply
1188+
*/
11151189
function $safeApply(fn) {
11161190
var phase = this.$root.$$phase;
11171191
if (phase === '$apply' || phase === '$digest') {
@@ -1178,17 +1252,25 @@ function fnInitTreeDnD($timeout, $http, $compile, $parse, $window, $document, $t
11781252
}
11791253
}
11801254

1255+
/**
1256+
* do_f
1257+
*
1258+
* @callback do_f
1259+
*
1260+
* @param {Node[]} root
1261+
* @param {Node} node
1262+
* @param {Node} parent
1263+
* @param {int} parent_real
1264+
* @param {int} level
1265+
* @param {boolean|*} visible
1266+
* @param {int} index
1267+
* @returns {number}
1268+
*/
11811269
function do_f(root, node, parent, parent_real, level, visible, index) {
1182-
/**
1183-
* Data base
1184-
* @name NodeData
1185-
* @typedef {Object} NodeData
1186-
*/
11871270
/**
11881271
* Node of tree
11891272
* @name Node
1190-
* @typedef {NodeData} Node
1191-
* @extends NodeData
1273+
* @type {NodeBase}
11921274
* @property {int} __parent_real__
11931275
* @property {Node} __parent__
11941276
* @property {boolean} __expanded__
@@ -1201,7 +1283,6 @@ function fnInitTreeDnD($timeout, $http, $compile, $parse, $window, $document, $t
12011283
* @property {string} __uid__
12021284
* @property {string} __hashKey__
12031285
* @property {int} __dept__
1204-
* @property {Node[]|undefined} [__children__]
12051286
*/
12061287
if (typeof node !== 'object') {
12071288
return 0;
@@ -1296,19 +1377,19 @@ function fnInitTreeDnD($timeout, $http, $compile, $parse, $window, $document, $t
12961377
*
12971378
* @callback reload_data
12981379
*
1299-
* @param oData
1380+
* @param {Node[]|undefined} [data=undefined]
13001381
* @returns {Node[]}
13011382
*/
1302-
function reload_data(oData) {
1383+
function reload_data(data) {
13031384
var _data,
13041385
_len,
13051386
_tree_nodes = [];
13061387

1307-
if (angular.isDefined(oData)) {
1308-
if (!angular.isArray(oData) || oData.length === 0) {
1388+
if (angular.isDefined(data)) {
1389+
if (!angular.isArray(data) || data.length === 0) {
13091390
return init_data([]);
13101391
} else {
1311-
_data = oData;
1392+
_data = data;
13121393
}
13131394
} else if (!angular.isArray($scope.treeData) || $scope.treeData.length === 0) {
13141395
return init_data([]);

src/factory/angular-tree-dnd-convert.js

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
1+
/**
2+
* Factory $TreeDnDConvert
3+
*
4+
* @name Factory.$TreeDnDConvert
5+
* @type {$TreeDnDConvert}
6+
*/
17
angular.module('ntt.TreeDnD')
28
.factory('$TreeDnDConvert', function () {
3-
var _$initConvert = {
9+
/**
10+
* NodeBase
11+
* @name NodeBase
12+
* @type object
13+
* @property {NodeBase[]|undefined} [__children__]
14+
*/
15+
16+
/**
17+
* @name $TreeDnDConvert
18+
* @type object
19+
* @default
20+
*/
21+
var $TreeDnDConvert = {
22+
/**
23+
* Line to tree
24+
*
25+
* @param {Array|Object} data
26+
* @param {string} primaryKey
27+
* @param {string} parentKey
28+
* @param {function} callback
29+
* @returns {NodeBase[]}
30+
*/
431
line2tree: function (data, primaryKey, parentKey, callback) {
532
callback = typeof callback === 'function' ? callback : function () {
633
};
@@ -62,6 +89,14 @@ angular.module('ntt.TreeDnD')
6289

6390
return tree;
6491
},
92+
/**
93+
* Convert tree to tree
94+
*
95+
* @param {array|object} data
96+
* @param {string} containKey
97+
* @param {function} callback
98+
* @returns {NodeBase[]}
99+
*/
65100
tree2tree: function access_child(data, containKey, callback) {
66101
callback = typeof callback === 'function' ? callback : function () {
67102
};
@@ -89,5 +124,5 @@ angular.module('ntt.TreeDnD')
89124
}
90125
};
91126

92-
return _$initConvert;
127+
return $TreeDnDConvert;
93128
});

0 commit comments

Comments
 (0)