{"version":3,"file":"form-block.js","mappings":";;;;;;;;;;;AAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,8CAA8C;AAC9C;AACA,6CAA6C;;AAE7C;;AAEA;AACA;AACA;;AAEA,wBAAwB,2BAA2B;;AAEnD;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAAS;;AAET;AACA;AACA,SAAS;;AAET;AACA;AACA,SAAS;;AAET;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,SAAS;AACT;AACA;AACA;;AAEA,gCAAgC,8BAA8B;AAC9D;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,+FAA+F,2CAA2C;;AAE1I;AACA,mGAAmG,2CAA2C;AAC9I,qBAAqB;;AAErB;AACA;;AAEA,aAAa;;AAEb;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA,oEAAoE,qCAAqC;;AAEzG;AACA,wEAAwE,qCAAqC;AAC7G,qBAAqB;AACrB;;AAEA;AACA;;AAEA;AACA,SAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,wDAAwD,0CAA0C;AAClG,wDAAwD,0CAA0C;;AAElG;;AAEA;AACA;;AAEA;AACA,SAAS;AACT;AACA;;AAEA;AACA,mCAAmC,yBAAyB,gCAAgC,IAAI,QAAQ,IAAI,QAAQ,IAAI,QAAQ,IAAI,iCAAiC,GAAG;AACxK;AACA;;AAEA;AACA,0DAA0D,sCAAsC;AAChG,yDAAyD,sDAAsD;AAC/G;;AAEA;;AAEA;AACA;AACA;AACA,uFAAuF,kCAAkC,EAAE,oEAAoE;;AAE/L;AACA,6CAA6C,+CAA+C;AAC5F,6CAA6C,oDAAoD;AACjG;;AAEA;AACA,8EAA8E,2CAA2C;AACzH,SAAS;;AAET;AACA,MAAM;AACN;AACA,uFAAuF,kCAAkC,EAAE,oEAAoE;AAC/L,iDAAiD,gDAAgD;AACjG,iDAAiD,gDAAgD;;AAEjG;AACA,8EAA8E,2CAA2C;AACzH,SAAS;;AAET;AACA;;AAEA;AACA;;AAEA,+DAAe;AACf;AACA;AACA;AACA;AACA;AACA,CAAC;;;;;;;;;;;AChND;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,GAAG;AACd,WAAW,GAAG;AACd,WAAW,GAAG;AACd,WAAW,GAAG;AACd;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,qBAAqB;AACrB;;AAEA,wEAAwE;AACxE;;AAEA;AACA;AACA;AACA;AACA,WAAW,GAAG;AACd;AACA;AACA;AACA;AACA,mBAAmB;AACnB,+BAA+B;;AAE/B;AACA,mCAAmC;AACnC;;AAEA;AACA,EAAE;;AAEF,+DAAe;AACf;AACA;AACA,CAAC;;;;;;;;;;;ACnDD;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA,+BAA+B,qDAAqD;AACpF;AACA,GAAG;AACH,+BAA+B,oDAAoD;AACnF;AACA;AACA;;AAEA,CAAC,+DAAe;AAChB;AACA,CAAC,EAAC;;;;;;;UCpBF;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;;ACNA;AACA;AACA;AACA;AACA;;AAEA,CAA+C;AAC/C,CAA+C;AAC/C,CAA0C;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,yCAAyC;;AAEzC;AACA;AACA;AACA;AACA,MAAM;AACN;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB;;AAEjB,sCAAsC,iEAAwB;AAC9D;;AAEA;AACA;AACA,oBAAoB,mEAA0B;;AAE9C;AACA,kBAAkB;;AAElB;AACA;;AAEA,uDAAuD,gBAAgB;AACvE,oBAAoB,uEAAa;;AAEjC;AACA;AACA,gGAAgG,kEAAkE;;;AAGlK;AACA;AACA;AACA;AACA;AACA,gDAAgD,mEAAgB,qBAAqB,mEAAgB;;AAErG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,4BAA4B,uEAAa;AACzC,6GAA6G,mDAAmD;AAChK,0EAA0E,uEAAuE;AACjJ;;AAEA,yBAAyB;AACzB;AACA;AACA;AACA,qBAAqB;;AAErB,iBAAiB;;AAEjB,aAAa,EAAE;;AAEf;AACA;AACA;;AAEA;AACA,+CAA+C,qCAAqC;AACpF;;AAEA,aAAa;;AAEb,SAAS;;AAET,KAAK,EAAE;;AAEP,CAAC,U","sources":["webpack://prophet_asia/./src/js/forms/form-method.js","webpack://prophet_asia/./src/js/global/cookie.js","webpack://prophet_asia/./src/js/template-tags/modal.js","webpack://prophet_asia/webpack/bootstrap","webpack://prophet_asia/webpack/runtime/make namespace object","webpack://prophet_asia/./src/js/forms/form-block.js"],"sourcesContent":["let $ = jQuery;\nlet $window = $(window);\n\nlet phone \t\t = 650;\nlet portrait \t = 768;\nlet landscape \t = 1024;\nlet desktop \t = 1500;\nlet widescreen \t = 2160;\nlet windowHeight = window.innerHeight; //get height of the window\nlet windowHalfHeight = window.innerHeight / 2;\nlet windowWidth = window.innerWidth; //get width of window\n\nlet rgxWhiteSpace = /\\s/;\n\nfunction checkForm(form_name, fields){\n let field_list = fields;\n let valid_fields = false;\n\n for (let index = 0; index < field_list.length; index++) {\n\n if ( field_list[index].indexOf('first_name') !== -1 ||\n field_list[index].indexOf('last_name') !== -1 ){\n valid_fields = addValidation(form_name).name(field_list[index]);\n }// if\n\n if ( field_list[index].indexOf('email') !== -1 ){\n valid_fields = addValidation(form_name).email(field_list[index]);\n }// if\n\n if ( field_list[index].indexOf('inquiry_type') !== -1 ||\n field_list[index].indexOf('seniority') !== -1 ||\n field_list[index].indexOf('job_function') !== -1 ||\n field_list[index].indexOf('country') !== -1 ||\n field_list[index].indexOf('state_province') !== -1 ||\n field_list[index].indexOf('company') !== -1 ||\n field_list[index].indexOf('title') !== -1 ||\n field_list[index].indexOf('message') !== -1 ||\n field_list[index].indexOf('referral') !== -1 ||\n field_list[index].indexOf('referral_details') !== -1 ||\n field_list[index].indexOf('phase_question') !== -1 ){\n\n valid_fields = addValidation(form_name).defaultText(field_list[index]);\n }// if\n\n if ( field_list[index].indexOf('radio-button') !== -1 ){\n valid_fields = addValidation(form_name).radioButton(field_list[index]);\n }// if\n\n if ( field_list[index].indexOf('file_attachment') !== -1 ){\n valid_fields = addValidation(form_name).fileAttachment(field_list[index]);\n }// if\n\n if ( !valid_fields ){\n break;\n }// if\n }// for\n\n return valid_fields;\n};\n\nfunction addValidation(form_name){\n return {\n name: (id_name) => {\n\n let name = $(form_name).find('#'+id_name);\n let split_text = $(name).val().split('');\n\n // Invalid when white space is found at the beginning of the text\n if ( split_text[0] == ' ' || $(name).val().length < 1){\n // console.log('name ', name);\n invalidField(name);\n\n return false;\n }\n\n return true;\n },\n email: (id_name) =>{\n let email = $(form_name).find('#'+id_name);\n\n if ( !validateEmail( $(email).val() ) ){\n // console.log('email');\n invalidField(email);\n\n return false;\n }\n\n return true;\n },\n radioButton: (name) =>{\n let radio_buttons = $(form_name).find('#'+name).find('input[type=\"radio\"]');\n let radio_button_checked = 0;\n\n for (let index = 0; index < radio_buttons.length; index++) {\n // console.log('radio_buttons ', radio_buttons[index]);\n\n if ( !$(radio_buttons[index]).prop('checked') ){\n /* Increment if radio button isn't checked */\n radio_button_checked++;\n }\n\n /* if radio_button_checked equals to the total of radio button there is in the form then display error message */\n if ( radio_buttons.length == radio_button_checked ){\n\n TweenMax.to( $(form_name).find('#'+name).find('.radio-content span'), .4, {borderColor: '#f00', ease: Power3.easeOut} );\n\n setTimeout(function(){\n TweenMax.to( $(form_name).find('#'+name).find('.radio-content span'), .4, {borderColor: '#000', ease: Power3.easeOut} );\n }, 5000);\n\n return false;\n }\n\n }// for\n\n return true;\n },\n fileAttachment: (id_name) =>{\n let file_attachment = $(form_name).find('#'+id_name);\n\n if ( !$(file_attachment).val() ){\n // console.log('file_attachment ', file_attachment);\n if ( $(file_attachment).prop('id').indexOf('1') !== -1 ){\n TweenMax.to( $(file_attachment).parent(), .4, { color: '#f00', ease: Power3.easeOut} );\n\n setTimeout(function(){\n TweenMax.to( $(file_attachment).parent(), .4, { color: '#000', ease: Power3.easeOut} );\n }, 5000);\n }\n\n return false;\n }\n\n return true;\n },\n defaultText: (id_name) => {\n // Any field with the greater value length of 2\n let default_text = $(form_name).find('#'+id_name);\n let split_text = $(default_text).val().split('');\n\n // Invalid when white space is found at the beginning of the text and 2 should never be changed to any other number or validation will fail\n if ( split_text[0] == ' ' || $(default_text).val().length < 2 ){\n // console.log('default_text ', default_text);\n invalidField(default_text);\n\n let default_text_fail = new TimelineLite()\n .add(TweenMax.to(default_text, .4, {borderColor: '#f00', ease: Power3.easeOut}, '-=0.4'))\n .add(TweenMax.to(default_text, .4, {borderColor: '#000', ease: Power3.easeOut}, '+=1'));\n\n default_text_fail.play();\n\n return false;\n }\n\n return true;\n },\n };\n}\n\nfunction validateEmail(email) {\n let regExp = /^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n return regExp.test(email); \n}\n\nfunction invalidField(field){\n TweenMax.to( $(field).siblings('.bottom-line'), .5, { width: '100%', ease: Power3.easeOut } );\n TweenMax.to( $(field).siblings('.bottom-line'), 0, { borderBottom: '1px solid red', ease: Power3.easeOut } );\n}\n\nfunction failMessage(submit_button, dark_mode=false) {\n\n // For forms with black layout\n if ( dark_mode ){\n let dark_button_fail = new TimelineLite()\n .add(TweenMax.fromTo( $(submit_button).siblings('.required-message'), .4, {y: '-20px', bottom: 0, opacity: 1},{y: '0px', opacity: 1, left: 0, ease: Elastic.easeOut.config(1, 0.2)}));\n\n if ( windowWidth <= phone ) {\n TweenMax.to(submit_button, .4, { backgroundColor: '#f00', ease: Power3.easeOut });\n TweenMax.to(submit_button, .4, { backgroundColor: color_green, ease: Power3.easeOut }).delay(.4);\n }\n\n setTimeout(function(){\n TweenMax.to( $(submit_button).siblings('.required-message'), .4, {opacity: 0, bottom: 0, ease: Power3.easeIn});\n }, 5000);\n\n dark_button_fail.play();\n } else {\n let button_fail = new TimelineLite()\n .add(TweenMax.fromTo( $(submit_button).siblings('.required-message'), .4, {y: '-20px', bottom: 0, opacity: 1},{y: '0px', opacity: 1, left: 0, ease: Elastic.easeOut.config(1, 0.2)})) \n .add(TweenMax.to(submit_button, .4, {backgroundColor: '#ff0000', ease: Power3.easeIn}, '-=0.4'))\n .add(TweenMax.to(submit_button, .4, {backgroundColor: '#22ffab', ease: Power3.easeIn}, '+=1'));\n\n setTimeout(function(){\n TweenMax.to( $(submit_button).siblings('.required-message'), .4, {opacity: 0, bottom: 0, ease: Power3.easeIn});\n }, 5000);\n\n button_fail.play();\n }\n\n return false;\n}\n\nexport default {\n checkForm: checkForm,\n addValidation: addValidation,\n validateEmail: validateEmail,\n invalidField: invalidField,\n failMessage: failMessage\n};","/**\n *\n * JS Cookies\n * \n */\n\n/**\n * Set Cookie\n * Redundant code, need to consolidate with master.js function()\n * \n * @param {*} name \n * @param {*} value \n * @param {*} days \n * @param {*} path \n * @returns \n */\nlet setCookie = (name, value, days, path) => {\n let expires = \"\";\n\n if ( days ) {\n let date = new Date();\n\n date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));\n expires = \"; expires=\" + date.toUTCString();\n }\n\n return document.cookie = name + \"=\" + (value || \"\") + expires + \"; path=\"+path;\n}\n\n/**\n * Get Cookie\n * Redundant code, need to consolidate with master.js function()\n * \n * @param {*} name \n * @returns \n */\nlet getCookie = (name) => {\n //Get cookie by name\n let value = \"; \" + document.cookie;\n let parts = value.split(\"; \" + name + \"=\");\n\n if ( parts.length == 2 ) {\n return parts.pop().split(\";\").shift();\n }\n\n return false;\n};// getCookie\n\nexport default {\n setCookie: setCookie,\n getCookie: getCookie,\n};","/**\n * File modal.js\n *\n * Deal with multiple modals and their media.\n */\n\n\nfunction overLay( mode ) {\n\tconst modalOverLay = document.querySelector( '.modalOverlay' );\n\tif ( mode == 'show' ) {\n\t\tgsap.to( modalOverLay, .4, { display: 'block', opacity: 1, ease: Power3.easeOut } );\n\t\tmodalOverLay.classList.add('active');\n\t} else {\n\t\tgsap.to( modalOverLay , .4, {display: 'none', opacity: 0, ease: Power3.easeOut } );\n\t\tmodalOverLay.classList.remove('active');\n\t}\n};\n\n export default {\n overLay: overLay,\n};\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n *\n * Form Block\n * \n */\n\n import FormSubmission from './form-method.js';\n import Modal from '../template-tags/modal.js';\n import Cookie from '../global/cookie.js';\n \n (function ($) {\n \n const iPadAgent = navigator.userAgent.match(/iPad/i) \t\t!= null;\n const iPodAgent = navigator.userAgent.match(/iPhone/i) \t\t!= null;\n const AndroidAgent = navigator.userAgent.match(/Android/i) \t!= null;\n const webOSAgent = navigator.userAgent.match(/webOS/i) \t\t!= null;\n\n let mobile;\n let phone = 670;\n let windowWidth = window.innerWidth; //get width of window\n\n // Check to see if screen is mobile\n if (iPadAgent || iPodAgent || AndroidAgent || webOSAgent || windowWidth <= phone) {\n $('body').addClass('mobile');\n mobile = true;\n } else {\n mobile = false;\n }// if - else\n \n $(function() {\n const formBlock = document.getElementById('form-block');\n\n if ( formBlock ) {\n formBlock.addEventListener( 'submit', ( evt ) => {\n evt.preventDefault();\n // To validate a field you must add the id name of the field to the validate_fields array, or the field will be ignored when validation is executed.\n // The order of the array elements is important to validate the form fields in the proper order.\n let _this_form = evt.target;\n let allRequiredFields = document.querySelectorAll('.required-form-field');\n let validate_fields = [];\n\n allRequiredFields.forEach( elem => {\n // Add field name to array so it can validated by checkForm()\n validate_fields.push(elem.name);\n })\n\n let valid_form = FormSubmission.checkForm(_this_form, validate_fields);\n let connect_submit = $(_this_form, '.form-row').find('.connect-submit-btn');\n\n if ( !valid_form ){\n // console.log('connect_form not valid');\n FormSubmission.failMessage(connect_submit);\n\n return false;\n } else {\n\n // Disable submit button until page gets redirected\n connect_submit.disabled = true;\n\n gsap.to($( '.modalOverlay'), .4, { 'z-index': 998} );\n Modal.overLay('show');\n\n document.querySelector('body').style.overflow = 'hidden';\n $('body > .modalOverlay').find('.circle-arrows').addClass('animate-spin');\n gsap.to( $('body > .modalOverlay').find('.loading-circle-container'), .3, { display: 'flex', opacity: 1, zIndex: '999', ease: Power3.easeIn } );\n\n\n // Add empty value to field/fields that are hidden by ACF\n const inquiry_type = ( _this_form.querySelector('#inquiry_type') ) ? _this_form.querySelector('#inquiry_type').value : '';\n const referral = ( _this_form.querySelector('#referral') ) ? _this_form.querySelector('#referral').value : '';\n const referral_details = ( _this_form.querySelector('#referral_details') ) ? _this_form.querySelector('#referral_details').value : '';\n const subscribed = ( _this_form.querySelector('.connect-checkbox') ) ? _this_form.querySelector('.connect-checkbox').checked : false;\n const referrerUrl = ( Cookie.getCookie( 'p_referrer' ) ) ? Cookie.getCookie( 'p_referrer' ) : '';\n\n const FORM_HANDLER_URL = '/process/form-connect-handler.php';\n let form_data = {\n 'form_type' : _this_form.name,\n 'inquiry_type' : inquiry_type,\n 'first_name' : _this_form.querySelector('#first_name').value,\n 'last_name' : _this_form.querySelector('#last_name').value,\n 'email' : _this_form.querySelector('#email').value,\n 'company' : _this_form.querySelector('#company').value,\n 'seniority' : _this_form.querySelector('#seniority').value,\n 'job_function' : _this_form.querySelector('#job_function').value,\n 'country' : _this_form.querySelector('#country').value,\n 'message' : _this_form.querySelector('#message').value,\n 'site_language' : _this_form.querySelector('.site_language').value,\n 'report_name' : _this_form.querySelector('.report_name').value,\n 'referral' : referral,\n 'referral_details' : referral_details,\n 'subscribe_box' : subscribed,\n 'utm_source' : _this_form.querySelector('.utm_source').value,\n 'utm_medium' : _this_form.querySelector('.utm_medium').value,\n 'utm_campaign' : _this_form.querySelector('.utm_campaign').value,\n 'referrer_url' : referrerUrl\n };\n\n $.ajax({\n method: 'POST',\n url: FORM_HANDLER_URL,\n data: form_data,\n success: function(response, status) {\n // console.log(\"Data posted successfully: \", response);\n\n Modal.overLay('hide');\n gsap.to( [ 'body > .modalOverlay .loading-circle-container', _this_form ], .4, { display: 'none', opacity: 0, ease: Power3.easeIn } );\n gsap.to( _this_form.nextElementSibling, .4, { display: 'flex', opacity: 1, bottom: 0, left: 0, ease: Power3.easeIn } ).delay(.6);\n document.querySelector('body').style.overflow = 'scroll';\n\n },\n error: function(error) {\n console.log(\"Error posting data: \", error.responseJSON );\n }\n });\n\n }// if/else\n\n });// #form-block\n\n formBlock.addEventListener( 'focus', ( evt ) => {\n let _this_form = evt.target;\n let bottomLine = _this_form.nextElementSibling;\n\n if ( bottomLine ) {\n gsap.to( bottomLine, .4, { width: '0', ease: Power3.easeInOut } );\n }\n\n }, true);\n\n }// if (form-block)\n\n });// ready\n\n})(jQuery);"],"names":[],"sourceRoot":""}