Skip to content
This repository has been archived by the owner on Oct 14, 2019. It is now read-only.

Commit

Permalink
chore(Release): Release v5.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed Feb 26, 2018
1 parent 0c75853 commit 0bcccdb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
38 changes: 20 additions & 18 deletions dist/js/bc-phone-number.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ angular.module('bcPhoneNumber', ['bcPhoneNumberTemplates', 'ui.bootstrap'])
this.isValid = bcCountries.isValidNumber;
this.format = bcCountries.formatNumber;
})
.directive('bcPhoneNumber', function() {
.directive('bcPhoneNumber', ['$timeout', function($timeout) {

if (typeof (bcCountries) === 'undefined') {
throw new Error('bc-countries not found, did you forget to load the Javascript?');
Expand Down Expand Up @@ -94,28 +94,30 @@ angular.module('bcPhoneNumber', ['bcPhoneNumberTemplates', 'ui.bootstrap'])
});

scope.$watch('number', function(newValue) {
if (newValue === '') { scope.ngModel = ''; }
else if (newValue) {
var digits = bcCountries.getDigits(newValue);
var countryCode = bcCountries.getIso2CodeByDigits(digits);

if (countryCode) {
var dialCode = bcCountries.getDialCodeByDigits(digits);
var number = bcCountries.formatNumber(newValue);

if (dialCode !== scope.selectedCountry.dialCode) {
scope.selectedCountry = bcCountries.getCountryByIso2Code(countryCode);
$timeout(function () {
if (newValue === '') { scope.ngModel = ''; }
else if (newValue) {
var digits = bcCountries.getDigits(newValue);
var countryCode = bcCountries.getIso2CodeByDigits(digits);

if (countryCode) {
var dialCode = bcCountries.getDialCodeByDigits(digits);
var number = bcCountries.formatNumber(newValue);

if (dialCode !== scope.selectedCountry.dialCode) {
scope.selectedCountry = bcCountries.getCountryByIso2Code(countryCode);
}

scope.ngModel = number;
scope.number = number;
}

scope.ngModel = number;
scope.number = number;
else { scope.ngModel = newValue; }
}
else { scope.ngModel = newValue; }
}
});
});
}
};
});
}]);

module.exports = 'bcPhoneNumber';

Expand Down
2 changes: 1 addition & 1 deletion dist/js/bc-phone-number.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0bcccdb

Please sign in to comment.