Skip to content

Commit 6776768

Browse files
author
Niels Dequeker
committed
Fix JSCS issues
1 parent 9736c71 commit 6776768

File tree

10 files changed

+396
-368
lines changed

10 files changed

+396
-368
lines changed

.jscsrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"preset": "crockford",
33
"validateIndentation": 2,
4-
"validateQuoteMarks": "'"
4+
"validateQuoteMarks": "'",
5+
"disallowDanglingUnderscores": null
56
}

source/controllers/nodeCtrl.js

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
$scope.$$apply = false;
1818
$scope.collapsed = false;
1919

20-
$scope.init = function(controllersArr) {
20+
$scope.init = function (controllersArr) {
2121
var treeNodesCtrl = controllersArr[0];
2222
$scope.$treeScope = controllersArr[1] ? controllersArr[1].scope : null;
2323

@@ -28,83 +28,83 @@
2828
$scope.$parentNodesScope = treeNodesCtrl.scope;
2929
treeNodesCtrl.scope.initSubNode($scope); // init sub nodes
3030

31-
$element.on('$destroy', function() {
31+
$element.on('$destroy', function () {
3232
treeNodesCtrl.scope.destroySubNode($scope); // destroy sub nodes
3333
});
3434
};
3535

36-
$scope.index = function() {
36+
$scope.index = function () {
3737
return $scope.$parentNodesScope.$modelValue.indexOf($scope.$modelValue);
3838
};
3939

40-
$scope.dragEnabled = function() {
40+
$scope.dragEnabled = function () {
4141
return !($scope.$treeScope && !$scope.$treeScope.dragEnabled);
4242
};
4343

44-
$scope.isSibling = function(targetNode) {
44+
$scope.isSibling = function (targetNode) {
4545
return $scope.$parentNodesScope == targetNode.$parentNodesScope;
4646
};
4747

48-
$scope.isChild = function(targetNode) {
48+
$scope.isChild = function (targetNode) {
4949
var nodes = $scope.childNodes();
5050
return nodes && nodes.indexOf(targetNode) > -1;
5151
};
5252

53-
$scope.prev = function() {
53+
$scope.prev = function () {
5454
var index = $scope.index();
5555
if (index > 0) {
5656
return $scope.siblings()[index - 1];
5757
}
5858
return null;
5959
};
6060

61-
$scope.siblings = function() {
61+
$scope.siblings = function () {
6262
return $scope.$parentNodesScope.childNodes();
6363
};
6464

65-
$scope.childNodesCount = function() {
65+
$scope.childNodesCount = function () {
6666
return $scope.childNodes() ? $scope.childNodes().length : 0;
6767
};
6868

69-
$scope.hasChild = function() {
69+
$scope.hasChild = function () {
7070
return $scope.childNodesCount() > 0;
7171
};
7272

73-
$scope.childNodes = function() {
73+
$scope.childNodes = function () {
7474
return $scope.$childNodesScope && $scope.$childNodesScope.$modelValue ?
7575
$scope.$childNodesScope.childNodes() :
7676
null;
7777
};
7878

79-
$scope.accept = function(sourceNode, destIndex) {
79+
$scope.accept = function (sourceNode, destIndex) {
8080
return $scope.$childNodesScope &&
8181
$scope.$childNodesScope.$modelValue &&
8282
$scope.$childNodesScope.accept(sourceNode, destIndex);
8383
};
8484

85-
$scope.removeNode = function(){
85+
$scope.removeNode = function () {
8686
var node = $scope.remove();
8787
$scope.$callbacks.removed(node);
8888
return node;
8989
};
9090

91-
$scope.remove = function() {
91+
$scope.remove = function () {
9292
return $scope.$parentNodesScope.removeNode($scope);
9393
};
9494

95-
$scope.toggle = function() {
95+
$scope.toggle = function () {
9696
$scope.collapsed = !$scope.collapsed;
9797
};
9898

99-
$scope.collapse = function() {
99+
$scope.collapse = function () {
100100
$scope.collapsed = true;
101101
};
102102

103-
$scope.expand = function() {
103+
$scope.expand = function () {
104104
$scope.collapsed = false;
105105
};
106106

107-
$scope.depth = function() {
107+
$scope.depth = function () {
108108
var parentNode = $scope.$parentNodeScope;
109109
if (parentNode) {
110110
return parentNode.depth() + 1;
@@ -113,20 +113,23 @@
113113
};
114114

115115
var subDepth = 0;
116-
var countSubDepth = function(scope) {
117-
var count = 0;
118-
var nodes = scope.childNodes();
119-
for (var i = 0; i < nodes.length; i++) {
120-
var childNodes = nodes[i].$childNodesScope;
116+
function countSubDepth(scope) {
117+
var i, childNodes,
118+
count = 0,
119+
nodes = scope.childNodes();
120+
121+
for (i = 0; i < nodes.length; i++) {
122+
childNodes = nodes[i].$childNodesScope;
123+
121124
if (childNodes) {
122125
count = 1;
123126
countSubDepth(childNodes);
124127
}
125128
}
126129
subDepth += count;
127-
};
130+
}
128131

129-
$scope.maxSubDepth = function() {
132+
$scope.maxSubDepth = function () {
130133
subDepth = 0;
131134
if ($scope.$childNodesScope) {
132135
countSubDepth($scope.$childNodesScope);

source/controllers/nodesCtrl.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,83 +18,83 @@
1818
$scope.maxDepth = 0;
1919
$scope.cloneEnabled = false;
2020

21-
$scope.initSubNode = function(subNode) {
22-
if(!subNode.$modelValue) {
21+
$scope.initSubNode = function (subNode) {
22+
if (!subNode.$modelValue) {
2323
return null;
2424
}
2525
$scope.$nodesMap[subNode.$modelValue.$$hashKey] = subNode;
2626
};
2727

28-
$scope.destroySubNode = function(subNode) {
29-
if(!subNode.$modelValue) {
28+
$scope.destroySubNode = function (subNode) {
29+
if (!subNode.$modelValue) {
3030
return null;
3131
}
3232
$scope.$nodesMap[subNode.$modelValue.$$hashKey] = null;
3333
};
3434

35-
$scope.accept = function(sourceNode, destIndex) {
35+
$scope.accept = function (sourceNode, destIndex) {
3636
return $scope.$treeScope.$callbacks.accept(sourceNode, $scope, destIndex);
3737
};
3838

39-
$scope.beforeDrag = function(sourceNode) {
39+
$scope.beforeDrag = function (sourceNode) {
4040
return $scope.$treeScope.$callbacks.beforeDrag(sourceNode);
4141
};
4242

43-
$scope.isParent = function(node) {
43+
$scope.isParent = function (node) {
4444
return node.$parentNodesScope == $scope;
4545
};
4646

47-
$scope.hasChild = function() {
47+
$scope.hasChild = function () {
4848
return $scope.$modelValue.length > 0;
4949
};
5050

51-
$scope.safeApply = function(fn) {
51+
$scope.safeApply = function (fn) {
5252
var phase = this.$root.$$phase;
53-
if(phase == '$apply' || phase == '$digest') {
54-
if(fn && (typeof(fn) === 'function')) {
53+
if (phase == '$apply' || phase == '$digest') {
54+
if (fn && (typeof (fn) === 'function')) {
5555
fn();
5656
}
5757
} else {
5858
this.$apply(fn);
5959
}
6060
};
6161

62-
$scope.removeNode = function(node) {
62+
$scope.removeNode = function (node) {
6363
var index = $scope.$modelValue.indexOf(node.$modelValue);
6464
if (index > -1) {
65-
$scope.safeApply(function() {
65+
$scope.safeApply(function () {
6666
$scope.$modelValue.splice(index, 1)[0];
6767
});
6868
return node;
6969
}
7070
return null;
7171
};
7272

73-
$scope.insertNode = function(index, nodeData) {
74-
$scope.safeApply(function() {
73+
$scope.insertNode = function (index, nodeData) {
74+
$scope.safeApply(function () {
7575
$scope.$modelValue.splice(index, 0, nodeData);
7676
});
7777
};
7878

79-
$scope.childNodes = function() {
80-
var nodes = [];
79+
$scope.childNodes = function () {
80+
var i, nodes = [];
8181
if ($scope.$modelValue) {
82-
for (var i = 0; i < $scope.$modelValue.length; i++) {
82+
for (i = 0; i < $scope.$modelValue.length; i++) {
8383
nodes.push($scope.$nodesMap[$scope.$modelValue[i].$$hashKey]);
8484
}
8585
}
8686
return nodes;
8787
};
8888

89-
$scope.depth = function() {
89+
$scope.depth = function () {
9090
if ($scope.$nodeScope) {
9191
return $scope.$nodeScope.depth();
9292
}
9393
return 0; // if it has no $nodeScope, it's root
9494
};
9595

9696
// check if depth limit has reached
97-
$scope.outOfDepth = function(sourceNode) {
97+
$scope.outOfDepth = function (sourceNode) {
9898
var maxDepth = $scope.maxDepth || $scope.$treeScope.maxDepth;
9999
if (maxDepth > 0) {
100100
return $scope.depth() + sourceNode.maxSubDepth() + 1 > maxDepth;
@@ -104,4 +104,4 @@
104104

105105
}
106106
]);
107-
})();
107+
})();

source/controllers/treeCtrl.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121
$scope.nodropEnabled = false;
2222

2323
// Check if it's a empty tree
24-
$scope.isEmpty = function() {
24+
$scope.isEmpty = function () {
2525
return ($scope.$nodesScope && $scope.$nodesScope.$modelValue
2626
&& $scope.$nodesScope.$modelValue.length === 0);
2727
};
2828

2929
// add placeholder to empty tree
30-
$scope.place = function(placeElm) {
30+
$scope.place = function (placeElm) {
3131
$scope.$nodesScope.$element.append(placeElm);
3232
$scope.$emptyElm.remove();
3333
};
3434

35-
$scope.resetEmptyElement = function() {
35+
$scope.resetEmptyElement = function () {
3636
if ($scope.$nodesScope.$modelValue.length === 0 &&
3737
$scope.emptyPlaceHolderEnabled) {
3838
$element.append($scope.$emptyElm);
@@ -41,22 +41,23 @@
4141
}
4242
};
4343

44-
var collapseOrExpand = function(scope, collapsed) {
45-
var nodes = scope.childNodes();
46-
for (var i = 0; i < nodes.length; i++) {
44+
var collapseOrExpand = function (scope, collapsed) {
45+
var i, subScope,
46+
nodes = scope.childNodes();
47+
for (i = 0; i < nodes.length; i++) {
4748
collapsed ? nodes[i].collapse() : nodes[i].expand();
48-
var subScope = nodes[i].$childNodesScope;
49+
subScope = nodes[i].$childNodesScope;
4950
if (subScope) {
5051
collapseOrExpand(subScope, collapsed);
5152
}
5253
}
5354
};
5455

55-
$scope.collapseAll = function() {
56+
$scope.collapseAll = function () {
5657
collapseOrExpand($scope.$nodesScope, true);
5758
};
5859

59-
$scope.expandAll = function() {
60+
$scope.expandAll = function () {
6061
collapseOrExpand($scope.$nodesScope, false);
6162
};
6263

source/directives/uiTree.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
var callbacks = {
1313
accept: null,
1414
beforeDrag: null
15-
};
15+
},
16+
config = {};
1617

17-
var config = {};
1818
angular.extend(config, treeConfig);
1919
if (config.treeClass) {
2020
element.addClass(config.treeClass);
@@ -32,37 +32,37 @@
3232
}, true);
3333

3434
scope.$watch(attrs.dragEnabled, function (val) {
35-
if ((typeof val) == "boolean") {
35+
if ((typeof val) == 'boolean') {
3636
scope.dragEnabled = val;
3737
}
3838
});
3939

4040
scope.$watch(attrs.emptyPlaceHolderEnabled, function (val) {
41-
if ((typeof val) == "boolean") {
41+
if ((typeof val) == 'boolean') {
4242
scope.emptyPlaceHolderEnabled = val;
4343
}
4444
});
4545

4646
scope.$watch(attrs.nodropEnabled, function (val) {
47-
if ((typeof val) == "boolean") {
47+
if ((typeof val) == 'boolean') {
4848
scope.nodropEnabled = val;
4949
}
5050
});
5151

5252
scope.$watch(attrs.cloneEnabled, function (val) {
53-
if ((typeof val) == "boolean") {
53+
if ((typeof val) == 'boolean') {
5454
scope.cloneEnabled = val;
5555
}
5656
});
5757

5858
scope.$watch(attrs.maxDepth, function (val) {
59-
if ((typeof val) == "number") {
59+
if ((typeof val) == 'number') {
6060
scope.maxDepth = val;
6161
}
6262
});
6363

6464
scope.$watch(attrs.dragDelay, function (val) {
65-
if ((typeof val) == "number") {
65+
if ((typeof val) == 'number') {
6666
scope.dragDelay = val;
6767
}
6868
});
@@ -109,7 +109,7 @@
109109
scope.$watch(attrs.uiTree, function (newVal, oldVal) {
110110
angular.forEach(newVal, function (value, key) {
111111
if (callbacks[key]) {
112-
if (typeof value === "function") {
112+
if (typeof value === 'function') {
113113
callbacks[key] = value;
114114
}
115115
}

source/directives/uiTreeHandle.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
'use strict';
33

44
angular.module('ui.tree')
5-
.directive('uiTreeHandle', [ 'treeConfig',
6-
function(treeConfig) {
5+
.directive('uiTreeHandle', ['treeConfig',
6+
function (treeConfig) {
77
return {
88
require: '^uiTreeNode',
99
restrict: 'A',
1010
scope: true,
1111
controller: 'TreeHandleController',
12-
link: function(scope, element, attrs, treeNodeCtrl) {
12+
link: function (scope, element, attrs, treeNodeCtrl) {
1313
var config = {};
1414
angular.extend(config, treeConfig);
1515
if (config.handleClass) {

0 commit comments

Comments
 (0)