intl-tel-input-rails 8.4.9 → 11.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/images/flags.png +0 -0
- data/app/assets/images/flags@2x.png +0 -0
- data/app/assets/javascripts/intlTelInput.js +154 -147
- data/app/assets/stylesheets/intlTelInput.scss +979 -1
- data/intl-tel-input-rails.gemspec +1 -1
- data/lib/intl-tel-input/version.rb +1 -1
- data/vendor/assets/javascripts/libphonenumber/utils.js +372 -377
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c1d0988f6040e334d0d0f477c285fa03e730b5f
|
4
|
+
data.tar.gz: a59b836b0efbdcb54f2405006569670744a6dda2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71a0443b29d296f37ba74eef68e6f1952823df72920e3f68aa73bde76061a946062d69643c6c3dd1c4d2299ad2023ff0d0b9fb716897ccf631d56dd533d9ce13
|
7
|
+
data.tar.gz: 5f62dd3c9790beca9c02e4342ddddf63d847a90341b167c4b03717d2d7b42ec4f5a21881a1ff7e95c17778b4350b4a6256465db54601c8c1dc7dd43a78e709b0
|
data/README.md
CHANGED
@@ -50,6 +50,6 @@ More options for [initializing the plugin](https://github.com/jackocnr/intl-tel-
|
|
50
50
|
|
51
51
|
## Versioning
|
52
52
|
|
53
|
-
intl-tel-input-rails
|
53
|
+
intl-tel-input-rails 11.0.14.x == intl-tel-input 11.0.14
|
54
54
|
|
55
55
|
Where x is used for gem fixes while keeping the same original library version.
|
data/app/assets/images/flags.png
CHANGED
Binary file
|
Binary file
|
@@ -1,8 +1,9 @@
|
|
1
1
|
/*
|
2
|
-
* International Telephone Input
|
2
|
+
* International Telephone Input v11.0.14
|
3
3
|
* https://github.com/jackocnr/intl-tel-input.git
|
4
4
|
* Licensed under the MIT license
|
5
5
|
*/
|
6
|
+
|
6
7
|
// wrap in UMD - see https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js
|
7
8
|
(function(factory) {
|
8
9
|
if (typeof define === "function" && define.amd) {
|
@@ -23,26 +24,26 @@
|
|
23
24
|
allowDropdown: true,
|
24
25
|
// if there is just a dial code in the input: remove it on blur, and re-add it on focus
|
25
26
|
autoHideDialCode: true,
|
26
|
-
// add
|
27
|
-
autoPlaceholder:
|
27
|
+
// add a placeholder in the input with an example number for the selected country
|
28
|
+
autoPlaceholder: "polite",
|
28
29
|
// modify the auto placeholder
|
29
30
|
customPlaceholder: null,
|
30
31
|
// append menu to a specific element
|
31
32
|
dropdownContainer: "",
|
32
33
|
// don't display these countries
|
33
34
|
excludeCountries: [],
|
34
|
-
// format the input value during initialisation
|
35
|
-
|
35
|
+
// format the input value during initialisation and on setNumber
|
36
|
+
formatOnDisplay: true,
|
36
37
|
// geoIp lookup function
|
37
38
|
geoIpLookup: null,
|
38
39
|
// initial country
|
39
40
|
initialCountry: "",
|
40
41
|
// don't insert international dial codes
|
41
42
|
nationalMode: true,
|
42
|
-
// number type to use for placeholders
|
43
|
-
numberType: "MOBILE",
|
44
43
|
// display only these countries
|
45
44
|
onlyCountries: [],
|
45
|
+
// number type to use for placeholders
|
46
|
+
placeholderNumberType: "MOBILE",
|
46
47
|
// the countries at the top of the list. defaults to united states and united kingdom
|
47
48
|
preferredCountries: [ "us", "gb" ],
|
48
49
|
// display the country dial code next to the selected flag so it's not part of the typed number
|
@@ -59,9 +60,10 @@
|
|
59
60
|
Z: 90,
|
60
61
|
SPACE: 32,
|
61
62
|
TAB: 9
|
62
|
-
}
|
63
|
+
}, // https://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes#Non-geographic_area_codes
|
64
|
+
regionlessNanpNumbers = [ "800", "822", "833", "844", "855", "866", "877", "880", "881", "882", "883", "884", "885", "886", "887", "888", "889" ];
|
63
65
|
// keep track of if the window.load event has fired as impossible to check after the fact
|
64
|
-
$(window).load
|
66
|
+
$(window).on("load", function() {
|
65
67
|
// UPDATE: use a public static field so we can fudge it in the tests
|
66
68
|
$.fn[pluginName].windowLoaded = true;
|
67
69
|
});
|
@@ -83,13 +85,11 @@
|
|
83
85
|
// if separateDialCode then doesn't make sense to A) insert dial code into input (autoHideDialCode), and B) display national numbers (because we're displaying the country dial code next to them)
|
84
86
|
if (this.options.separateDialCode) {
|
85
87
|
this.options.autoHideDialCode = this.options.nationalMode = false;
|
86
|
-
// let's force this for now for simplicity - we can support this later if need be
|
87
|
-
this.options.allowDropdown = true;
|
88
88
|
}
|
89
89
|
// we cannot just test screen size as some smartphones/website meta tags will report desktop resolutions
|
90
90
|
// Note: for some reason jasmine breaks if you put this in the main Plugin function with the rest of these declarations
|
91
91
|
// Note: to target Android Mobiles (and not Tablets), we must find "Android" and "Mobile"
|
92
|
-
this.isMobile = /Android.+Mobile|webOS|iPhone|
|
92
|
+
this.isMobile = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
93
93
|
if (this.isMobile) {
|
94
94
|
// trigger the mobile dropdown css
|
95
95
|
$("body").addClass("iti-mobile");
|
@@ -102,6 +102,8 @@
|
|
102
102
|
// Note: again, jasmine breaks when I put these in the Plugin function
|
103
103
|
this.autoCountryDeferred = new $.Deferred();
|
104
104
|
this.utilsScriptDeferred = new $.Deferred();
|
105
|
+
// in various situations there could be no country selected initially, but we need to be able to assume this variable exists
|
106
|
+
this.selectedCountryData = {};
|
105
107
|
// process all the data: onlyCountries, excludeCountries, preferredCountries etc
|
106
108
|
this._processCountryData();
|
107
109
|
// generate the markup
|
@@ -135,34 +137,21 @@
|
|
135
137
|
var index = priority || 0;
|
136
138
|
this.countryCodes[dialCode][index] = iso2;
|
137
139
|
},
|
138
|
-
// filter the given countries using the process function
|
139
|
-
_filterCountries: function(countryArray, processFunc) {
|
140
|
-
var i;
|
141
|
-
// standardise case
|
142
|
-
for (i = 0; i < countryArray.length; i++) {
|
143
|
-
countryArray[i] = countryArray[i].toLowerCase();
|
144
|
-
}
|
145
|
-
// build instance country array
|
146
|
-
this.countries = [];
|
147
|
-
for (i = 0; i < allCountries.length; i++) {
|
148
|
-
if (processFunc($.inArray(allCountries[i].iso2, countryArray))) {
|
149
|
-
this.countries.push(allCountries[i]);
|
150
|
-
}
|
151
|
-
}
|
152
|
-
},
|
153
140
|
// process onlyCountries or excludeCountries array if present
|
154
141
|
_processAllCountries: function() {
|
155
142
|
if (this.options.onlyCountries.length) {
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
143
|
+
var lowerCaseOnlyCountries = this.options.onlyCountries.map(function(country) {
|
144
|
+
return country.toLowerCase();
|
145
|
+
});
|
146
|
+
this.countries = allCountries.filter(function(country) {
|
147
|
+
return lowerCaseOnlyCountries.indexOf(country.iso2) > -1;
|
160
148
|
});
|
161
149
|
} else if (this.options.excludeCountries.length) {
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
150
|
+
var lowerCaseExcludeCountries = this.options.excludeCountries.map(function(country) {
|
151
|
+
return country.toLowerCase();
|
152
|
+
});
|
153
|
+
this.countries = allCountries.filter(function(country) {
|
154
|
+
return lowerCaseExcludeCountries.indexOf(country.iso2) === -1;
|
166
155
|
});
|
167
156
|
} else {
|
168
157
|
this.countries = allCountries;
|
@@ -284,18 +273,18 @@
|
|
284
273
|
// 4. picking the first country
|
285
274
|
_setInitialState: function() {
|
286
275
|
var val = this.telInput.val();
|
287
|
-
// if we already have a dial code we can go ahead and set the flag, else fall back to default
|
288
|
-
if (this._getDialCode(val)) {
|
289
|
-
this._updateFlagFromNumber(val
|
276
|
+
// if we already have a dial code, and it's not a regionlessNanp we can go ahead and set the flag, else fall back to default
|
277
|
+
if (this._getDialCode(val) && !this._isRegionlessNanp(val)) {
|
278
|
+
this._updateFlagFromNumber(val);
|
290
279
|
} else if (this.options.initialCountry !== "auto") {
|
291
280
|
// see if we should select a flag
|
292
281
|
if (this.options.initialCountry) {
|
293
|
-
this._setFlag(this.options.initialCountry
|
282
|
+
this._setFlag(this.options.initialCountry.toLowerCase());
|
294
283
|
} else {
|
295
284
|
// no dial code and no initialCountry, so default to first in list
|
296
285
|
this.defaultCountry = this.preferredCountries.length ? this.preferredCountries[0].iso2 : this.countries[0].iso2;
|
297
286
|
if (!val) {
|
298
|
-
this._setFlag(this.defaultCountry
|
287
|
+
this._setFlag(this.defaultCountry);
|
299
288
|
}
|
300
289
|
}
|
301
290
|
// if empty and no nationalMode and no autoHideDialCode then insert the default dial code
|
@@ -307,7 +296,7 @@
|
|
307
296
|
// format
|
308
297
|
if (val) {
|
309
298
|
// this wont be run after _updateDialCode as that's only called if no val
|
310
|
-
this._updateValFromNumber(val
|
299
|
+
this._updateValFromNumber(val);
|
311
300
|
}
|
312
301
|
},
|
313
302
|
// initialise the main event listeners: input keyup, and click selected flag
|
@@ -371,7 +360,7 @@
|
|
371
360
|
$.fn[pluginName].loadUtils(this.options.utilsScript, this.utilsScriptDeferred);
|
372
361
|
} else {
|
373
362
|
// wait until the load event so we don't block any other requests e.g. the flags image
|
374
|
-
$(window).load
|
363
|
+
$(window).on("load", function() {
|
375
364
|
$.fn[pluginName].loadUtils(that.options.utilsScript, that.utilsScriptDeferred);
|
376
365
|
});
|
377
366
|
}
|
@@ -387,11 +376,6 @@
|
|
387
376
|
// perform the geo ip lookup
|
388
377
|
_loadAutoCountry: function() {
|
389
378
|
var that = this;
|
390
|
-
// check for cookie
|
391
|
-
var cookieAutoCountry = window.Cookies ? Cookies.get("itiAutoCountry") : "";
|
392
|
-
if (cookieAutoCountry) {
|
393
|
-
$.fn[pluginName].autoCountry = cookieAutoCountry;
|
394
|
-
}
|
395
379
|
// 3 options:
|
396
380
|
// 1) already loaded (we're done)
|
397
381
|
// 2) not already started loading (start)
|
@@ -404,11 +388,6 @@
|
|
404
388
|
if (typeof this.options.geoIpLookup === "function") {
|
405
389
|
this.options.geoIpLookup(function(countryCode) {
|
406
390
|
$.fn[pluginName].autoCountry = countryCode.toLowerCase();
|
407
|
-
if (window.Cookies) {
|
408
|
-
Cookies.set("itiAutoCountry", $.fn[pluginName].autoCountry, {
|
409
|
-
path: "/"
|
410
|
-
});
|
411
|
-
}
|
412
391
|
// tell all instances the auto country is ready
|
413
392
|
// TODO: this should just be the current instances
|
414
393
|
// UPDATE: use setTimeout in case their geoIpLookup function calls this callback straight away (e.g. if they have already done the geo ip lookup somewhere else). Using setTimeout means that the current thread of execution will finish before executing this, which allows the plugin to finish initialising.
|
@@ -425,13 +404,17 @@
|
|
425
404
|
// update flag on keyup
|
426
405
|
// (keep this listener separate otherwise the setTimeout breaks all the tests)
|
427
406
|
this.telInput.on("keyup" + this.ns, function() {
|
428
|
-
that._updateFlagFromNumber(that.telInput.val())
|
407
|
+
if (that._updateFlagFromNumber(that.telInput.val())) {
|
408
|
+
that._triggerCountryChange();
|
409
|
+
}
|
429
410
|
});
|
430
411
|
// update flag on cut/paste events (now supported in all major browsers)
|
431
|
-
this.telInput.on("cut" + this.ns + " paste" + this.ns
|
412
|
+
this.telInput.on("cut" + this.ns + " paste" + this.ns, function() {
|
432
413
|
// hack because "paste" event is fired before input is updated
|
433
414
|
setTimeout(function() {
|
434
|
-
that._updateFlagFromNumber(that.telInput.val())
|
415
|
+
if (that._updateFlagFromNumber(that.telInput.val())) {
|
416
|
+
that._triggerCountryChange();
|
417
|
+
}
|
435
418
|
});
|
436
419
|
});
|
437
420
|
},
|
@@ -472,20 +455,29 @@
|
|
472
455
|
});
|
473
456
|
}
|
474
457
|
});
|
475
|
-
// on blur: if just a dial code then remove it
|
458
|
+
// on blur or form submit: if just a dial code then remove it
|
459
|
+
var form = this.telInput.prop("form");
|
460
|
+
if (form) {
|
461
|
+
$(form).on("submit" + this.ns, function() {
|
462
|
+
that._removeEmptyDialCode();
|
463
|
+
});
|
464
|
+
}
|
476
465
|
this.telInput.on("blur" + this.ns, function() {
|
477
|
-
|
478
|
-
if (startsPlus) {
|
479
|
-
var numeric = that._getNumeric(value);
|
480
|
-
// if just a plus, or if just a dial code
|
481
|
-
if (!numeric || that.selectedCountryData.dialCode == numeric) {
|
482
|
-
that.telInput.val("");
|
483
|
-
}
|
484
|
-
}
|
485
|
-
// remove the keypress listener we added on focus
|
486
|
-
that.telInput.off("keypress.plus" + that.ns);
|
466
|
+
that._removeEmptyDialCode();
|
487
467
|
});
|
488
468
|
},
|
469
|
+
_removeEmptyDialCode: function() {
|
470
|
+
var value = this.telInput.val(), startsPlus = value.charAt(0) == "+";
|
471
|
+
if (startsPlus) {
|
472
|
+
var numeric = this._getNumeric(value);
|
473
|
+
// if just a plus, or if just a dial code
|
474
|
+
if (!numeric || this.selectedCountryData.dialCode == numeric) {
|
475
|
+
this.telInput.val("");
|
476
|
+
}
|
477
|
+
}
|
478
|
+
// remove the keypress listener we added on focus
|
479
|
+
this.telInput.off("keypress.plus" + this.ns);
|
480
|
+
},
|
489
481
|
// extract the numeric digits from the given string
|
490
482
|
_getNumeric: function(s) {
|
491
483
|
return s.replace(/\D/g, "");
|
@@ -626,11 +618,9 @@
|
|
626
618
|
},
|
627
619
|
// update the input's value to the given val (format first if possible)
|
628
620
|
// NOTE: this is called from _setInitialState, handleUtils and setNumber
|
629
|
-
_updateValFromNumber: function(number
|
630
|
-
if (
|
631
|
-
|
632
|
-
format = this.options.nationalMode || number.charAt(0) != "+" ? intlTelInputUtils.numberFormat.NATIONAL : intlTelInputUtils.numberFormat.INTERNATIONAL;
|
633
|
-
}
|
621
|
+
_updateValFromNumber: function(number) {
|
622
|
+
if (this.options.formatOnDisplay && window.intlTelInputUtils && this.selectedCountryData) {
|
623
|
+
var format = !this.options.separateDialCode && (this.options.nationalMode || number.charAt(0) != "+") ? intlTelInputUtils.numberFormat.NATIONAL : intlTelInputUtils.numberFormat.INTERNATIONAL;
|
634
624
|
number = intlTelInputUtils.formatNumber(number, this.selectedCountryData.iso2, format);
|
635
625
|
}
|
636
626
|
number = this._beforeSetNumber(number);
|
@@ -638,22 +628,26 @@
|
|
638
628
|
},
|
639
629
|
// check if need to select a new flag based on the given number
|
640
630
|
// Note: called from _setInitialState, keyup handler, setNumber
|
641
|
-
_updateFlagFromNumber: function(number
|
631
|
+
_updateFlagFromNumber: function(number) {
|
642
632
|
// if we're in nationalMode and we already have US/Canada selected, make sure the number starts with a +1 so _getDialCode will be able to extract the area code
|
643
633
|
// update: if we dont yet have selectedCountryData, but we're here (trying to update the flag from the number), that means we're initialising the plugin with a number that already has a dial code, so fine to ignore this bit
|
644
|
-
if (number && this.options.nationalMode && this.selectedCountryData
|
634
|
+
if (number && this.options.nationalMode && this.selectedCountryData.dialCode == "1" && number.charAt(0) != "+") {
|
645
635
|
if (number.charAt(0) != "1") {
|
646
636
|
number = "1" + number;
|
647
637
|
}
|
648
638
|
number = "+" + number;
|
649
639
|
}
|
650
640
|
// try and extract valid dial code from input
|
651
|
-
var dialCode = this._getDialCode(number), countryCode = null;
|
641
|
+
var dialCode = this._getDialCode(number), countryCode = null, numeric = this._getNumeric(number);
|
652
642
|
if (dialCode) {
|
653
643
|
// check if one of the matching countries is already selected
|
654
|
-
var countryCodes = this.countryCodes[this._getNumeric(dialCode)], alreadySelected =
|
655
|
-
|
656
|
-
|
644
|
+
var countryCodes = this.countryCodes[this._getNumeric(dialCode)], alreadySelected = $.inArray(this.selectedCountryData.iso2, countryCodes) > -1, // check if the given number contains a NANP area code i.e. the only dialCode that could be extracted was +1 (instead of say +1204) and the actual number's length is >=4
|
645
|
+
isNanpAreaCode = dialCode == "+1" && numeric.length >= 4, nanpSelected = this.selectedCountryData.dialCode == "1";
|
646
|
+
// only update the flag if:
|
647
|
+
// A) NOT (we currently have a NANP flag selected, and the number is a regionlessNanp)
|
648
|
+
// AND
|
649
|
+
// B) either a matching country is not already selected OR the number contains a NANP area code (ensure the flag is set to the first matching country)
|
650
|
+
if (!(nanpSelected && this._isRegionlessNanp(numeric)) && (!alreadySelected || isNanpAreaCode)) {
|
657
651
|
// if using onlyCountries option, countryCodes[0] may be empty, so we must find the first non-empty index
|
658
652
|
for (var j = 0; j < countryCodes.length; j++) {
|
659
653
|
if (countryCodes[j]) {
|
@@ -662,7 +656,7 @@
|
|
662
656
|
}
|
663
657
|
}
|
664
658
|
}
|
665
|
-
} else if (number.charAt(0) == "+" &&
|
659
|
+
} else if (number.charAt(0) == "+" && numeric.length) {
|
666
660
|
// invalid dial code, so empty
|
667
661
|
// Note: use getNumeric here because the number has not been formatted yet, so could contain bad chars
|
668
662
|
countryCode = "";
|
@@ -671,12 +665,18 @@
|
|
671
665
|
countryCode = this.defaultCountry;
|
672
666
|
}
|
673
667
|
if (countryCode !== null) {
|
674
|
-
this._setFlag(countryCode
|
668
|
+
return this._setFlag(countryCode);
|
675
669
|
}
|
670
|
+
return false;
|
676
671
|
},
|
677
|
-
// check if the given number
|
678
|
-
|
679
|
-
|
672
|
+
// check if the given number is a regionless NANP number (expects the number to contain an international dial code)
|
673
|
+
_isRegionlessNanp: function(number) {
|
674
|
+
var numeric = this._getNumeric(number);
|
675
|
+
if (numeric.charAt(0) == "1") {
|
676
|
+
var areaCode = numeric.substr(1, 3);
|
677
|
+
return $.inArray(areaCode, regionlessNanpNumbers) > -1;
|
678
|
+
}
|
679
|
+
return false;
|
680
680
|
},
|
681
681
|
// remove highlighting from other list items and highlight the given item
|
682
682
|
_highlightListItem: function(listItem) {
|
@@ -700,8 +700,8 @@
|
|
700
700
|
},
|
701
701
|
// select the given flag, update the placeholder and the active list item
|
702
702
|
// Note: called from _setInitialState, _updateFlagFromNumber, _selectListItem, setCountry
|
703
|
-
_setFlag: function(countryCode
|
704
|
-
var prevCountry = this.selectedCountryData
|
703
|
+
_setFlag: function(countryCode) {
|
704
|
+
var prevCountry = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
|
705
705
|
// do this first as it will throw an error and stop if countryCode is invalid
|
706
706
|
this.selectedCountryData = countryCode ? this._getCountryData(countryCode, false, false) : {};
|
707
707
|
// update the defaultCountry - we only need the iso2 from now on, so just store that
|
@@ -729,15 +729,14 @@
|
|
729
729
|
if (countryCode) {
|
730
730
|
this.countryListItems.find(".iti-flag." + countryCode).first().closest(".country").addClass("active");
|
731
731
|
}
|
732
|
-
//
|
733
|
-
|
734
|
-
this.telInput.trigger("countrychange", this.selectedCountryData);
|
735
|
-
}
|
732
|
+
// return if the flag has changed or not
|
733
|
+
return prevCountry.iso2 !== countryCode;
|
736
734
|
},
|
737
735
|
// update the input placeholder to an example number from the currently selected country
|
738
736
|
_updatePlaceholder: function() {
|
739
|
-
|
740
|
-
|
737
|
+
var shouldSetPlaceholder = this.options.autoPlaceholder === "aggressive" || !this.hadInitialPlaceholder && (this.options.autoPlaceholder === true || this.options.autoPlaceholder === "polite");
|
738
|
+
if (window.intlTelInputUtils && shouldSetPlaceholder) {
|
739
|
+
var numberType = intlTelInputUtils.numberType[this.options.placeholderNumberType], placeholder = this.selectedCountryData.iso2 ? intlTelInputUtils.getExampleNumber(this.selectedCountryData.iso2, this.options.nationalMode, numberType) : "";
|
741
740
|
placeholder = this._beforeSetNumber(placeholder);
|
742
741
|
if (typeof this.options.customPlaceholder === "function") {
|
743
742
|
placeholder = this.options.customPlaceholder(placeholder, this.selectedCountryData);
|
@@ -748,16 +747,19 @@
|
|
748
747
|
// called when the user selects a list item from the dropdown
|
749
748
|
_selectListItem: function(listItem) {
|
750
749
|
// update selected flag and active list item
|
751
|
-
this._setFlag(listItem.attr("data-country-code"));
|
750
|
+
var flagChanged = this._setFlag(listItem.attr("data-country-code"));
|
752
751
|
this._closeDropdown();
|
753
752
|
this._updateDialCode(listItem.attr("data-dial-code"), true);
|
754
753
|
// focus the input
|
755
754
|
this.telInput.focus();
|
756
|
-
// fix for FF and IE11 (with nationalMode=false i.e. auto inserting dial code), who try to put the cursor at the beginning the first time
|
755
|
+
// put cursor at end - this fix is required for FF and IE11 (with nationalMode=false i.e. auto inserting dial code), who try to put the cursor at the beginning the first time
|
757
756
|
if (this.isGoodBrowser) {
|
758
757
|
var len = this.telInput.val().length;
|
759
758
|
this.telInput[0].setSelectionRange(len, len);
|
760
759
|
}
|
760
|
+
if (flagChanged) {
|
761
|
+
this._triggerCountryChange();
|
762
|
+
}
|
761
763
|
},
|
762
764
|
// close the dropdown and unbind any listeners
|
763
765
|
_closeDropdown: function() {
|
@@ -859,8 +861,17 @@
|
|
859
861
|
},
|
860
862
|
// get the input val, adding the dial code if separateDialCode is enabled
|
861
863
|
_getFullNumber: function() {
|
862
|
-
var
|
863
|
-
|
864
|
+
var val = $.trim(this.telInput.val()), dialCode = this.selectedCountryData.dialCode, prefix, numericVal = this._getNumeric(val), // normalized means ensure starts with a 1, so we can match against the full dial code
|
865
|
+
normalizedVal = numericVal.charAt(0) == "1" ? numericVal : "1" + numericVal;
|
866
|
+
if (this.options.separateDialCode) {
|
867
|
+
prefix = "+" + dialCode;
|
868
|
+
} else if (val.charAt(0) != "+" && val.charAt(0) != "1" && dialCode && dialCode.charAt(0) == "1" && dialCode.length == 4 && dialCode != normalizedVal.substr(0, 4)) {
|
869
|
+
// if the user has entered a national NANP number, then ensure it includes the full dial code / area code
|
870
|
+
prefix = dialCode.substr(1);
|
871
|
+
} else {
|
872
|
+
prefix = "";
|
873
|
+
}
|
874
|
+
return prefix + val;
|
864
875
|
},
|
865
876
|
// remove the dial code if separateDialCode is enabled
|
866
877
|
_beforeSetNumber: function(number) {
|
@@ -882,9 +893,13 @@
|
|
882
893
|
}
|
883
894
|
return this._cap(number);
|
884
895
|
},
|
885
|
-
|
886
|
-
|
887
|
-
|
896
|
+
// trigger the 'countrychange' event
|
897
|
+
_triggerCountryChange: function() {
|
898
|
+
this.telInput.trigger("countrychange", this.selectedCountryData);
|
899
|
+
},
|
900
|
+
/**************************
|
901
|
+
* SECRET PUBLIC METHODS
|
902
|
+
**************************/
|
888
903
|
// this is called when the geoip call returns
|
889
904
|
handleAutoCountry: function() {
|
890
905
|
if (this.options.initialCountry === "auto") {
|
@@ -897,6 +912,21 @@
|
|
897
912
|
this.autoCountryDeferred.resolve();
|
898
913
|
}
|
899
914
|
},
|
915
|
+
// this is called when the utils request completes
|
916
|
+
handleUtils: function() {
|
917
|
+
// if the request was successful
|
918
|
+
if (window.intlTelInputUtils) {
|
919
|
+
// if there's an initial value in the input, then format it
|
920
|
+
if (this.telInput.val()) {
|
921
|
+
this._updateValFromNumber(this.telInput.val());
|
922
|
+
}
|
923
|
+
this._updatePlaceholder();
|
924
|
+
}
|
925
|
+
this.utilsScriptDeferred.resolve();
|
926
|
+
},
|
927
|
+
/********************
|
928
|
+
* PUBLIC METHODS
|
929
|
+
********************/
|
900
930
|
// remove plugin
|
901
931
|
destroy: function() {
|
902
932
|
if (this.allowDropdown) {
|
@@ -907,6 +937,13 @@
|
|
907
937
|
// label click hack
|
908
938
|
this.telInput.closest("label").off(this.ns);
|
909
939
|
}
|
940
|
+
// unbind submit event handler on form
|
941
|
+
if (this.options.autoHideDialCode) {
|
942
|
+
var form = this.telInput.prop("form");
|
943
|
+
if (form) {
|
944
|
+
$(form).off(this.ns);
|
945
|
+
}
|
946
|
+
}
|
910
947
|
// unbind all events: key events, and focus/blur events if autoHideDialCode=true
|
911
948
|
this.telInput.off(this.ns);
|
912
949
|
// remove markup (but leave the original input)
|
@@ -936,8 +973,7 @@
|
|
936
973
|
},
|
937
974
|
// get the country data for the currently selected flag
|
938
975
|
getSelectedCountryData: function() {
|
939
|
-
|
940
|
-
return this.selectedCountryData || {};
|
976
|
+
return this.selectedCountryData;
|
941
977
|
},
|
942
978
|
// get the validation error
|
943
979
|
getValidationError: function() {
|
@@ -958,26 +994,17 @@
|
|
958
994
|
if (!this.selectedFlagInner.hasClass(countryCode)) {
|
959
995
|
this._setFlag(countryCode);
|
960
996
|
this._updateDialCode(this.selectedCountryData.dialCode, false);
|
997
|
+
this._triggerCountryChange();
|
961
998
|
}
|
962
999
|
},
|
963
1000
|
// set the input value and update the flag
|
964
|
-
|
965
|
-
setNumber: function(number, format) {
|
1001
|
+
setNumber: function(number) {
|
966
1002
|
// we must update the flag first, which updates this.selectedCountryData, which is used for formatting the number before displaying it
|
967
|
-
this._updateFlagFromNumber(number);
|
968
|
-
this._updateValFromNumber(number
|
969
|
-
|
970
|
-
|
971
|
-
handleUtils: function() {
|
972
|
-
// if the request was successful
|
973
|
-
if (window.intlTelInputUtils) {
|
974
|
-
// if there's an initial value in the input, then format it
|
975
|
-
if (this.telInput.val()) {
|
976
|
-
this._updateValFromNumber(this.telInput.val(), this.options.formatOnInit);
|
977
|
-
}
|
978
|
-
this._updatePlaceholder();
|
1003
|
+
var flagChanged = this._updateFlagFromNumber(number);
|
1004
|
+
this._updateValFromNumber(number);
|
1005
|
+
if (flagChanged) {
|
1006
|
+
this._triggerCountryChange();
|
979
1007
|
}
|
980
|
-
this.utilsScriptDeferred.resolve();
|
981
1008
|
}
|
982
1009
|
};
|
983
1010
|
// using https://github.com/jquery-boilerplate/jquery-boilerplate/wiki/Extending-jQuery-Boilerplate
|
@@ -1040,6 +1067,7 @@
|
|
1040
1067
|
$.fn[pluginName].loadedUtilsScript = true;
|
1041
1068
|
// dont use $.getScript as it prevents caching
|
1042
1069
|
$.ajax({
|
1070
|
+
type: "GET",
|
1043
1071
|
url: path,
|
1044
1072
|
complete: function() {
|
1045
1073
|
// tell all instances that the utils request is complete
|
@@ -1052,46 +1080,25 @@
|
|
1052
1080
|
utilsScriptDeferred.resolve();
|
1053
1081
|
}
|
1054
1082
|
};
|
1083
|
+
// default options
|
1084
|
+
$.fn[pluginName].defaults = defaults;
|
1055
1085
|
// version
|
1056
|
-
$.fn[pluginName].version = "
|
1057
|
-
// Tell JSHint to ignore this warning: "character may get silently deleted by one or more browsers"
|
1058
|
-
// jshint -W100
|
1086
|
+
$.fn[pluginName].version = "11.0.14";
|
1059
1087
|
// Array of country objects for the flag dropdown.
|
1060
|
-
//
|
1061
|
-
//
|
1062
|
-
//
|
1063
|
-
//
|
1064
|
-
//
|
1065
|
-
//
|
1066
|
-
// and Curacao from +5999 to +599
|
1067
|
-
// Removed: Kosovo, Pitcairn Islands, South Georgia
|
1068
|
-
// UPDATE Sept 12th 2015
|
1069
|
-
// List of regions that have iso2 country codes, which I have chosen to omit:
|
1070
|
-
// (based on this information: https://en.wikipedia.org/wiki/List_of_country_calling_codes)
|
1071
|
-
// AQ - Antarctica - all different country codes depending on which "base"
|
1072
|
-
// BV - Bouvet Island - no calling code
|
1073
|
-
// GS - South Georgia and the South Sandwich Islands - "inhospitable collection of islands" - same flag and calling code as Falkland Islands
|
1074
|
-
// HM - Heard Island and McDonald Islands - no calling code
|
1075
|
-
// PN - Pitcairn - tiny population (56), same calling code as New Zealand
|
1076
|
-
// TF - French Southern Territories - no calling code
|
1077
|
-
// UM - United States Minor Outlying Islands - no calling code
|
1078
|
-
// UPDATE the criteria of supported countries or territories (see issue 297)
|
1079
|
-
// Have an iso2 code: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
1080
|
-
// Have a country calling code: https://en.wikipedia.org/wiki/List_of_country_calling_codes
|
1081
|
-
// Have a flag
|
1082
|
-
// Must be supported by libphonenumber: https://github.com/googlei18n/libphonenumber
|
1083
|
-
// Update: converted objects to arrays to save bytes!
|
1084
|
-
// Update: added "priority" for countries with the same dialCode as others
|
1085
|
-
// Update: added array of area codes for countries with the same dialCode as others
|
1086
|
-
// So each country array has the following information:
|
1088
|
+
// Here is the criteria for the plugin to support a given country/territory
|
1089
|
+
// - It has an iso2 code: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
1090
|
+
// - It has it's own country calling code (it is not a sub-region of another country): https://en.wikipedia.org/wiki/List_of_country_calling_codes
|
1091
|
+
// - It has a flag in the region-flags project: https://github.com/behdad/region-flags/tree/gh-pages/png
|
1092
|
+
// - It is supported by libphonenumber (it must be listed on this page): https://github.com/googlei18n/libphonenumber/blob/master/resources/ShortNumberMetadata.xml
|
1093
|
+
// Each country array has the following information:
|
1087
1094
|
// [
|
1088
1095
|
// Country name,
|
1089
1096
|
// iso2 code,
|
1090
1097
|
// International dial code,
|
1091
1098
|
// Order (if >1 country with same dial code),
|
1092
|
-
// Area codes
|
1099
|
+
// Area codes
|
1093
1100
|
// ]
|
1094
|
-
var allCountries = [ [ "Afghanistan (افغانستان)", "af", "93" ], [ "Albania (Shqipëri)", "al", "355" ], [ "Algeria (الجزائر)", "dz", "213" ], [ "American Samoa", "as", "1684" ], [ "Andorra", "ad", "376" ], [ "Angola", "ao", "244" ], [ "Anguilla", "ai", "1264" ], [ "Antigua and Barbuda", "ag", "1268" ], [ "Argentina", "ar", "54" ], [ "Armenia (Հայաստան)", "am", "374" ], [ "Aruba", "aw", "297" ], [ "Australia", "au", "61", 0 ], [ "Austria (Österreich)", "at", "43" ], [ "Azerbaijan (Azərbaycan)", "az", "994" ], [ "Bahamas", "bs", "1242" ], [ "Bahrain (البحرين)", "bh", "973" ], [ "Bangladesh (বাংলাদেশ)", "bd", "880" ], [ "Barbados", "bb", "1246" ], [ "Belarus (Беларусь)", "by", "375" ], [ "Belgium (België)", "be", "32" ], [ "Belize", "bz", "501" ], [ "Benin (Bénin)", "bj", "229" ], [ "Bermuda", "bm", "1441" ], [ "Bhutan (འབྲུག)", "bt", "975" ], [ "Bolivia", "bo", "591" ], [ "Bosnia and Herzegovina (Босна и Херцеговина)", "ba", "387" ], [ "Botswana", "bw", "267" ], [ "Brazil (Brasil)", "br", "55" ], [ "British Indian Ocean Territory", "io", "246" ], [ "British Virgin Islands", "vg", "1284" ], [ "Brunei", "bn", "673" ], [ "Bulgaria (България)", "bg", "359" ], [ "Burkina Faso", "bf", "226" ], [ "Burundi (Uburundi)", "bi", "257" ], [ "Cambodia (កម្ពុជា)", "kh", "855" ], [ "Cameroon (Cameroun)", "cm", "237" ], [ "Canada", "ca", "1", 1, [ "204", "226", "236", "249", "250", "289", "306", "343", "365", "387", "403", "416", "418", "431", "437", "438", "450", "506", "514", "519", "548", "579", "581", "587", "604", "613", "639", "647", "672", "705", "709", "742", "778", "780", "782", "807", "819", "825", "867", "873", "902", "905" ] ], [ "Cape Verde (Kabu Verdi)", "cv", "238" ], [ "Caribbean Netherlands", "bq", "599", 1 ], [ "Cayman Islands", "ky", "1345" ], [ "Central African Republic (République centrafricaine)", "cf", "236" ], [ "Chad (Tchad)", "td", "235" ], [ "Chile", "cl", "56" ], [ "China (中国)", "cn", "86" ], [ "Christmas Island", "cx", "61", 2 ], [ "Cocos (Keeling) Islands", "cc", "61", 1 ], [ "Colombia", "co", "57" ], [ "Comoros (جزر القمر)", "km", "269" ], [ "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)", "cd", "243" ], [ "Congo (Republic) (Congo-Brazzaville)", "cg", "242" ], [ "Cook Islands", "ck", "682" ], [ "Costa Rica", "cr", "506" ], [ "Côte d’Ivoire", "ci", "225" ], [ "Croatia (Hrvatska)", "hr", "385" ], [ "Cuba", "cu", "53" ], [ "Curaçao", "cw", "599", 0 ], [ "Cyprus (Κύπρος)", "cy", "357" ], [ "Czech Republic (Česká republika)", "cz", "420" ], [ "Denmark (Danmark)", "dk", "45" ], [ "Djibouti", "dj", "253" ], [ "Dominica", "dm", "1767" ], [ "Dominican Republic (República Dominicana)", "do", "1", 2, [ "809", "829", "849" ] ], [ "Ecuador", "ec", "593" ], [ "Egypt (مصر)", "eg", "20" ], [ "El Salvador", "sv", "503" ], [ "Equatorial Guinea (Guinea Ecuatorial)", "gq", "240" ], [ "Eritrea", "er", "291" ], [ "Estonia (Eesti)", "ee", "372" ], [ "Ethiopia", "et", "251" ], [ "Falkland Islands (Islas Malvinas)", "fk", "500" ], [ "Faroe Islands (Føroyar)", "fo", "298" ], [ "Fiji", "fj", "679" ], [ "Finland (Suomi)", "fi", "358", 0 ], [ "France", "fr", "33" ], [ "French Guiana (Guyane française)", "gf", "594" ], [ "French Polynesia (Polynésie française)", "pf", "689" ], [ "Gabon", "ga", "241" ], [ "Gambia", "gm", "220" ], [ "Georgia (საქართველო)", "ge", "995" ], [ "Germany (Deutschland)", "de", "49" ], [ "Ghana (Gaana)", "gh", "233" ], [ "Gibraltar", "gi", "350" ], [ "Greece (Ελλάδα)", "gr", "30" ], [ "Greenland (Kalaallit Nunaat)", "gl", "299" ], [ "Grenada", "gd", "1473" ], [ "Guadeloupe", "gp", "590", 0 ], [ "Guam", "gu", "1671" ], [ "Guatemala", "gt", "502" ], [ "Guernsey", "gg", "44", 1 ], [ "Guinea (Guinée)", "gn", "224" ], [ "Guinea-Bissau (Guiné Bissau)", "gw", "245" ], [ "Guyana", "gy", "592" ], [ "Haiti", "ht", "509" ], [ "Honduras", "hn", "504" ], [ "Hong Kong (香港)", "hk", "852" ], [ "Hungary (Magyarország)", "hu", "36" ], [ "Iceland (Ísland)", "is", "354" ], [ "India (भारत)", "in", "91" ], [ "Indonesia", "id", "62" ], [ "Iran (ایران)", "ir", "98" ], [ "Iraq (العراق)", "iq", "964" ], [ "Ireland", "ie", "353" ], [ "Isle of Man", "im", "44", 2 ], [ "Israel (ישראל)", "il", "972" ], [ "Italy (Italia)", "it", "39", 0 ], [ "Jamaica", "jm", "1876" ], [ "Japan (日本)", "jp", "81" ], [ "Jersey", "je", "44", 3 ], [ "Jordan (الأردن)", "jo", "962" ], [ "Kazakhstan (Казахстан)", "kz", "7", 1 ], [ "Kenya", "ke", "254" ], [ "Kiribati", "ki", "686" ], [ "Kuwait (الكويت)", "kw", "965" ], [ "Kyrgyzstan (Кыргызстан)", "kg", "996" ], [ "Laos (ລາວ)", "la", "856" ], [ "Latvia (Latvija)", "lv", "371" ], [ "Lebanon (لبنان)", "lb", "961" ], [ "Lesotho", "ls", "266" ], [ "Liberia", "lr", "231" ], [ "Libya (ليبيا)", "ly", "218" ], [ "Liechtenstein", "li", "423" ], [ "Lithuania (Lietuva)", "lt", "370" ], [ "Luxembourg", "lu", "352" ], [ "Macau (澳門)", "mo", "853" ], [ "Macedonia (FYROM) (Македонија)", "mk", "389" ], [ "Madagascar (Madagasikara)", "mg", "261" ], [ "Malawi", "mw", "265" ], [ "Malaysia", "my", "60" ], [ "Maldives", "mv", "960" ], [ "Mali", "ml", "223" ], [ "Malta", "mt", "356" ], [ "Marshall Islands", "mh", "692" ], [ "Martinique", "mq", "596" ], [ "Mauritania (موريتانيا)", "mr", "222" ], [ "Mauritius (Moris)", "mu", "230" ], [ "Mayotte", "yt", "262", 1 ], [ "Mexico (México)", "mx", "52" ], [ "Micronesia", "fm", "691" ], [ "Moldova (Republica Moldova)", "md", "373" ], [ "Monaco", "mc", "377" ], [ "Mongolia (Монгол)", "mn", "976" ], [ "Montenegro (Crna Gora)", "me", "382" ], [ "Montserrat", "ms", "1664" ], [ "Morocco (المغرب)", "ma", "212", 0 ], [ "Mozambique (Moçambique)", "mz", "258" ], [ "Myanmar (Burma) (မြန်မာ)", "mm", "95" ], [ "Namibia (Namibië)", "na", "264" ], [ "Nauru", "nr", "674" ], [ "Nepal (नेपाल)", "np", "977" ], [ "Netherlands (Nederland)", "nl", "31" ], [ "New Caledonia (Nouvelle-Calédonie)", "nc", "687" ], [ "New Zealand", "nz", "64" ], [ "Nicaragua", "ni", "505" ], [ "Niger (Nijar)", "ne", "227" ], [ "Nigeria", "ng", "234" ], [ "Niue", "nu", "683" ], [ "Norfolk Island", "nf", "672" ], [ "North Korea (조선 민주주의 인민 공화국)", "kp", "850" ], [ "Northern Mariana Islands", "mp", "1670" ], [ "Norway (Norge)", "no", "47", 0 ], [ "Oman (عُمان)", "om", "968" ], [ "Pakistan (پاکستان)", "pk", "92" ], [ "Palau", "pw", "680" ], [ "Palestine (فلسطين)", "ps", "970" ], [ "Panama (Panamá)", "pa", "507" ], [ "Papua New Guinea", "pg", "675" ], [ "Paraguay", "py", "595" ], [ "Peru (Perú)", "pe", "51" ], [ "Philippines", "ph", "63" ], [ "Poland (Polska)", "pl", "48" ], [ "Portugal", "pt", "351" ], [ "Puerto Rico", "pr", "1", 3, [ "787", "939" ] ], [ "Qatar (قطر)", "qa", "974" ], [ "Réunion (La Réunion)", "re", "262", 0 ], [ "Romania (România)", "ro", "40" ], [ "Russia (Россия)", "ru", "7", 0 ], [ "Rwanda", "rw", "250" ], [ "Saint Barthélemy (Saint-Barthélemy)", "bl", "590", 1 ], [ "Saint Helena", "sh", "290" ], [ "Saint Kitts and Nevis", "kn", "1869" ], [ "Saint Lucia", "lc", "1758" ], [ "Saint Martin (Saint-Martin (partie française))", "mf", "590", 2 ], [ "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)", "pm", "508" ], [ "Saint Vincent and the Grenadines", "vc", "1784" ], [ "Samoa", "ws", "685" ], [ "San Marino", "sm", "378" ], [ "São Tomé and Príncipe (São Tomé e Príncipe)", "st", "239" ], [ "Saudi Arabia (المملكة العربية السعودية)", "sa", "966" ], [ "Senegal (Sénégal)", "sn", "221" ], [ "Serbia (Србија)", "rs", "381" ], [ "Seychelles", "sc", "248" ], [ "Sierra Leone", "sl", "232" ], [ "Singapore", "sg", "65" ], [ "Sint Maarten", "sx", "1721" ], [ "Slovakia (Slovensko)", "sk", "421" ], [ "Slovenia (Slovenija)", "si", "386" ], [ "Solomon Islands", "sb", "677" ], [ "Somalia (Soomaaliya)", "so", "252" ], [ "South Africa", "za", "27" ], [ "South Korea (대한민국)", "kr", "82" ], [ "South Sudan (جنوب السودان)", "ss", "211" ], [ "Spain (España)", "es", "34" ], [ "Sri Lanka (ශ්රී ලංකාව)", "lk", "94" ], [ "Sudan (السودان)", "sd", "249" ], [ "Suriname", "sr", "597" ], [ "Svalbard and Jan Mayen", "sj", "47", 1 ], [ "Swaziland", "sz", "268" ], [ "Sweden (Sverige)", "se", "46" ], [ "Switzerland (Schweiz)", "ch", "41" ], [ "Syria (سوريا)", "sy", "963" ], [ "Taiwan (台灣)", "tw", "886" ], [ "Tajikistan", "tj", "992" ], [ "Tanzania", "tz", "255" ], [ "Thailand (ไทย)", "th", "66" ], [ "Timor-Leste", "tl", "670" ], [ "Togo", "tg", "228" ], [ "Tokelau", "tk", "690" ], [ "Tonga", "to", "676" ], [ "Trinidad and Tobago", "tt", "1868" ], [ "Tunisia (تونس)", "tn", "216" ], [ "Turkey (Türkiye)", "tr", "90" ], [ "Turkmenistan", "tm", "993" ], [ "Turks and Caicos Islands", "tc", "1649" ], [ "Tuvalu", "tv", "688" ], [ "U.S. Virgin Islands", "vi", "1340" ], [ "Uganda", "ug", "256" ], [ "Ukraine (Україна)", "ua", "380" ], [ "United Arab Emirates (الإمارات العربية المتحدة)", "ae", "971" ], [ "United Kingdom", "gb", "44", 0 ], [ "United States", "us", "1", 0 ], [ "Uruguay", "uy", "598" ], [ "Uzbekistan (Oʻzbekiston)", "uz", "998" ], [ "Vanuatu", "vu", "678" ], [ "Vatican City (Città del Vaticano)", "va", "39", 1 ], [ "Venezuela", "ve", "58" ], [ "Vietnam (Việt Nam)", "vn", "84" ], [ "Wallis and Futuna", "wf", "681" ], [ "Western Sahara (الصحراء الغربية)", "eh", "212", 1 ], [ "Yemen (اليمن)", "ye", "967" ], [ "Zambia", "zm", "260" ], [ "Zimbabwe", "zw", "263" ], [ "Åland Islands", "ax", "358", 1 ] ];
|
1101
|
+
var allCountries = [ [ "Afghanistan (افغانستان)", "af", "93" ], [ "Albania (Shqipëri)", "al", "355" ], [ "Algeria (الجزائر)", "dz", "213" ], [ "American Samoa", "as", "1684" ], [ "Andorra", "ad", "376" ], [ "Angola", "ao", "244" ], [ "Anguilla", "ai", "1264" ], [ "Antigua and Barbuda", "ag", "1268" ], [ "Argentina", "ar", "54" ], [ "Armenia (Հայաստան)", "am", "374" ], [ "Aruba", "aw", "297" ], [ "Australia", "au", "61", 0 ], [ "Austria (Österreich)", "at", "43" ], [ "Azerbaijan (Azərbaycan)", "az", "994" ], [ "Bahamas", "bs", "1242" ], [ "Bahrain (البحرين)", "bh", "973" ], [ "Bangladesh (বাংলাদেশ)", "bd", "880" ], [ "Barbados", "bb", "1246" ], [ "Belarus (Беларусь)", "by", "375" ], [ "Belgium (België)", "be", "32" ], [ "Belize", "bz", "501" ], [ "Benin (Bénin)", "bj", "229" ], [ "Bermuda", "bm", "1441" ], [ "Bhutan (འབྲུག)", "bt", "975" ], [ "Bolivia", "bo", "591" ], [ "Bosnia and Herzegovina (Босна и Херцеговина)", "ba", "387" ], [ "Botswana", "bw", "267" ], [ "Brazil (Brasil)", "br", "55" ], [ "British Indian Ocean Territory", "io", "246" ], [ "British Virgin Islands", "vg", "1284" ], [ "Brunei", "bn", "673" ], [ "Bulgaria (България)", "bg", "359" ], [ "Burkina Faso", "bf", "226" ], [ "Burundi (Uburundi)", "bi", "257" ], [ "Cambodia (កម្ពុជា)", "kh", "855" ], [ "Cameroon (Cameroun)", "cm", "237" ], [ "Canada", "ca", "1", 1, [ "204", "226", "236", "249", "250", "289", "306", "343", "365", "387", "403", "416", "418", "431", "437", "438", "450", "506", "514", "519", "548", "579", "581", "587", "604", "613", "639", "647", "672", "705", "709", "742", "778", "780", "782", "807", "819", "825", "867", "873", "902", "905" ] ], [ "Cape Verde (Kabu Verdi)", "cv", "238" ], [ "Caribbean Netherlands", "bq", "599", 1 ], [ "Cayman Islands", "ky", "1345" ], [ "Central African Republic (République centrafricaine)", "cf", "236" ], [ "Chad (Tchad)", "td", "235" ], [ "Chile", "cl", "56" ], [ "China (中国)", "cn", "86" ], [ "Christmas Island", "cx", "61", 2 ], [ "Cocos (Keeling) Islands", "cc", "61", 1 ], [ "Colombia", "co", "57" ], [ "Comoros (جزر القمر)", "km", "269" ], [ "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)", "cd", "243" ], [ "Congo (Republic) (Congo-Brazzaville)", "cg", "242" ], [ "Cook Islands", "ck", "682" ], [ "Costa Rica", "cr", "506" ], [ "Côte d’Ivoire", "ci", "225" ], [ "Croatia (Hrvatska)", "hr", "385" ], [ "Cuba", "cu", "53" ], [ "Curaçao", "cw", "599", 0 ], [ "Cyprus (Κύπρος)", "cy", "357" ], [ "Czech Republic (Česká republika)", "cz", "420" ], [ "Denmark (Danmark)", "dk", "45" ], [ "Djibouti", "dj", "253" ], [ "Dominica", "dm", "1767" ], [ "Dominican Republic (República Dominicana)", "do", "1", 2, [ "809", "829", "849" ] ], [ "Ecuador", "ec", "593" ], [ "Egypt (مصر)", "eg", "20" ], [ "El Salvador", "sv", "503" ], [ "Equatorial Guinea (Guinea Ecuatorial)", "gq", "240" ], [ "Eritrea", "er", "291" ], [ "Estonia (Eesti)", "ee", "372" ], [ "Ethiopia", "et", "251" ], [ "Falkland Islands (Islas Malvinas)", "fk", "500" ], [ "Faroe Islands (Føroyar)", "fo", "298" ], [ "Fiji", "fj", "679" ], [ "Finland (Suomi)", "fi", "358", 0 ], [ "France", "fr", "33" ], [ "French Guiana (Guyane française)", "gf", "594" ], [ "French Polynesia (Polynésie française)", "pf", "689" ], [ "Gabon", "ga", "241" ], [ "Gambia", "gm", "220" ], [ "Georgia (საქართველო)", "ge", "995" ], [ "Germany (Deutschland)", "de", "49" ], [ "Ghana (Gaana)", "gh", "233" ], [ "Gibraltar", "gi", "350" ], [ "Greece (Ελλάδα)", "gr", "30" ], [ "Greenland (Kalaallit Nunaat)", "gl", "299" ], [ "Grenada", "gd", "1473" ], [ "Guadeloupe", "gp", "590", 0 ], [ "Guam", "gu", "1671" ], [ "Guatemala", "gt", "502" ], [ "Guernsey", "gg", "44", 1 ], [ "Guinea (Guinée)", "gn", "224" ], [ "Guinea-Bissau (Guiné Bissau)", "gw", "245" ], [ "Guyana", "gy", "592" ], [ "Haiti", "ht", "509" ], [ "Honduras", "hn", "504" ], [ "Hong Kong (香港)", "hk", "852" ], [ "Hungary (Magyarország)", "hu", "36" ], [ "Iceland (Ísland)", "is", "354" ], [ "India (भारत)", "in", "91" ], [ "Indonesia", "id", "62" ], [ "Iran (ایران)", "ir", "98" ], [ "Iraq (العراق)", "iq", "964" ], [ "Ireland", "ie", "353" ], [ "Isle of Man", "im", "44", 2 ], [ "Israel (ישראל)", "il", "972" ], [ "Italy (Italia)", "it", "39", 0 ], [ "Jamaica", "jm", "1876" ], [ "Japan (日本)", "jp", "81" ], [ "Jersey", "je", "44", 3 ], [ "Jordan (الأردن)", "jo", "962" ], [ "Kazakhstan (Казахстан)", "kz", "7", 1 ], [ "Kenya", "ke", "254" ], [ "Kiribati", "ki", "686" ], [ "Kosovo", "xk", "383" ], [ "Kuwait (الكويت)", "kw", "965" ], [ "Kyrgyzstan (Кыргызстан)", "kg", "996" ], [ "Laos (ລາວ)", "la", "856" ], [ "Latvia (Latvija)", "lv", "371" ], [ "Lebanon (لبنان)", "lb", "961" ], [ "Lesotho", "ls", "266" ], [ "Liberia", "lr", "231" ], [ "Libya (ليبيا)", "ly", "218" ], [ "Liechtenstein", "li", "423" ], [ "Lithuania (Lietuva)", "lt", "370" ], [ "Luxembourg", "lu", "352" ], [ "Macau (澳門)", "mo", "853" ], [ "Macedonia (FYROM) (Македонија)", "mk", "389" ], [ "Madagascar (Madagasikara)", "mg", "261" ], [ "Malawi", "mw", "265" ], [ "Malaysia", "my", "60" ], [ "Maldives", "mv", "960" ], [ "Mali", "ml", "223" ], [ "Malta", "mt", "356" ], [ "Marshall Islands", "mh", "692" ], [ "Martinique", "mq", "596" ], [ "Mauritania (موريتانيا)", "mr", "222" ], [ "Mauritius (Moris)", "mu", "230" ], [ "Mayotte", "yt", "262", 1 ], [ "Mexico (México)", "mx", "52" ], [ "Micronesia", "fm", "691" ], [ "Moldova (Republica Moldova)", "md", "373" ], [ "Monaco", "mc", "377" ], [ "Mongolia (Монгол)", "mn", "976" ], [ "Montenegro (Crna Gora)", "me", "382" ], [ "Montserrat", "ms", "1664" ], [ "Morocco (المغرب)", "ma", "212", 0 ], [ "Mozambique (Moçambique)", "mz", "258" ], [ "Myanmar (Burma) (မြန်မာ)", "mm", "95" ], [ "Namibia (Namibië)", "na", "264" ], [ "Nauru", "nr", "674" ], [ "Nepal (नेपाल)", "np", "977" ], [ "Netherlands (Nederland)", "nl", "31" ], [ "New Caledonia (Nouvelle-Calédonie)", "nc", "687" ], [ "New Zealand", "nz", "64" ], [ "Nicaragua", "ni", "505" ], [ "Niger (Nijar)", "ne", "227" ], [ "Nigeria", "ng", "234" ], [ "Niue", "nu", "683" ], [ "Norfolk Island", "nf", "672" ], [ "North Korea (조선 민주주의 인민 공화국)", "kp", "850" ], [ "Northern Mariana Islands", "mp", "1670" ], [ "Norway (Norge)", "no", "47", 0 ], [ "Oman (عُمان)", "om", "968" ], [ "Pakistan (پاکستان)", "pk", "92" ], [ "Palau", "pw", "680" ], [ "Palestine (فلسطين)", "ps", "970" ], [ "Panama (Panamá)", "pa", "507" ], [ "Papua New Guinea", "pg", "675" ], [ "Paraguay", "py", "595" ], [ "Peru (Perú)", "pe", "51" ], [ "Philippines", "ph", "63" ], [ "Poland (Polska)", "pl", "48" ], [ "Portugal", "pt", "351" ], [ "Puerto Rico", "pr", "1", 3, [ "787", "939" ] ], [ "Qatar (قطر)", "qa", "974" ], [ "Réunion (La Réunion)", "re", "262", 0 ], [ "Romania (România)", "ro", "40" ], [ "Russia (Россия)", "ru", "7", 0 ], [ "Rwanda", "rw", "250" ], [ "Saint Barthélemy (Saint-Barthélemy)", "bl", "590", 1 ], [ "Saint Helena", "sh", "290" ], [ "Saint Kitts and Nevis", "kn", "1869" ], [ "Saint Lucia", "lc", "1758" ], [ "Saint Martin (Saint-Martin (partie française))", "mf", "590", 2 ], [ "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)", "pm", "508" ], [ "Saint Vincent and the Grenadines", "vc", "1784" ], [ "Samoa", "ws", "685" ], [ "San Marino", "sm", "378" ], [ "São Tomé and Príncipe (São Tomé e Príncipe)", "st", "239" ], [ "Saudi Arabia (المملكة العربية السعودية)", "sa", "966" ], [ "Senegal (Sénégal)", "sn", "221" ], [ "Serbia (Србија)", "rs", "381" ], [ "Seychelles", "sc", "248" ], [ "Sierra Leone", "sl", "232" ], [ "Singapore", "sg", "65" ], [ "Sint Maarten", "sx", "1721" ], [ "Slovakia (Slovensko)", "sk", "421" ], [ "Slovenia (Slovenija)", "si", "386" ], [ "Solomon Islands", "sb", "677" ], [ "Somalia (Soomaaliya)", "so", "252" ], [ "South Africa", "za", "27" ], [ "South Korea (대한민국)", "kr", "82" ], [ "South Sudan (جنوب السودان)", "ss", "211" ], [ "Spain (España)", "es", "34" ], [ "Sri Lanka (ශ්රී ලංකාව)", "lk", "94" ], [ "Sudan (السودان)", "sd", "249" ], [ "Suriname", "sr", "597" ], [ "Svalbard and Jan Mayen", "sj", "47", 1 ], [ "Swaziland", "sz", "268" ], [ "Sweden (Sverige)", "se", "46" ], [ "Switzerland (Schweiz)", "ch", "41" ], [ "Syria (سوريا)", "sy", "963" ], [ "Taiwan (台灣)", "tw", "886" ], [ "Tajikistan", "tj", "992" ], [ "Tanzania", "tz", "255" ], [ "Thailand (ไทย)", "th", "66" ], [ "Timor-Leste", "tl", "670" ], [ "Togo", "tg", "228" ], [ "Tokelau", "tk", "690" ], [ "Tonga", "to", "676" ], [ "Trinidad and Tobago", "tt", "1868" ], [ "Tunisia (تونس)", "tn", "216" ], [ "Turkey (Türkiye)", "tr", "90" ], [ "Turkmenistan", "tm", "993" ], [ "Turks and Caicos Islands", "tc", "1649" ], [ "Tuvalu", "tv", "688" ], [ "U.S. Virgin Islands", "vi", "1340" ], [ "Uganda", "ug", "256" ], [ "Ukraine (Україна)", "ua", "380" ], [ "United Arab Emirates (الإمارات العربية المتحدة)", "ae", "971" ], [ "United Kingdom", "gb", "44", 0 ], [ "United States", "us", "1", 0 ], [ "Uruguay", "uy", "598" ], [ "Uzbekistan (Oʻzbekiston)", "uz", "998" ], [ "Vanuatu", "vu", "678" ], [ "Vatican City (Città del Vaticano)", "va", "39", 1 ], [ "Venezuela", "ve", "58" ], [ "Vietnam (Việt Nam)", "vn", "84" ], [ "Wallis and Futuna", "wf", "681" ], [ "Western Sahara (الصحراء الغربية)", "eh", "212", 1 ], [ "Yemen (اليمن)", "ye", "967" ], [ "Zambia", "zm", "260" ], [ "Zimbabwe", "zw", "263" ], [ "Åland Islands", "ax", "358", 1 ] ];
|
1095
1102
|
// loop over all of the countries above
|
1096
1103
|
for (var i = 0; i < allCountries.length; i++) {
|
1097
1104
|
var c = allCountries[i];
|
@@ -1103,4 +1110,4 @@
|
|
1103
1110
|
areaCodes: c[4] || null
|
1104
1111
|
};
|
1105
1112
|
}
|
1106
|
-
});
|
1113
|
+
});
|