501function t_form_phonemask__calcMaxlength(input) {502var maskWithoutCode = input503.getAttribute('data-phonemask-mask')504.substr(input.getAttribute('data-phonemask-code').length);505506if (maskWithoutCode.charAt(0) === '-') {507maskWithoutCode = maskWithoutCode.substring(1);508}509510input.setAttribute('maxlength', maskWithoutCode.length);511input.setAttribute('data-phonemask-without-code', maskWithoutCode);512
}/** * Notifies about complete initialization for inputGroup with phone input * @param {Element} inputGroup */function t_form_phonemask__triggerInitMask(inputGroup) { inputGroup.dispatchEvent(new CustomEvent('phoneMaskReady')); inputGroup.dispatchEvent(new CustomEvent('inputReady')); inputGroup.setAttribute('data-init-mask', 'yes'); inputGroup.setAttribute('data-input-ready', 'true');}/** * * @param {Element} inputGroup * @param {object} countryConfig */function t_form_phonemask__initResetListener(inputGroup, countryConfig) { inputGroup.addEventListener('reset', () => { t_form_phonemask__setValue(inputGroup, '', countryConfig.iso, { silent: true, noFocus: true }); });}/** * Add style for select group * * @param {Node} inputGroup */function t_form_phonemask__addCurrentStyle(inputGroup) { var inputWrap = inputGroup.querySelector('.t-input-phonemask__wrap'); var input = inputGroup.querySelector('.t-input-phonemask'); var inputBlock = inputGroup.querySelector('.t-input-block'); var selectCode = inputGroup.querySelector('.t-input-phonemask__select-code'); var color = inputWrap.style.color; var fontSize = inputWrap.style.fontSize; var fontWeight = inputWrap.style.fontWeight; var fontFamily = inputWrap.style.fontFamily; inputBlock.style.overflow = 'visible'; if (color !== 'rgb(0, 0, 0)') input.style.color = color; input.style.fontSize = fontSize; input.style.fontWeight = fontWeight; input.style.fontFamily = fontFamily; selectCode.style.fontSize = fontSize; selectCode.style.fontWeight = fontWeight;}/** * Get country list * * @param {Array} countries - array list country * @returns {string} - string list country */function t_form_phonemask__getDrawSelector(countries) { var str = ''; str += '<noindex>'; for (var country in countries) { str += '<div class="t-input-phonemask__options-item" id="t-phonemask_' + country + '" data-phonemask-name="' + countries[country].n + '" data-phonemask-mask="' + countries[country].m + '" data-phonemask-country-code="' + country + '" data-phonemask-code="' + countries[country].c + '">'; str += '<div class="t-input-phonemask__options-name">' + countries[country].n + '</div>'; str += '<div class="t-input-phonemask__options-right">'; str += '<span class="t-input-phonemask__options-code">' + countries[country].c + '</span>'; str += '<span class="t-input-phonemask__options-flag t-input-phonemask__options-flag_' + country + '"></span>'; str += '</div>'; str += '</div>'; } str += '</noindex>'; return str;}/** * Add events for select country * * @param {number | string} rec - rec id block * @param {HTMLElement} inputGroup - group field