1(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["sendify_frontend"],{ 2
3/***/ "./app/front/frontend.js": 4/*!*******************************!*\ 5 !*** ./app/front/frontend.js ***! 6 \*******************************/ 7/*! no exports provided */ 8/***/ (function(module, __webpack_exports__, __webpack_require__) { 9 10"use strict"; 11__webpack_require__.r(__webpack_exports__); 12/* harmony import */ var _utils_helper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils/helper */ "./app/front/utils/helper.js"); 13 14window.addEventListener("DOMContentLoaded", function (event) { 15 document.querySelectorAll('.optin-form__button').forEach(function (optin_button) { 16 optin_button.addEventListener('click', function () { 17 var parentContainer = optin_button.parentElement.parentElement; 18 var email_field = parentContainer.querySelector('.optin-form__email'); 19 var listId = parentContainer.getAttribute('data-list'); 20 var double_optin = parentContainer.getAttribute('data-double-optin'); 21 22 if (Object(_utils_helper__WEBPACK_IMPORTED_MODULE_0__["validateEmail"])(email_field.value)) { 23 $( document ).trigger("sendify:subscribe_start"); 24 fetch(sendify.ajaxurl, { 25 method: 'POST', 26 headers: { 27 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' 28 }, 29 body: "action=subscribe_to_list&email=".concat(encodeURIComponent(email_field.value), "&list=").concat(listId, "&double_optin=").concat(double_optin), 30 credentials: 'same-origin' 31 }).then(function (res) { 32 return res.json(); 33 }).then(function (data) { 34 $( document ).trigger("sendify:subscribe_end",[data.success, data]); 35 if (data.success) { 36 Object(_utils_helper__WEBPACK_IMPORTED_MODULE_0__["render_alert"])('success', sendify.js_strings.optin_success_validation, optin_button.parentElement); 37 } else { 38 if (data.data.message === 'Contact already exist') { 39 Object(_utils_helper__WEBPACK_IMPORTED_MODULE_0__["render_alert"])('success', sendify.js_strings.optin_success_validation, optin_button.parentElement); 40 } else { 41 Object(_utils_helper__WEBPACK_IMPORTED_MODULE_0__["render_alert"])('error', data.data.message, optin_button.parentElement); 42 } 43 } 44 }); 45 } else { 46 Object(_utils_helper__WEBPACK_IMPORTED_MODULE_0__["render_alert"])('error', sendify.js_strings.optin_email_invalid, optin_button.parentElement); 47 } 48 }); 49 }); 50 document.querySelectorAll('.optin-form__email').forEach(function (input) { 51 input.addEventListener("keyup", function (event) { 52 // Number 13 is the "Enter" key on the keyboard 53 if (event.keyCode === 13) { 54 // Cancel the default action, if needed 55 event.preventDefault(); // Trigger the button element with a click 56 57 input.parentElement.querySelector('.optin-form__button').click(); 58 } 59 }); 60 }); 61 62 if (document.querySelector('#sendify_multi_list_optins')) { 63 document.querySelector('#sendify_multi_list_optins').addEventListener('submit', function (e) { 64 e.preventDefault(); 65 var form = document.querySelector('#sendify_multi_list_optins'); // const formData = serialize( document.querySelector('#sendify_multi_list_optins')); 66 67 var formData = Object(_utils_helper__WEBPACK_IMPORTED_MODULE_0__["serialize"])(form); 68 var email = form.querySelector('#email_to_optin').value; 69 fetch(sendify.ajaxurl, { 70 method: 'POST', 71 headers: { 72 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' 73 }, 74 body: "action=subscribe_mutiple_list&".concat(formData, "&email=").concat(email), 75 credentials: 'same-origin' 76 }).then(function (res) { 77 return res.json(); 78 }).then(function (data) {}); 79 }); 80 } 81}); 82 83/***/ }), 84
85/***/ "./app/front/utils/helper.js": 86/*!***********************************!*\ 87 !*** ./app/front/utils/helper.js ***! 88 \***********************************/ 89/*! exports provided: validateEmail, render_alert, serialize */ 90/***/ (function(module, __webpack_exports__, __webpack_require__) { 91 92"use strict"; 93__webpack_require__.r(__webpack_exports__); 94/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "validateEmail", function() { return validateEmail; }); 95/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render_alert", function() { return render_alert; }); 96/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; }); 97function validateEmail(email) { 98 var re = /^(([^<>()\[\]\\.,;:\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,}))$/; 99 return re.test(String(email).toLowerCase()); 100} 101function render_alert(type, message, dom_container) { 102 if (dom_container.querySelector('.optin-form__alert')) { 103 var message_element = dom_container.querySelector('.optin-form__alert'); 104 message_element.className = ''; 105 message_element.classList.add('optin-form__alert'); 106 message_element.classList.add('optin-form__alert--' + type + ''); 107 message_element.innerText = message; 108 setTimeout(function () { 109 message_element.remove(); 110 }, sendify.timeout_msg_hide); 111 } else { 112 var _message_element = document.createElement('span'); 113 114 _message_element.classList.add('optin-form__alert'); 115 116 _message_element.classList.add('optin-form__alert--' + type + ''); 117 118 _message_element.innerText = message; 119 dom_container.appendChild(_message_element); 120 setTimeout(function () { 121 _message_element.remove(); 122 }, sendify.timeout_msg_hide); 123 } 124} 125function serialize(form) { 126 // Setup our serialized data 127 var serialized = []; // Loop through each field in the form 128 129 for (var i = 0; i < form.elements.length; i++) { 130 var field = form.elements[i]; // Don't serialize fields without a name, submits, buttons, file and reset inputs, and disabled fields 131 132 if (!field.name || field.disabled || field.type === 'file' || field.type === 'reset' || field.type === 'submit' || field.type === 'button') continue; // If a multi-select, get all selections 133 134 if (field.type === 'select-multiple') { 135 for (var n = 0; n < field.options.length; n++) { 136 if (!field.options[n].selected) continue; 137 serialized.push(encodeURIComponent(field.name) + "=" + encodeURIComponent(field.options[n].value)); 138 } 139 } // Convert field data to a query string 140 else if (field.type !== 'checkbox' && field.type !== 'radio' || field.checked) { 141 serialized.push(encodeURIComponent(field.name) + "=" + encodeURIComponent(field.value)); 142 } 143 } 144 145 return serialized.join('&'); 146} 147; 148 149/***/ })
149 150 151},[["./app/front/frontend.js","runtime"]]]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.