mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-19 12:01:07 +00:00
chore(parseInt): cleanup parseInt() for our int()
This commit is contained in:
parent
5ac14f633a
commit
d4ae7988da
6 changed files with 10 additions and 9 deletions
|
|
@ -61,7 +61,7 @@ var $boolean = 'boolean',
|
||||||
$undefined = 'undefined',
|
$undefined = 'undefined',
|
||||||
Error = window.Error,
|
Error = window.Error,
|
||||||
/** holds major version number for IE or NaN for real browsers */
|
/** holds major version number for IE or NaN for real browsers */
|
||||||
msie = parseInt((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1], 10),
|
msie = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]),
|
||||||
jqLite, // delay binding since jQuery could be loaded after us.
|
jqLite, // delay binding since jQuery could be loaded after us.
|
||||||
jQuery, // delay binding
|
jQuery, // delay binding
|
||||||
slice = [].slice,
|
slice = [].slice,
|
||||||
|
|
@ -205,6 +205,10 @@ function extend(dst) {
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function int(str) {
|
||||||
|
return parseInt(str, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function inherit(parent, extra) {
|
function inherit(parent, extra) {
|
||||||
return extend(new (extend(function() {}, {prototype:parent}))(), extra);
|
return extend(new (extend(function() {}, {prototype:parent}))(), extra);
|
||||||
|
|
|
||||||
|
|
@ -74,9 +74,6 @@ function jsonStringToDate(string){
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
return string;
|
return string;
|
||||||
function int(str) {
|
|
||||||
return parseInt(str, 10);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function jsonDateToString(date){
|
function jsonDateToString(date){
|
||||||
|
|
|
||||||
|
|
@ -415,7 +415,7 @@ function textInputType(scope, element, attr, ctrl) {
|
||||||
|
|
||||||
// min length validator
|
// min length validator
|
||||||
if (attr.ngMinlength) {
|
if (attr.ngMinlength) {
|
||||||
var minlength = parseInt(attr.ngMinlength, 10);
|
var minlength = int(attr.ngMinlength);
|
||||||
var minLengthValidator = function(value) {
|
var minLengthValidator = function(value) {
|
||||||
if (!isEmpty(value) && value.length < minlength) {
|
if (!isEmpty(value) && value.length < minlength) {
|
||||||
ctrl.$setValidity('minlength', false);
|
ctrl.$setValidity('minlength', false);
|
||||||
|
|
@ -432,7 +432,7 @@ function textInputType(scope, element, attr, ctrl) {
|
||||||
|
|
||||||
// max length validator
|
// max length validator
|
||||||
if (attr.ngMaxlength) {
|
if (attr.ngMaxlength) {
|
||||||
var maxlength = parseInt(attr.ngMaxlength, 10);
|
var maxlength = int(attr.ngMaxlength);
|
||||||
var maxLengthValidator = function(value) {
|
var maxLengthValidator = function(value) {
|
||||||
if (!isEmpty(value) && value.length > maxlength) {
|
if (!isEmpty(value) && value.length > maxlength) {
|
||||||
ctrl.$setValidity('maxlength', false);
|
ctrl.$setValidity('maxlength', false);
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,7 @@ function dateFilter($locale) {
|
||||||
format = $locale.DATETIME_FORMATS[format] || format;
|
format = $locale.DATETIME_FORMATS[format] || format;
|
||||||
if (isString(date)) {
|
if (isString(date)) {
|
||||||
if (NUMBER_STRING.test(date)) {
|
if (NUMBER_STRING.test(date)) {
|
||||||
date = parseInt(date, 10);
|
date = int(date);
|
||||||
} else {
|
} else {
|
||||||
date = jsonStringToDate(date);
|
date = jsonStringToDate(date);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
function limitToFilter(){
|
function limitToFilter(){
|
||||||
return function(array, limit) {
|
return function(array, limit) {
|
||||||
if (!(array instanceof Array)) return array;
|
if (!(array instanceof Array)) return array;
|
||||||
limit = parseInt(limit, 10);
|
limit = int(limit);
|
||||||
var out = [],
|
var out = [],
|
||||||
i, n;
|
i, n;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ function matchUrl(url, obj) {
|
||||||
match = {
|
match = {
|
||||||
protocol: match[1],
|
protocol: match[1],
|
||||||
host: match[3],
|
host: match[3],
|
||||||
port: parseInt(match[5], 10) || DEFAULT_PORTS[match[1]] || null,
|
port: int(match[5]) || DEFAULT_PORTS[match[1]] || null,
|
||||||
path: match[6] || '/',
|
path: match[6] || '/',
|
||||||
search: match[8],
|
search: match[8],
|
||||||
hash: match[10]
|
hash: match[10]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue