intl-tel-input 18.0.2 → 18.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -15
- package/build/css/intlTelInput.css +1 -1
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput-jquery.js +58 -35
- package/build/js/intlTelInput-jquery.min.js +3 -3
- package/build/js/intlTelInput.js +58 -35
- package/build/js/intlTelInput.min.js +3 -3
- package/composer.json +1 -1
- package/demo.html +4 -3
- package/examples/gen/country-sync.html +6 -6
- package/examples/gen/default-country-ip.html +7 -7
- package/examples/gen/display-number.html +5 -5
- package/examples/gen/hidden-input.html +5 -5
- package/examples/gen/init-promise.html +5 -5
- package/examples/gen/is-valid-number.html +6 -6
- package/examples/gen/js/countrySync.js +1 -1
- package/examples/gen/js/defaultCountryIp.js +3 -3
- package/examples/gen/js/displayNumber.js +1 -1
- package/examples/gen/js/hiddenInput.js +1 -1
- package/examples/gen/js/initPromise.js +1 -1
- package/examples/gen/js/isValidNumber.js +1 -1
- package/examples/gen/js/modifyCountryData.js +1 -1
- package/examples/gen/js/multipleInstances.js +2 -2
- package/examples/gen/js/nationalMode.js +1 -1
- package/examples/gen/js/onlyCountriesEurope.js +1 -1
- package/examples/gen/modify-country-data.html +5 -5
- package/examples/gen/multiple-instances.html +6 -6
- package/examples/gen/national-mode.html +5 -5
- package/examples/gen/only-countries-europe.html +5 -5
- package/examples/js/defaultCountryIp.js.ejs +2 -2
- package/package.json +1 -1
- package/src/css/intlTelInput.scss +1 -1
- package/src/js/intlTelInput.js +64 -30
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<title>Example: Validation</title>
|
|
6
6
|
<link rel="stylesheet" href="../css/prism.css">
|
|
7
|
-
<link rel="stylesheet" href="../../build/css/intlTelInput.css?
|
|
8
|
-
<link rel="stylesheet" href="../../build/css/demo.css?
|
|
7
|
+
<link rel="stylesheet" href="../../build/css/intlTelInput.css?1680993492797">
|
|
8
|
+
<link rel="stylesheet" href="../../build/css/demo.css?1680993492797">
|
|
9
9
|
|
|
10
|
-
<link rel="stylesheet" href="../css/isValidNumber.css?
|
|
10
|
+
<link rel="stylesheet" href="../css/isValidNumber.css?1680993492797">
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
<!-- Global site tag (gtag.js) - Google Analytics -->
|
|
@@ -41,7 +41,7 @@ var errorMap = ["Invalid number", "Invalid country code", &q
|
|
|
41
41
|
|
|
42
42
|
// initialise plugin
|
|
43
43
|
var iti = window.intlTelInput(input, {
|
|
44
|
-
utilsScript: "../../build/js/utils.js?
|
|
44
|
+
utilsScript: "../../build/js/utils.js?1680993492797"
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
var reset = function() {
|
|
@@ -80,7 +80,7 @@ input.addEventListener('keyup', reset);
|
|
|
80
80
|
</div>
|
|
81
81
|
|
|
82
82
|
<script src="../js/prism.js"></script>
|
|
83
|
-
<script src="../../build/js/intlTelInput.js?
|
|
84
|
-
<script src="./js/isValidNumber.js?
|
|
83
|
+
<script src="../../build/js/intlTelInput.js?1680993492797"></script>
|
|
84
|
+
<script src="./js/isValidNumber.js?1680993492797"></script>
|
|
85
85
|
</body>
|
|
86
86
|
</html>
|
|
@@ -5,7 +5,7 @@ var countryData = window.intlTelInputGlobals.getCountryData(),
|
|
|
5
5
|
|
|
6
6
|
// init plugin
|
|
7
7
|
var iti = window.intlTelInput(input, {
|
|
8
|
-
utilsScript: "../../build/js/utils.js?
|
|
8
|
+
utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
// populate the country dropdown
|
|
@@ -2,10 +2,10 @@ var input = document.querySelector("#phone");
|
|
|
2
2
|
window.intlTelInput(input, {
|
|
3
3
|
initialCountry: "auto",
|
|
4
4
|
geoIpLookup: function(callback) {
|
|
5
|
-
fetch("
|
|
5
|
+
fetch("https://ipapi.co/json")
|
|
6
6
|
.then(function(res) { return res.json(); })
|
|
7
|
-
.then(function(data) { callback(data.
|
|
7
|
+
.then(function(data) { callback(data.country_code); })
|
|
8
8
|
.catch(function() { callback("us"); });
|
|
9
9
|
},
|
|
10
|
-
utilsScript: "../../build/js/utils.js?
|
|
10
|
+
utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
|
|
11
11
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
var input = document.querySelector("#phone");
|
|
2
2
|
window.intlTelInput(input, {
|
|
3
|
-
utilsScript: "../../build/js/utils.js?
|
|
3
|
+
utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
|
|
4
4
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var input = document.querySelector("#phone");
|
|
2
2
|
window.intlTelInput(input, {
|
|
3
3
|
hiddenInput: "full_phone",
|
|
4
|
-
utilsScript: "../../build/js/utils.js?
|
|
4
|
+
utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
|
|
5
5
|
});
|
|
@@ -2,7 +2,7 @@ var input = document.querySelector("#phone");
|
|
|
2
2
|
var statusElement = document.querySelector("#status");
|
|
3
3
|
|
|
4
4
|
var iti = window.intlTelInput(input, {
|
|
5
|
-
utilsScript: "../../build/js/utils.js?
|
|
5
|
+
utilsScript: "../../build/js/utils.js?1680993492797",
|
|
6
6
|
});
|
|
7
7
|
iti.promise.then(function() {
|
|
8
8
|
statusElement.innerHTML = "Initialised!";
|
|
@@ -7,7 +7,7 @@ var errorMap = ["Invalid number", "Invalid country code", "Too short", "Too long
|
|
|
7
7
|
|
|
8
8
|
// initialise plugin
|
|
9
9
|
var iti = window.intlTelInput(input, {
|
|
10
|
-
utilsScript: "../../build/js/utils.js?
|
|
10
|
+
utilsScript: "../../build/js/utils.js?1680993492797"
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
var reset = function() {
|
|
@@ -7,5 +7,5 @@ for (var i = 0; i < countryData.length; i++) {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
window.intlTelInput(input, {
|
|
10
|
-
utilsScript: "../../build/js/utils.js?
|
|
10
|
+
utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
|
|
11
11
|
});
|
|
@@ -4,10 +4,10 @@ var inputMobile = document.querySelector("#mobile");
|
|
|
4
4
|
window.intlTelInput(inputHome, {
|
|
5
5
|
initialCountry: 'gb',
|
|
6
6
|
placeholderNumberType: 'FIXED_LINE',
|
|
7
|
-
utilsScript: "../../build/js/utils.js?
|
|
7
|
+
utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
|
|
8
8
|
});
|
|
9
9
|
window.intlTelInput(inputMobile, {
|
|
10
10
|
initialCountry: 'gb',
|
|
11
11
|
placeholderNumberType: 'MOBILE',
|
|
12
|
-
utilsScript: "../../build/js/utils.js?
|
|
12
|
+
utilsScript: "../../build/js/utils.js?1680993492797"
|
|
13
13
|
});
|
|
@@ -3,7 +3,7 @@ var input = document.querySelector("#phone"),
|
|
|
3
3
|
|
|
4
4
|
var iti = window.intlTelInput(input, {
|
|
5
5
|
nationalMode: true,
|
|
6
|
-
utilsScript: "../../build/js/utils.js?
|
|
6
|
+
utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
var handleChange = function() {
|
|
@@ -4,5 +4,5 @@ window.intlTelInput(input, {
|
|
|
4
4
|
"ee", "fo", "fi", "fr", "de", "gi", "gr", "va", "hu", "is", "ie", "it", "lv",
|
|
5
5
|
"li", "lt", "lu", "mk", "mt", "md", "mc", "me", "nl", "no", "pl", "pt", "ro",
|
|
6
6
|
"ru", "sm", "rs", "sk", "si", "es", "se", "ch", "ua", "gb"],
|
|
7
|
-
utilsScript: "../../build/js/utils.js?
|
|
7
|
+
utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
|
|
8
8
|
});
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<title>Example: Modify country data</title>
|
|
6
6
|
<link rel="stylesheet" href="../css/prism.css">
|
|
7
|
-
<link rel="stylesheet" href="../../build/css/intlTelInput.css?
|
|
8
|
-
<link rel="stylesheet" href="../../build/css/demo.css?
|
|
7
|
+
<link rel="stylesheet" href="../../build/css/intlTelInput.css?1680993492797">
|
|
8
|
+
<link rel="stylesheet" href="../../build/css/demo.css?1680993492797">
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
<!-- Global site tag (gtag.js) - Google Analytics -->
|
|
@@ -36,7 +36,7 @@ for (var i = 0; i < countryData.length; i++) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
window.intlTelInput(input, {
|
|
39
|
-
utilsScript: "../../build/js/utils.js?
|
|
39
|
+
utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
|
|
40
40
|
});
|
|
41
41
|
</code></pre>
|
|
42
42
|
|
|
@@ -46,7 +46,7 @@ window.intlTelInput(input, {
|
|
|
46
46
|
</div>
|
|
47
47
|
|
|
48
48
|
<script src="../js/prism.js"></script>
|
|
49
|
-
<script src="../../build/js/intlTelInput.js?
|
|
50
|
-
<script src="./js/modifyCountryData.js?
|
|
49
|
+
<script src="../../build/js/intlTelInput.js?1680993492797"></script>
|
|
50
|
+
<script src="./js/modifyCountryData.js?1680993492797"></script>
|
|
51
51
|
</body>
|
|
52
52
|
</html>
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<title>Example: Multiple Instances</title>
|
|
6
6
|
<link rel="stylesheet" href="../css/prism.css">
|
|
7
|
-
<link rel="stylesheet" href="../../build/css/intlTelInput.css?
|
|
8
|
-
<link rel="stylesheet" href="../../build/css/demo.css?
|
|
7
|
+
<link rel="stylesheet" href="../../build/css/intlTelInput.css?1680993492797">
|
|
8
|
+
<link rel="stylesheet" href="../../build/css/demo.css?1680993492797">
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
<!-- Global site tag (gtag.js) - Google Analytics -->
|
|
@@ -36,12 +36,12 @@ var inputMobile = document.querySelector("#mobile");
|
|
|
36
36
|
window.intlTelInput(inputHome, {
|
|
37
37
|
initialCountry: 'gb',
|
|
38
38
|
placeholderNumberType: 'FIXED_LINE',
|
|
39
|
-
utilsScript: "../../build/js/utils.js?
|
|
39
|
+
utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
|
|
40
40
|
});
|
|
41
41
|
window.intlTelInput(inputMobile, {
|
|
42
42
|
initialCountry: 'gb',
|
|
43
43
|
placeholderNumberType: 'MOBILE',
|
|
44
|
-
utilsScript: "../../build/js/utils.js?
|
|
44
|
+
utilsScript: "../../build/js/utils.js?1680993492797"
|
|
45
45
|
});
|
|
46
46
|
</code></pre>
|
|
47
47
|
|
|
@@ -54,7 +54,7 @@ Mobile: <input id="mobile" type="tel">
|
|
|
54
54
|
</div>
|
|
55
55
|
|
|
56
56
|
<script src="../js/prism.js"></script>
|
|
57
|
-
<script src="../../build/js/intlTelInput.js?
|
|
58
|
-
<script src="./js/multipleInstances.js?
|
|
57
|
+
<script src="../../build/js/intlTelInput.js?1680993492797"></script>
|
|
58
|
+
<script src="./js/multipleInstances.js?1680993492797"></script>
|
|
59
59
|
</body>
|
|
60
60
|
</html>
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<title>Example: National Mode</title>
|
|
6
6
|
<link rel="stylesheet" href="../css/prism.css">
|
|
7
|
-
<link rel="stylesheet" href="../../build/css/intlTelInput.css?
|
|
8
|
-
<link rel="stylesheet" href="../../build/css/demo.css?
|
|
7
|
+
<link rel="stylesheet" href="../../build/css/intlTelInput.css?1680993492797">
|
|
8
|
+
<link rel="stylesheet" href="../../build/css/demo.css?1680993492797">
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
<!-- Global site tag (gtag.js) - Google Analytics -->
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
|
|
35
35
|
var iti = window.intlTelInput(input, {
|
|
36
36
|
nationalMode: true,
|
|
37
|
-
utilsScript: "../../build/js/utils.js?
|
|
37
|
+
utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
var handleChange = function() {
|
|
@@ -57,7 +57,7 @@ input.addEventListener('keyup', handleChange);
|
|
|
57
57
|
</div>
|
|
58
58
|
|
|
59
59
|
<script src="../js/prism.js"></script>
|
|
60
|
-
<script src="../../build/js/intlTelInput.js?
|
|
61
|
-
<script src="./js/nationalMode.js?
|
|
60
|
+
<script src="../../build/js/intlTelInput.js?1680993492797"></script>
|
|
61
|
+
<script src="./js/nationalMode.js?1680993492797"></script>
|
|
62
62
|
</body>
|
|
63
63
|
</html>
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<title>Example: Only countries option</title>
|
|
6
6
|
<link rel="stylesheet" href="../css/prism.css">
|
|
7
|
-
<link rel="stylesheet" href="../../build/css/intlTelInput.css?
|
|
8
|
-
<link rel="stylesheet" href="../../build/css/demo.css?
|
|
7
|
+
<link rel="stylesheet" href="../../build/css/intlTelInput.css?1680993492797">
|
|
8
|
+
<link rel="stylesheet" href="../../build/css/demo.css?1680993492797">
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
<!-- Global site tag (gtag.js) - Google Analytics -->
|
|
@@ -33,7 +33,7 @@ window.intlTelInput(input, {
|
|
|
33
33
|
"ee", "fo", "fi", "fr", "de", "gi", "gr", "va", "hu", "is", "ie", "it", "lv",
|
|
34
34
|
"li", "lt", "lu", "mk", "mt", "md", "mc", "me", "nl", "no", "pl", "pt", "ro",
|
|
35
35
|
"ru", "sm", "rs", "sk", "si", "es", "se", "ch", "ua", "gb"],
|
|
36
|
-
utilsScript: "../../build/js/utils.js?
|
|
36
|
+
utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
|
|
37
37
|
});
|
|
38
38
|
</code></pre>
|
|
39
39
|
|
|
@@ -43,7 +43,7 @@ window.intlTelInput(input, {
|
|
|
43
43
|
</div>
|
|
44
44
|
|
|
45
45
|
<script src="../js/prism.js"></script>
|
|
46
|
-
<script src="../../build/js/intlTelInput.js?
|
|
47
|
-
<script src="./js/onlyCountriesEurope.js?
|
|
46
|
+
<script src="../../build/js/intlTelInput.js?1680993492797"></script>
|
|
47
|
+
<script src="./js/onlyCountriesEurope.js?1680993492797"></script>
|
|
48
48
|
</body>
|
|
49
49
|
</html>
|
|
@@ -2,9 +2,9 @@ var input = document.querySelector("#phone");
|
|
|
2
2
|
window.intlTelInput(input, {
|
|
3
3
|
initialCountry: "auto",
|
|
4
4
|
geoIpLookup: function(callback) {
|
|
5
|
-
fetch("
|
|
5
|
+
fetch("https://ipapi.co/json")
|
|
6
6
|
.then(function(res) { return res.json(); })
|
|
7
|
-
.then(function(data) { callback(data.
|
|
7
|
+
.then(function(data) { callback(data.country_code); })
|
|
8
8
|
.catch(function() { callback("us"); });
|
|
9
9
|
},
|
|
10
10
|
utilsScript: "../../build/js/utils.js?<%= time %>" // just for formatting/placeholders etc
|
package/package.json
CHANGED
|
@@ -248,7 +248,7 @@ $mobilePopupMargin: 30px !default;
|
|
|
248
248
|
// now that we have digits in this section, it needs this visual separation
|
|
249
249
|
background-color: $hoverColor;
|
|
250
250
|
}
|
|
251
|
-
.iti__selected-dial-code {
|
|
251
|
+
&.iti--show-flags .iti__selected-dial-code {
|
|
252
252
|
margin-left: $arrowPadding;
|
|
253
253
|
}
|
|
254
254
|
}
|
package/src/js/intlTelInput.js
CHANGED
|
@@ -48,6 +48,8 @@ const defaults = {
|
|
|
48
48
|
preferredCountries: ['us', 'gb'],
|
|
49
49
|
// display the country dial code next to the selected flag
|
|
50
50
|
separateDialCode: false,
|
|
51
|
+
// option to hide the flags - must be used with separateDialCode, or allowDropdown=false
|
|
52
|
+
showFlags: true,
|
|
51
53
|
// specify the path to the libphonenumber script to enable validation/formatting
|
|
52
54
|
utilsScript: '',
|
|
53
55
|
};
|
|
@@ -101,6 +103,13 @@ class Iti {
|
|
|
101
103
|
// if separateDialCode enabled, do not insert dial codes
|
|
102
104
|
if (this.options.separateDialCode) this.options.autoInsertDialCode = false;
|
|
103
105
|
|
|
106
|
+
// force showFlags=true if there's a dropdown and we're not displaying the dial code,
|
|
107
|
+
// as otherwise you just have a down arrow on it's own which doesn't make sense
|
|
108
|
+
const forceShowFlags = (this.options.allowDropdown && !this.options.separateDialCode);
|
|
109
|
+
if (!this.options.showFlags && forceShowFlags) {
|
|
110
|
+
this.options.showFlags = true;
|
|
111
|
+
}
|
|
112
|
+
|
|
104
113
|
// we cannot just test screen size as some smartphones/website meta tags will report desktop
|
|
105
114
|
// resolutions
|
|
106
115
|
// Note: for some reason jasmine breaks if you put this in the main Plugin function with the
|
|
@@ -313,45 +322,62 @@ class Iti {
|
|
|
313
322
|
this.telInput.setAttribute('autocomplete', 'off');
|
|
314
323
|
}
|
|
315
324
|
|
|
325
|
+
const {
|
|
326
|
+
allowDropdown,
|
|
327
|
+
separateDialCode,
|
|
328
|
+
showFlags,
|
|
329
|
+
customContainer,
|
|
330
|
+
hiddenInput,
|
|
331
|
+
dropdownContainer,
|
|
332
|
+
} = this.options;
|
|
333
|
+
|
|
316
334
|
// containers (mostly for positioning)
|
|
317
335
|
let parentClass = 'iti';
|
|
318
|
-
if (
|
|
319
|
-
if (
|
|
320
|
-
if (
|
|
321
|
-
|
|
322
|
-
parentClass +=
|
|
336
|
+
if (allowDropdown) parentClass += ' iti--allow-dropdown';
|
|
337
|
+
if (separateDialCode) parentClass += ' iti--separate-dial-code';
|
|
338
|
+
if (showFlags) parentClass += ' iti--show-flags';
|
|
339
|
+
if (customContainer) {
|
|
340
|
+
parentClass += ` ${customContainer}`;
|
|
323
341
|
}
|
|
324
342
|
|
|
325
343
|
const wrapper = this._createEl('div', { class: parentClass });
|
|
326
344
|
this.telInput.parentNode.insertBefore(wrapper, this.telInput);
|
|
327
|
-
|
|
345
|
+
// only hide the flagsContainer if allowDropdown, showFlags and separateDialCode are all false
|
|
346
|
+
const showFlagsContainer = (allowDropdown || showFlags || separateDialCode);
|
|
347
|
+
if (showFlagsContainer) {
|
|
348
|
+
this.flagsContainer = this._createEl('div', { class: 'iti__flag-container' }, wrapper);
|
|
349
|
+
}
|
|
328
350
|
wrapper.appendChild(this.telInput);
|
|
329
351
|
|
|
330
352
|
// selected flag (displayed to left of input)
|
|
331
353
|
// using Aria tags for "Select-Only Combobox Example"
|
|
332
354
|
// https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
if (
|
|
355
|
+
if (showFlagsContainer) {
|
|
356
|
+
this.selectedFlag = this._createEl('div', {
|
|
357
|
+
class: 'iti__selected-flag',
|
|
358
|
+
...(allowDropdown && {
|
|
359
|
+
role: 'combobox',
|
|
360
|
+
'aria-haspopup': 'listbox',
|
|
361
|
+
'aria-controls': `iti-${this.id}__country-listbox`,
|
|
362
|
+
'aria-owns': `iti-${this.id}__country-listbox`,
|
|
363
|
+
'aria-expanded': 'false',
|
|
364
|
+
'aria-label': 'Telephone country code',
|
|
365
|
+
}),
|
|
366
|
+
}, this.flagsContainer);
|
|
367
|
+
}
|
|
368
|
+
if (showFlags) {
|
|
369
|
+
this.selectedFlagInner = this._createEl('div', { class: 'iti__flag' }, this.selectedFlag);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (this.selectedFlag && this.telInput.disabled) {
|
|
347
373
|
this.selectedFlag.setAttribute('aria-disabled', 'true');
|
|
348
374
|
}
|
|
349
375
|
|
|
350
|
-
if (
|
|
376
|
+
if (separateDialCode) {
|
|
351
377
|
this.selectedDialCode = this._createEl('div', { class: 'iti__selected-dial-code' }, this.selectedFlag);
|
|
352
378
|
}
|
|
353
379
|
|
|
354
|
-
if (
|
|
380
|
+
if (allowDropdown) {
|
|
355
381
|
if (!this.telInput.disabled) {
|
|
356
382
|
// make element focusable and tab navigable
|
|
357
383
|
this.selectedFlag.setAttribute('tabindex', '0');
|
|
@@ -377,7 +403,7 @@ class Iti {
|
|
|
377
403
|
this._appendListItems(this.countries, 'iti__standard');
|
|
378
404
|
|
|
379
405
|
// create dropdownContainer markup
|
|
380
|
-
if (
|
|
406
|
+
if (dropdownContainer) {
|
|
381
407
|
this.dropdown = this._createEl('div', { class: 'iti iti--container' });
|
|
382
408
|
this.dropdown.appendChild(this.countryList);
|
|
383
409
|
} else {
|
|
@@ -385,8 +411,8 @@ class Iti {
|
|
|
385
411
|
}
|
|
386
412
|
}
|
|
387
413
|
|
|
388
|
-
if (
|
|
389
|
-
let hiddenInputName =
|
|
414
|
+
if (hiddenInput) {
|
|
415
|
+
let hiddenInputName = hiddenInput;
|
|
390
416
|
const name = this.telInput.getAttribute('name');
|
|
391
417
|
if (name) {
|
|
392
418
|
const i = name.lastIndexOf('[');
|
|
@@ -415,7 +441,9 @@ class Iti {
|
|
|
415
441
|
// open the list item
|
|
416
442
|
tmp += `<li class='iti__country ${className}' tabIndex='-1' id='iti-${this.id}__item-${c.iso2}${idSuffix}' role='option' data-dial-code='${c.dialCode}' data-country-code='${c.iso2}' aria-selected='false'>`;
|
|
417
443
|
// add the flag
|
|
418
|
-
|
|
444
|
+
if (this.options.showFlags) {
|
|
445
|
+
tmp += `<div class='iti__flag-box'><div class='iti__flag iti__${c.iso2}'></div></div>`;
|
|
446
|
+
}
|
|
419
447
|
// and the country name and dial code
|
|
420
448
|
tmp += `<span class='iti__country-name'>${c.name}</span>`;
|
|
421
449
|
tmp += `<span class='iti__dial-code'>+${c.dialCode}</span>`;
|
|
@@ -979,10 +1007,14 @@ class Iti {
|
|
|
979
1007
|
this.defaultCountry = this.selectedCountryData.iso2;
|
|
980
1008
|
}
|
|
981
1009
|
|
|
982
|
-
this.
|
|
1010
|
+
if (this.options.showFlags) {
|
|
1011
|
+
this.selectedFlagInner.setAttribute('class', `iti__flag iti__${countryCode}`);
|
|
1012
|
+
}
|
|
983
1013
|
// update the selected country's title attribute
|
|
984
|
-
|
|
985
|
-
|
|
1014
|
+
if (this.selectedFlag) {
|
|
1015
|
+
const title = (countryCode) ? `${this.selectedCountryData.name}: +${this.selectedCountryData.dialCode}` : 'Unknown';
|
|
1016
|
+
this.selectedFlag.setAttribute('title', title);
|
|
1017
|
+
}
|
|
986
1018
|
|
|
987
1019
|
if (this.options.separateDialCode) {
|
|
988
1020
|
const dialCode = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : '';
|
|
@@ -1020,6 +1052,8 @@ class Iti {
|
|
|
1020
1052
|
|
|
1021
1053
|
// when the input is in a hidden container during initialisation, we must inject some markup
|
|
1022
1054
|
// into the end of the DOM to calculate the correct offsetWidth
|
|
1055
|
+
// NOTE: this is only used when separateDialCode is enabled, so flagsContainer and selectedFlag
|
|
1056
|
+
// will definitely exist
|
|
1023
1057
|
_getHiddenSelectedFlagWidth() {
|
|
1024
1058
|
// to get the right styling to apply, all we need is a shallow clone of the container,
|
|
1025
1059
|
// and then to inject a deep clone of the selectedFlag element
|
|
@@ -1378,7 +1412,7 @@ class Iti {
|
|
|
1378
1412
|
setCountry(originalCountryCode) {
|
|
1379
1413
|
const countryCode = originalCountryCode.toLowerCase();
|
|
1380
1414
|
// check if already selected
|
|
1381
|
-
if (
|
|
1415
|
+
if (this.selectedCountryData.iso2 !== countryCode) {
|
|
1382
1416
|
this._setFlag(countryCode);
|
|
1383
1417
|
this._updateDialCode(this.selectedCountryData.dialCode);
|
|
1384
1418
|
this._triggerCountryChange();
|