{"version":3,"file":"complaints.min.js","sources":["complaints.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\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\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$('#contact-phone2').on('blur', function () {\n\t // Only validate if the field is not empty\n\t if ($(this).val().trim()) {\n\t validatePhoneNumber($(this));\n\t }\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-complaints-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 ($('#description').length > 0) {\n\t $('#description').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\tvar checkbox = document.getElementById('underage');\n\tvar toggleFields = document.querySelectorAll('.toggle-required');\n\n\t// Function for toggling required class\n\tfunction toggleRequiredFields() {\n\t toggleFields.forEach(function (field) {\n\t if (checkbox.checked) {\n\t field.classList.add('required');\n\t } else {\n\t field.classList.remove('required');\n\t }\n\t });\n\t}\n\n\ttoggleRequiredFields();\n\n\tcheckbox.addEventListener('change', toggleRequiredFields);\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#complaints').on('submit', function (e) {\n\t e.preventDefault();\n\t var form = $(this);\n\t var url = form.attr('action');\n\t var documentType = form.find('#document-type option:selected').text().trim();\n\t var responseType = form.find('#response-type option:selected').text().trim();\n\t var placeOfPurchase = form.find('#place-of-purchase option:selected').text().trim();\n\t var documentType2 = form.find('#document-type2 option:selected').text().trim();\n\t $('input#topic-hidden').attr('value', documentType);\n\t $('input#topic2-hidden').attr('value', responseType);\n\t $('input#topic3-hidden').attr('value', placeOfPurchase);\n\t $('input#topic4-hidden').attr('value', documentType2);\n\n\t validatePhoneNumber($('#contact-phone'));\n\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 $('#exampleModalLongTitle').text(data.title);\n\t $('#modal-body').text(data.msg);\n\t $.spinner().stop();\n\t $('#complaints-modal-submit').modal('show');\n\t },\n\t error: function error(err) {\n\t $('#exampleModalLongTitle').text(err.title);\n\t $('#modal-form-body').text(err.msg);\n\t $.spinner().stop();\n\t $('#complaints-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","validatePhoneNumber","$phoneField","contactPhone","val","minLength","replace","attr","maxLength","data","errorLengthLabel","lenghtValid","length","parseInt","removeClass","parents","find","text","closest","addClass","parent","hasClass","pattern","match","$","on","this","trim","e","modalArea","document","getElementById","target","url","window","location","href","checkbox","toggleFields","querySelectorAll","toggleRequiredFields","forEach","field","checked","classList","add","remove","addEventListener","preventDefault","form","documentType","responseType","placeOfPurchase","documentType2","spinner","start","ajax","type","dataType","serialize","success","title","msg","stop","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,EAAOC,QAASD,EAAQA,EAAOC,QAASH,CAAmB,EAGlFE,EAAOG,OAAS,CAAA,EAGTH,IAhB4BC,OAiBpC,CAIAH,EAAoBO,EAAIT,EAGxBE,EAAoBQ,EAAIT,EAGxBC,EAAoBS,EAAI,GAGjBT,EAAoB,CAAC,CAC5B,EAEA,CAEJ,SAAUE,EAAQC,GAUvB,SAASO,EAAoBC,GACzB,IAAIC,EAAeD,EAAYE,IAAI,EAM/BC,GALAF,IACAA,EAAeA,EAAaG,QAAQ,MAAO,EAAE,EAC7CJ,EAAYE,IAAID,CAAY,GAGhBD,EAAYK,KAAK,WAAW,GACxCC,EAAYN,EAAYO,KAAK,KAAK,EAClCC,EAAmB,GACnBC,EAAc,CAAA,EACdN,GAAaF,EAAaS,OAASC,SAASR,CAAS,GACrDK,EAA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