Skip to content

Commit

Permalink
1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Sep 7, 2017
1 parent 487ecaf commit c01d070
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mage2pro/phone"
,"version": "1.0.7"
,"version": "1.0.8"
,"description": "A telephone numbers handling library for my Magento 2 extensions."
,"type": "magento2-module"
,"homepage": "https://github.com/mage2pro/phone"
Expand Down
21 changes: 15 additions & 6 deletions view/base/web/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,29 @@ function(c) {ko.bindingHandlers['df-phone'] = {init: function(e, accessor) {var
// Type: string. Default: "".
,utilsScript: ''
}, config.options));
$.fn.intlTelInput.loadUtils(c.utils);
var $container = $e.closest('div.intl-tel-input');
var eValid = $container.siblings('.df-valid');
var eInvalid = $container.siblings('.df-invalid');
var reset = function() {
eInvalid.addClass('df-hidden');
eValid.addClass('df-hidden');
};
$e.blur(function() {
var reset = function() {eInvalid.addClass('df-hidden'); eValid.addClass('df-hidden');};
var validate = function() {
reset();
if ($.trim($e.val())) {
($e.intlTelInput('isValidNumber') ? eValid : eInvalid).removeClass('df-hidden');
}
};
/**
* 2017-09-08
* loadUtils():
* https://github.com/jackocnr/intl-tel-input/blob/v12.0.2/build/js/intlTelInput.js#L1086-L1105
* handleUtils():
* https://github.com/jackocnr/intl-tel-input/blob/v12.0.2/build/js/intlTelInput.js#L938-L949
*/
require(['Df_Phone/lib/js/utils'], function() {
$.fn.intlTelInput.loadedUtilsScript = true;
$e.intlTelInput('handleUtils');
validate();
});
$e.blur(validate);
$e.on('change keyup', reset);
ko.utils.registerEventHandler(e, 'change', function() {config.storage(this.value);});
}};});});

0 comments on commit c01d070

Please sign in to comment.