Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wpforms-.../assets/js/componen.../admin/gutenber...
File: formselector.es5.js
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
[0] Fix | Delete
"use strict";
[1] Fix | Delete
[2] Fix | Delete
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); }
[3] Fix | Delete
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
[4] Fix | Delete
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
[5] Fix | Delete
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
[6] Fix | Delete
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
[7] Fix | Delete
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
[8] Fix | Delete
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
[9] Fix | Delete
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
[10] Fix | Delete
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
[11] Fix | Delete
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
[12] Fix | Delete
/* global wpforms_gutenberg_form_selector, Choices, JSX, DOM */
[13] Fix | Delete
/* jshint es3: false, esversion: 6 */
[14] Fix | Delete
[15] Fix | Delete
/**
[16] Fix | Delete
* Gutenberg editor block.
[17] Fix | Delete
*
[18] Fix | Delete
* @since 1.8.1
[19] Fix | Delete
*/
[20] Fix | Delete
var WPForms = window.WPForms || {};
[21] Fix | Delete
WPForms.FormSelector = WPForms.FormSelector || function (document, window, $) {
[22] Fix | Delete
var _wp = wp,
[23] Fix | Delete
_wp$serverSideRender = _wp.serverSideRender,
[24] Fix | Delete
ServerSideRender = _wp$serverSideRender === void 0 ? wp.components.ServerSideRender : _wp$serverSideRender;
[25] Fix | Delete
var _wp$element = wp.element,
[26] Fix | Delete
createElement = _wp$element.createElement,
[27] Fix | Delete
Fragment = _wp$element.Fragment,
[28] Fix | Delete
useState = _wp$element.useState,
[29] Fix | Delete
createInterpolateElement = _wp$element.createInterpolateElement;
[30] Fix | Delete
var registerBlockType = wp.blocks.registerBlockType;
[31] Fix | Delete
var _ref = wp.blockEditor || wp.editor,
[32] Fix | Delete
InspectorControls = _ref.InspectorControls,
[33] Fix | Delete
InspectorAdvancedControls = _ref.InspectorAdvancedControls,
[34] Fix | Delete
PanelColorSettings = _ref.PanelColorSettings;
[35] Fix | Delete
var _wp$components = wp.components,
[36] Fix | Delete
SelectControl = _wp$components.SelectControl,
[37] Fix | Delete
ToggleControl = _wp$components.ToggleControl,
[38] Fix | Delete
PanelBody = _wp$components.PanelBody,
[39] Fix | Delete
Placeholder = _wp$components.Placeholder,
[40] Fix | Delete
Flex = _wp$components.Flex,
[41] Fix | Delete
FlexBlock = _wp$components.FlexBlock,
[42] Fix | Delete
__experimentalUnitControl = _wp$components.__experimentalUnitControl,
[43] Fix | Delete
TextareaControl = _wp$components.TextareaControl,
[44] Fix | Delete
Button = _wp$components.Button,
[45] Fix | Delete
Modal = _wp$components.Modal;
[46] Fix | Delete
var _wpforms_gutenberg_fo = wpforms_gutenberg_form_selector,
[47] Fix | Delete
strings = _wpforms_gutenberg_fo.strings,
[48] Fix | Delete
defaults = _wpforms_gutenberg_fo.defaults,
[49] Fix | Delete
sizes = _wpforms_gutenberg_fo.sizes,
[50] Fix | Delete
urls = _wpforms_gutenberg_fo.urls,
[51] Fix | Delete
isPro = _wpforms_gutenberg_fo.isPro;
[52] Fix | Delete
var defaultStyleSettings = defaults;
[53] Fix | Delete
var __ = wp.i18n.__;
[54] Fix | Delete
[55] Fix | Delete
/**
[56] Fix | Delete
* List of forms.
[57] Fix | Delete
*
[58] Fix | Delete
* Default value is localized in FormSelector.php.
[59] Fix | Delete
*
[60] Fix | Delete
* @since 1.8.4
[61] Fix | Delete
*
[62] Fix | Delete
* @type {Object}
[63] Fix | Delete
*/
[64] Fix | Delete
var formList = wpforms_gutenberg_form_selector.forms;
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Blocks runtime data.
[68] Fix | Delete
*
[69] Fix | Delete
* @since 1.8.1
[70] Fix | Delete
*
[71] Fix | Delete
* @type {Object}
[72] Fix | Delete
*/
[73] Fix | Delete
var blocks = {};
[74] Fix | Delete
[75] Fix | Delete
/**
[76] Fix | Delete
* Whether it is needed to trigger server rendering.
[77] Fix | Delete
*
[78] Fix | Delete
* @since 1.8.1
[79] Fix | Delete
*
[80] Fix | Delete
* @type {boolean}
[81] Fix | Delete
*/
[82] Fix | Delete
var triggerServerRender = true;
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Popup container.
[86] Fix | Delete
*
[87] Fix | Delete
* @since 1.8.3
[88] Fix | Delete
*
[89] Fix | Delete
* @type {Object}
[90] Fix | Delete
*/
[91] Fix | Delete
var $popup = {};
[92] Fix | Delete
[93] Fix | Delete
/**
[94] Fix | Delete
* Track fetch status.
[95] Fix | Delete
*
[96] Fix | Delete
* @since 1.8.4
[97] Fix | Delete
*
[98] Fix | Delete
* @type {boolean}
[99] Fix | Delete
*/
[100] Fix | Delete
var isFetching = false;
[101] Fix | Delete
[102] Fix | Delete
/**
[103] Fix | Delete
* Public functions and properties.
[104] Fix | Delete
*
[105] Fix | Delete
* @since 1.8.1
[106] Fix | Delete
*
[107] Fix | Delete
* @type {Object}
[108] Fix | Delete
*/
[109] Fix | Delete
var app = {
[110] Fix | Delete
/**
[111] Fix | Delete
* Start the engine.
[112] Fix | Delete
*
[113] Fix | Delete
* @since 1.8.1
[114] Fix | Delete
*/
[115] Fix | Delete
init: function init() {
[116] Fix | Delete
app.initDefaults();
[117] Fix | Delete
app.registerBlock();
[118] Fix | Delete
$(app.ready);
[119] Fix | Delete
},
[120] Fix | Delete
/**
[121] Fix | Delete
* Document ready.
[122] Fix | Delete
*
[123] Fix | Delete
* @since 1.8.1
[124] Fix | Delete
*/
[125] Fix | Delete
ready: function ready() {
[126] Fix | Delete
app.events();
[127] Fix | Delete
},
[128] Fix | Delete
/**
[129] Fix | Delete
* Events.
[130] Fix | Delete
*
[131] Fix | Delete
* @since 1.8.1
[132] Fix | Delete
*/
[133] Fix | Delete
events: function events() {
[134] Fix | Delete
$(window).on('wpformsFormSelectorEdit', _.debounce(app.blockEdit, 250)).on('wpformsFormSelectorFormLoaded', _.debounce(app.formLoaded, 250));
[135] Fix | Delete
},
[136] Fix | Delete
/**
[137] Fix | Delete
* Get fresh list of forms via REST-API.
[138] Fix | Delete
*
[139] Fix | Delete
* @since 1.8.4
[140] Fix | Delete
*
[141] Fix | Delete
* @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-api-fetch/
[142] Fix | Delete
*/
[143] Fix | Delete
getForms: function getForms() {
[144] Fix | Delete
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
[145] Fix | Delete
var response;
[146] Fix | Delete
return _regeneratorRuntime().wrap(function _callee$(_context) {
[147] Fix | Delete
while (1) switch (_context.prev = _context.next) {
[148] Fix | Delete
case 0:
[149] Fix | Delete
if (!isFetching) {
[150] Fix | Delete
_context.next = 2;
[151] Fix | Delete
break;
[152] Fix | Delete
}
[153] Fix | Delete
return _context.abrupt("return");
[154] Fix | Delete
case 2:
[155] Fix | Delete
// Set the flag to true indicating a fetch is in progress.
[156] Fix | Delete
isFetching = true;
[157] Fix | Delete
_context.prev = 3;
[158] Fix | Delete
_context.next = 6;
[159] Fix | Delete
return wp.apiFetch({
[160] Fix | Delete
path: '/wpforms/v1/forms/',
[161] Fix | Delete
method: 'GET',
[162] Fix | Delete
cache: 'no-cache'
[163] Fix | Delete
});
[164] Fix | Delete
case 6:
[165] Fix | Delete
response = _context.sent;
[166] Fix | Delete
// Update the form list.
[167] Fix | Delete
formList = response.forms;
[168] Fix | Delete
_context.next = 13;
[169] Fix | Delete
break;
[170] Fix | Delete
case 10:
[171] Fix | Delete
_context.prev = 10;
[172] Fix | Delete
_context.t0 = _context["catch"](3);
[173] Fix | Delete
// eslint-disable-next-line no-console
[174] Fix | Delete
console.error(_context.t0);
[175] Fix | Delete
case 13:
[176] Fix | Delete
_context.prev = 13;
[177] Fix | Delete
isFetching = false;
[178] Fix | Delete
return _context.finish(13);
[179] Fix | Delete
case 16:
[180] Fix | Delete
case "end":
[181] Fix | Delete
return _context.stop();
[182] Fix | Delete
}
[183] Fix | Delete
}, _callee, null, [[3, 10, 13, 16]]);
[184] Fix | Delete
}))();
[185] Fix | Delete
},
[186] Fix | Delete
/**
[187] Fix | Delete
* Open builder popup.
[188] Fix | Delete
*
[189] Fix | Delete
* @since 1.6.2
[190] Fix | Delete
*
[191] Fix | Delete
* @param {string} clientID Block Client ID.
[192] Fix | Delete
*/
[193] Fix | Delete
openBuilderPopup: function openBuilderPopup(clientID) {
[194] Fix | Delete
if ($.isEmptyObject($popup)) {
[195] Fix | Delete
var tmpl = $('#wpforms-gutenberg-popup');
[196] Fix | Delete
var parent = $('#wpwrap');
[197] Fix | Delete
parent.after(tmpl);
[198] Fix | Delete
$popup = parent.siblings('#wpforms-gutenberg-popup');
[199] Fix | Delete
}
[200] Fix | Delete
var url = wpforms_gutenberg_form_selector.get_started_url,
[201] Fix | Delete
$iframe = $popup.find('iframe');
[202] Fix | Delete
app.builderCloseButtonEvent(clientID);
[203] Fix | Delete
$iframe.attr('src', url);
[204] Fix | Delete
$popup.fadeIn();
[205] Fix | Delete
},
[206] Fix | Delete
/**
[207] Fix | Delete
* Close button (inside the form builder) click event.
[208] Fix | Delete
*
[209] Fix | Delete
* @since 1.8.3
[210] Fix | Delete
*
[211] Fix | Delete
* @param {string} clientID Block Client ID.
[212] Fix | Delete
*/
[213] Fix | Delete
builderCloseButtonEvent: function builderCloseButtonEvent(clientID) {
[214] Fix | Delete
$popup.off('wpformsBuilderInPopupClose').on('wpformsBuilderInPopupClose', function (e, action, formId, formTitle) {
[215] Fix | Delete
if (action !== 'saved' || !formId) {
[216] Fix | Delete
return;
[217] Fix | Delete
}
[218] Fix | Delete
[219] Fix | Delete
// Insert a new block when a new form is created from the popup to update the form list and attributes.
[220] Fix | Delete
var newBlock = wp.blocks.createBlock('wpforms/form-selector', {
[221] Fix | Delete
formId: formId.toString() // Expects string value, make sure we insert string.
[222] Fix | Delete
});
[223] Fix | Delete
[224] Fix | Delete
// eslint-disable-next-line camelcase
[225] Fix | Delete
formList = [{
[226] Fix | Delete
ID: formId,
[227] Fix | Delete
post_title: formTitle
[228] Fix | Delete
}];
[229] Fix | Delete
[230] Fix | Delete
// Insert a new block.
[231] Fix | Delete
wp.data.dispatch('core/block-editor').removeBlock(clientID);
[232] Fix | Delete
wp.data.dispatch('core/block-editor').insertBlocks(newBlock);
[233] Fix | Delete
});
[234] Fix | Delete
},
[235] Fix | Delete
/**
[236] Fix | Delete
* Register block.
[237] Fix | Delete
*
[238] Fix | Delete
* @since 1.8.1
[239] Fix | Delete
*/
[240] Fix | Delete
// eslint-disable-next-line max-lines-per-function
[241] Fix | Delete
registerBlock: function registerBlock() {
[242] Fix | Delete
registerBlockType('wpforms/form-selector', {
[243] Fix | Delete
title: strings.title,
[244] Fix | Delete
description: strings.description,
[245] Fix | Delete
icon: app.getIcon(),
[246] Fix | Delete
keywords: strings.form_keywords,
[247] Fix | Delete
category: 'widgets',
[248] Fix | Delete
attributes: app.getBlockAttributes(),
[249] Fix | Delete
supports: {
[250] Fix | Delete
customClassName: app.hasForms()
[251] Fix | Delete
},
[252] Fix | Delete
example: {
[253] Fix | Delete
attributes: {
[254] Fix | Delete
preview: true
[255] Fix | Delete
}
[256] Fix | Delete
},
[257] Fix | Delete
edit: function edit(props) {
[258] Fix | Delete
// Get fresh list of forms.
[259] Fix | Delete
app.getForms();
[260] Fix | Delete
var attributes = props.attributes;
[261] Fix | Delete
var formOptions = app.getFormOptions();
[262] Fix | Delete
var handlers = app.getSettingsFieldsHandlers(props);
[263] Fix | Delete
[264] Fix | Delete
// Store block clientId in attributes.
[265] Fix | Delete
if (!attributes.clientId) {
[266] Fix | Delete
// We just want client ID to update once.
[267] Fix | Delete
// The block editor doesn't have a fixed block ID, so we need to get it on the initial load, but only once.
[268] Fix | Delete
props.setAttributes({
[269] Fix | Delete
clientId: props.clientId
[270] Fix | Delete
});
[271] Fix | Delete
}
[272] Fix | Delete
[273] Fix | Delete
// Main block settings.
[274] Fix | Delete
var jsx = [app.jsxParts.getMainSettings(attributes, handlers, formOptions)];
[275] Fix | Delete
[276] Fix | Delete
// Block preview picture.
[277] Fix | Delete
if (!app.hasForms()) {
[278] Fix | Delete
jsx.push(app.jsxParts.getEmptyFormsPreview(props));
[279] Fix | Delete
return jsx;
[280] Fix | Delete
}
[281] Fix | Delete
var sizeOptions = app.getSizeOptions();
[282] Fix | Delete
[283] Fix | Delete
// Form style settings & block content.
[284] Fix | Delete
if (attributes.formId) {
[285] Fix | Delete
jsx.push(app.jsxParts.getStyleSettings(props, handlers, sizeOptions), app.jsxParts.getAdvancedSettings(props, handlers), app.jsxParts.getBlockFormContent(props));
[286] Fix | Delete
handlers.updateCopyPasteContent();
[287] Fix | Delete
$(window).trigger('wpformsFormSelectorEdit', [props]);
[288] Fix | Delete
return jsx;
[289] Fix | Delete
}
[290] Fix | Delete
[291] Fix | Delete
// Block preview picture.
[292] Fix | Delete
if (attributes.preview) {
[293] Fix | Delete
jsx.push(app.jsxParts.getBlockPreview());
[294] Fix | Delete
return jsx;
[295] Fix | Delete
}
[296] Fix | Delete
[297] Fix | Delete
// Block placeholder (form selector).
[298] Fix | Delete
jsx.push(app.jsxParts.getBlockPlaceholder(props.attributes, handlers, formOptions));
[299] Fix | Delete
return jsx;
[300] Fix | Delete
},
[301] Fix | Delete
save: function save() {
[302] Fix | Delete
return null;
[303] Fix | Delete
}
[304] Fix | Delete
});
[305] Fix | Delete
},
[306] Fix | Delete
/**
[307] Fix | Delete
* Init default style settings.
[308] Fix | Delete
*
[309] Fix | Delete
* @since 1.8.1
[310] Fix | Delete
*/
[311] Fix | Delete
initDefaults: function initDefaults() {
[312] Fix | Delete
['formId', 'copyPasteJsonValue'].forEach(function (key) {
[313] Fix | Delete
return delete defaultStyleSettings[key];
[314] Fix | Delete
});
[315] Fix | Delete
},
[316] Fix | Delete
/**
[317] Fix | Delete
* Check if site has forms.
[318] Fix | Delete
*
[319] Fix | Delete
* @since 1.8.3
[320] Fix | Delete
*
[321] Fix | Delete
* @return {boolean} Whether site has at least one form.
[322] Fix | Delete
*/
[323] Fix | Delete
hasForms: function hasForms() {
[324] Fix | Delete
return formList.length >= 1;
[325] Fix | Delete
},
[326] Fix | Delete
/**
[327] Fix | Delete
* Block JSX parts.
[328] Fix | Delete
*
[329] Fix | Delete
* @since 1.8.1
[330] Fix | Delete
*
[331] Fix | Delete
* @type {Object}
[332] Fix | Delete
*/
[333] Fix | Delete
jsxParts: {
[334] Fix | Delete
/**
[335] Fix | Delete
* Get main settings JSX code.
[336] Fix | Delete
*
[337] Fix | Delete
* @since 1.8.1
[338] Fix | Delete
*
[339] Fix | Delete
* @param {Object} attributes Block attributes.
[340] Fix | Delete
* @param {Object} handlers Block event handlers.
[341] Fix | Delete
* @param {Object} formOptions Form selector options.
[342] Fix | Delete
*
[343] Fix | Delete
* @return {JSX.Element} Main setting JSX code.
[344] Fix | Delete
*/
[345] Fix | Delete
getMainSettings: function getMainSettings(attributes, handlers, formOptions) {
[346] Fix | Delete
if (!app.hasForms()) {
[347] Fix | Delete
return app.jsxParts.printEmptyFormsNotice(attributes.clientId);
[348] Fix | Delete
}
[349] Fix | Delete
return /*#__PURE__*/React.createElement(InspectorControls, {
[350] Fix | Delete
key: "wpforms-gutenberg-form-selector-inspector-main-settings"
[351] Fix | Delete
}, /*#__PURE__*/React.createElement(PanelBody, {
[352] Fix | Delete
className: "wpforms-gutenberg-panel",
[353] Fix | Delete
title: strings.form_settings
[354] Fix | Delete
}, /*#__PURE__*/React.createElement(SelectControl, {
[355] Fix | Delete
label: strings.form_selected,
[356] Fix | Delete
value: attributes.formId,
[357] Fix | Delete
options: formOptions,
[358] Fix | Delete
onChange: function onChange(value) {
[359] Fix | Delete
return handlers.attrChange('formId', value);
[360] Fix | Delete
}
[361] Fix | Delete
}), attributes.formId ? /*#__PURE__*/React.createElement("p", {
[362] Fix | Delete
className: "wpforms-gutenberg-form-selector-actions"
[363] Fix | Delete
}, /*#__PURE__*/React.createElement("a", {
[364] Fix | Delete
href: urls.form_url.replace('{ID}', attributes.formId),
[365] Fix | Delete
rel: "noreferrer",
[366] Fix | Delete
target: "_blank"
[367] Fix | Delete
}, strings.form_edit), isPro && /*#__PURE__*/React.createElement(React.Fragment, null, "\xA0\xA0|\xA0\xA0", /*#__PURE__*/React.createElement("a", {
[368] Fix | Delete
href: urls.entries_url.replace('{ID}', attributes.formId),
[369] Fix | Delete
rel: "noreferrer",
[370] Fix | Delete
target: "_blank"
[371] Fix | Delete
}, strings.form_entries))) : null, /*#__PURE__*/React.createElement(ToggleControl, {
[372] Fix | Delete
label: strings.show_title,
[373] Fix | Delete
checked: attributes.displayTitle,
[374] Fix | Delete
onChange: function onChange(value) {
[375] Fix | Delete
return handlers.attrChange('displayTitle', value);
[376] Fix | Delete
}
[377] Fix | Delete
}), /*#__PURE__*/React.createElement(ToggleControl, {
[378] Fix | Delete
label: strings.show_description,
[379] Fix | Delete
checked: attributes.displayDesc,
[380] Fix | Delete
onChange: function onChange(value) {
[381] Fix | Delete
return handlers.attrChange('displayDesc', value);
[382] Fix | Delete
}
[383] Fix | Delete
}), /*#__PURE__*/React.createElement("p", {
[384] Fix | Delete
className: "wpforms-gutenberg-panel-notice"
[385] Fix | Delete
}, /*#__PURE__*/React.createElement("strong", null, strings.panel_notice_head), strings.panel_notice_text, /*#__PURE__*/React.createElement("a", {
[386] Fix | Delete
href: strings.panel_notice_link,
[387] Fix | Delete
rel: "noreferrer",
[388] Fix | Delete
target: "_blank"
[389] Fix | Delete
}, strings.panel_notice_link_text))));
[390] Fix | Delete
},
[391] Fix | Delete
/**
[392] Fix | Delete
* Print empty forms notice.
[393] Fix | Delete
*
[394] Fix | Delete
* @since 1.8.3
[395] Fix | Delete
*
[396] Fix | Delete
* @param {string} clientId Block client ID.
[397] Fix | Delete
*
[398] Fix | Delete
* @return {JSX.Element} Field styles JSX code.
[399] Fix | Delete
*/
[400] Fix | Delete
printEmptyFormsNotice: function printEmptyFormsNotice(clientId) {
[401] Fix | Delete
return /*#__PURE__*/React.createElement(InspectorControls, {
[402] Fix | Delete
key: "wpforms-gutenberg-form-selector-inspector-main-settings"
[403] Fix | Delete
}, /*#__PURE__*/React.createElement(PanelBody, {
[404] Fix | Delete
className: "wpforms-gutenberg-panel",
[405] Fix | Delete
title: strings.form_settings
[406] Fix | Delete
}, /*#__PURE__*/React.createElement("p", {
[407] Fix | Delete
className: "wpforms-gutenberg-panel-notice wpforms-warning wpforms-empty-form-notice",
[408] Fix | Delete
style: {
[409] Fix | Delete
display: 'block'
[410] Fix | Delete
}
[411] Fix | Delete
}, /*#__PURE__*/React.createElement("strong", null, __('You haven’t created a form, yet!', 'wpforms-lite')), __('What are you waiting for?', 'wpforms-lite')), /*#__PURE__*/React.createElement("button", {
[412] Fix | Delete
type: "button",
[413] Fix | Delete
className: "get-started-button components-button is-secondary",
[414] Fix | Delete
onClick: function onClick() {
[415] Fix | Delete
app.openBuilderPopup(clientId);
[416] Fix | Delete
}
[417] Fix | Delete
}, __('Get Started', 'wpforms-lite'))));
[418] Fix | Delete
},
[419] Fix | Delete
/**
[420] Fix | Delete
* Get Field styles JSX code.
[421] Fix | Delete
*
[422] Fix | Delete
* @since 1.8.1
[423] Fix | Delete
*
[424] Fix | Delete
* @param {Object} props Block properties.
[425] Fix | Delete
* @param {Object} handlers Block event handlers.
[426] Fix | Delete
* @param {Object} sizeOptions Size selector options.
[427] Fix | Delete
*
[428] Fix | Delete
* @return {Object} Field styles JSX code.
[429] Fix | Delete
*/
[430] Fix | Delete
getFieldStyles: function getFieldStyles(props, handlers, sizeOptions) {
[431] Fix | Delete
// eslint-disable-line max-lines-per-function
[432] Fix | Delete
return /*#__PURE__*/React.createElement(PanelBody, {
[433] Fix | Delete
className: app.getPanelClass(props),
[434] Fix | Delete
title: strings.field_styles
[435] Fix | Delete
}, /*#__PURE__*/React.createElement("p", {
[436] Fix | Delete
className: "wpforms-gutenberg-panel-notice wpforms-use-modern-notice"
[437] Fix | Delete
}, /*#__PURE__*/React.createElement("strong", null, strings.use_modern_notice_head), strings.use_modern_notice_text, " ", /*#__PURE__*/React.createElement("a", {
[438] Fix | Delete
href: strings.use_modern_notice_link,
[439] Fix | Delete
rel: "noreferrer",
[440] Fix | Delete
target: "_blank"
[441] Fix | Delete
}, strings.learn_more)), /*#__PURE__*/React.createElement("p", {
[442] Fix | Delete
className: "wpforms-gutenberg-panel-notice wpforms-warning wpforms-lead-form-notice",
[443] Fix | Delete
style: {
[444] Fix | Delete
display: 'none'
[445] Fix | Delete
}
[446] Fix | Delete
}, /*#__PURE__*/React.createElement("strong", null, strings.lead_forms_panel_notice_head), strings.lead_forms_panel_notice_text), /*#__PURE__*/React.createElement(Flex, {
[447] Fix | Delete
gap: 4,
[448] Fix | Delete
align: "flex-start",
[449] Fix | Delete
className: 'wpforms-gutenberg-form-selector-flex',
[450] Fix | Delete
justify: "space-between"
[451] Fix | Delete
}, /*#__PURE__*/React.createElement(FlexBlock, null, /*#__PURE__*/React.createElement(SelectControl, {
[452] Fix | Delete
label: strings.size,
[453] Fix | Delete
value: props.attributes.fieldSize,
[454] Fix | Delete
options: sizeOptions,
[455] Fix | Delete
onChange: function onChange(value) {
[456] Fix | Delete
return handlers.styleAttrChange('fieldSize', value);
[457] Fix | Delete
}
[458] Fix | Delete
})), /*#__PURE__*/React.createElement(FlexBlock, null, /*#__PURE__*/React.createElement(__experimentalUnitControl, {
[459] Fix | Delete
label: strings.border_radius,
[460] Fix | Delete
value: props.attributes.fieldBorderRadius,
[461] Fix | Delete
isUnitSelectTabbable: true,
[462] Fix | Delete
onChange: function onChange(value) {
[463] Fix | Delete
return handlers.styleAttrChange('fieldBorderRadius', value);
[464] Fix | Delete
}
[465] Fix | Delete
}))), /*#__PURE__*/React.createElement("div", {
[466] Fix | Delete
className: "wpforms-gutenberg-form-selector-color-picker"
[467] Fix | Delete
}, /*#__PURE__*/React.createElement("div", {
[468] Fix | Delete
className: "wpforms-gutenberg-form-selector-control-label"
[469] Fix | Delete
}, strings.colors), /*#__PURE__*/React.createElement(PanelColorSettings, {
[470] Fix | Delete
__experimentalIsRenderedInSidebar: true,
[471] Fix | Delete
enableAlpha: true,
[472] Fix | Delete
showTitle: false,
[473] Fix | Delete
className: "wpforms-gutenberg-form-selector-color-panel",
[474] Fix | Delete
colorSettings: [{
[475] Fix | Delete
value: props.attributes.fieldBackgroundColor,
[476] Fix | Delete
onChange: function onChange(value) {
[477] Fix | Delete
return handlers.styleAttrChange('fieldBackgroundColor', value);
[478] Fix | Delete
},
[479] Fix | Delete
label: strings.background
[480] Fix | Delete
}, {
[481] Fix | Delete
value: props.attributes.fieldBorderColor,
[482] Fix | Delete
onChange: function onChange(value) {
[483] Fix | Delete
return handlers.styleAttrChange('fieldBorderColor', value);
[484] Fix | Delete
},
[485] Fix | Delete
label: strings.border
[486] Fix | Delete
}, {
[487] Fix | Delete
value: props.attributes.fieldTextColor,
[488] Fix | Delete
onChange: function onChange(value) {
[489] Fix | Delete
return handlers.styleAttrChange('fieldTextColor', value);
[490] Fix | Delete
},
[491] Fix | Delete
label: strings.text
[492] Fix | Delete
}]
[493] Fix | Delete
})));
[494] Fix | Delete
},
[495] Fix | Delete
/**
[496] Fix | Delete
* Get Label styles JSX code.
[497] Fix | Delete
*
[498] Fix | Delete
* @since 1.8.1
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function