Skip to content

Commit 4f4a9bb

Browse files
committed
Changing all indentation to 2 spaces as per style guide. #6
1 parent 7d92190 commit 4f4a9bb

File tree

6 files changed

+114
-112
lines changed

6 files changed

+114
-112
lines changed

.jshintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"curly": true,
88
"eqeqeq": true,
99
"immed": true,
10-
"indent": 4,
10+
"indent": 2,
1111
"latedef": true,
1212
"newcap": true,
1313
"noarg": true,
14-
"quotmark": "double",
14+
"quotmark": "single",
1515
"regexp": true,
1616
"undef": true,
1717
"unused": true,

ChangeLog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
## 0.0.1
44

5-
First version of the basic validtion in Angular with Bootstrap like jQuery.
5+
First version of the basic validation in Angular with Bootstrap like jQuery.

Gruntfile.js

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,51 @@
11
/* global module:false */
22

3-
"use strict";
3+
'use strict';
44

55
module.exports = function (grunt) {
6-
var yeomanConfig;
7-
require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks);
8-
yeomanConfig = {
9-
src: "src",
10-
dist: "dist"
11-
};
12-
return grunt.initConfig({
13-
yeoman: yeomanConfig,
14-
uglify: {
15-
build: {
16-
src: ["<%=yeoman.src %>/app.js", "<%=yeoman.src %>/**/*.js"],
17-
dest: "<%=yeoman.dist %>/bootstrap-angular-validation.min.js"
18-
}
19-
},
20-
bump: {
21-
options: {
22-
files: ["package.json"],
23-
updateConfigs: [],
24-
commit: true,
25-
commitMessage: "Release v%VERSION%",
26-
commitFiles: ["package.json"],
27-
createTag: true,
28-
tagName: "v%VERSION%",
29-
tagMessage: "Version %VERSION%",
30-
push: true,
31-
pushTo: "origin",
32-
gitDescribeOptions: "--tags --always --abbrev=1 --dirty=-d",
33-
globalReplace: false,
34-
prereleaseName: false,
35-
metadata: "",
36-
regExp: false
37-
}
38-
},
39-
watch: {
40-
scripts: {
41-
files: ["<%=yeoman.src %>/**/*.js"],
42-
tasks: ["uglify"],
43-
options: {
44-
spawn: false
45-
}
46-
}
6+
var yeomanConfig;
7+
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
8+
9+
yeomanConfig = {
10+
src: 'src',
11+
dist: 'dist'
12+
};
13+
14+
return grunt.initConfig({
15+
yeoman: yeomanConfig,
16+
uglify: {
17+
build: {
18+
src: ['<%=yeoman.src %>/app.js', '<%=yeoman.src %>/**/*.js'],
19+
dest: '<%=yeoman.dist %>/bootstrap-angular-validation.min.js'
20+
}
21+
},
22+
bump: {
23+
options: {
24+
files: ['package.json'],
25+
updateConfigs: [],
26+
commit: true,
27+
commitMessage: 'Release v%VERSION%',
28+
commitFiles: ['package.json'],
29+
createTag: true,
30+
tagName: 'v%VERSION%',
31+
tagMessage: 'Version %VERSION%',
32+
push: true,
33+
pushTo: 'origin',
34+
gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
35+
globalReplace: false,
36+
prereleaseName: false,
37+
metadata: '',
38+
regExp: false
39+
}
40+
},
41+
watch: {
42+
scripts: {
43+
files: ['<%=yeoman.src %>/**/*.js'],
44+
tasks: ['uglify'],
45+
options: {
46+
spawn: false
4747
}
48-
}, grunt.registerTask("default", ["uglify"]));
48+
}
49+
}
50+
}, grunt.registerTask('default', ['uglify']));
4951
};

src/app.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
/* global document */
22

3-
"use strict";
3+
'use strict';
44

5-
angular.module("bootstrap.angular.validation", []).config(["$httpProvider", function ($httpProvider) {
6-
var interceptor = ["$rootScope", "BsValidationService", function($rootScope, bsValidationService) {
7-
return {
8-
"response": function(response) {
9-
/**
10-
* Intercept all ng-included templates in a form and add validation-errors directive. See form
11-
* directive in this component itself.
12-
*/
13-
if (bsValidationService.checkNgIncludedURL(response.config.url)) {
14-
/**
15-
* Empty "div" is being used to temporarily store the received HTML from the server to find out
16-
* all the child form elements to add the "bs-validation" directive. And then later the innerHTML
17-
* i.e. the received HTML can easily be extracted using the html() and the temporary "div" will
18-
* be discarded.
19-
*
20-
* http://stackoverflow.com/a/652771/2405040
21-
*/
22-
var parsedJQLiteElements = angular.element(document.createElement("div"));
23-
parsedJQLiteElements.append(response.data);
24-
bsValidationService.addDirective(parsedJQLiteElements);
5+
angular.module('bootstrap.angular.validation', []).config(['$httpProvider', function ($httpProvider) {
6+
var interceptor = ['$rootScope', 'BsValidationService', function ($rootScope, bsValidationService) {
7+
return {
8+
'response': function (response) {
9+
/**
10+
* Intercept all ng-included templates in a form and add validation-errors directive. See form
11+
* directive in this component itself.
12+
*/
13+
if (bsValidationService.checkNgIncludedURL(response.config.url)) {
14+
/**
15+
* Empty 'div' is being used to temporarily store the received HTML from the server to find out
16+
* all the child form elements to add the 'bs-validation' directive. And then later the innerHTML
17+
* i.e. the received HTML can easily be extracted using the html() and the temporary 'div' will
18+
* be discarded.
19+
*
20+
* http://stackoverflow.com/a/652771/2405040
21+
*/
22+
var parsedJQLiteElements = angular.element(document.createElement('div'));
23+
parsedJQLiteElements.append(response.data);
24+
bsValidationService.addDirective(parsedJQLiteElements);
2525

26-
/*
27-
* Get the modified HTML template which is now having the "bs-validation" directive.
28-
* (Not iterating over the every jQlite element otherwise it will append a string "undefined"
29-
* for every new empty line in the HTML)
30-
*/
31-
response.data = parsedJQLiteElements.html();
32-
}
26+
/*
27+
* Get the modified HTML template which is now having the 'bs-validation' directive.
28+
* (Not iterating over the every jQlite element otherwise it will append a string 'undefined'
29+
* for every new empty line in the HTML)
30+
*/
31+
response.data = parsedJQLiteElements.html();
32+
}
3333

34-
return response;
35-
}
36-
};
37-
}];
34+
return response;
35+
}
36+
};
37+
}];
3838

39-
$httpProvider.interceptors.push(interceptor);
39+
$httpProvider.interceptors.push(interceptor);
4040
}]);

src/directives/validation.directive.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ angular.module('bootstrap.angular.validation').directive('bsValidation', [
7070
}, displayOrHideError);
7171

7272
$scope.$watchCollection(function() {
73-
return ngModelController.$valid
73+
return ngModelController.$valid;
7474
}, displayOrHideError);
7575

7676
function resolveMessage(key) {
@@ -118,7 +118,7 @@ angular.module('bootstrap.angular.validation').directive('bsValidation', [
118118
function addErrorMessage(){
119119
var message = resolveMessage(Object.keys(ngModelController.$error)[0]);
120120
var errorElement = formGroupElement.findOne('.' + errorElementClass);
121-
if (errorElement.length === 0) { errorContainer(message) }
121+
if (errorElement.length === 0) { errorContainer(message); }
122122
errorElement.html(iconMarkup + message).removeClass('ng-hide');
123123
}
124124

src/utils.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* var element = domElement.findOne(".form");
1414
* var element = domElement.findOne("#form");
1515
*/
16-
angular.element.prototype.findOne = function(selector) {
17-
return angular.element(this[0].querySelector(selector));
16+
angular.element.prototype.findOne = function (selector) {
17+
return angular.element(this[0].querySelector(selector));
1818
};
1919

2020
/**
@@ -29,8 +29,8 @@ angular.element.prototype.findOne = function(selector) {
2929
* var elementList = domElement.findAll(".form");
3030
* var elementList = domElement.findAll("#form");
3131
*/
32-
angular.element.prototype.findAll = function(selector) {
33-
return angular.element(this[0].querySelectorAll(selector));
32+
angular.element.prototype.findAll = function (selector) {
33+
return angular.element(this[0].querySelectorAll(selector));
3434
};
3535

3636
/**
@@ -45,36 +45,36 @@ angular.element.prototype.findAll = function(selector) {
4545
* var parents = domElement.parents(".form");
4646
* var parents = domElement.parents("#form");
4747
*/
48-
angular.element.prototype.parents = function(selector) {
49-
// At least IE6
50-
var isIE = /*@cc_on!@*/false || !!document.documentMode;
48+
angular.element.prototype.parents = function (selector) {
49+
// At least IE6
50+
var isIE = /*@cc_on!@*/false || !!document.documentMode;
5151

52-
var element = this[0];
53-
var parents = [];
52+
var element = this[0];
53+
var parents = [];
5454

55-
// Traverse element's ancestor tree until the upto the root and pushing all the ancestors to an array.
56-
while (element.parentNode.parentNode) {
57-
element = element.parentNode;
55+
// Traverse element's ancestor tree until the upto the root and pushing all the ancestors to an array.
56+
while (element.parentNode.parentNode) {
57+
element = element.parentNode;
5858

59-
// Get the ancestors of element filtered by a selector (if any)
60-
if (selector) {
61-
if (isIE) {
62-
/*
63-
* For IE versions less then 9. Since Microsoft introduces msMatchesSelector method from 9.
64-
* @see Browser compatibility in https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
65-
*/
66-
if (element.msMatchesSelector(selector)) {
67-
parents.push(element);
68-
}
69-
} else {
70-
if (element.matches(selector)) {
71-
parents.push(element);
72-
}
73-
}
74-
} else {
75-
// If no selector is defined then get all the ancestors with no filtering
76-
parents.push(element);
59+
// Get the ancestors of element filtered by a selector (if any)
60+
if (selector) {
61+
if (isIE) {
62+
/*
63+
* For IE versions less then 9. Since Microsoft introduces msMatchesSelector method from 9.
64+
* @see Browser compatibility in https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
65+
*/
66+
if (element.msMatchesSelector(selector)) {
67+
parents.push(element);
7768
}
69+
} else {
70+
if (element.matches(selector)) {
71+
parents.push(element);
72+
}
73+
}
74+
} else {
75+
// If no selector is defined then get all the ancestors with no filtering
76+
parents.push(element);
7877
}
79-
return angular.element(parents);
78+
}
79+
return angular.element(parents);
8080
};

0 commit comments

Comments
 (0)