1angular.module('ngIntlTelInput', []);angular.module('ngIntlTelInput') 2 .provider('ngIntlTelInput', function () { 3 var me = this; 4 var props = {}; 5 var setFn = function (obj) { 6 if (typeof obj === 'object') { 7 for (var key in obj) { 8 props[key] = obj[key]; 9 } 10 } 11 }; 12 me.set = setFn; 13 14 me.$get = ['$log', function ($log) { 15 return Object.create(me, { 16 init: { 17 value: function (elm) { 18 if (!window.intlTelInputUtils) { 19 $log.warn('intlTelInputUtils is not defined. Formatting and validation will not work.'); 20 } 21 elm.intlTelInput(props); 22 } 23 }, 24 }); 25 }]; 26 }); 27angular.module('ngIntlTelInput') 28 .directive('ngIntlTelInput', ['ngIntlTelInput', '$log', '$window', '$parse', 29 function (ngIntlTelInput, $log, $window, $parse) { 30 return { 31 restrict: 'A', 32 require: 'ngModel', 33 link: function (scope, elm, attr, ctrl) { 34 // Warning for bad directive usage. 35 if ((!!attr.type && (attr.type !== 'text' && attr.type !== 'tel')) || elm[0].tagName !== 'INPUT') { 36 $log.warn('ng-intl-tel-input can only be applied to a *text* or *tel* input'); 37 return; 38 } 39 // Override default country. 40 if (attr.initialCountry) { 41 ngIntlTelInput.set({initialCountry: attr.initialCountry}); 42 } 43 // Initialize. 44 ngIntlTelInput.init(elm); 45 // Set Selected Country Data. 46 function setSelectedCountryData(model) { 47 var getter = $parse(model); 48 var setter = getter.assign; 49 setter(scope, elm.intlTelInput('getSelectedCountryData')); 50 } 51 // Handle Country Changes. 52 function handleCountryChange() { 53 setSelectedCountryData(attr.selectedCountry); 54 } 55 // Country Change cleanup. 56 function cleanUp() { 57 angular.element($window).off('countrychange', handleCountryChange); 58 } 59 // Selected Country Data. 60 if (attr.selectedCountry) { 61 setSelectedCountryData(attr.selectedCountry); 62 angular.element($window).on('countrychange', handleCountryChange); 63 scope.$on('$destroy', cleanUp); 64 } 65 // Validation. 66 ctrl.$validators.ngIntlTelInput = function (value) { 67 // if phone number is deleted / empty do not run phone number validation 68 if (value || elm[0].value.length > 0) { 69 return elm.intlTelInput('isValidNumber'); 70 } else { 71 return true; 72 } 73 }; 74 // Set model value to valid, formatted version. 75 ctrl.$parsers.push(function (value) { 76 return elm.intlTelInput('getNumber'); 77 }); 78 // Set input value to model value and trigger evaluation. 79 ctrl.$formatters.push(function (value) { 80 if (value) { 81 if(value.charAt(0) !== '+') { 82 value = '+' + value; 83 } 84 elm.intlTelInput('setNumber', value); 85 } 86 return value; 87 }); 88 } 89 }; 90 }]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.