Skip to content

Commit dbca0ff

Browse files
author
Kevin Dietrich
committed
Use jscs
1 parent 4851853 commit dbca0ff

7 files changed

Lines changed: 282 additions & 260 deletions

File tree

.jscsrc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"preset": "node-style-guide",
3+
"validateIndentation": 2,
4+
"maximumLineLength": 120,
5+
"jsDoc": {
6+
"checkAnnotations": {
7+
"preset": "jsdoc3",
8+
"extra": {
9+
"preserve": true
10+
}
11+
}
12+
},
13+
"requireCamelCaseOrUpperCaseIdentifiers": true,
14+
"validateLineBreaks": false,
15+
"requireTrailingComma": false,
16+
"requireSpaceAfterKeywords": false,
17+
"disallowTrailingWhitespace": true,
18+
"requireCapitalizedComments": false,
19+
"excludeFiles": ["dist/*.js", "demo/*"]
20+
}

dist/gridstack-angular.js

Lines changed: 131 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -6,163 +6,161 @@
66
* @license MIT
77
*/
88
(function() {
9-
'use strict';
9+
'use strict';
1010

11-
angular.module('gridstack-angular', []);
11+
angular.module('gridstack-angular', []);
1212

13-
var app = angular.module('gridstack-angular');
13+
var app = angular.module('gridstack-angular');
1414

15-
/** @ngInject */
16-
app.controller('GridstackController', ['$scope', function($scope) {
15+
app.controller('GridstackController', ['$scope', function($scope) {
1716

18-
var gridstack = null;
17+
var gridstack = null;
1918

20-
this.init = function(element, options) {
21-
gridstack = element.gridstack(options).data('gridstack');
22-
return gridstack;
23-
};
19+
this.init = function(element, options) {
20+
gridstack = element.gridstack(options).data('gridstack');
21+
return gridstack;
22+
};
2423

25-
this.removeItem = function(element) {
26-
if(gridstack) {
27-
return gridstack.removeWidget(element, false);
28-
}
29-
return null;
30-
};
24+
this.removeItem = function(element) {
25+
if(gridstack) {
26+
return gridstack.removeWidget(element, false);
27+
}
28+
return null;
29+
};
3130

32-
this.addItem = function(element) {
33-
if(gridstack) {
34-
gridstack.makeWidget(element);
35-
return element;
36-
}
37-
return null;
38-
};
31+
this.addItem = function(element) {
32+
if(gridstack) {
33+
gridstack.makeWidget(element);
34+
return element;
35+
}
36+
return null;
37+
};
3938

40-
}]);
39+
}]);
4140
})();
4241
(function() {
43-
'use strict';
44-
45-
var app = angular.module('gridstack-angular');
46-
47-
/** @ngInject */
48-
app.directive('gridstack', ['$timeout', function($timeout) {
49-
50-
return {
51-
restrict: "A",
52-
controller: 'GridstackController',
53-
scope: {
54-
onChange: '&',
55-
onDragStart: '&',
56-
onDragStop: '&',
57-
onResizeStart: '&',
58-
onResizeStop: '&',
59-
gridstackHandler: '=',
60-
options: '='
61-
},
62-
link: function (scope, element, attrs, controller, ngModel) {
63-
64-
var gridstack = controller.init(element, scope.options);
65-
scope.gridstackHandler = gridstack;
66-
67-
element.on('change', function (e, items) {
68-
$timeout(function() {
69-
scope.$apply();
70-
scope.onChange({event: e, items: items});
71-
});
42+
'use strict';
43+
44+
var app = angular.module('gridstack-angular');
45+
46+
app.directive('gridstack', ['$timeout', function($timeout) {
47+
48+
return {
49+
restrict: 'A',
50+
controller: 'GridstackController',
51+
scope: {
52+
onChange: '&',
53+
onDragStart: '&',
54+
onDragStop: '&',
55+
onResizeStart: '&',
56+
onResizeStop: '&',
57+
gridstackHandler: '=',
58+
options: '='
59+
},
60+
link: function(scope, element, attrs, controller, ngModel) {
61+
62+
var gridstack = controller.init(element, scope.options);
63+
scope.gridstackHandler = gridstack;
64+
65+
element.on('change', function(e, items) {
66+
$timeout(function() {
67+
scope.$apply();
68+
scope.onChange({event: e, items: items});
7269
});
70+
});
7371

74-
element.on('dragstart', function(e, ui) {
75-
scope.onDragStart({event: e, ui: ui});
76-
});
72+
element.on('dragstart', function(e, ui) {
73+
scope.onDragStart({event: e, ui: ui});
74+
});
7775

78-
element.on('dragstop', function(e, ui) {
79-
$timeout(function() {
80-
scope.$apply();
81-
scope.onDragStop({event: e, ui: ui});
82-
});
76+
element.on('dragstop', function(e, ui) {
77+
$timeout(function() {
78+
scope.$apply();
79+
scope.onDragStop({event: e, ui: ui});
8380
});
81+
});
8482

85-
element.on('resizestart', function(e, ui) {
86-
scope.onResizeStart({event: e, ui: ui});
87-
});
83+
element.on('resizestart', function(e, ui) {
84+
scope.onResizeStart({event: e, ui: ui});
85+
});
8886

89-
element.on('resizestop', function(e, ui) {
90-
$timeout(function() {
91-
scope.$apply();
92-
scope.onResizeStop({event: e, ui: ui});
93-
});
87+
element.on('resizestop', function(e, ui) {
88+
$timeout(function() {
89+
scope.$apply();
90+
scope.onResizeStop({event: e, ui: ui});
9491
});
92+
});
9593

96-
}
97-
};
94+
}
95+
};
9896

99-
}]);
97+
}]);
10098
})();
10199

102100
(function() {
103-
'use strict';
104-
105-
var app = angular.module('gridstack-angular');
106-
107-
/** @ngInject */
108-
app.directive('gridstackItem', ['$timeout', function($timeout) {
109-
110-
return {
111-
restrict: "A",
112-
controller: 'GridstackController',
113-
require: '^gridstack',
114-
scope: {
115-
gridstackItem: '=',
116-
onItemAdded: '&',
117-
onItemRemoved: '&',
118-
gsItemId: '=',
119-
gsItemX: '=',
120-
gsItemY: '=',
121-
gsItemWidth: '=',
122-
gsItemHeight: '=',
123-
gsItemAutopos: '='
124-
},
125-
link: function (scope, element, attrs, controller) {
126-
$(element).attr('data-gs-id', scope.gsItemId);
127-
$(element).attr('data-gs-x', scope.gsItemX);
128-
$(element).attr('data-gs-y', scope.gsItemY);
129-
$(element).attr('data-gs-width', scope.gsItemWidth);
130-
$(element).attr('data-gs-height', scope.gsItemHeight);
131-
$(element).attr('data-gs-auto-position', scope.gsItemAutopos);
132-
var widget = controller.addItem(element);
101+
'use strict';
102+
103+
var app = angular.module('gridstack-angular');
104+
105+
app.directive('gridstackItem', ['$timeout', function($timeout) {
106+
107+
return {
108+
restrict: 'A',
109+
controller: 'GridstackController',
110+
require: '^gridstack',
111+
scope: {
112+
gridstackItem: '=',
113+
onItemAdded: '&',
114+
onItemRemoved: '&',
115+
gsItemId: '=',
116+
gsItemX: '=',
117+
gsItemY: '=',
118+
gsItemWidth: '=',
119+
gsItemHeight: '=',
120+
gsItemAutopos: '='
121+
},
122+
link: function(scope, element, attrs, controller) {
123+
$(element).attr('data-gs-id', scope.gsItemId);
124+
$(element).attr('data-gs-x', scope.gsItemX);
125+
$(element).attr('data-gs-y', scope.gsItemY);
126+
$(element).attr('data-gs-width', scope.gsItemWidth);
127+
$(element).attr('data-gs-height', scope.gsItemHeight);
128+
$(element).attr('data-gs-auto-position', scope.gsItemAutopos);
129+
var widget = controller.addItem(element);
130+
var item = element.data('_gridstack_node');
131+
$timeout(function() {
132+
scope.onItemAdded({item: item});
133+
});
134+
135+
scope.$watch(function() { return $(element).attr('data-gs-id'); }, function(val) {
136+
scope.gsItemId = val;
137+
});
138+
139+
scope.$watch(function() { return $(element).attr('data-gs-x'); }, function(val) {
140+
scope.gsItemX = val;
141+
});
142+
143+
scope.$watch(function() { return $(element).attr('data-gs-y'); }, function(val) {
144+
scope.gsItemY = val;
145+
});
146+
147+
scope.$watch(function() { return $(element).attr('data-gs-width'); }, function(val) {
148+
scope.gsItemWidth = val;
149+
});
150+
151+
scope.$watch(function() { return $(element).attr('data-gs-height'); }, function(val) {
152+
scope.gsItemHeight = val;
153+
});
154+
155+
element.bind('$destroy', function() {
133156
var item = element.data('_gridstack_node');
134-
$timeout(function() {
135-
scope.onItemAdded({item: item});
136-
});
137-
138-
scope.$watch(function () { return $(element).attr('data-gs-id'); }, function (val) {
139-
scope.gsItemId = val;
140-
});
141-
scope.$watch(function(){ return $(element).attr('data-gs-x'); }, function(val) {
142-
scope.gsItemX = val;
143-
});
144-
145-
scope.$watch(function(){ return $(element).attr('data-gs-y'); }, function(val) {
146-
scope.gsItemY = val;
147-
});
148-
149-
scope.$watch(function(){ return $(element).attr('data-gs-width'); }, function(val) {
150-
scope.gsItemWidth = val;
151-
});
152-
153-
scope.$watch(function(){ return $(element).attr('data-gs-height'); }, function(val) {
154-
scope.gsItemHeight = val;
155-
});
156-
157-
element.bind('$destroy', function() {
158-
var item = element.data('_gridstack_node');
159-
scope.onItemRemoved({item: item});
160-
controller.removeItem(element);
161-
});
157+
scope.onItemRemoved({item: item});
158+
controller.removeItem(element);
159+
});
162160

163-
}
161+
}
164162

165-
};
163+
};
166164

167-
}]);
165+
}]);
168166
})();

gulpfile.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
var gulp = require('gulp');
44
var clean = require('gulp-clean');
55
var jshint = require('gulp-jshint');
6+
var jscs = require('gulp-jscs');
67
var concat = require('gulp-concat');
78
var uglify = require('gulp-uglify');
89
var header = require('gulp-header');
@@ -37,6 +38,8 @@ gulp.task('scripts', ['clean'], function() {
3738
gulp.src(paths.scripts, {cwd: bases.app})
3839
.pipe(jshint())
3940
.pipe(jshint.reporter('default'))
41+
.pipe(jscs())
42+
.pipe(jscs.reporter())
4043
.pipe(uglify())
4144
.pipe(concat('gridstack-angular.min.js'))
4245
.pipe(header(banner, { pkg : pkg } ))

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@
1919
"bugs": {
2020
"url": "https://github.com/kdietrich/gridstack-angular/issues"
2121
},
22-
"homepage": "https://github.com/kdietrich/gridstack-angular#readme"
22+
"homepage": "https://github.com/kdietrich/gridstack-angular#readme",
23+
"dependencies": {
24+
"gulp-jscs": "^4.0.0"
25+
}
2326
}

0 commit comments

Comments
 (0)