Skip to content

Commit e7370de

Browse files
author
Niels Dequeker
committed
Setup JSCS configuration
1 parent 3a38e71 commit e7370de

File tree

8 files changed

+126
-111
lines changed

8 files changed

+126
-111
lines changed

.jscsrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"requireSpaceAfterKeywords": [
3+
"do",
4+
"for",
5+
"if",
6+
"else",
7+
"switch",
8+
"case",
9+
"try",
10+
"catch",
11+
"void",
12+
"while",
13+
"with",
14+
"return",
15+
"typeof",
16+
"function"
17+
]
18+
}

source/controllers/handleCtrl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
angular.module('ui.tree')
55

6-
.controller('TreeHandleController', ['$scope', '$element', '$attrs', 'treeConfig',
7-
function ($scope, $element, $attrs, treeConfig) {
6+
.controller('TreeHandleController', ['$scope', '$element',
7+
function ($scope, $element) {
88
this.scope = $scope;
99

1010
$scope.$element = $element;

source/controllers/nodeCtrl.js

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

44
angular.module('ui.tree')
5-
6-
.controller('TreeNodeController', ['$scope', '$element', '$attrs', 'treeConfig',
7-
function ($scope, $element, $attrs, treeConfig) {
5+
.controller('TreeNodeController', ['$scope', '$element',
6+
function ($scope, $element) {
87
this.scope = $scope;
98

109
$scope.$element = $element;
@@ -15,8 +14,7 @@
1514
$scope.$treeScope = null; // uiTree scope
1615
$scope.$handleScope = null; // it's handle scope
1716
$scope.$type = 'uiTreeNode';
18-
$scope.$$apply = false; //
19-
17+
$scope.$$apply = false;
2018
$scope.collapsed = false;
2119

2220
$scope.init = function(controllersArr) {

source/controllers/nodesCtrl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
angular.module('ui.tree')
55

6-
.controller('TreeNodesController', ['$scope', '$element', 'treeConfig',
7-
function ($scope, $element, treeConfig) {
6+
.controller('TreeNodesController', ['$scope', '$element',
7+
function ($scope, $element) {
88
this.scope = $scope;
99

1010
$scope.$element = $element;

source/controllers/treeCtrl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
angular.module('ui.tree')
55

6-
.controller('TreeController', ['$scope', '$element', '$attrs', 'treeConfig',
7-
function ($scope, $element, $attrs, treeConfig) {
6+
.controller('TreeController', ['$scope', '$element',
7+
function ($scope, $element) {
88
this.scope = $scope;
99

1010
$scope.$element = $element;

source/directives/uiTree.js

Lines changed: 96 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -2,126 +2,125 @@
22
'use strict';
33

44
angular.module('ui.tree')
5-
.directive('uiTree', [ 'treeConfig', '$window',
6-
function(treeConfig, $window) {
7-
return {
8-
restrict: 'A',
9-
scope: true,
10-
controller: 'TreeController',
11-
link: function(scope, element, attrs) {
12-
var callbacks = {
13-
accept: null,
14-
beforeDrag: null
15-
};
16-
17-
var config = {};
18-
angular.extend(config, treeConfig);
19-
if (config.treeClass) {
20-
element.addClass(config.treeClass);
21-
}
22-
23-
scope.$emptyElm = angular.element($window.document.createElement('div'));
24-
if (config.emptyTreeClass) {
25-
scope.$emptyElm.addClass(config.emptyTreeClass);
26-
}
27-
28-
scope.$watch('$nodesScope.$modelValue.length', function() {
29-
if (scope.$nodesScope.$modelValue) {
30-
scope.resetEmptyElement();
5+
.directive('uiTree', ['treeConfig', '$window',
6+
function (treeConfig, $window) {
7+
return {
8+
restrict: 'A',
9+
scope: true,
10+
controller: 'TreeController',
11+
link: function (scope, element, attrs) {
12+
var callbacks = {
13+
accept: null,
14+
beforeDrag: null
15+
};
16+
17+
var config = {};
18+
angular.extend(config, treeConfig);
19+
if (config.treeClass) {
20+
element.addClass(config.treeClass);
3121
}
32-
}, true);
3322

34-
scope.$watch(attrs.dragEnabled, function(val) {
35-
if((typeof val) == "boolean") {
36-
scope.dragEnabled = val;
23+
scope.$emptyElm = angular.element($window.document.createElement('div'));
24+
if (config.emptyTreeClass) {
25+
scope.$emptyElm.addClass(config.emptyTreeClass);
3726
}
38-
});
3927

40-
scope.$watch(attrs.emptyPlaceHolderEnabled, function(val) {
41-
if((typeof val) == "boolean") {
42-
scope.emptyPlaceHolderEnabled = val;
43-
}
44-
});
28+
scope.$watch('$nodesScope.$modelValue.length', function () {
29+
if (scope.$nodesScope.$modelValue) {
30+
scope.resetEmptyElement();
31+
}
32+
}, true);
4533

46-
scope.$watch(attrs.nodropEnabled, function(val) {
47-
if((typeof val) == "boolean") {
48-
scope.nodropEnabled = val;
49-
}
50-
});
34+
scope.$watch(attrs.dragEnabled, function (val) {
35+
if ((typeof val) == "boolean") {
36+
scope.dragEnabled = val;
37+
}
38+
});
5139

52-
scope.$watch(attrs.cloneEnabled, function(val) {
53-
if((typeof val) == "boolean") {
54-
scope.cloneEnabled = val;
55-
}
56-
});
40+
scope.$watch(attrs.emptyPlaceHolderEnabled, function (val) {
41+
if ((typeof val) == "boolean") {
42+
scope.emptyPlaceHolderEnabled = val;
43+
}
44+
});
5745

58-
scope.$watch(attrs.maxDepth, function(val) {
59-
if((typeof val) == "number") {
60-
scope.maxDepth = val;
61-
}
62-
});
46+
scope.$watch(attrs.nodropEnabled, function (val) {
47+
if ((typeof val) == "boolean") {
48+
scope.nodropEnabled = val;
49+
}
50+
});
6351

64-
scope.$watch(attrs.dragDelay, function(val) {
65-
if((typeof val) == "number") {
66-
scope.dragDelay = val;
67-
}
68-
});
69-
70-
// check if the dest node can accept the dragging node
71-
// by default, we check the 'data-nodrop-enabled' attribute in `ui-tree-nodes`
72-
// and the 'max-depth' attribute in `ui-tree` or `ui-tree-nodes`.
73-
// the method can be overrided
74-
callbacks.accept = function(sourceNodeScope, destNodesScope, destIndex) {
75-
if (destNodesScope.nodropEnabled || destNodesScope.outOfDepth(sourceNodeScope)) {
76-
return false;
77-
}
78-
return true;
79-
};
52+
scope.$watch(attrs.cloneEnabled, function (val) {
53+
if ((typeof val) == "boolean") {
54+
scope.cloneEnabled = val;
55+
}
56+
});
8057

81-
callbacks.beforeDrag = function(sourceNodeScope) {
82-
return true;
83-
};
58+
scope.$watch(attrs.maxDepth, function (val) {
59+
if ((typeof val) == "number") {
60+
scope.maxDepth = val;
61+
}
62+
});
8463

85-
callbacks.removed = function(node){
86-
87-
};
64+
scope.$watch(attrs.dragDelay, function (val) {
65+
if ((typeof val) == "number") {
66+
scope.dragDelay = val;
67+
}
68+
});
8869

89-
callbacks.dropped = function(event) {
70+
// check if the dest node can accept the dragging node
71+
// by default, we check the 'data-nodrop-enabled' attribute in `ui-tree-nodes`
72+
// and the 'max-depth' attribute in `ui-tree` or `ui-tree-nodes`.
73+
// the method can be overrided
74+
callbacks.accept = function (sourceNodeScope, destNodesScope, destIndex) {
75+
if (destNodesScope.nodropEnabled || destNodesScope.outOfDepth(sourceNodeScope)) {
76+
return false;
77+
}
78+
return true;
79+
};
9080

91-
};
81+
callbacks.beforeDrag = function (sourceNodeScope) {
82+
return true;
83+
};
9284

93-
//
94-
callbacks.dragStart = function(event) {
85+
callbacks.removed = function (node) {
9586

96-
};
87+
};
9788

98-
callbacks.dragMove = function(event) {
89+
callbacks.dropped = function (event) {
9990

100-
};
91+
};
10192

102-
callbacks.dragStop = function(event) {
93+
callbacks.dragStart = function (event) {
10394

104-
};
95+
};
10596

106-
callbacks.beforeDrop = function(event) {
97+
callbacks.dragMove = function (event) {
10798

108-
};
99+
};
109100

110-
scope.$watch(attrs.uiTree, function(newVal, oldVal){
111-
angular.forEach(newVal, function(value, key){
112-
if (callbacks[key]) {
113-
if (typeof value === "function") {
114-
callbacks[key] = value;
101+
callbacks.dragStop = function (event) {
102+
103+
};
104+
105+
callbacks.beforeDrop = function (event) {
106+
107+
};
108+
109+
scope.$watch(attrs.uiTree, function (newVal, oldVal) {
110+
angular.forEach(newVal, function (value, key) {
111+
if (callbacks[key]) {
112+
if (typeof value === "function") {
113+
callbacks[key] = value;
114+
}
115115
}
116-
}
117-
});
116+
});
118117

119-
scope.$callbacks = callbacks;
120-
}, true);
118+
scope.$callbacks = callbacks;
119+
}, true);
121120

122121

123-
}
124-
};
125-
}
126-
]);
122+
}
123+
};
124+
}
125+
]);
127126
})();

source/directives/uiTreeHandle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'use strict';
33

44
angular.module('ui.tree')
5-
.directive('uiTreeHandle', [ 'treeConfig', '$window',
5+
.directive('uiTreeHandle', [ 'treeConfig',
66
function(treeConfig) {
77
return {
88
require: '^uiTreeNode',

tasks/scripts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module.exports = function (gulp, $) {
88
});
99

1010
gulp.task('jscs', function () {
11-
return gulp.src('source')
12-
.pipe($.jscs({}));
11+
return gulp.src('source/**/*.js')
12+
.pipe($.jscs());
1313
});
1414

1515
gulp.task('jshint', function () {

0 commit comments

Comments
 (0)