Skip to content

Commit 513d5bb

Browse files
committed
Update files to match jscs rules
1 parent 81cdecc commit 513d5bb

18 files changed

+87
-125
lines changed

gulp/tasks/default.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var gulp = require('gulp');
22

33
gulp.task('default', [
4-
'minify'
4+
'jscs'
55
]);

gulp/tasks/minify.js

-30
This file was deleted.

package.json

-7
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,7 @@
4444
"chai": "^3.5.0",
4545
"coveralls": "^2.11.0",
4646
"gulp": "^3.5.6",
47-
"gulp-angular-templatecache": "^1.2.1",
48-
"gulp-concat": "^2.2.0",
4947
"gulp-jscs": "^1.1.0",
50-
"gulp-minify-html": "^0.1.1",
51-
"gulp-protractor": "^1.0.0",
52-
"gulp-rename": "^1.2.0",
53-
"gulp-uglify": "^0.2.1",
54-
"gulp-umd": "^0.1.3",
5548
"json-schema-form-core": "git://github.com/json-schema-form/json-schema-form-core.git#develop",
5649
"karma": "^0.13.22",
5750
"karma-chai-sinon": "^0.1.5",

src/directives/WHERE_ARE_THE_DECORATORS.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ Hi there,
33
as you probably have noticed the `decorators` folder and the bootstrap decorator has
44
been removed. This is intentional. Each decorator has it's own repo.
55

6-
Material: https://github.com/Textalk/angular-schema-form-material
7-
Bootstrap: https://github.com/Textalk/angular-schema-form-bootstrap
6+
Material: https://github.com/json-schema-form/angular-schema-form-material
7+
Bootstrap: https://github.com/json-schema-form/angular-schema-form-bootstrap

src/directives/array.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,15 @@ export default function(sfSelect, schemaForm, sfValidator, sfPath) {
2828
// most notably for errors.
2929
// So we emit it up to the decorator directive so it can put it on scope.
3030
scope.$emit('schemaFormPropagateNgModelController', ngModel);
31-
}
32-
31+
};
3332

3433
// Watch for the form definition and then rewrite it.
3534
// It's the (first) array part of the key, '[]' that needs a number
3635
// corresponding to an index of the form.
3736
var once = scope.$watch(attrs.sfArray, function(form) {
3837
if (!form) {
3938
return;
40-
}
41-
39+
};
4240

4341
// An array model always needs a key so we know what part of the model
4442
// to look at. This makes us a bit incompatible with JSON Form, on the

src/directives/changed.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function() {
2121
if (angular.isFunction(form.onChange)) {
2222
form.onChange(ctrl.$modelValue, form);
2323
} else {
24-
scope.evalExpr(form.onChange, {'modelValue': ctrl.$modelValue, form: form});
24+
scope.evalExpr(form.onChange, { 'modelValue': ctrl.$modelValue, form: form });
2525
}
2626
});
2727
}

src/directives/field.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ sfPath, sfSelect) {
7979
/**
8080
* Evaluate an expression, i.e. scope.$eval
8181
* in this decorators scope
82+
*
8283
* @param {string} expression
8384
* @param {Object} locals (optional)
8485
* @return {Any} the result of the expression
@@ -98,7 +99,7 @@ sfPath, sfSelect) {
9899
* Use the Angular `{{ interpolation }}`
99100
* braces to access properties on `locals`.
100101
*
101-
* @param {string} content The string to interpolate.
102+
* @param {string} expression The string to interpolate.
102103
* @param {Object} locals (optional) Properties that may be accessed in the
103104
* `expression` string.
104105
* @return {Any} The result of the expression or `undefined`.

src/directives/message.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default function($injector, sfErrorMessage) {
7373
// Update once.
7474
update();
7575

76-
var once = scope.$watch('ngModel',function(ngModel) {
76+
var once = scope.$watch('ngModel', function(ngModel) {
7777
if (ngModel) {
7878
// We also listen to changes of the model via parsers and formatters.
7979
// This is since both the error message can change and given a pristine

src/directives/newArray.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default function(sel, sfPath, schemaForm) {
3232
if (angular.isFunction(scope.form.onChange)) {
3333
scope.form.onChange(scope.modelArray, scope.form);
3434
} else {
35-
scope.evalExpr(scope.form.onChange, {'modelValue': scope.modelArray, form: scope.form});
35+
scope.evalExpr(scope.form.onChange, { 'modelValue': scope.modelArray, form: scope.form });
3636
}
3737
}
3838
};
@@ -66,13 +66,13 @@ export default function(sel, sfPath, schemaForm) {
6666
scope.$watch(attrs.sfNewArray, watchFn, true);
6767

6868
// We still need to trigger onChange though.
69-
scope.$watch([attrs.sfNewArray, attrs.sfNewArray + '.length'], onChangeFn);
69+
scope.$watch([ attrs.sfNewArray, attrs.sfNewArray + '.length' ], onChangeFn);
7070

7171
} else {
7272
// Otherwise we like to check if the instance of the array has changed, or if something
7373
// has been added/removed.
7474
if (scope.$watchGroup) {
75-
scope.$watchGroup([attrs.sfNewArray, attrs.sfNewArray + '.length'], function() {
75+
scope.$watchGroup([ attrs.sfNewArray, attrs.sfNewArray + '.length' ], function() {
7676
watchFn();
7777
onChangeFn();
7878
});
@@ -121,12 +121,15 @@ export default function(sel, sfPath, schemaForm) {
121121
if (vals && vals !== old) {
122122
var arr = getOrCreateModel();
123123

124-
form.titleMap.forEach(function (item, index) {
124+
form.titleMap.forEach(function(item, index) {
125125
var arrIndex = arr.indexOf(item.value);
126-
if (arrIndex === -1 && vals[index])
126+
if (arrIndex === -1 && vals[index]) {
127127
arr.push(item.value);
128-
if (arrIndex !== -1 && !vals[index])
128+
};
129+
130+
if (arrIndex !== -1 && !vals[index]) {
129131
arr.splice(arrIndex, 1);
132+
};
130133
});
131134
// Time to validate the rebuilt array.
132135
// validateField method is exported by schema-validate

src/directives/schemaForm.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FIXME: real documentation
55
<form sf-form="form" sf-schema="schema" sf-decorator="foobar"></form>
66
*/
77

8-
export default function($compile, $http, $templateCache, $q, schemaForm, schemaFormDecorators,
8+
export default function($compile, $http, $templateCache, $q, schemaForm, schemaFormDecorators,
99
sfSelect, sfPath, sfBuilder) {
1010

1111
return {
@@ -15,7 +15,7 @@ sfSelect, sfPath, sfBuilder) {
1515
model: '=sfModel',
1616
options: '=sfOptions'
1717
},
18-
controller: ['$scope', function($scope) {
18+
controller: [ '$scope', function($scope) {
1919
this.evalInParentScope = function(expr, locals) {
2020
return $scope.$parent.$eval(expr, locals);
2121
};
@@ -71,7 +71,7 @@ sfSelect, sfPath, sfBuilder) {
7171
if (asyncTemplates.length > 0) {
7272
// Pre load all async templates and put them on the form for the builder to use.
7373
$q.all(asyncTemplates.map(function(form) {
74-
return $http.get(form.templateUrl, {cache: $templateCache}).then(function(res) {
74+
return $http.get(form.templateUrl, { cache: $templateCache }).then(function(res) {
7575
form.template = res.data;
7676
});
7777
})).then(function() {
@@ -80,9 +80,7 @@ sfSelect, sfPath, sfBuilder) {
8080

8181
} else {
8282
internalRender(schema, form, merged);
83-
}
84-
85-
83+
};
8684
};
8785

8886
var internalRender = function(schema, form, merged) {
@@ -95,11 +93,11 @@ sfSelect, sfPath, sfBuilder) {
9593
scope.externalDestructionInProgress = true;
9694
childScope.$destroy();
9795
scope.externalDestructionInProgress = false;
98-
}
96+
};
9997
childScope = scope.$new();
10098

10199
//make the form available to decorators
102-
childScope.schemaForm = {form: merged, schema: schema};
100+
childScope.schemaForm = { form: merged, schema: schema };
103101

104102
//clean all but pre existing html.
105103
element.children(':not(.schema-form-ignore)').remove();
@@ -146,7 +144,7 @@ sfSelect, sfPath, sfBuilder) {
146144
scope.$emit('sf-render-finished', element);
147145
};
148146

149-
var defaultForm = ['*'];
147+
var defaultForm = [ '*' ];
150148

151149
//Since we are dependant on up to three
152150
//attributes we'll do a common watch
@@ -170,7 +168,7 @@ sfSelect, sfPath, sfBuilder) {
170168
// part of the form or schema is chnaged without it being a new instance.
171169
scope.$on('schemaFormRedraw', function() {
172170
var schema = scope.schema;
173-
var form = scope.initialForm ? angular.copy(scope.initialForm) : ['*'];
171+
var form = scope.initialForm ? angular.copy(scope.initialForm) : [ '*' ];
174172
if (schema) {
175173
render(schema, form);
176174
}

src/directives/schemaValidate.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export default function(sfValidator, $parse, sfSelect) {
2727
});
2828
};
2929

30-
3130
// Validate against the schema.
3231

3332
var validate = function(viewValue) {
@@ -73,15 +72,15 @@ export default function(sfValidator, $parse, sfSelect) {
7372
form.ngModel(ngModel);
7473
}
7574

76-
['$parsers', '$viewChangeListeners', '$formatters'].forEach(function(attr) {
75+
[ '$parsers', '$viewChangeListeners', '$formatters' ].forEach(function(attr) {
7776
if (form[attr] && ngModel[attr]) {
7877
form[attr].forEach(function(fn) {
7978
ngModel[attr].push(fn);
8079
});
8180
}
8281
});
8382

84-
['$validators', '$asyncValidators'].forEach(function(attr) {
83+
[ '$validators', '$asyncValidators' ].forEach(function(attr) {
8584
// Check if our version of angular has validators, i.e. 1.3+
8685
if (form[attr] && ngModel[attr]) {
8786
angular.forEach(form[attr], function(fn, name) {

src/module.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import validator from './services/validator';
88
import errors from './services/errors';
99
import sfPath from './services/sfPath';
1010

11-
1211
import array from './directives/array';
1312
import changed from './directives/changed';
1413
import field from './directives/field';
@@ -42,21 +41,21 @@ try {
4241
angular.module('schemaForm', deps)
4342
// Providers and services
4443
.provider('sfPath', sfPath)
45-
.provider('sfBuilder', ['sfPathProvider', sfBuilder])
46-
.provider('schemaFormDecorators', ['$compileProvider', 'sfPathProvider', decorators])
44+
.provider('sfBuilder', [ 'sfPathProvider', sfBuilder ])
45+
.provider('schemaFormDecorators', [ '$compileProvider', 'sfPathProvider', decorators ])
4746
.provider('sfErrorMessage', errors)
48-
.provider('schemaForm', ['sfPathProvider', schemaForm])
49-
.factory('sfSelect',() => select)
47+
.provider('schemaForm', [ 'sfPathProvider', schemaForm ])
48+
.factory('sfSelect', () => select)
5049
.factory('sfValidator', validator)
5150

5251
// Directives
53-
.directive('sfArray', ['sfSelect', 'schemaForm', 'sfValidator', 'sfPath', array])
52+
.directive('sfArray', [ 'sfSelect', 'schemaForm', 'sfValidator', 'sfPath', array ])
5453
.directive('sfChanged', changed)
55-
.directive('sfField', ['$parse', '$compile', '$http', '$templateCache', '$interpolate', '$q',
56-
'sfErrorMessage','sfPath','sfSelect', field])
57-
.directive('sfMessage', ['$injector', 'sfErrorMessage', message])
58-
.directive('sfNewArray', ['sfSelect', 'sfPath', 'schemaForm', newArray])
59-
.directive('sfSchema', ['$compile', '$http', '$templateCache', '$q', 'schemaForm',
54+
.directive('sfField', [ '$parse', '$compile', '$http', '$templateCache', '$interpolate', '$q',
55+
'sfErrorMessage','sfPath','sfSelect', field ])
56+
.directive('sfMessage', [ '$injector', 'sfErrorMessage', message ])
57+
.directive('sfNewArray', [ 'sfSelect', 'sfPath', 'schemaForm', newArray ])
58+
.directive('sfSchema', [ '$compile', '$http', '$templateCache', '$q', 'schemaForm',
6059
'schemaFormDecorators', 'sfSelect', 'sfPath', 'sfBuilder',
61-
schemaFormDirective])
62-
.directive('schemaValidate', ['sfValidator', '$parse', 'sfSelect', schemaValidate]);
60+
schemaFormDirective ])
61+
.directive('schemaValidate', [ 'sfValidator', '$parse', 'sfSelect', schemaValidate ]);

src/services/builder.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,14 @@ export default function(sfPathProvider) {
173173

174174
if (maximum !== false) {
175175
if (exclusiveMaximum !== false && multipleOf !== false) {
176-
maximum = maximum-multipleOf;
176+
maximum = maximum - multipleOf;
177177
};
178178
inputFrag.setAttribute('max', maximum);
179179
};
180180

181181
if (minimum !== false) {
182182
if (exclusiveMinimum !== false && multipleOf !== false) {
183-
minimum = minimum+multipleOf;
183+
minimum = minimum + multipleOf;
184184
};
185185
inputFrag.setAttribute('min', minimum);
186186
};

0 commit comments

Comments
 (0)