@@ -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 ( [ ] ) ;
0 commit comments