Skip to content

Commit c43a12a

Browse files
committed
code style
1 parent 47218bd commit c43a12a

File tree

5 files changed

+36
-28
lines changed

5 files changed

+36
-28
lines changed

.jscsrc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"preset": "google",
3-
"validateIndentation": "\t",
2+
"preset": "node-style-guide",
3+
"validateIndentation": 4,
44
"maximumLineLength": 120,
55
"jsDoc": {
66
"checkAnnotations": {
@@ -10,5 +10,8 @@
1010
}
1111
}
1212
},
13-
"requireCamelCaseOrUpperCaseIdentifiers": true
13+
"requireCamelCaseOrUpperCaseIdentifiers": true,
14+
"validateLineBreaks": false,
15+
"requireTrailingComma": false,
16+
"excludeFiles": ["dist/*.js"]
1417
}

Gruntfile.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
module.exports = function (grunt) {
1+
module.exports = function(grunt) {
22
grunt.loadNpmTasks('grunt-sass');
33
grunt.loadNpmTasks('grunt-contrib-cssmin');
44
grunt.loadNpmTasks('grunt-contrib-copy');
55
grunt.loadNpmTasks('grunt-contrib-uglify');
66
grunt.loadNpmTasks('grunt-doctoc');
77
grunt.loadNpmTasks('grunt-contrib-jshint');
8+
grunt.loadNpmTasks('grunt-jscs');
89

910
grunt.initConfig({
1011
sass: {
@@ -54,14 +55,18 @@ module.exports = function (grunt) {
5455
removeAd: false
5556
},
5657
readme: {
57-
target: "./README.md"
58+
target: './README.md'
5859
}
5960
},
6061

6162
jshint: {
6263
all: ['src/*.js']
63-
}
64+
},
65+
66+
jscs: {
67+
all: ['*.js', 'src/*.js', ],
68+
},
6469
});
6570

66-
grunt.registerTask('default', ['sass', 'cssmin', 'copy', 'uglify', 'doctoc', 'jshint']);
71+
grunt.registerTask('default', ['sass', 'cssmin', 'copy', 'uglify', 'doctoc', 'jshint', 'jscs']);
6772
};

dist/gridstack.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
var obsolete = function(f, oldName, newName) {
2424
var wrapper = function() {
25-
console.warn('gridstack.js: Function `' + oldName + '` is deprecated as of v0.2.5 and has been replaced with `' +
26-
newName + '`. It will be **completely** removed in v1.0.');
25+
console.warn('gridstack.js: Function `' + oldName + '` is deprecated as of v0.2.5 and has been replaced ' +
26+
'with `' + newName + '`. It will be **completely** removed in v1.0.');
2727
return f.apply(this, arguments);
2828
};
2929
wrapper.prototype = f.prototype;
@@ -633,7 +633,7 @@
633633
};
634634

635635
GridStack.prototype._initStyles = function() {
636-
if (!this.opts.cellHeight) { //that will be handled by CSS
636+
if (!this.opts.cellHeight) { // That will be handled by CSS
637637
return ;
638638
}
639639
if (this._stylesId) {
@@ -660,7 +660,7 @@
660660
this._initStyles();
661661
this._updateContainerHeight();
662662
}
663-
if (!this.opts.cellHeight) { //the rest will be handled by CSS
663+
if (!this.opts.cellHeight) { // The rest will be handled by CSS
664664
return ;
665665
}
666666
if (this._styles._max !== 0 && maxHeight <= this._styles._max) {
@@ -669,12 +669,14 @@
669669

670670
if (!this.opts.verticalMargin || this.opts.cellHeightUnit === this.opts.verticalMarginUnit) {
671671
getHeight = function(nbRows, nbMargins) {
672-
return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) + self.opts.cellHeightUnit;
672+
return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) +
673+
self.opts.cellHeightUnit;
673674
};
674675
} else {
675676
getHeight = function(nbRows, nbMargins) {
676677
if (!nbRows || !nbMargins) {
677-
return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) + self.opts.cellHeightUnit;
678+
return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) +
679+
self.opts.cellHeightUnit;
678680
}
679681
return 'calc(' + ((self.opts.cellHeight * nbRows) + self.opts.cellHeightUnit) + ' + ' +
680682
((self.opts.verticalMargin * nbMargins) + self.opts.verticalMarginUnit) + ')';
@@ -1156,11 +1158,9 @@
11561158
if (typeof val == 'undefined') {
11571159
if (this.opts.cellHeight) {
11581160
return this.opts.cellHeight;
1159-
} else {
1160-
var o = this.container.children('.' + this.opts.itemClass).first();
1161-
return Math.ceil(o.outerHeight() / o.attr('data-gs-height'));
11621161
}
1163-
1162+
var o = this.container.children('.' + this.opts.itemClass).first();
1163+
return Math.ceil(o.outerHeight() / o.attr('data-gs-height'));
11641164
}
11651165
var heightData = parseHeight(val);
11661166

dist/gridstack.min.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.

src/gridstack.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
var obsolete = function(f, oldName, newName) {
2424
var wrapper = function() {
25-
console.warn('gridstack.js: Function `' + oldName + '` is deprecated as of v0.2.5 and has been replaced with `' +
26-
newName + '`. It will be **completely** removed in v1.0.');
25+
console.warn('gridstack.js: Function `' + oldName + '` is deprecated as of v0.2.5 and has been replaced ' +
26+
'with `' + newName + '`. It will be **completely** removed in v1.0.');
2727
return f.apply(this, arguments);
2828
};
2929
wrapper.prototype = f.prototype;
@@ -633,7 +633,7 @@
633633
};
634634

635635
GridStack.prototype._initStyles = function() {
636-
if (!this.opts.cellHeight) { //that will be handled by CSS
636+
if (!this.opts.cellHeight) { // That will be handled by CSS
637637
return ;
638638
}
639639
if (this._stylesId) {
@@ -660,7 +660,7 @@
660660
this._initStyles();
661661
this._updateContainerHeight();
662662
}
663-
if (!this.opts.cellHeight) { //the rest will be handled by CSS
663+
if (!this.opts.cellHeight) { // The rest will be handled by CSS
664664
return ;
665665
}
666666
if (this._styles._max !== 0 && maxHeight <= this._styles._max) {
@@ -669,12 +669,14 @@
669669

670670
if (!this.opts.verticalMargin || this.opts.cellHeightUnit === this.opts.verticalMarginUnit) {
671671
getHeight = function(nbRows, nbMargins) {
672-
return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) + self.opts.cellHeightUnit;
672+
return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) +
673+
self.opts.cellHeightUnit;
673674
};
674675
} else {
675676
getHeight = function(nbRows, nbMargins) {
676677
if (!nbRows || !nbMargins) {
677-
return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) + self.opts.cellHeightUnit;
678+
return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) +
679+
self.opts.cellHeightUnit;
678680
}
679681
return 'calc(' + ((self.opts.cellHeight * nbRows) + self.opts.cellHeightUnit) + ' + ' +
680682
((self.opts.verticalMargin * nbMargins) + self.opts.verticalMarginUnit) + ')';
@@ -1156,11 +1158,9 @@
11561158
if (typeof val == 'undefined') {
11571159
if (this.opts.cellHeight) {
11581160
return this.opts.cellHeight;
1159-
} else {
1160-
var o = this.container.children('.' + this.opts.itemClass).first();
1161-
return Math.ceil(o.outerHeight() / o.attr('data-gs-height'));
11621161
}
1163-
1162+
var o = this.container.children('.' + this.opts.itemClass).first();
1163+
return Math.ceil(o.outerHeight() / o.attr('data-gs-height'));
11641164
}
11651165
var heightData = parseHeight(val);
11661166

0 commit comments

Comments
 (0)