Skip to content

Commit d5686ff

Browse files
committed
style(ngModel): fix spacing
1 parent 203ea10 commit d5686ff

File tree

1 file changed

+68
-68
lines changed

1 file changed

+68
-68
lines changed

src/ng/directive/input.js

+68-68
Original file line numberDiff line numberDiff line change
@@ -1010,43 +1010,43 @@ function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) {
10101010
}
10111011

10121012
function weekParser(isoWeek) {
1013-
if(isDate(isoWeek)) {
1014-
return isoWeek;
1015-
}
1016-
1017-
if(isString(isoWeek)) {
1018-
WEEK_REGEXP.lastIndex = 0;
1019-
var parts = WEEK_REGEXP.exec(isoWeek);
1020-
if(parts) {
1021-
var year = +parts[1],
1022-
week = +parts[2],
1023-
firstThurs = getFirstThursdayOfYear(year),
1024-
addDays = (week - 1) * 7;
1025-
return new Date(year, 0, firstThurs.getDate() + addDays);
1026-
}
1027-
}
1013+
if (isDate(isoWeek)) {
1014+
return isoWeek;
1015+
}
10281016

1029-
return NaN;
1017+
if (isString(isoWeek)) {
1018+
WEEK_REGEXP.lastIndex = 0;
1019+
var parts = WEEK_REGEXP.exec(isoWeek);
1020+
if (parts) {
1021+
var year = +parts[1],
1022+
week = +parts[2],
1023+
firstThurs = getFirstThursdayOfYear(year),
1024+
addDays = (week - 1) * 7;
1025+
return new Date(year, 0, firstThurs.getDate() + addDays);
1026+
}
1027+
}
1028+
1029+
return NaN;
10301030
}
10311031

10321032
function createDateParser(regexp, mapping) {
1033-
return function(iso) {
1033+
return function(iso) {
10341034
var parts, map;
10351035

1036-
if(isDate(iso)) {
1037-
return iso;
1036+
if (isDate(iso)) {
1037+
return iso;
10381038
}
10391039

1040-
if(isString(iso)) {
1040+
if (isString(iso)) {
10411041
regexp.lastIndex = 0;
10421042
parts = regexp.exec(iso);
10431043

1044-
if(parts) {
1044+
if (parts) {
10451045
parts.shift();
10461046
map = { yyyy: 1970, MM: 1, dd: 1, HH: 0, mm: 0, ss: 0 };
10471047

10481048
forEach(parts, function(part, index) {
1049-
if(index < mapping.length) {
1049+
if (index < mapping.length) {
10501050
map[mapping[index]] = +part;
10511051
}
10521052
});
@@ -1055,47 +1055,47 @@ function createDateParser(regexp, mapping) {
10551055
}
10561056

10571057
return NaN;
1058-
};
1058+
};
10591059
}
10601060

10611061
function createDateInputType(type, regexp, parseDate, format) {
1062-
return function dynamicDateInputType(scope, element, attr, ctrl, $sniffer, $browser, $filter) {
1063-
badInputChecker(scope, element, attr, ctrl);
1064-
baseInputType(scope, element, attr, ctrl, $sniffer, $browser);
1065-
var timezone = ctrl && ctrl.$options && ctrl.$options.timezone;
1066-
1067-
ctrl.$$parserName = type;
1068-
ctrl.$parsers.push(function(value) {
1069-
if (ctrl.$isEmpty(value)) return null;
1070-
if (regexp.test(value)) {
1071-
var parsedDate = parseDate(value);
1072-
if (timezone === 'UTC') {
1073-
parsedDate.setMinutes(parsedDate.getMinutes() - parsedDate.getTimezoneOffset());
1074-
}
1075-
return parsedDate;
1076-
}
1077-
return undefined;
1078-
});
1079-
1080-
ctrl.$formatters.push(function(value) {
1081-
if(isDate(value)) {
1082-
return $filter('date')(value, format, timezone);
1083-
}
1084-
return '';
1085-
});
1062+
return function dynamicDateInputType(scope, element, attr, ctrl, $sniffer, $browser, $filter) {
1063+
badInputChecker(scope, element, attr, ctrl);
1064+
baseInputType(scope, element, attr, ctrl, $sniffer, $browser);
1065+
var timezone = ctrl && ctrl.$options && ctrl.$options.timezone;
10861066

1087-
if(attr.min) {
1088-
ctrl.$validators.min = function(value) {
1089-
return ctrl.$isEmpty(value) || isUndefined(attr.min) || parseDate(value) >= parseDate(attr.min);
1090-
};
1067+
ctrl.$$parserName = type;
1068+
ctrl.$parsers.push(function(value) {
1069+
if (ctrl.$isEmpty(value)) return null;
1070+
if (regexp.test(value)) {
1071+
var parsedDate = parseDate(value);
1072+
if (timezone === 'UTC') {
1073+
parsedDate.setMinutes(parsedDate.getMinutes() - parsedDate.getTimezoneOffset());
1074+
}
1075+
return parsedDate;
10911076
}
1077+
return undefined;
1078+
});
10921079

1093-
if(attr.max) {
1094-
ctrl.$validators.max = function(value) {
1095-
return ctrl.$isEmpty(value) || isUndefined(attr.max) || parseDate(value) <= parseDate(attr.max);
1096-
};
1080+
ctrl.$formatters.push(function(value) {
1081+
if (isDate(value)) {
1082+
return $filter('date')(value, format, timezone);
10971083
}
1098-
};
1084+
return '';
1085+
});
1086+
1087+
if (attr.min) {
1088+
ctrl.$validators.min = function(value) {
1089+
return ctrl.$isEmpty(value) || isUndefined(attr.min) || parseDate(value) >= parseDate(attr.min);
1090+
};
1091+
}
1092+
1093+
if (attr.max) {
1094+
ctrl.$validators.max = function(value) {
1095+
return ctrl.$isEmpty(value) || isUndefined(attr.max) || parseDate(value) <= parseDate(attr.max);
1096+
};
1097+
}
1098+
};
10991099
}
11001100

11011101
function badInputChecker(scope, element, attr, ctrl) {
@@ -1115,8 +1115,8 @@ function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) {
11151115

11161116
ctrl.$$parserName = 'number';
11171117
ctrl.$parsers.push(function(value) {
1118-
if(ctrl.$isEmpty(value)) return null;
1119-
if(NUMBER_REGEXP.test(value)) return parseFloat(value);
1118+
if (ctrl.$isEmpty(value)) return null;
1119+
if (NUMBER_REGEXP.test(value)) return parseFloat(value);
11201120
return undefined;
11211121
});
11221122

@@ -1528,7 +1528,7 @@ var VALID_CLASS = 'ng-valid',
15281528
restrict: 'A', // only activate on element attribute
15291529
require: '?ngModel', // get a hold of NgModelController
15301530
link: function(scope, element, attrs, ngModel) {
1531-
if(!ngModel) return; // do nothing if no ng-model
1531+
if (!ngModel) return; // do nothing if no ng-model
15321532
15331533
// Specify how UI should be updated
15341534
ngModel.$render = function() {
@@ -1546,7 +1546,7 @@ var VALID_CLASS = 'ng-valid',
15461546
var html = element.html();
15471547
// When we clear the content editable the browser leaves a <br> behind
15481548
// If strip-br attribute is provided then we strip this out
1549-
if( attrs.stripBr && html == '<br>' ) {
1549+
if ( attrs.stripBr && html == '<br>' ) {
15501550
html = '';
15511551
}
15521552
ngModel.$setViewValue(html);
@@ -1693,7 +1693,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
16931693

16941694
// just incase an asnyc validator is still running while
16951695
// the parser fails
1696-
if(ctrl.$pending) {
1696+
if (ctrl.$pending) {
16971697
ctrl.$$clearPending();
16981698
}
16991699

@@ -1777,7 +1777,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
17771777
ctrl.$valid = true;
17781778
ctrl.$invalid = false;
17791779
}
1780-
} else if(!$error[validationErrorKey]) {
1780+
} else if (!$error[validationErrorKey]) {
17811781
invalidCount++;
17821782
if (!pendingCount) {
17831783
toggleValidCss(false);
@@ -1933,7 +1933,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
19331933
this.$$runValidators = function(modelValue, viewValue) {
19341934
// this is called in the event if incase the input value changes
19351935
// while a former asynchronous validator is still doing its thing
1936-
if(ctrl.$pending) {
1936+
if (ctrl.$pending) {
19371937
ctrl.$$clearPending();
19381938
}
19391939

@@ -2001,7 +2001,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
20012001
var hasBadInput, modelValue = viewValue;
20022002
for(var i = 0; i < ctrl.$parsers.length; i++) {
20032003
modelValue = ctrl.$parsers[i](modelValue);
2004-
if(isUndefined(modelValue)) {
2004+
if (isUndefined(modelValue)) {
20052005
hasBadInput = true;
20062006
break;
20072007
}
@@ -2092,11 +2092,11 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
20922092
options = ctrl.$options,
20932093
debounce;
20942094

2095-
if(options && isDefined(options.debounce)) {
2095+
if (options && isDefined(options.debounce)) {
20962096
debounce = options.debounce;
2097-
if(isNumber(debounce)) {
2097+
if (isNumber(debounce)) {
20982098
debounceDelay = debounce;
2099-
} else if(isNumber(debounce[trigger])) {
2099+
} else if (isNumber(debounce[trigger])) {
21002100
debounceDelay = debounce[trigger];
21012101
} else if (isNumber(debounce['default'])) {
21022102
debounceDelay = debounce['default'];
@@ -2452,7 +2452,7 @@ var patternDirective = function() {
24522452

24532453
var regexp, patternExp = attr.ngPattern || attr.pattern;
24542454
attr.$observe('pattern', function(regex) {
2455-
if(isString(regex) && regex.length > 0) {
2455+
if (isString(regex) && regex.length > 0) {
24562456
regex = new RegExp(regex);
24572457
}
24582458

0 commit comments

Comments
 (0)