/*!
* WPMU DEV Forminator UI
* Copyright 2019 Incsub (https://incsub.com)
* Licensed under GPL v3 (http://www.gnu.org/licenses/gpl-3.0.html)
*/
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
(function ($) {
'use strict';
// Define global FUI object if it doesn't exist.
if ('object' !== _typeof(window.FUI)) {
window.FUI = {};
}
FUI.formLoad = function (el) {
var form = $(el);
var message = form.find('.forminator-response-message');
if (!form.is('.forminator-ui') && !form.is('.forminator-custom-form')) {
return;
}
function reset() {
// Hide response message
message.removeClass('forminator-show');
message.removeClass('forminator-accessible');
// Make sure response message
// is not accessible by screen readers
message.attr('aria-hidden', 'true');
}
function formId() {
var attrId = form.data('id');
var dataId = form.data('id');
if (attrId.length && '' !== attrId) {
form.addClass('forminator-form-' + dataId);
}
}
function formDesign() {
var attrDesign = form.data('design');
var dataDesign = form.data('design');
if (attrDesign && '' !== attrDesign) {
form.addClass('forminator-design--' + dataDesign);
} else {
form.addClass('forminator-design--none');
}
}
function formGrid() {
var attrGrid = form.data('grid');
var dataGrid = form.data('grid');
// Reset
form.removeClass('forminator-custom');
form.removeClass('forminator-enclosed');
// Assign class
if (attrGrid && '' !== attrGrid) {
if ('open' !== attrGrid) {
form.addClass('forminator-' + dataGrid);
}
}
}
function init() {
// Reset
reset();
// Form unique id
formId();
// Form design class
formDesign();
// Form grid class
formGrid();
}
init();
return this;
};
})(jQuery);
(function ($) {
'use strict';
// Define global FUI object if it doesn't exist.
if ('object' !== _typeof(window.FUI)) {
window.FUI = {};
}
FUI.formSimulation = function (el) {
var submit = $(el);
var form = submit.closest('form');
var response = form.find('.forminator-response-message');
var message = '';
if (!form.is('.forminator-ui') && !form.is('.forminator-custom-form')) {
return;
}
function validateReset() {
message = '';
// Empty response
response.html(message);
// Hide response
response.removeClass('forminator-show');
response.removeClass('forminator-accessible');
// Clear out response type
response.removeClass('forminator-error');
response.removeClass('forminator-success');
// Hide response for screen readers
response.attr('aria-hidden', 'true');
response.removeAttr('tabindex');
// Remove error class from fields
form.find('.forminator-field').removeClass('forminator-has_error');
}
function validateError() {
// Show response
response.addClass('forminator-accessible');
// Show response for screen readers
response.removeAttr('aria-hidden');
response.prop('tabindex', '-1');
// Focus message
response.focus();
}
function validateSuccess() {
message = '
Form was submitted successfully.
';
// Print message
response.html(message);
// Show response
response.addClass('forminator-success');
response.addClass('forminator-show');
// Show response for screen readers
response.removeAttr('aria-hidden');
response.prop('tabindex', '-1');
// Focus message
response.focus();
}
function validateInput() {
var input = form.find('.forminator-input');
input.each(function () {
var current = $(this);
var inputField = current.closest('.forminator-field');
var inputLabel = inputField.find('.forminator-label');
if (inputField.hasClass('forminator-is_required') && '' === current.val()) {
inputField.addClass('forminator-has_error');
if (inputLabel.length) {
message += '' + inputLabel.text() + ' needs to be filled.';
} else {
message += '' + current.prop('id') + ' needs to be filled.';
}
}
});
// Print message
response.html(message);
}
function validateTextarea() {
var textarea = form.find('.forminator-textarea');
textarea.each(function () {
var current = $(this);
var textareaField = current.closest('.forminator-field');
var textareaLabel = textareaField.find('.forminator-label');
if (textareaField.hasClass('forminator-is_required') && '' === current.val()) {
textareaField.addClass('forminator-has_error');
if (textareaLabel.length) {
message += '' + textareaLabel.text() + ' needs to be filled.';
} else {
message += '' + current.prop('id') + ' needs to be filled.';
}
}
});
// Print message
response.html(message);
}
function validateRadio() {
var radioField = form.find('.forminator-field-radio');
radioField.each(function () {
var field = $(this);
var label = field.find('.forminator-label');
var radio = field.find('.forminator-radio');
var options = radio.find('input').map(function () {
return this.id;
}).get();
if (field.hasClass('forminator-is_required') && 0 === radio.find('input:checked').length) {
field.addClass('forminator-has_error');
if (label.length) {
message += '' + label.text() + ' needs at least one option selected.';
} else {
message += 'You must select at lease one of these options: ' + options.join(',') + '';
}
}
});
// Print message
response.html(message);
}
function validateMultiSelect() {
var multiselect = form.find('.forminator-multiselect');
multiselect.each(function () {
var current = $(this);
var field = current.closest('.forminator-field');
var label = field.find('.forminator-label');
var options = current.find('.forminator-option');
var optionsMap = options.find('input').map(function () {
return this.id;
}).get();
if (field.hasClass('forminator-is_required') && 0 === options.find('input:checked').length) {
field.addClass('forminator-has_error');
if (label.length) {
message += '' + label.text() + ' needs at least one option selected.';
} else {
message += 'You must select at lease one of these options: ' + optionsMap.join(',') + '';
}
}
});
// Print message
response.html(message);
}
function validation() {
var input = form.find('.forminator-input');
var inputField = input.closest('.forminator-field');
var inputRequired = input.closest('.forminator-field.forminator-is_required');
var inputFilled = inputRequired.find('.forminator-input').filter(function () {
return !!this.value;
});
var textarea = form.find('.forminator-textarea');
var textareaField = textarea.closest('.forminator-field');
var textareaRequired = textarea.closest('.forminator-field.forminator-is_required');
var textareaFilled = textareaRequired.find('.forminator-textarea').val();
var radioField = form.find('.forminator-field-radio');
var radioRequired = form.find('.forminator-field-radio.forminator-is_required');
var radioSelected = radioRequired.find('input:checked');
var multiselect = form.find('.forminator-multiselect');
var multiselectField = multiselect.closest('.forminator-field');
var multiselectRequired = multiselect.closest('.forminator-field.forminator-is_required');
var multiselectSelected = multiselectRequired.find('input:checked');
// Reset - Hide message
validateReset();
if (inputField.hasClass('forminator-is_required') && inputFilled.length !== inputRequired.length || textareaField.hasClass('forminator-is_required') && '' === textareaFilled.length || radioField.hasClass('forminator-is_required') && 0 === radioSelected.length || multiselectField.hasClass('forminator-is_required') && 0 === multiselectSelected.length) {
validateInput();
validateTextarea();
validateRadio();
validateMultiSelect();
validateError();
} else {
validateSuccess();
}
}
function init() {
submit.on('click', function (e) {
validation();
e.preventDefault();
e.stopPropagation();
return false;
});
}
init();
return this;
};
})(jQuery);
(function ($) {
// Enable strict mode.
'use strict';
// Define global SUI object if it doesn't exist.
if ('object' !== _typeof(window.FUI)) {
window.FUI = {};
}
FUI.inputStates = function (el) {
var input = $(el);
var form = input.closest('form');
if (!input.is('input') && (!form.is('.forminator-poll') || !form.is('.forminator-ui') && !form.is('.forminator-custom-form'))) {
return;
}
function hover(element) {
var getInput = $(element);
var getField = getInput.closest('.forminator-field');
getInput.mouseover(function (e) {
getField.addClass('forminator-is_hover');
e.stopPropagation();
}).mouseout(function (e) {
getField.removeClass('forminator-is_hover');
e.stopPropagation();
});
}
function focused(element) {
var getInput = $(element);
var getField = getInput.closest('.forminator-field');
getInput.focus(function (e) {
getField.addClass('forminator-is_active');
e.stopPropagation();
}).blur(function (e) {
getField.removeClass('forminator-is_active');
e.stopPropagation();
});
}
function filled(element) {
var getInput = $(element);
var getField = getInput.closest('.forminator-field');
// On input load
if ('' !== getInput.val().trim()) {
getField.addClass('forminator-is_filled');
}
// On input changes
getInput.on('change', function () {
if ('' !== getInput.val().trim()) {
getField.addClass('forminator-is_filled');
} else {
getField.removeClass('forminator-is_filled');
}
});
}
function init() {
input.each(function () {
hover(this);
focused(this);
filled(this);
});
}
init();
return this;
};
})(jQuery);
(function ($) {
// Enable strict mode.
'use strict';
// Define global SUI object if it doesn't exist.
if ('object' !== _typeof(window.FUI)) {
window.FUI = {};
}
FUI.inputMaterial = function (el) {
var input = $(el);
var field = input.closest('.forminator-field');
var label = field.find('.forminator-label');
var form = input.closest('form');
if (!input.is('input') && (!form.is('.forminator-poll') || !form.is('.forminator-ui') && !form.is('.forminator-custom-form'))) {
return;
}
function init() {
// Wrap Element
if (!input.parent().hasClass('forminator-input--wrap')) {
input.wrap('');
}
// Wrap Label
if (label.length) {
// Add floating class
label.addClass('forminator-floating--input');
// Add icon class (if applies)
if (field.find('.forminator-input-with-icon').length) {
label.addClass('forminator-has_icon');
}
// Add phone class (if applies)
if (field.find('.forminator-input-with-phone').length) {
label.addClass('forminator-has_phone');
if (field.find('.intl-tel-input').hasClass('allow-dropdown')) {
label.addClass('allow-dropdown');
}
}
}
}
init();
return this;
};
})(jQuery);
(function ($) {
// Enable strict mode.
'use strict';
// Define global SUI object if it doesn't exist.
if ('object' !== _typeof(window.FUI)) {
window.FUI = {};
}
FUI.textareaStates = function (el) {
var textarea = $(el);
var form = textarea.closest('form');
if (!textarea.is('textarea') && !form.is('.forminator-ui') && !form.is('.forminator-custom-form')) {
return;
}
function hover(element) {
var getTextarea = $(element);
var getField = getTextarea.closest('.forminator-field');
getTextarea.mouseover(function (e) {
getField.addClass('forminator-is_hover');
e.stopPropagation();
}).mouseout(function (e) {
getField.removeClass('forminator-is_hover');
e.stopPropagation();
});
}
function focused(element) {
var getTextarea = $(element);
var getField = getTextarea.closest('.forminator-field');
getTextarea.focus(function (e) {
getField.addClass('forminator-is_active');
e.stopPropagation();
}).blur(function (e) {
getField.removeClass('forminator-is_active');
e.stopPropagation();
});
}
function filled(element) {
var getTextarea = $(element);
var getField = getTextarea.closest('.forminator-field');
// On textarea load
getTextarea.on('load', function () {
if ('' !== getTextarea.val().trim()) {
getField.addClass('forminator-is_filled');
}
});
// On textarea changes
getTextarea.on('change', function () {
if ('' !== getTextarea.val().trim()) {
getField.addClass('forminator-is_filled');
} else {
getField.removeClass('forminator-is_filled');
}
});
}
function init() {
textarea.each(function () {
hover(this);
focused(this);
filled(this);
});
}
init();
return this;
};
})(jQuery);
(function ($) {
// Enable strict mode.
'use strict';
// Define global SUI object if it doesn't exist.
if ('object' !== _typeof(window.FUI)) {
window.FUI = {};
}
FUI.textareaMaterial = function (el) {
var textarea = $(el);
var field = textarea.closest('.forminator-field');
var label = field.find('.forminator-label');
var form = textarea.closest('form');
if (!textarea.is('textarea') && !form.is('.forminator-ui') && !form.is('.forminator-custom-form')) {
return;
}
if (textarea.hasClass('wp-editor-area')) {
return;
}
function init() {
// Wrap Element
if (!textarea.parent().hasClass('forminator-textarea--wrap')) {
textarea.wrap('');
}
// Wrap Label
if (label.length) {
var labelHeight = 0 === label.height() ? 20 : label.height();
var labelPadding = 9;
var labelMath = labelHeight + labelPadding;
// Add floating class
label.addClass('forminator-floating--textarea');
// Align textarea
field.css({
'position': 'relative'
});
if (textarea.val()) {
field.addClass('forminator-is_filled');
}
if (!field.hasClass('forminator-is_filled') || !field.hasClass('forminator-is_active')) {
label.css({
'padding-top': labelMath + 'px'
});
}
textarea.css({
'padding-top': labelMath + 'px'
});
}
}
init();
return this;
};
})(jQuery);
(function ($) {
// Enable strict mode.
'use strict';
// Define global FUI object if it doesn't exist.
if ('object' !== _typeof(window.FUI)) {
window.FUI = {};
}
FUI.radioStates = function (el) {
var label = $(el);
var input = label.find('input');
if (!label.is('label') || 'radio' !== input.prop('type')) {
return;
}
function init() {
input.each(function () {
$(this).on('click', function () {
var radioInput = $(this);
var radioLabel = radioInput.parent();
var radioField = radioLabel.closest('.forminator-field');
var radioOptions = radioField.find('.forminator-radio');
// Remove checked attribute
radioOptions.find('input').prop('checked', false);
// Remove checked class
radioOptions.removeClass('forminator-is_checked');
// Assign checked attribute
radioInput.prop('checked', 'checked');
// Assign checked class
radioLabel.addClass('forminator-is_checked');
});
});
}
init();
return this;
};
})(jQuery);
(function ($) {
// Enable strict mode.
'use strict';
// Define global FUI object if it doesn't exist.
if ('object' !== _typeof(window.FUI)) {
window.FUI = {};
}
FUI.checkboxStates = function (el) {
var label = $(el);
var input = label.find('input');
if (!label.is('label') || 'checkbox' !== input.prop('type')) {
return;
}
function init() {
input.each(function () {
$(this).on('click', function () {
var checkInput = $(this);
var checkLabel = checkInput.parent();
if (checkLabel.is('.forminator-is_checked')) {
checkLabel.removeClass('forminator-is_checked');
} else {
checkLabel.addClass('forminator-is_checked');
}
});
});
}
init();
return this;
};
})(jQuery);
(function ($) {
// Enable strict mode.
'use strict';
// Define global FUI object if it doesn't exist.
if ('object' !== _typeof(window.FUI)) {
window.FUI = {};
}
FUI.multiSelectStates = function (el) {
var container = $(el);
var option = container.find('.forminator-option');
var input = option.find('input');
if (!container.is('.forminator-multiselect') || 0 === option.length) {
return;
}
function init() {
input.each(function () {
$(this).on('click', function () {
var checkInput = $(this);
var checkLabel = checkInput.parent();
if (checkLabel.is('.forminator-is_checked')) {
checkLabel.removeClass('forminator-is_checked');
} else {
checkLabel.addClass('forminator-is_checked');
}
});
});
}
init();
return this;
};
})(jQuery);
(function ($) {
// Enable strict mode
'use strict';
// Define global FUI object if it doesn't exist.
if ('object' !== _typeof(window.FUI)) {
window.FUI = {};
}
FUI.select = {};
FUI.select.escapeJS = function (string) {
// Create a temporary element using jQuery and set the HTML content.
var div = $('
').html(string);
// Get the text content of the
element and remove script tags
var text = div.text().replace(/