From e37577a854ea6961c7a831be43e71d28efb1fe39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20=C5=81abu=C5=9B?= Date: Tue, 10 Jun 2014 09:06:36 +0200 Subject: [PATCH] Rename int() to toInt() - issue #1304 --- src/Angular.js | 6 +++--- src/ng/directive/input.js | 4 ++-- src/ng/filter/filters.js | 14 +++++++------- src/ng/filter/limitTo.js | 2 +- src/ng/location.js | 2 +- src/ng/sniffer.js | 2 +- src/ngMock/angular-mocks.js | 16 ++++++++-------- test/ng/directive/inputSpec.js | 4 ++-- 8 files changed, 25 insertions(+), 25 deletions(-) mode change 100644 => 100755 src/Angular.js mode change 100644 => 100755 src/ng/directive/input.js mode change 100644 => 100755 src/ng/filter/filters.js mode change 100644 => 100755 src/ng/filter/limitTo.js mode change 100644 => 100755 src/ng/location.js mode change 100644 => 100755 src/ng/sniffer.js mode change 100644 => 100755 src/ngMock/angular-mocks.js mode change 100644 => 100755 test/ng/directive/inputSpec.js diff --git a/src/Angular.js b/src/Angular.js old mode 100644 new mode 100755 index 725164808d9a..896e59e3b5e8 --- a/src/Angular.js +++ b/src/Angular.js @@ -173,9 +173,9 @@ var /** holds major version number for IE or NaN for real browsers */ * IE 11 changed the format of the UserAgent string. * See http://msdn.microsoft.com/en-us/library/ms537503.aspx */ -msie = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]); +msie = toInt((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]); if (isNaN(msie)) { - msie = int((/trident\/.*; rv:(\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]); + msie = toInt((/trident\/.*; rv:(\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]); } @@ -357,7 +357,7 @@ function extend(dst) { return dst; } -function int(str) { +function toInt(str) { return parseInt(str, 10); } diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js old mode 100644 new mode 100755 index 554e930e5dbf..faac814b2080 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -1004,7 +1004,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) { // min length validator if (attr.ngMinlength) { - var minlength = int(attr.ngMinlength); + var minlength = toInt(attr.ngMinlength); var minLengthValidator = function(value) { return validate(ctrl, 'minlength', ctrl.$isEmpty(value) || value.length >= minlength, value); }; @@ -1015,7 +1015,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) { // max length validator if (attr.ngMaxlength) { - var maxlength = int(attr.ngMaxlength); + var maxlength = toInt(attr.ngMaxlength); var maxLengthValidator = function(value) { return validate(ctrl, 'maxlength', ctrl.$isEmpty(value) || value.length <= maxlength, value); }; diff --git a/src/ng/filter/filters.js b/src/ng/filter/filters.js old mode 100644 new mode 100755 index 14e71b53e266..bb727ac3764b --- a/src/ng/filter/filters.js +++ b/src/ng/filter/filters.js @@ -396,13 +396,13 @@ function dateFilter($locale) { timeSetter = match[8] ? date.setUTCHours : date.setHours; if (match[9]) { - tzHour = int(match[9] + match[10]); - tzMin = int(match[9] + match[11]); + tzHour = toInt(match[9] + match[10]); + tzMin = toInt(match[9] + match[11]); } - dateSetter.call(date, int(match[1]), int(match[2]) - 1, int(match[3])); - var h = int(match[4]||0) - tzHour; - var m = int(match[5]||0) - tzMin; - var s = int(match[6]||0); + dateSetter.call(date, toInt(match[1]), toInt(match[2]) - 1, toInt(match[3])); + var h = toInt(match[4]||0) - tzHour; + var m = toInt(match[5]||0) - tzMin; + var s = toInt(match[6]||0); var ms = Math.round(parseFloat('0.' + (match[7]||0)) * 1000); timeSetter.call(date, h, m, s, ms); return date; @@ -420,7 +420,7 @@ function dateFilter($locale) { format = $locale.DATETIME_FORMATS[format] || format; if (isString(date)) { if (NUMBER_STRING.test(date)) { - date = int(date); + date = toInt(date); } else { date = jsonStringToDate(date); } diff --git a/src/ng/filter/limitTo.js b/src/ng/filter/limitTo.js old mode 100644 new mode 100755 index 019a630dce31..c8c8737bd4e3 --- a/src/ng/filter/limitTo.js +++ b/src/ng/filter/limitTo.js @@ -76,7 +76,7 @@ function limitToFilter(){ if (Math.abs(Number(limit)) === Infinity) { limit = Number(limit); } else { - limit = int(limit); + limit = toInt(limit); } if (isString(input)) { diff --git a/src/ng/location.js b/src/ng/location.js old mode 100644 new mode 100755 index 522154514ca1..4cce0008522a --- a/src/ng/location.js +++ b/src/ng/location.js @@ -27,7 +27,7 @@ function parseAbsoluteUrl(absoluteUrl, locationObj, appBase) { locationObj.$$protocol = parsedUrl.protocol; locationObj.$$host = parsedUrl.hostname; - locationObj.$$port = int(parsedUrl.port) || DEFAULT_PORTS[parsedUrl.protocol] || null; + locationObj.$$port = toInt(parsedUrl.port) || DEFAULT_PORTS[parsedUrl.protocol] || null; } diff --git a/src/ng/sniffer.js b/src/ng/sniffer.js old mode 100644 new mode 100755 index c225ab8c1ff2..3dfac51c4aec --- a/src/ng/sniffer.js +++ b/src/ng/sniffer.js @@ -19,7 +19,7 @@ function $SnifferProvider() { this.$get = ['$window', '$document', function($window, $document) { var eventSupport = {}, android = - int((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]), + toInt((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]), boxee = /Boxee/i.test(($window.navigator || {}).userAgent), document = $document[0] || {}, documentMode = document.documentMode, diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js old mode 100644 new mode 100755 index a44b90b5aa3e..a0f638ea2718 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -559,20 +559,20 @@ function jsonStringToDate(string) { tzHour = 0, tzMin = 0; if (match[9]) { - tzHour = int(match[9] + match[10]); - tzMin = int(match[9] + match[11]); + tzHour = toInt(match[9] + match[10]); + tzMin = toInt(match[9] + match[11]); } - date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3])); - date.setUTCHours(int(match[4]||0) - tzHour, - int(match[5]||0) - tzMin, - int(match[6]||0), - int(match[7]||0)); + date.setUTCFullYear(toInt(match[1]), toInt(match[2]) - 1, toInt(match[3])); + date.setUTCHours(toInt(match[4]||0) - tzHour, + toInt(match[5]||0) - tzMin, + toInt(match[6]||0), + toInt(match[7]||0)); return date; } return string; } -function int(str) { +function toInt(str) { return parseInt(str, 10); } diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js old mode 100644 new mode 100755 index 4c2f62274485..27ddc2bf84ac --- a/test/ng/directive/inputSpec.js +++ b/test/ng/directive/inputSpec.js @@ -1165,7 +1165,7 @@ describe('input', function() { var value = 0; compileInput(''); attrs.$observe('minlength', function(v) { - value = int(attrs.minlength); + value = toInt(attrs.minlength); }); scope.$apply(function() { @@ -1193,7 +1193,7 @@ describe('input', function() { var value = 0; compileInput(''); attrs.$observe('maxlength', function(v) { - value = int(attrs.maxlength); + value = toInt(attrs.maxlength); }); scope.$apply(function() {