{"version":3,"file":"contactUs.min.js","sources":["contactUs.min.js"],"sourcesContent":["/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n\n\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\n\tvar reCaptchaEnterpriseEnabled = $('.contact-us').data('recaptcha-enterprise-enabled');\n\tvar captchaEnabled = $('.contact-us').data('captcha-enable');\n\t/**\n\t * Validate whole form. Requires `this` to be set to form object\n\t * @param {Object} $phoneField - Phone number field input.\n\t * @returns {boolean} - Flag to indicate if form is valid\n\t */\n\tfunction validatePhoneNumber($phoneField) {\n\t var contactPhone = $phoneField.val();\n\t if (contactPhone) {\n\t contactPhone = contactPhone.replace(/\\s/g, '');\n\t $phoneField.val(contactPhone);\n\t }\n\t // check the phone length\n\t var minLength = $phoneField.attr('minlength'),\n\t maxLength = $phoneField.data('max'),\n\t errorLengthLabel = '',\n\t lenghtValid = true;\n\t if (minLength && contactPhone.length < parseInt(minLength)) {\n\t errorLengthLabel = $phoneField.data('minlength-error');\n\t lenghtValid = false;\n\t } else if (maxLength && contactPhone.length > parseInt(maxLength)) {\n\t errorLengthLabel = $phoneField.data('maxlength-error');\n\t lenghtValid = false;\n\t }\n\n\t if (lenghtValid) {\n\t $phoneField.removeClass('is-invalid custom-error');\n\t } else {\n\t $phoneField.parents('.cc-form-group').find('.cc-text-message').text(errorLengthLabel);\n\t $phoneField.closest('.cc-content-input').removeClass('is-valid');\n\t $phoneField.addClass('is-invalid custom-error');\n\t }\n\n\t /**\n\t * Check the phone pattern - usefull only for th, my, id, in, cl sites. Since these sites do have an extra div (located inside\n\t * a phoneField.isml component) that encapsulates an input phone field.\n\t */\n\t if ($phoneField.parent().hasClass('cc-phone-input-box')) {\n\t var pattern = $phoneField.attr('pattern');\n\t var patternValid = pattern && !contactPhone.match(pattern) ? false : true;\n\t if (patternValid) {\n\t $phoneField.parent().removeClass('is-invalid custom-error');\n\t } else {\n\t $phoneField.parent().addClass('is-invalid custom-error');\n\t }\n\t }\n\t}\n\n\t/**\n\t * when the user focuses out of the contact phone input label, removes all the whitespaces if present (for example from autofill)\n\t*/\n\t$('#contact-phone').on('blur', function () {\n\t validatePhoneNumber($(this));\n\t});\n\n\t/**\n\t * Method used when the user clicks on the button or outside of the modal and redirect to the homepage\n\t */\n\t$('.js-submit').on('click', function (e) {\n\t var modalArea = document.getElementById('js-contactUs-submit');\n\t var targetElement = e.target;\n\t if (targetElement !== modalArea) {\n\t var url = $(e.target).data('redirecturl');\n\t window.location.href = url;\n\t }\n\t});\n\n\t/**\n\t * It's solves an issues when nothing is filled in the phone field and obviously validatePhoneNumber method is not executed\n\t * in that case because form's submit event is not executed when there are some html validation errors.\n\t */\n\t$('#contact-phone').on('invalid', function () {\n\t // for th, my, id, in, cl sites only\n\t if ($(this).parent().hasClass('cc-phone-input-box')) {\n\t $(this).parent().addClass('is-invalid custom-error');\n\t }\n\t $(this).addClass('is-invalid custom-error');\n\t});\n\n\tfunction countCommentWords() {\n\t if ($('#contact-comment').length > 0) {\n\t $('#contact-comment').on('keyup', function () {\n\t var count = $('#wordCommentCounter');\n\t var maxLength = $(this).attr('maxlength');\n\t var newMaxLengthValue = parseInt(maxLength);\n\t count.text(newMaxLengthValue - this.value.length);\n\t });\n\t }\n\t}\n\n\twindow.captchaError = function () {\n\t if (captchaEnabled !== null && captchaEnabled) {\n\t $('.captchaMessage').removeClass('d-none');\n\t $('.captchaMessage').addClass('invalid-captcha custom-error');\n\t }\n\t};\n\twindow.captchaSuccess = function () {\n\t if (captchaEnabled !== null && captchaEnabled) {\n\t $('.captchaMessage').addClass('d-none');\n\t $('.captchaMessage').removeClass('invalid-captcha custom-error');\n\t }\n\t};\n\twindow.captchaReset = function () {\n\t if (captchaEnabled !== null && captchaEnabled) {\n\t reCaptchaEnterpriseEnabled ? window.grecaptcha.enterprise.reset() : window.grecaptcha.reset();\n\t }\n\t};\n\n\t/**\n\t * Ajax script that allows to submit contact us form without refreshing the page and shows modal on submit\n\t */\n\tfunction subscribeContact() {\n\t $('form#contact-us').on('submit', function (e) {\n\t e.preventDefault();\n\t var form = $(this);\n\t var url = form.attr('action');\n\t var topic = form.find('#contact-topic option:selected').text().trim();\n\t $('input#topic-hidden').attr('value', topic);\n\n\t var captcha = null;\n\t if (captchaEnabled) {\n\t captcha = reCaptchaEnterpriseEnabled ? window.grecaptcha.enterprise.getResponse() : window.grecaptcha.getResponse();\n\t if (captcha.length === 0) {\n\t window.captchaError();\n\t $('.error-message-contact-us').show();\n\t //var test = $('.custom-error').first().parents('.cc-form-group');\n\t document.querySelector('.error-message-contact-us').scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' });\n\t $.spinner().stop();\n\t } else {\n\t window.captchaSuccess();\n\t $('input#captcha-token').attr('value', captcha);\n\t }\n\t }\n\n\t validatePhoneNumber($('#contact-phone'));\n\t // check the phone length\n\t if ($('.custom-error').length === 0) {\n\t $.spinner().start();\n\t $.ajax({\n\t url: url,\n\t type: 'POST',\n\t dataType: 'json',\n\t data: form.serialize(),\n\t success: function success(data) {\n\t // in case of error, reset the captcha token to avoid timeout\n\t if (!!data.serverErrors && data.serverErrors.length) {\n\t window.captchaReset();\n\t $('.error-message-contact-us').show();\n\t $('.error-message-text-contact-us').text(data.serverErrors);\n\t document.querySelector('.error-message-contact-us').scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' });\n\t } else {\n\t $('#exampleModalLongTitle').text(data.title);\n\t $('#modal-body').text(data.msg);\n\t $('#contactUs-modal-submit').modal('show');\n\t }\n\t $.spinner().stop();\n\t },\n\t error: function error(err) {\n\t $('#exampleModalLongTitle').text(err.title);\n\t $('#modal-body').text(err.msg);\n\t $.spinner().stop();\n\t $('#contactUs-modal-submit').modal('show');\n\t }\n\t });\n\t }\n\t });\n\t}\n\tsubscribeContact();\n\tcountCommentWords();\n\n/***/ })\n/******/ ]);"],"names":["modules","installedModules","__webpack_require__","moduleId","module","exports","id","loaded","call","m","c","p","reCaptchaEnterpriseEnabled","$","data","captchaEnabled","validatePhoneNumber","$phoneField","contactPhone","val","minLength","replace","attr","maxLength","errorLengthLabel","lenghtValid","length","parseInt","removeClass","parents","find","text","closest","addClass","parent","hasClass","pattern","match","on","this","e","modalArea","document","getElementById","target","url","window","location","href","captchaError","captchaSuccess","captchaReset","grecaptcha","enterprise","reset","preventDefault","form","topic","trim","captcha","getResponse","show","querySelector","scrollIntoView","behavior","block","inline","spinner","stop","start","ajax","type","dataType","serialize","success","serverErrors","title","msg","modal","error","err","count","newMaxLengthValue","value"],"mappings":"AAAS,CAAA,SAAUA,GAET,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,IAIIC,EAJJ,OAAGH,EAAiBE,KAIhBC,EAASH,EAAiBE,GAAY,CACzCE,QAAS,GACTC,GAAIH,EACJI,OAAQ,CAAA,CACT,EAGAP,EAAQG,GAAUK,KAAKJ,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