diff --git a/bower.json b/bower.json index 73fdef0e3..1674f0cb2 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "intl-tel-input", - "version": "3.5.2", + "version": "3.6.0", "main": [ "./build/js/intlTelInput.min.js", "./build/img/flags.png", diff --git a/build/js/intlTelInput.js b/build/js/intlTelInput.js index 79c3bd56d..167852e66 100644 --- a/build/js/intlTelInput.js +++ b/build/js/intlTelInput.js @@ -1,5 +1,5 @@ /* -International Telephone Input v3.5.2 +International Telephone Input v3.6.0 https://github.com/Bluefieldscom/intl-tel-input.git */ // wrap in UMD - see https://github.com/umdjs/umd/blob/master/jqueryPlugin.js diff --git a/build/js/intlTelInput.min.js b/build/js/intlTelInput.min.js index ec48ce55b..3f5df43a3 100644 --- a/build/js/intlTelInput.min.js +++ b/build/js/intlTelInput.min.js @@ -1,5 +1,5 @@ /* -International Telephone Input v3.5.2 +International Telephone Input v3.6.0 https://github.com/Bluefieldscom/intl-tel-input.git */ !function(a){"function"==typeof define&&define.amd?define(["jquery"],function(b){a(b,window,document)}):a(jQuery,window,document)}(function(a,b,c,d){"use strict";function e(b,c){this.element=b,this.options=a.extend({},h,c),this._defaults=h,this.ns="."+f+g++,this.isGoodBrowser=Boolean(b.setSelectionRange),this.hadInitialPlaceholder=Boolean(a(b).attr("placeholder")),this._name=f,this.init()}var f="intlTelInput",g=1,h={autoFormat:!0,autoHideDialCode:!0,defaultCountry:"",nationalMode:!1,numberType:"",onlyCountries:[],preferredCountries:["us","gb"],responsiveDropdown:!1,utilsScript:""},i={UP:38,DOWN:40,ENTER:13,ESC:27,PLUS:43,A:65,Z:90,ZERO:48,NINE:57,SPACE:32,BSPACE:8,DEL:46,CTRL:17,CMD1:91,CMD2:224},j=!1;a(b).load(function(){j=!0}),e.prototype={init:function(){var b=this;"auto"==this.options.defaultCountry?a.get("http://ipinfo.io",function(a){b.options.defaultCountry=a&&a.country?a.country.toLowerCase():"",b.ready()},"jsonp"):this.ready()},ready:function(){this.options.nationalMode&&(this.options.autoHideDialCode=!1),(navigator.userAgent.match(/IEMobile/i)||navigator.userAgent.match(/Android/i)&&navigator.userAgent.match(/Chrome/i))&&(this.options.autoFormat=!1),b.innerWidth<500&&(this.options.responsiveDropdown=!0),this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners()},_processCountryData:function(){this._setInstanceCountryData(),this._setPreferredCountries()},_addCountryCode:function(a,b,c){b in this.countryCodes||(this.countryCodes[b]=[]);var d=c||0;this.countryCodes[b][d]=a},_setInstanceCountryData:function(){var a;if(this.options.onlyCountries.length)for(this.countries=[],a=0;a",{"class":"intl-tel-input"}));var b=a("
",{"class":"flag-dropdown"}).insertAfter(this.telInput),c=a("
",{"class":"selected-flag"}).appendTo(b);this.selectedFlagInner=a("
",{"class":"flag"}).appendTo(c),a("
",{"class":"arrow"}).appendTo(this.selectedFlagInner),this.countryList=a("
    ",{"class":"country-list v-hide"}).appendTo(b),this.preferredCountries.length&&(this._appendListItems(this.preferredCountries,"preferred"),a("
  • ",{"class":"divider"}).appendTo(this.countryList)),this._appendListItems(this.countries,""),this.dropdownHeight=this.countryList.outerHeight(),this.countryList.removeClass("v-hide").addClass("hide"),this.options.responsiveDropdown&&this.countryList.outerWidth(this.telInput.outerWidth()),this.countryListItems=this.countryList.children(".country")},_appendListItems:function(a,b){for(var c="",d=0;d",c+="
    ",c+=""+e.name+"",c+="+"+e.dialCode+"",c+="
  • "}this.countryList.append(c)},_setInitialState:function(){var a=this.telInput.val();if(this._getDialCode(a))this._updateFlagFromNumber(a);else{var b;b=this.options.defaultCountry?this._getCountryData(this.options.defaultCountry,!1,!1):this.preferredCountries.length?this.preferredCountries[0]:this.countries[0],this._selectFlag(b.iso2),a||this._updateDialCode(b.dialCode,!1)}a&&this._updateVal(a,!1)},_initListeners:function(){var c=this;this._initKeyListeners(),(this.options.autoHideDialCode||this.options.autoFormat)&&this._initFocusListeners();var d=this.telInput.closest("label");d.length&&d.on("click"+this.ns,function(a){c.countryList.hasClass("hide")?c.telInput.focus():a.preventDefault()});var e=this.selectedFlagInner.parent();e.on("click"+this.ns,function(){c.countryList.hasClass("hide")&&!c.telInput.prop("disabled")&&c._showDropdown()}),this.options.utilsScript&&(j?this.loadUtils():a(b).load(function(){c.loadUtils()}))},_initKeyListeners:function(){var a=this;this.options.autoFormat&&this.telInput.on("keypress"+this.ns,function(b){if(b.which>=i.SPACE&&!b.metaKey){b.preventDefault();var c=b.which>=i.ZERO&&b.which<=i.NINE||b.which==i.PLUS,d=a.telInput[0],e=a.isGoodBrowser&&d.selectionStart==d.selectionEnd,f=a.telInput.attr("maxlength"),g=f?a.telInput.val().lengthd,g=!e&&f?"-"+(this.dropdownHeight-1)+"px":"";this.countryList.css("top",g)},_bindDropdownListeners:function(){var b=this;this.countryList.on("mouseover"+this.ns,".country",function(){b._highlightListItem(a(this))}),this.countryList.on("click"+this.ns,".country",function(){b._selectListItem(a(this))});var d=!0;a("html").on("click"+this.ns,function(){d||b._closeDropdown(),d=!1});var e="",f=null;a(c).on("keydown"+this.ns,function(a){a.preventDefault(),a.which==i.UP||a.which==i.DOWN?b._handleUpDownKey(a.which):a.which==i.ENTER?b._handleEnterKey():a.which==i.ESC?b._closeDropdown():(a.which>=i.A&&a.which<=i.Z||a.which==i.SPACE)&&(f&&clearTimeout(f),e+=String.fromCharCode(a.which),b._searchForCountry(e),f=setTimeout(function(){e=""},1e3))})},_handleUpDownKey:function(a){var b=this.countryList.children(".highlight").first(),c=a==i.UP?b.prev():b.next();c.length&&(c.hasClass("divider")&&(c=a==i.UP?c.prev():c.next()),this._highlightListItem(c),this._scrollTo(c))},_handleEnterKey:function(){var a=this.countryList.children(".highlight").first();a.length&&this._selectListItem(a)},_searchForCountry:function(a){for(var b=0;be&&(d=d.substr(0,e))}else d=a;this.telInput.val(d)},_updateFlagFromNumber:function(a){this.options.nationalMode&&this.selectedCountryData&&"1"==this.selectedCountryData.dialCode&&"+"!=a.substr(0,1)&&(a="+1"+a);var b=this._getDialCode(a);if(b){var c=this.countryCodes[this._getNumeric(b)],d=!1;if(this.selectedCountryData)for(var e=0;e=4},_highlightListItem:function(a){this.countryListItems.removeClass("highlight"),a.addClass("highlight")},_getCountryData:function(a,b,c){for(var d=b?k:this.countries,e=0;eh)b&&(j-=k),c.scrollTop(j);else if(i>f){b&&(j+=k);var l=d-g;c.scrollTop(j-l)}},_updateDialCode:function(b,c){var d,e=this.telInput.val();if(b="+"+b,this.options.nationalMode&&"+"!=e.substr(0,1))d=e;else if(e){var f=this._getDialCode(e);if(f.length>1)d=e.replace(f,b);else{var g="+"!=e.substr(0,1)?a.trim(e):"";d=b+g}}else d=!this.options.autoHideDialCode||c?b:"";this._updateVal(d,c)},_getDialCode:function(b){var c="";if("+"==b.charAt(0))for(var d="",e=0;e