Tumbili: Mailchimp Signup for Gutenberg - Version 0.7

Version Description

  • Added extra controls for label color and submit text
  • Fixed bug with form reset
Download this release

Release Info

Developer gubbigubbi
Plugin Icon 128x128 Tumbili: Mailchimp Signup for Gutenberg
Version 0.7
Comparing to
See all releases

Code changes from version 0.6 to 0.7

dist/blocks.build.js CHANGED
@@ -1,134 +1 @@
1
- /******/ (function(modules) { // webpackBootstrap
2
- /******/ // The module cache
3
- /******/ var installedModules = {};
4
- /******/
5
- /******/ // The require function
6
- /******/ function __webpack_require__(moduleId) {
7
- /******/
8
- /******/ // Check if module is in cache
9
- /******/ if(installedModules[moduleId]) {
10
- /******/ return installedModules[moduleId].exports;
11
- /******/ }
12
- /******/ // Create a new module (and put it into the cache)
13
- /******/ var module = installedModules[moduleId] = {
14
- /******/ i: moduleId,
15
- /******/ l: false,
16
- /******/ exports: {}
17
- /******/ };
18
- /******/
19
- /******/ // Execute the module function
20
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21
- /******/
22
- /******/ // Flag the module as loaded
23
- /******/ module.l = true;
24
- /******/
25
- /******/ // Return the exports of the module
26
- /******/ return module.exports;
27
- /******/ }
28
- /******/
29
- /******/
30
- /******/ // expose the modules object (__webpack_modules__)
31
- /******/ __webpack_require__.m = modules;
32
- /******/
33
- /******/ // expose the module cache
34
- /******/ __webpack_require__.c = installedModules;
35
- /******/
36
- /******/ // define getter function for harmony exports
37
- /******/ __webpack_require__.d = function(exports, name, getter) {
38
- /******/ if(!__webpack_require__.o(exports, name)) {
39
- /******/ Object.defineProperty(exports, name, {
40
- /******/ configurable: false,
41
- /******/ enumerable: true,
42
- /******/ get: getter
43
- /******/ });
44
- /******/ }
45
- /******/ };
46
- /******/
47
- /******/ // getDefaultExport function for compatibility with non-harmony modules
48
- /******/ __webpack_require__.n = function(module) {
49
- /******/ var getter = module && module.__esModule ?
50
- /******/ function getDefault() { return module['default']; } :
51
- /******/ function getModuleExports() { return module; };
52
- /******/ __webpack_require__.d(getter, 'a', getter);
53
- /******/ return getter;
54
- /******/ };
55
- /******/
56
- /******/ // Object.prototype.hasOwnProperty.call
57
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
58
- /******/
59
- /******/ // __webpack_public_path__
60
- /******/ __webpack_require__.p = "";
61
- /******/
62
- /******/ // Load entry module and return exports
63
- /******/ return __webpack_require__(__webpack_require__.s = 0);
64
- /******/ })
65
- /************************************************************************/
66
- /******/ ([
67
- /* 0 */
68
- /*!***********************!*\
69
- !*** ./src/blocks.js ***!
70
- \***********************/
71
- /*! no exports provided */
72
- /*! all exports used */
73
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
74
-
75
- "use strict";
76
- eval("Object.defineProperty(__webpack_exports__, \"__esModule\", { value: true });\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__block_block_js__ = __webpack_require__(/*! ./block/block.js */ 1);\n/**\n * Gutenberg Blocks\n *\n * All blocks related JavaScript files should be imported here.\n * You can create a new block folder in this dir and include code\n * for that block here as well.\n *\n * All blocks should be included here since this is the file that\n * Webpack is compiling as the input file.\n */\n\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL3NyYy9ibG9ja3MuanM/N2I1YiJdLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEd1dGVuYmVyZyBCbG9ja3NcbiAqXG4gKiBBbGwgYmxvY2tzIHJlbGF0ZWQgSmF2YVNjcmlwdCBmaWxlcyBzaG91bGQgYmUgaW1wb3J0ZWQgaGVyZS5cbiAqIFlvdSBjYW4gY3JlYXRlIGEgbmV3IGJsb2NrIGZvbGRlciBpbiB0aGlzIGRpciBhbmQgaW5jbHVkZSBjb2RlXG4gKiBmb3IgdGhhdCBibG9jayBoZXJlIGFzIHdlbGwuXG4gKlxuICogQWxsIGJsb2NrcyBzaG91bGQgYmUgaW5jbHVkZWQgaGVyZSBzaW5jZSB0aGlzIGlzIHRoZSBmaWxlIHRoYXRcbiAqIFdlYnBhY2sgaXMgY29tcGlsaW5nIGFzIHRoZSBpbnB1dCBmaWxlLlxuICovXG5cbmltcG9ydCAnLi9ibG9jay9ibG9jay5qcyc7XG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gLi9zcmMvYmxvY2tzLmpzXG4vLyBtb2R1bGUgaWQgPSAwXG4vLyBtb2R1bGUgY2h1bmtzID0gMCJdLCJtYXBwaW5ncyI6IkFBQUE7QUFBQTtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7Iiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///0\n");
77
-
78
- /***/ }),
79
- /* 1 */
80
- /*!****************************!*\
81
- !*** ./src/block/block.js ***!
82
- \****************************/
83
- /*! no exports provided */
84
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
85
-
86
- "use strict";
87
- eval("/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__style_scss__ = __webpack_require__(/*! ./style.scss */ 2);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__style_scss___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__style_scss__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__editor_scss__ = __webpack_require__(/*! ./editor.scss */ 3);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__editor_scss___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__editor_scss__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__attributes__ = __webpack_require__(/*! ./attributes */ 4);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__edit__ = __webpack_require__(/*! ./edit */ 5);\n/**\n * BLOCK: tumbili: mailchimp for Gutenberg\n */\n\n// Import CSS.\n\n\n\n\n\n\nvar __ = wp.i18n.__; // Import __() from wp.i18n\n\nvar registerBlockType = wp.blocks.registerBlockType; // Import registerBlockType() from wp.blocks\n\n/**\n * Register: aa Gutenberg Block.\n *\n * @link https://wordpress.org/gutenberg/handbook/block-api/\n * @param {string} name Block name.\n * @param {Object} settings Block settings.\n * @return {?WPBlock} The block, if it has been successfully\n * registered; otherwise `undefined`.\n */\n\nregisterBlockType('cgb/tumbili-mailchimp-for-gutenberg', {\n\t// Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.\n\ttitle: __('Tumbili: Mailchimp for Gutenberg'), // Block title.\n\ticon: 'email-alt', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.\n\tcategory: 'common', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.\n\tkeywords: [__('tumbili'), __('mailchimp')],\n\tattributes: __WEBPACK_IMPORTED_MODULE_2__attributes__[\"a\" /* attributes */],\n\n\t/**\n * Edit\n * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/\n */\n\tedit: __WEBPACK_IMPORTED_MODULE_3__edit__[\"a\" /* default */],\n\t/**\n * Save\n * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/\n * @return {null} null\n */\n\tsave: function save(_ref) {\n\t\tvar attributes = _ref.attributes,\n\t\t className = _ref.className;\n\n\t\t//gutenberg will save attributes we can use in server-side callback\n\t\treturn null;\n\t}\n});//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL3NyYy9ibG9jay9ibG9jay5qcz85MjFkIl0sInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQkxPQ0s6IHR1bWJpbGk6IG1haWxjaGltcCBmb3IgR3V0ZW5iZXJnXG4gKi9cblxuLy8gIEltcG9ydCBDU1MuXG5pbXBvcnQgJy4vc3R5bGUuc2Nzcyc7XG5pbXBvcnQ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XG59KTtcblxuXG4vLy8vLy8vLy8vLy8vLy8vLy9cbi8vIFdFQlBBQ0sgRk9PVEVSXG4vLyAuL3NyYy9ibG9jay9ibG9jay5qc1xuLy8gbW9kdWxlIGlkID0gMVxuLy8gbW9kdWxlIGNodW5rcyA9IDAiXSwibWFwcGluZ3MiOiJBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///1\n");
88
-
89
- /***/ }),
90
- /* 2 */
91
- /*!******************************!*\
92
- !*** ./src/block/style.scss ***!
93
- \******************************/
94
- /*! dynamic exports provided */
95
- /***/ (function(module, exports) {
96
-
97
- eval("// removed by extract-text-webpack-plugin//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMi5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL3NyYy9ibG9jay9zdHlsZS5zY3NzPzgwZjMiXSwic291cmNlc0NvbnRlbnQiOlsiLy8gcmVtb3ZlZCBieSBleHRyYWN0LXRleHQtd2VicGFjay1wbHVnaW5cblxuXG4vLy8vLy8vLy8vLy8vLy8vLy9cbi8vIFdFQlBBQ0sgRk9PVEVSXG4vLyAuL3NyYy9ibG9jay9zdHlsZS5zY3NzXG4vLyBtb2R1bGUgaWQgPSAyXG4vLyBtb2R1bGUgY2h1bmtzID0gMCJdLCJtYXBwaW5ncyI6IkFBQUEiLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///2\n");
98
-
99
- /***/ }),
100
- /* 3 */
101
- /*!*******************************!*\
102
- !*** ./src/block/editor.scss ***!
103
- \*******************************/
104
- /*! dynamic exports provided */
105
- /***/ (function(module, exports) {
106
-
107
- eval("// removed by extract-text-webpack-plugin//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMy5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL3NyYy9ibG9jay9lZGl0b3Iuc2Nzcz80OWQyIl0sInNvdXJjZXNDb250ZW50IjpbIi8vIHJlbW92ZWQgYnkgZXh0cmFjdC10ZXh0LXdlYnBhY2stcGx1Z2luXG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gLi9zcmMvYmxvY2svZWRpdG9yLnNjc3Ncbi8vIG1vZHVsZSBpZCA9IDNcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///3\n");
108
-
109
- /***/ }),
110
- /* 4 */
111
- /*!*********************************!*\
112
- !*** ./src/block/attributes.js ***!
113
- \*********************************/
114
- /*! exports provided: attributes */
115
- /*! exports used: attributes */
116
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
117
-
118
- "use strict";
119
- eval("/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"a\", function() { return attributes; });\nvar attributes = {\n\tapiKey: {\n\t\ttype: 'string',\n\t\tdefault: ''\n\t},\n\tlistID: {\n\t\ttype: 'string',\n\t\tdefault: ''\n\t},\n\tshowFirstName: {\n\t\ttype: 'boolean',\n\t\tdefault: false\n\t},\n\tshowLastName: {\n\t\ttype: 'boolean',\n\t\tdefault: false\n\t},\n\tbuttonBackground: {\n\t\ttype: 'string',\n\t\tdefault: ''\n\t},\n\tbuttonColor: {\n\t\ttype: 'string',\n\t\tdefault: ''\n\t},\n\tfields: {\n\t\ttype: 'array',\n\t\tdefault: []\n\t}\n};//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL3NyYy9ibG9jay9hdHRyaWJ1dGVzLmpzPzg4MDEiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHZhciBhdHRyaWJ1dGVzID0ge1xuXHRhcGlLZXk6IHtcblx0XHR0eXBlOiAnc3RyaW5nJyxcblx0XHRkZWZhdWx0OiAnJ1xuXHR9LFxuXHRsaXN0SUQ6IHtcblx0XHR0eXBlOiAnc3RyaW5nJyxcblx0XHRkZWZhdWx0OiAnJ1xuXHR9LFxuXHRzaG93Rmlyc3ROYW1lOiB7XG5cdFx0dHlwZTogJ2Jvb2xlYW4nLFxuXHRcdGRlZmF1bHQ6IGZhbHNlXG5cdH0sXG5cdHNob3dMYXN0TmFtZToge1xuXHRcdHR5cGU6ICdib29sZWFuJyxcblx0XHRkZWZhdWx0OiBmYWxzZVxuXHR9LFxuXHRidXR0b25CYWNrZ3JvdW5kOiB7XG5cdFx0dHlwZTogJ3N0cmluZycsXG5cdFx0ZGVmYXVsdDogJydcblx0fSxcblx0YnV0dG9uQ29sb3I6IHtcblx0XHR0eXBlOiAnc3RyaW5nJyxcblx0XHRkZWZhdWx0OiAnJ1xuXHR9LFxuXHRmaWVsZHM6IHtcblx0XHR0eXBlOiAnYXJyYXknLFxuXHRcdGRlZmF1bHQ6IFtdXG5cdH1cbn07XG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gLi9zcmMvYmxvY2svYXR0cmlidXRlcy5qc1xuLy8gbW9kdWxlIGlkID0gNFxuLy8gbW9kdWxlIGNodW5rcyA9IDAiXSwibWFwcGluZ3MiOiJBQUFBO0FBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///4\n");
120
-
121
- /***/ }),
122
- /* 5 */
123
- /*!***************************!*\
124
- !*** ./src/block/edit.js ***!
125
- \***************************/
126
- /*! exports provided: default */
127
- /*! exports used: default */
128
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
129
-
130
- "use strict";
131
- eval("var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n//import Inspector from './inspector';\nvar Component = wp.element.Component;\nvar _wp$editor = wp.editor,\n InspectorControls = _wp$editor.InspectorControls,\n PanelColorSettings = _wp$editor.PanelColorSettings;\nvar _wp$components = wp.components,\n PanelBody = _wp$components.PanelBody,\n TextControl = _wp$components.TextControl,\n ToggleControl = _wp$components.ToggleControl,\n Button = _wp$components.Button,\n SelectControl = _wp$components.SelectControl,\n Icon = _wp$components.Icon;\nvar __ = wp.i18n.__;\n\nvar mailchimpEdit = function (_Component) {\n\t_inherits(mailchimpEdit, _Component);\n\n\tfunction mailchimpEdit() {\n\t\t_classCallCheck(this, mailchimpEdit);\n\n\t\tvar _this = _possibleConstructorReturn(this, (mailchimpEdit.__proto__ || Object.getPrototypeOf(mailchimpEdit)).apply(this, arguments));\n\n\t\t_this.addField = function () {\n\n\t\t\tvar newField = {\n\t\t\t\tlabel: _this.state.newFieldLabel,\n\t\t\t\tvalue: _this.state.newFieldValue,\n\t\t\t\ttype: _this.state.newFieldType,\n\t\t\t\toptions: _this.state.newFieldOptions,\n\t\t\t\tfullWidth: _this.state.newFieldFullWidth\n\t\t\t};\n\n\t\t\tif (!newField.label && !newField.value) {\n\t\t\t\talert('Please add a label and MERGE tag first');\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t_this.props.setAttributes({\n\t\t\t\tfields: _this.props.attributes.fields.concat(newField)\n\t\t\t});\n\n\t\t\t_this.setState({\n\t\t\t\tnewFieldLabel: '',\n\t\t\t\tnewFieldValue: '',\n\t\t\t\tnewFieldOptions: [],\n\t\t\t\tnewFieldOptionLabel: '',\n\t\t\t\tnewFieldFullWidth: false\n\t\t\t});\n\t\t};\n\n\t\t_this.addFieldOption = function () {\n\t\t\tvar newOption = {\n\t\t\t\tlabel: _this.state.newFieldOptionLabel\n\t\t\t};\n\n\t\t\t_this.setState({\n\t\t\t\tnewFieldOptions: _this.state.newFieldOptions.concat(newOption),\n\t\t\t\tnewFieldOptionLabel: '' // effectively reset the form\n\t\t\t});\n\t\t};\n\n\t\t_this.removeField = function (index) {\n\t\t\tvar newFields = _this.props.attributes.fields.filter(function (item, i) {\n\t\t\t\treturn i !== index;\n\t\t\t});\n\n\t\t\t_this.props.setAttributes({\n\t\t\t\tfields: newFields\n\t\t\t});\n\t\t};\n\n\t\t_this.removeFieldOption = function (index) {\n\t\t\tvar newOptions = _this.state.newFieldOptions.filter(function (item, i) {\n\t\t\t\treturn i !== index;\n\t\t\t});\n\n\t\t\t_this.setState({\n\t\t\t\tnewFieldOptions: newOptions\n\t\t\t});\n\t\t};\n\n\t\t_this.onReorder = function () {\n\t\t\tvar type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'options';\n\t\t\tvar list = arguments[1];\n\t\t\tvar startIndex = arguments[2];\n\t\t\tvar endIndex = arguments[3];\n\n\t\t\tvar result = Array.from(list);\n\n\t\t\tvar _result$splice = result.splice(startIndex, 1),\n\t\t\t _result$splice2 = _slicedToArray(_result$splice, 1),\n\t\t\t removed = _result$splice2[0];\n\n\t\t\tresult.splice(endIndex, 0, removed);\n\n\t\t\tif (type === 'options') {\n\t\t\t\t_this.setState({\n\t\t\t\t\tnewFieldOptions: result\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t_this.props.setAttributes({\n\t\t\t\t\tfields: result\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\n\t\t_this.state = {\n\t\t\tnewFieldLabel: '',\n\t\t\tnewFieldValue: '',\n\t\t\tnewFieldType: 'text',\n\t\t\tnewFieldFullWidth: false,\n\t\t\tnewFieldOptions: [],\n\t\t\tnewFieldOptionLabel: ''\n\t\t};\n\t\treturn _this;\n\t}\n\n\t_createClass(mailchimpEdit, [{\n\t\tkey: 'render',\n\t\tvalue: function render() {\n\t\t\tvar _this2 = this;\n\n\t\t\tvar _props = this.props,\n\t\t\t _props$attributes = _props.attributes,\n\t\t\t showFirstName = _props$attributes.showFirstName,\n\t\t\t showLastName = _props$attributes.showLastName,\n\t\t\t apiKey = _props$attributes.apiKey,\n\t\t\t listID = _props$attributes.listID,\n\t\t\t buttonBackground = _props$attributes.buttonBackground,\n\t\t\t buttonColor = _props$attributes.buttonColor,\n\t\t\t fields = _props$attributes.fields,\n\t\t\t className = _props.className,\n\t\t\t setAttributes = _props.setAttributes;\n\t\t\tvar _state = this.state,\n\t\t\t newFieldLabel = _state.newFieldLabel,\n\t\t\t newFieldValue = _state.newFieldValue,\n\t\t\t newFieldType = _state.newFieldType,\n\t\t\t newFieldOptionLabel = _state.newFieldOptionLabel,\n\t\t\t newFieldFullWidth = _state.newFieldFullWidth;\n\n\n\t\t\tvar firstNameInput = void 0;\n\n\t\t\tif (showFirstName) {\n\t\t\t\tfirstNameInput = wp.element.createElement(\n\t\t\t\t\t'div',\n\t\t\t\t\t{ className: 'tumbili-form-control flex-grow' },\n\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\t'label',\n\t\t\t\t\t\t{ htmlFor: 'firstName' },\n\t\t\t\t\t\t'First Name',\n\t\t\t\t\t\twp.element.createElement('input', { name: 'firstName', type: 'text' })\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tvar lastNameInput = void 0;\n\n\t\t\tif (showLastName) {\n\t\t\t\tlastNameInput = wp.element.createElement(\n\t\t\t\t\t'div',\n\t\t\t\t\t{ className: 'tumbili-form-control flex-grow' },\n\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\t'label',\n\t\t\t\t\t\t{ htmlFor: 'lasttName' },\n\t\t\t\t\t\t'Last Name',\n\t\t\t\t\t\twp.element.createElement('input', { name: 'lastName', type: 'text' })\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tvar button = wp.element.createElement('input', {\n\t\t\t\tstyle: { color: buttonColor, background: buttonBackground },\n\t\t\t\tclassName: 'tumbili-submit',\n\t\t\t\ttype: 'submit',\n\t\t\t\tvalue: 'Submit'\n\t\t\t});\n\n\t\t\tvar fieldsHTML = fields.map(function (f, index) {\n\t\t\t\tvar widthClass = f.fullWidth ? 'is-full-width' : '';\n\n\t\t\t\tvar input = f.type === 'text' ? wp.element.createElement('input', { name: f.value, type: 'text' }) : wp.element.createElement(\n\t\t\t\t\t'select',\n\t\t\t\t\t{ name: f.value },\n\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\t'option',\n\t\t\t\t\t\t{ value: f.options[0].label },\n\t\t\t\t\t\tf.options[0].label\n\t\t\t\t\t)\n\t\t\t\t);\n\n\t\t\t\tvar up = index > 0 ? wp.element.createElement(\n\t\t\t\t\t'span',\n\t\t\t\t\t{\n\t\t\t\t\t\tonClick: function onClick() {\n\t\t\t\t\t\t\treturn _this2.onReorder('fields', _this2.props.attributes.fields, index, index - 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\twp.element.createElement(Icon, { icon: 'arrow-up' })\n\t\t\t\t) : '';\n\n\t\t\t\tvar down = index < fields.length - 1 ? wp.element.createElement(\n\t\t\t\t\t'span',\n\t\t\t\t\t{\n\t\t\t\t\t\tonClick: function onClick() {\n\t\t\t\t\t\t\treturn _this2.onReorder('fields', _this2.props.attributes.fields, index, index + 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\twp.element.createElement(Icon, { icon: 'arrow-down' })\n\t\t\t\t) : '';\n\n\t\t\t\treturn wp.element.createElement(\n\t\t\t\t\t'div',\n\t\t\t\t\t{\n\t\t\t\t\t\tkey: index,\n\t\t\t\t\t\tclassName: 'tumbili-form-control flex-grow ' + widthClass\n\t\t\t\t\t},\n\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\t'label',\n\t\t\t\t\t\t{ htmlFor: f.value },\n\t\t\t\t\t\tf.label,\n\t\t\t\t\t\tinput\n\t\t\t\t\t),\n\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\t'div',\n\t\t\t\t\t\t{ className: 'tumbili-field-action' },\n\t\t\t\t\t\tup,\n\t\t\t\t\t\tdown,\n\t\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\t\t'span',\n\t\t\t\t\t\t\t{ onClick: function onClick() {\n\t\t\t\t\t\t\t\t\treturn _this2.removeField(index);\n\t\t\t\t\t\t\t\t} },\n\t\t\t\t\t\t\twp.element.createElement(Icon, { icon: 'dismiss' })\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t});\n\n\t\t\tvar container = void 0;\n\n\t\t\tif (apiKey && listID) {\n\t\t\t\tcontainer = wp.element.createElement(\n\t\t\t\t\t'div',\n\t\t\t\t\t{ className: 'display-flex tumbili-container' },\n\t\t\t\t\tfirstNameInput,\n\t\t\t\t\tlastNameInput,\n\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\t'div',\n\t\t\t\t\t\t{ className: 'tumbili-form-control flex-grow' },\n\t\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\t\t'label',\n\t\t\t\t\t\t\t{ htmlFor: 'email' },\n\t\t\t\t\t\t\t'Email',\n\t\t\t\t\t\t\twp.element.createElement('input', { name: 'email', type: 'email' })\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\tfieldsHTML,\n\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\t'div',\n\t\t\t\t\t\t{ className: 'tumbili-form-control flex-grow flex-is-at-bottom' },\n\t\t\t\t\t\tbutton\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcontainer = wp.element.createElement(\n\t\t\t\t\t'div',\n\t\t\t\t\t{ className: className },\n\t\t\t\t\t'To get started please add an API Key & List ID.'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tvar newFieldOptionHTML = void 0;\n\n\t\t\tif (newFieldType === 'select') {\n\t\t\t\tvar fieldOptions = this.state.newFieldOptions.map(function (option, index) {\n\t\t\t\t\treturn wp.element.createElement(\n\t\t\t\t\t\t'div',\n\t\t\t\t\t\t{ key: index, className: 'tumbili-field-option' },\n\t\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\t\t'span',\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\toption.label\n\t\t\t\t\t\t),\n\t\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\t\t'div',\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\t\t\t'span',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tonClick: function onClick() {\n\t\t\t\t\t\t\t\t\t\treturn _this2.onReorder('options', _this2.state.newFieldOptions, index, index - 1);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\twp.element.createElement(Icon, { icon: 'arrow-up' })\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\t\t\t'span',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tonClick: function onClick() {\n\t\t\t\t\t\t\t\t\t\treturn _this2.onReorder('options', _this2.state.newFieldOptions, index, index + 1);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\twp.element.createElement(Icon, { icon: 'arrow-down' })\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\t\t\t'span',\n\t\t\t\t\t\t\t\t{ onClick: function onClick() {\n\t\t\t\t\t\t\t\t\t\treturn _this2.removeFieldOption(index);\n\t\t\t\t\t\t\t\t\t} },\n\t\t\t\t\t\t\t\twp.element.createElement(Icon, { icon: 'dismiss' })\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tnewFieldOptionHTML = wp.element.createElement(\n\t\t\t\t\t'div',\n\t\t\t\t\t{ className: 'tumbili-type-options' },\n\t\t\t\t\twp.element.createElement(TextControl, {\n\t\t\t\t\t\tlabel: 'Option',\n\t\t\t\t\t\tvalue: newFieldOptionLabel,\n\t\t\t\t\t\tonChange: function onChange(label) {\n\t\t\t\t\t\t\treturn _this2.setState({ newFieldOptionLabel: label });\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\tButton,\n\t\t\t\t\t\t{ isOutline: true, isSmall: true, onClick: this.addFieldOption },\n\t\t\t\t\t\t'Add Option'\n\t\t\t\t\t),\n\t\t\t\t\tfieldOptions\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn wp.element.createElement(\n\t\t\t\t'div',\n\t\t\t\t{ className: className },\n\t\t\t\twp.element.createElement(\n\t\t\t\t\tInspectorControls,\n\t\t\t\t\tnull,\n\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\tPanelBody,\n\t\t\t\t\t\t{ title: __('Form Options') },\n\t\t\t\t\t\twp.element.createElement(TextControl, {\n\t\t\t\t\t\t\tlabel: __('Mailchimp API Key'),\n\t\t\t\t\t\t\tvalue: apiKey,\n\t\t\t\t\t\t\tonChange: function onChange(apiKey) {\n\t\t\t\t\t\t\t\treturn setAttributes({ apiKey: apiKey });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twp.element.createElement(TextControl, {\n\t\t\t\t\t\t\tlabel: __('Mailchimp List ID'),\n\t\t\t\t\t\t\tvalue: listID,\n\t\t\t\t\t\t\tonChange: function onChange(listID) {\n\t\t\t\t\t\t\t\treturn setAttributes({ listID: listID });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twp.element.createElement(ToggleControl, {\n\t\t\t\t\t\t\tlabel: __('Show First Name?'),\n\t\t\t\t\t\t\tchecked: showFirstName,\n\t\t\t\t\t\t\tonChange: function onChange(showFirstName) {\n\t\t\t\t\t\t\t\treturn setAttributes({ showFirstName: showFirstName });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twp.element.createElement(ToggleControl, {\n\t\t\t\t\t\t\tlabel: __('Show Last Name?'),\n\t\t\t\t\t\t\tchecked: showLastName,\n\t\t\t\t\t\t\tonChange: function onChange(showLastName) {\n\t\t\t\t\t\t\t\treturn setAttributes({ showLastName: showLastName });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twp.element.createElement(PanelColorSettings, {\n\t\t\t\t\t\t\ttitle: __('Color Settings'),\n\t\t\t\t\t\t\tcolorSettings: [{\n\t\t\t\t\t\t\t\tvalue: buttonBackground,\n\t\t\t\t\t\t\t\tonChange: function onChange(buttonBackground) {\n\t\t\t\t\t\t\t\t\treturn setAttributes({ buttonBackground: buttonBackground });\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tlabel: __('Button Background Color')\n\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\tvalue: buttonColor,\n\t\t\t\t\t\t\t\tonChange: function onChange(buttonColor) {\n\t\t\t\t\t\t\t\t\treturn setAttributes({ buttonColor: buttonColor });\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tlabel: __('Button Text Color')\n\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t})\n\t\t\t\t\t),\n\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\tPanelBody,\n\t\t\t\t\t\t{ title: __(' Custom Fields ') },\n\t\t\t\t\t\twp.element.createElement(TextControl, {\n\t\t\t\t\t\t\tlabel: 'Field label',\n\t\t\t\t\t\t\tvalue: newFieldLabel,\n\t\t\t\t\t\t\tonChange: function onChange(label) {\n\t\t\t\t\t\t\t\treturn _this2.setState({ newFieldLabel: label });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twp.element.createElement(TextControl, {\n\t\t\t\t\t\t\tlabel: '*|MERGE|* Tag',\n\t\t\t\t\t\t\tvalue: newFieldValue,\n\t\t\t\t\t\t\thelp: __('the *|MERGE|* tag value corresponding with that field, in your MailChimp audience'),\n\t\t\t\t\t\t\tonChange: function onChange(label) {\n\t\t\t\t\t\t\t\treturn _this2.setState({ newFieldValue: label });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twp.element.createElement(ToggleControl, {\n\t\t\t\t\t\t\tlabel: 'Full width',\n\t\t\t\t\t\t\tchecked: newFieldFullWidth,\n\t\t\t\t\t\t\tonChange: function onChange() {\n\t\t\t\t\t\t\t\treturn _this2.setState(function (state) {\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\tnewFieldFullWidth: !state.newFieldFullWidth\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twp.element.createElement(SelectControl, {\n\t\t\t\t\t\t\tlabel: 'Field type (more coming soon)',\n\t\t\t\t\t\t\tvalue: newFieldType,\n\t\t\t\t\t\t\toptions: [{ label: 'Text', value: 'text' }, { label: 'Select', value: 'select' }],\n\t\t\t\t\t\t\tonChange: function onChange(newFieldType) {\n\t\t\t\t\t\t\t\t_this2.setState({ newFieldType: newFieldType });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tnewFieldOptionHTML,\n\t\t\t\t\t\twp.element.createElement(\n\t\t\t\t\t\t\tButton,\n\t\t\t\t\t\t\t{ isDefault: true, onClick: this.addField },\n\t\t\t\t\t\t\t'Add Custom Field'\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\tcontainer\n\t\t\t);\n\t\t}\n\t}]);\n\n\treturn mailchimpEdit;\n}(Component);\n\n/* harmony default export */ __webpack_exports__[\"a\"] = (mailchimpEdit);//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL3NyYy9ibG9jay9lZGl0LmpzPzNmZTEiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIF9zbGljZWRUb0FycmF5ID0gZnVuY3Rpb24gKCkgeyBmdW5jdGlvbiBzbGljZUl0ZXJhdG9yKGFyciwgaSkgeyB2YXIgX2FyciA9IFtdOyB2YXIgX24gPSB0cnVlOyB2YXIgX2QgPSBmYWxzZTsgdmFyIF9lID0gdW5kZWZpbmVkOyB0cnkgeyBmb3IgKHZhciBfaSA9IGFycltTeW1ib2wuaXRlcmF0b3JdKCksIF9zOyAhKF9uID0gKF9zID0gX2kubmV4dCgpKS5kb25lKTsgX24gPSB0cnVlKSB7IF9hcnIucHVzaChfcy52YWx1ZSk7IGlmIChpICYmIF9hcnIubGVuZ3RoID09PSBpKSBicmVhazsgfSB9IGNhdGNoIChlcnIpIHsgX2QgPSB0cnVlOyBfZSA9IGVycjsgfSBmaW5hbGx5IHsgdHJ5IHsgaWYgKCFfbiAmJiBfaVtcInJldHVyblwiXSkgX2lbXCJyZXR1cm5cIl0oKTsgfSBmaW5hbGx5IHsgaWYgKF9kKSB0aHJvdyBfZTsgfSB9IHJldHVybiBfYXJyOyB9IHJldHVybiBmdW5jdGlvbiAoYXJyLCBpKSB7IGlmIChBcnJheS5pc0FycmF5KGFycikpIHsgcmV0dXJuIGFycjsgfSBlbHNlIGlmIChTeW1ib2wuaXRlcmF0b3IgaW4gT2JqZWN0KGFycikpIHsgcmV0dXJuIHNsaWNlSXRlcmF0b3IoYXJyLCBpKTsgfSBlbHNlIHsgdGhyb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TtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///5\n");
132
-
133
- /***/ })
134
- /******/ ]);
1
+ !function(e){function t(l){if(n[l])return n[l].exports;var i=n[l]={i:l,l:!1,exports:{}};return e[l].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,l){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:l})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});n(1)},function(e,t,n){"use strict";var l=n(2),i=(n.n(l),n(3)),r=(n.n(i),n(4)),a=n(5),__=wp.i18n.__;(0,wp.blocks.registerBlockType)("cgb/tumbili-mailchimp-for-gutenberg",{title:__("Tumbili: Mailchimp for Gutenberg"),icon:"email-alt",category:"common",keywords:[__("tumbili"),__("mailchimp")],attributes:r.a,edit:a.a,save:function(e){return e.attributes,e.className,null}})},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",function(){return l});var l={apiKey:{type:"string",default:""},listID:{type:"string",default:""},showFirstName:{type:"boolean",default:!1},showLastName:{type:"boolean",default:!1},buttonBackground:{type:"string",default:""},buttonColor:{type:"string",default:""},buttonText:{type:"string",default:"Submit"},labelColor:{type:"string",default:""},fields:{type:"array",default:[]}}},function(e,t,n){"use strict";function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==typeof t&&"function"!==typeof t?e:t}function r(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){var n=[],_n=!0,l=!1,i=void 0;try{for(var r,a=e[Symbol.iterator]();!(_n=(r=a.next()).done)&&(n.push(r.value),!t||n.length!==t);_n=!0);}catch(e){l=!0,i=e}finally{try{!_n&&a.return&&a.return()}finally{if(l)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=function(){function e(e,t){for(var n=0;n<t.length;n++){var l=t[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(e,l.key,l)}}return function(t,n,l){return n&&e(t.prototype,n),l&&e(t,l),t}}(),u=wp.element.Component,s=wp.editor,c=s.InspectorControls,m=s.PanelColorSettings,p=wp.components,d=p.PanelBody,f=p.TextControl,w=p.ToggleControl,b=p.Button,h=p.SelectControl,v=p.Icon,__=wp.i18n.__,y=function(e){function t(){l(this,t);var e=i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments));return e.addField=function(){var t={label:e.state.newFieldLabel,value:e.state.newFieldValue,type:e.state.newFieldType,options:e.state.newFieldOptions,fullWidth:e.state.newFieldFullWidth};if(!t.label&&!t.value)return alert("Please add a label and MERGE tag first"),!1;e.props.setAttributes({fields:e.props.attributes.fields.concat(t)}),e.setState({newFieldLabel:"",newFieldValue:"",newFieldOptions:[],newFieldOptionLabel:"",newFieldFullWidth:!1})},e.addFieldOption=function(){var t={label:e.state.newFieldOptionLabel};e.setState({newFieldOptions:e.state.newFieldOptions.concat(t),newFieldOptionLabel:""})},e.removeField=function(t){var n=e.props.attributes.fields.filter(function(e,n){return n!==t});e.props.setAttributes({fields:n})},e.removeFieldOption=function(t){var n=e.state.newFieldOptions.filter(function(e,n){return n!==t});e.setState({newFieldOptions:n})},e.onReorder=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"options",n=arguments[1],l=arguments[2],i=arguments[3],r=Array.from(n),o=r.splice(l,1),u=a(o,1),s=u[0];r.splice(i,0,s),"options"===t?e.setState({newFieldOptions:r}):e.props.setAttributes({fields:r})},e.state={newFieldLabel:"",newFieldValue:"",newFieldType:"text",newFieldFullWidth:!1,newFieldOptions:[],newFieldOptionLabel:""},e}return r(t,e),o(t,[{key:"render",value:function(){var e=this,t=this.props,n=t.attributes,l=n.showFirstName,i=n.showLastName,r=n.apiKey,a=n.listID,o=n.buttonBackground,u=n.buttonColor,s=n.fields,p=n.buttonText,y=n.labelColor,F=t.className,E=t.setAttributes,g=this.state,C=g.newFieldLabel,O=g.newFieldValue,N=g.newFieldType,x=g.newFieldOptionLabel,k=g.newFieldFullWidth,S=void 0;l&&(S=wp.element.createElement("div",{className:"tumbili-form-control flex-grow"},wp.element.createElement("label",{htmlFor:"firstName",style:{color:y}},"First Name",wp.element.createElement("input",{name:"firstName",type:"text"}))));var L=void 0;i&&(L=wp.element.createElement("div",{className:"tumbili-form-control flex-grow"},wp.element.createElement("label",{htmlFor:"lasttName",style:{color:y}},"Last Name",wp.element.createElement("input",{name:"lastName",type:"text"}))));var T=wp.element.createElement("input",{style:{color:u,background:o},className:"tumbili-submit",type:"submit",value:p}),_=s.map(function(t,n){var l=t.fullWidth?"is-full-width":"",i="text"===t.type?wp.element.createElement("input",{name:t.value,type:"text"}):wp.element.createElement("select",{name:t.value},wp.element.createElement("option",{value:t.options[0].label},t.options[0].label)),r=n>0?wp.element.createElement("span",{onClick:function(){return e.onReorder("fields",e.props.attributes.fields,n,n-1)}},wp.element.createElement(v,{icon:"arrow-up"})):"",a=n<s.length-1?wp.element.createElement("span",{onClick:function(){return e.onReorder("fields",e.props.attributes.fields,n,n+1)}},wp.element.createElement(v,{icon:"arrow-down"})):"";return wp.element.createElement("div",{key:n,className:"tumbili-form-control flex-grow "+l},wp.element.createElement("label",{htmlFor:t.value,style:{color:y}},t.label,i),wp.element.createElement("div",{className:"tumbili-field-action"},r,a,wp.element.createElement("span",{onClick:function(){return e.removeField(n)}},wp.element.createElement(v,{icon:"dismiss"}))))}),P=void 0;P=r&&a?wp.element.createElement("div",{className:"display-flex tumbili-container"},S,L,wp.element.createElement("div",{className:"tumbili-form-control flex-grow"},wp.element.createElement("label",{htmlFor:"email",style:{color:y}},"Email",wp.element.createElement("input",{name:"email",type:"email"}))),_,wp.element.createElement("div",{className:"tumbili-form-control flex-grow flex-is-at-bottom"},T)):wp.element.createElement("div",{className:F},"To get started please add an API Key & List ID.");var A=void 0;if("select"===N){var j=this.state.newFieldOptions.map(function(t,n){return wp.element.createElement("div",{key:n,className:"tumbili-field-option"},wp.element.createElement("span",null,t.label),wp.element.createElement("div",null,wp.element.createElement("span",{onClick:function(){return e.onReorder("options",e.state.newFieldOptions,n,n-1)}},wp.element.createElement(v,{icon:"arrow-up"})),wp.element.createElement("span",{onClick:function(){return e.onReorder("options",e.state.newFieldOptions,n,n+1)}},wp.element.createElement(v,{icon:"arrow-down"})),wp.element.createElement("span",{onClick:function(){return e.removeFieldOption(n)}},wp.element.createElement(v,{icon:"dismiss"}))))});A=wp.element.createElement("div",{className:"tumbili-type-options"},wp.element.createElement(f,{label:"Option",value:x,onChange:function(t){return e.setState({newFieldOptionLabel:t})}}),wp.element.createElement(b,{isOutline:!0,isSmall:!0,onClick:this.addFieldOption},"Add Option"),j)}return wp.element.createElement("div",{className:F},wp.element.createElement(c,null,wp.element.createElement(d,{title:__("Form Options")},wp.element.createElement(f,{label:__("Mailchimp API Key"),value:r,onChange:function(e){return E({apiKey:e})}}),wp.element.createElement(f,{label:__("Mailchimp List ID"),value:a,onChange:function(e){return E({listID:e})}}),wp.element.createElement(w,{label:__("Show First Name?"),checked:l,onChange:function(e){return E({showFirstName:e})}}),wp.element.createElement(w,{label:__("Show Last Name?"),checked:i,onChange:function(e){return E({showLastName:e})}}),wp.element.createElement(m,{title:__("Color Settings"),colorSettings:[{value:o,onChange:function(e){return E({buttonBackground:e})},label:__("Button Background Color")},{value:u,onChange:function(e){return E({buttonColor:e})},label:__("Button Text Color")},{value:y,onChange:function(e){return E({labelColor:e})},label:__("Field Label Color")}]}),wp.element.createElement(f,{label:__("Submit Text"),value:p,onChange:function(e){return E({buttonText:e})}})),wp.element.createElement(d,{title:__(" Custom Fields ")},wp.element.createElement(f,{label:"Field label",value:C,onChange:function(t){return e.setState({newFieldLabel:t})}}),wp.element.createElement(f,{label:"*|MERGE|* Tag",value:O,help:__("the *|MERGE|* tag value corresponding with that field, in your MailChimp audience"),onChange:function(t){return e.setState({newFieldValue:t})}}),wp.element.createElement(w,{label:"Full width",checked:k,onChange:function(){return e.setState(function(e){return{newFieldFullWidth:!e.newFieldFullWidth}})}}),wp.element.createElement(h,{label:"Field type (more coming soon)",value:N,options:[{label:"Text",value:"text"},{label:"Select",value:"select"}],onChange:function(t){e.setState({newFieldType:t})}}),A,wp.element.createElement(b,{isDefault:!0,onClick:this.addField},"Add Custom Field"))),P)}}]),t}(u);t.a=y}]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dist/blocks.editor.build.css CHANGED
@@ -1,53 +1 @@
1
- /**
2
- * #.# Common SCSS
3
- *
4
- * Can include things like variables and mixins
5
- * that are used across the project.
6
- */
7
- /**
8
- * #.# Editor Styles
9
- *
10
- * CSS for just Backend enqueued after style.scss
11
- * which makes it higher in priority.
12
- */
13
- .tumbili-submit {
14
- color: #fff;
15
- padding: 6px 9px;
16
- font-size: 13px;
17
- -webkit-transition: all 0.5s ease;
18
- -o-transition: all 0.5s ease;
19
- transition: all 0.5s ease;
20
- border-width: 0px; }
21
- .tumbili-submit:hover, .tumbili-submit:active {
22
- background-color: #753a10; }
23
-
24
- .tumbili-form-control {
25
- position: relative; }
26
-
27
- .tumbili-type-options {
28
- padding: 8px;
29
- margin-bottom: 19.5px;
30
- border: 1px solid #ccc;
31
- border-radius: 5px; }
32
-
33
- .tumbili-field-option {
34
- padding: 5px;
35
- margin-top: 5px;
36
- background-color: #f1f1f1;
37
- border-radius: 5px;
38
- font-size: 12px;
39
- display: -ms-flexbox;
40
- display: flex;
41
- -ms-flex-pack: justify;
42
- justify-content: space-between;
43
- -ms-flex-align: center;
44
- align-items: center; }
45
-
46
- .tumbili-field-action {
47
- position: absolute;
48
- top: 6px;
49
- right: 5px; }
50
- .tumbili-field-action > * {
51
- opacity: 0.5; }
52
- .tumbili-field-action > *:hover {
53
- opacity: 1; }
1
+ .tumbili-submit{color:#fff;padding:6px 9px;font-size:13px;-webkit-transition:all 0.5s ease;-o-transition:all 0.5s ease;transition:all 0.5s ease;border-width:0px}.tumbili-submit:hover,.tumbili-submit:active{background-color:#753a10}.tumbili-form-control{position:relative}.tumbili-type-options{padding:8px;margin-bottom:19.5px;border:1px solid #ccc;border-radius:5px}.tumbili-field-option{padding:5px;margin-top:5px;background-color:#f1f1f1;border-radius:5px;font-size:12px;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center}.tumbili-field-action{position:absolute;top:6px;right:5px}.tumbili-field-action>*{opacity:0.5}.tumbili-field-action>*:hover{opacity:1}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dist/blocks.style.build.css CHANGED
@@ -1,174 +1 @@
1
- /**
2
- * #.# Common SCSS
3
- *
4
- * Can include things like variables and mixins
5
- * that are used across the project.
6
- */
7
- /**
8
- * #.# Styles
9
- *
10
- * CSS for both Frontend+Backend.
11
- */
12
- .tumbili-form,
13
- .wp-block-cgb-tumbili-mailchimp-for-gutenberg {
14
- margin: 0 auto;
15
- position: relative; }
16
-
17
- .display-flex {
18
- display: -ms-flexbox;
19
- display: flex;
20
- -ms-flex-wrap: wrap;
21
- flex-wrap: wrap; }
22
- .display-flex > * {
23
- padding-left: 0.6rem;
24
- padding-right: 0.6rem; }
25
-
26
- .flex-grow {
27
- -ms-flex-positive: 1;
28
- flex-grow: 1; }
29
-
30
- .flex-is-at-bottom {
31
- display: -ms-flexbox;
32
- display: flex;
33
- -ms-flex-align: end;
34
- align-items: end; }
35
-
36
- /**
37
- Labels
38
- **/
39
- .tumbili-form-control {
40
- margin-bottom: 1rem; }
41
- .tumbili-form-control input,
42
- .tumbili-form-control select,
43
- .tumbili-form-control label {
44
- display: block; }
45
- .tumbili-form-control input,
46
- .tumbili-form-control select {
47
- width: 100%; }
48
- .tumbili-form-control.is-full-width {
49
- -ms-flex-preferred-size: 100%;
50
- flex-basis: 100%; }
51
-
52
- /**
53
- Submit
54
- **/
55
- .tumbili-submit {
56
- width: 100%;
57
- background-color: saddlebrown;
58
- border-color: saddlebrown; }
59
- .tumbili-submit .tumbili-loader {
60
- display: inline-block;
61
- margin-right: 0.5rem; }
62
- .tumbili-submit .tumbili-loader.is-hiding {
63
- width: 0;
64
- margin-right: 0;
65
- display: none; }
66
-
67
- /**
68
- Response
69
- **/
70
- .tumbili-response {
71
- text-align: center;
72
- position: absolute;
73
- width: 100%;
74
- max-width: 440px;
75
- top: 50%;
76
- left: 50%;
77
- -webkit-transform: translateY(-50%) translateX(-50%);
78
- -ms-transform: translateY(-50%) translateX(-50%);
79
- transform: translateY(-50%) translateX(-50%);
80
- padding: 0.5rem;
81
- -webkit-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.12), 0 2px 4px 0 rgba(0, 0, 0, 0.08);
82
- box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.12), 0 2px 4px 0 rgba(0, 0, 0, 0.08);
83
- border-radius: 0.25rem; }
84
- .tumbili-response:after {
85
- content: '';
86
- background-image: url("../assets/reload.svg");
87
- background-size: 24px 24px;
88
- height: 24px;
89
- width: 24px;
90
- margin-left: 0.5rem;
91
- display: inline-block;
92
- vertical-align: middle; }
93
-
94
- /**
95
- Interactivity
96
- **/
97
- .tumbili-container {
98
- -webkit-transition: all 0.3s ease;
99
- -o-transition: all 0.3s ease;
100
- transition: all 0.3s ease;
101
- margin-bottom: -1rem; }
102
-
103
- .isSubmitting input {
104
- -webkit-filter: blur(1px);
105
- filter: blur(1px); }
106
-
107
- .will-animate {
108
- -webkit-transition: all 400ms;
109
- -o-transition: all 400ms;
110
- transition: all 400ms; }
111
-
112
- .is-showing {
113
- opacity: 1; }
114
-
115
- .is-hiding {
116
- opacity: 0;
117
- visibility: hidden; }
118
-
119
- /**
120
- * Copyright (c) 2016 Connor Atherton
121
- *
122
- * All animations must live in their own file
123
- * in the animations directory and be included
124
- * here.
125
- *
126
- */
127
- /**
128
- * Styles shared by multiple animations
129
- */
130
- /**
131
- * Dots
132
- */
133
- @-webkit-keyframes ball-pulse-sync {
134
- 33% {
135
- -webkit-transform: translateY(7px);
136
- transform: translateY(7px); }
137
- 66% {
138
- -webkit-transform: translateY(-7px);
139
- transform: translateY(-7px); }
140
- 100% {
141
- -webkit-transform: translateY(0);
142
- transform: translateY(0); } }
143
- @keyframes ball-pulse-sync {
144
- 33% {
145
- -webkit-transform: translateY(7px);
146
- transform: translateY(7px); }
147
- 66% {
148
- -webkit-transform: translateY(-7px);
149
- transform: translateY(-7px); }
150
- 100% {
151
- -webkit-transform: translateY(0);
152
- transform: translateY(0); } }
153
-
154
- .ball-pulse-sync > div:nth-child(1) {
155
- -webkit-animation: ball-pulse-sync 0.7s -0.14s infinite ease-in-out;
156
- animation: ball-pulse-sync 0.7s -0.14s infinite ease-in-out; }
157
-
158
- .ball-pulse-sync > div:nth-child(2) {
159
- -webkit-animation: ball-pulse-sync 0.7s -0.07s infinite ease-in-out;
160
- animation: ball-pulse-sync 0.7s -0.07s infinite ease-in-out; }
161
-
162
- .ball-pulse-sync > div:nth-child(3) {
163
- -webkit-animation: ball-pulse-sync 0.7s 0s infinite ease-in-out;
164
- animation: ball-pulse-sync 0.7s 0s infinite ease-in-out; }
165
-
166
- .ball-pulse-sync > div {
167
- background-color: #fff;
168
- width: 8px;
169
- height: 8px;
170
- border-radius: 100%;
171
- margin: 2px;
172
- -webkit-animation-fill-mode: both;
173
- animation-fill-mode: both;
174
- display: inline-block; }
1
+ .tumbili-form,.wp-block-cgb-tumbili-mailchimp-for-gutenberg{margin:0 auto;position:relative}.display-flex{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}.display-flex>*{padding-left:.6rem;padding-right:.6rem}.flex-grow{-ms-flex-positive:1;flex-grow:1}.flex-is-at-bottom{display:-ms-flexbox;display:flex;-ms-flex-align:end;align-items:end}.tumbili-form-control{margin-bottom:1rem}.tumbili-form-control input,.tumbili-form-control select,.tumbili-form-control label{display:block}.tumbili-form-control input,.tumbili-form-control select{width:100%}.tumbili-form-control.is-full-width{-ms-flex-preferred-size:100%;flex-basis:100%}.tumbili-submit{width:100%;background-color:#8b4513;border-color:#8b4513}.tumbili-submit .tumbili-loader{display:inline-block;margin-right:0.5rem}.tumbili-submit .tumbili-loader.is-hiding{width:0;margin-right:0;display:none}.tumbili-response{text-align:center;position:absolute;width:100%;max-width:440px;top:50%;left:50%;-webkit-transform:translateY(-50%) translateX(-50%);-ms-transform:translateY(-50%) translateX(-50%);transform:translateY(-50%) translateX(-50%);padding:0.5rem;-webkit-box-shadow:0 4px 8px 0 rgba(0,0,0,0.12),0 2px 4px 0 rgba(0,0,0,0.08);box-shadow:0 4px 8px 0 rgba(0,0,0,0.12),0 2px 4px 0 rgba(0,0,0,0.08);border-radius:0.25rem}.tumbili-response:after{content:'';background-image:url("../assets/reload.svg");background-size:24px 24px;height:24px;width:24px;margin-left:0.5rem;display:inline-block;vertical-align:middle}.tumbili-container{-webkit-transition:all 0.3s ease;-o-transition:all 0.3s ease;transition:all 0.3s ease;margin-bottom:-1rem}.isSubmitting input{-webkit-filter:blur(1px);filter:blur(1px)}.will-animate{-webkit-transition:all 400ms;-o-transition:all 400ms;transition:all 400ms}.is-showing{opacity:1}.is-hiding{opacity:0;visibility:hidden}@-webkit-keyframes ball-pulse-sync{33%{-webkit-transform:translateY(7px);transform:translateY(7px)}66%{-webkit-transform:translateY(-7px);transform:translateY(-7px)}100%{-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes ball-pulse-sync{33%{-webkit-transform:translateY(7px);transform:translateY(7px)}66%{-webkit-transform:translateY(-7px);transform:translateY(-7px)}100%{-webkit-transform:translateY(0);transform:translateY(0)}}.ball-pulse-sync>div:nth-child(1){-webkit-animation:ball-pulse-sync 0.7s -.14s infinite ease-in-out;animation:ball-pulse-sync 0.7s -.14s infinite ease-in-out}.ball-pulse-sync>div:nth-child(2){-webkit-animation:ball-pulse-sync 0.7s -.07s infinite ease-in-out;animation:ball-pulse-sync 0.7s -.07s infinite ease-in-out}.ball-pulse-sync>div:nth-child(3){-webkit-animation:ball-pulse-sync 0.7s 0s infinite ease-in-out;animation:ball-pulse-sync 0.7s 0s infinite ease-in-out}.ball-pulse-sync>div{background-color:#fff;width:8px;height:8px;border-radius:100%;margin:2px;-webkit-animation-fill-mode:both;animation-fill-mode:both;display:inline-block}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dist/client.babel.js CHANGED
@@ -1,36 +1,40 @@
1
  "use strict";
2
 
3
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
4
 
5
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
6
 
7
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
8
 
9
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
 
 
 
 
10
 
11
  //
12
  // DOM READY SCRIPT
13
  //
14
  var domIsReady = function (domIsReady) {
15
  var isBrowserIeOrNot = function isBrowserIeOrNot() {
16
- return !document.attachEvent || typeof document.attachEvent === 'undefined' ? 'not-ie' : 'ie';
17
  };
18
 
19
  domIsReady = function domIsReady(callback) {
20
- if (callback && typeof callback === 'function') {
21
- if (isBrowserIeOrNot() !== 'ie') {
22
- document.addEventListener('DOMContentLoaded', function () {
23
  return callback();
24
  });
25
  } else {
26
- document.attachEvent('onreadystatechange', function () {
27
- if (document.readyState === 'complete') {
28
  return callback();
29
  }
30
  });
31
  }
32
  } else {
33
- console.error('The callback is not a function!');
34
  }
35
  };
36
 
@@ -44,15 +48,15 @@ var domIsReady = function (domIsReady) {
44
  domIsReady(function () {
45
  function tumbiliSubmitForm(evt) {
46
  var form = evt.target;
47
- var loader = form.querySelector('.tumbili-loader');
48
  var data = {};
49
- data.fname = form.querySelector('.tumbiliFName') ? form.querySelector('.tumbiliFName').value : '';
50
- data.lname = form.querySelector('.tumbiliLName') ? form.querySelector('.tumbiliLName').value : '';
51
- data.email = form.querySelector('.tumbiliEmail') ? form.querySelector('.tumbiliEmail').value : '';
52
- var fields = form.querySelectorAll('.tumbili-custom-field') ? form.querySelectorAll('.tumbili-custom-field') : [];
53
  data.fields = _toConsumableArray(fields).map(function (field) {
54
  var type = field.dataset.type;
55
- var value = type === 'select' ? field.options[field.selectedIndex].text : field.value;
56
  return {
57
  mergeField: field.name,
58
  value: value,
@@ -61,12 +65,12 @@ var domIsReady = function (domIsReady) {
61
  });
62
  data.apikey = form.dataset.apikey;
63
  data.listID = form.dataset.listid;
64
- data.dc = form.dataset.apikey.split('-')[1];
65
  sendRequestViaAJAX(data, form, loader);
66
  }
67
 
68
  function sendRequestViaAJAX(formData, form, loader) {
69
- var fields = '';
70
 
71
  if (formData.fields) {
72
  formData.fields.map(function (field) {
@@ -80,29 +84,29 @@ var domIsReady = function (domIsReady) {
80
  var serializedData = encodeURI(data);
81
  var xhr = new XMLHttpRequest();
82
  var url = tumbili.ajax_url;
83
- form.classList.toggle('isSubmitting');
84
- loader.classList.toggle('is-hiding');
85
- xhr.open('POST', url, true);
86
- xhr.setRequestHeader('Accept', 'application/json, text/javascript, */*; q=0.01');
87
- xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
88
- xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
89
- xhr.responseType = 'json';
90
 
91
  xhr.onerror = function () {
92
- console.log('Error: Do something else...');
93
  };
94
 
95
  xhr.onprogress = function () {
96
- console.log('status:LOADING', xhr.status, ' STATE', xhr.readyState, ' RESPONSE', JSON.parse(xhr.response));
97
  };
98
 
99
  xhr.onload = function (response) {
100
- if (this.status == 200) {
101
- form.classList.toggle('isSubmitting');
102
- loader.classList.toggle('is-hiding');
103
- console.log('status:DONE', xhr.status, ' STATE', xhr.readyState, 'NoParseResponse', this.response); // JSON response
104
 
105
- var mailchimpResponse = this.response;
106
  showApiResult(mailchimpResponse, form);
107
  }
108
  };
@@ -111,50 +115,50 @@ var domIsReady = function (domIsReady) {
111
  }
112
 
113
  function showApiResult(response, form) {
114
- var title;
115
 
116
  if (response.status === 400) {
117
  switch (response.title) {
118
- case 'Forgotten Email Not Subscribed':
119
- title = 'Looks like you unsubscribed from this list previously, please contact us to resubscribe';
120
  break;
121
 
122
- case 'Member Exists':
123
- title = '😄 Looks you are already subscribed';
124
  break;
125
 
126
  default:
127
  title = "Oops something wen't wrong: ".concat(response.title);
128
  }
129
  } else {
130
- title = '🎉 You have subscribed. Please check your inbox for confirmation.';
131
  }
132
 
133
  toggleForm(title, form);
134
  }
135
 
136
- function toggleForm() {
137
- var title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
138
- var form = arguments.length > 1 ? arguments[1] : undefined;
139
- var formContainer = form.querySelector('.tumbili-container');
140
- var responseContainer = form.querySelector('.tumbili-response');
141
- formContainer.classList.toggle('is-hiding');
142
- responseContainer.classList.toggle('is-hiding');
143
  responseContainer.innerHTML = title;
144
  }
145
 
146
- var formTumbili = document.querySelectorAll('.tumbili-form');
147
 
148
  for (var i = 0; i < formTumbili.length; i++) {
149
- formTumbili[i].addEventListener('submit', function (evt) {
150
  evt.preventDefault();
151
  tumbiliSubmitForm(evt);
152
  });
153
  }
154
 
155
- if (document.querySelector('.tumbili-response')) {
156
- document.querySelector('.tumbili-response').onclick = function () {
157
- toggleForm();
 
 
158
  };
159
  }
160
  });
1
  "use strict";
2
 
3
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
 
5
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
 
7
+ 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); }
8
 
9
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
10
+
11
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
+
13
+ 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; }
14
 
15
  //
16
  // DOM READY SCRIPT
17
  //
18
  var domIsReady = function (domIsReady) {
19
  var isBrowserIeOrNot = function isBrowserIeOrNot() {
20
+ return !document.attachEvent || typeof document.attachEvent === "undefined" ? "not-ie" : "ie";
21
  };
22
 
23
  domIsReady = function domIsReady(callback) {
24
+ if (callback && typeof callback === "function") {
25
+ if (isBrowserIeOrNot() !== "ie") {
26
+ document.addEventListener("DOMContentLoaded", function () {
27
  return callback();
28
  });
29
  } else {
30
+ document.attachEvent("onreadystatechange", function () {
31
+ if (document.readyState === "complete") {
32
  return callback();
33
  }
34
  });
35
  }
36
  } else {
37
+ console.error("The callback is not a function!");
38
  }
39
  };
40
 
48
  domIsReady(function () {
49
  function tumbiliSubmitForm(evt) {
50
  var form = evt.target;
51
+ var loader = form.querySelector(".tumbili-loader");
52
  var data = {};
53
+ data.fname = form.querySelector(".tumbiliFName") ? form.querySelector(".tumbiliFName").value : "";
54
+ data.lname = form.querySelector(".tumbiliLName") ? form.querySelector(".tumbiliLName").value : "";
55
+ data.email = form.querySelector(".tumbiliEmail") ? form.querySelector(".tumbiliEmail").value : "";
56
+ var fields = form.querySelectorAll(".tumbili-custom-field") ? form.querySelectorAll(".tumbili-custom-field") : [];
57
  data.fields = _toConsumableArray(fields).map(function (field) {
58
  var type = field.dataset.type;
59
+ var value = type === "select" ? field.options[field.selectedIndex].text : field.value;
60
  return {
61
  mergeField: field.name,
62
  value: value,
65
  });
66
  data.apikey = form.dataset.apikey;
67
  data.listID = form.dataset.listid;
68
+ data.dc = form.dataset.apikey.split("-")[1];
69
  sendRequestViaAJAX(data, form, loader);
70
  }
71
 
72
  function sendRequestViaAJAX(formData, form, loader) {
73
+ var fields = "";
74
 
75
  if (formData.fields) {
76
  formData.fields.map(function (field) {
84
  var serializedData = encodeURI(data);
85
  var xhr = new XMLHttpRequest();
86
  var url = tumbili.ajax_url;
87
+ form.classList.toggle("isSubmitting");
88
+ loader.classList.toggle("is-hiding");
89
+ xhr.open("POST", url, true);
90
+ xhr.setRequestHeader("Accept", "application/json, text/javascript, */*; q=0.01");
91
+ xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
92
+ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
93
+ xhr.responseType = "json";
94
 
95
  xhr.onerror = function () {
96
+ console.log("Error: Do something else...");
97
  };
98
 
99
  xhr.onprogress = function () {
100
+ console.log("status:LOADING", xhr.status, " STATE", xhr.readyState, " RESPONSE", JSON.parse(xhr.response));
101
  };
102
 
103
  xhr.onload = function (response) {
104
+ if (xhr.status == 200) {
105
+ form.classList.toggle("isSubmitting");
106
+ loader.classList.toggle("is-hiding");
107
+ console.log("status:DONE", xhr.status, " STATE", xhr.readyState, "NoParseResponse", xhr.response); // JSON response
108
 
109
+ var mailchimpResponse = xhr.response;
110
  showApiResult(mailchimpResponse, form);
111
  }
112
  };
115
  }
116
 
117
  function showApiResult(response, form) {
118
+ var title = "";
119
 
120
  if (response.status === 400) {
121
  switch (response.title) {
122
+ case "Forgotten Email Not Subscribed":
123
+ title = "Looks like you unsubscribed from this list previously, please contact us to resubscribe";
124
  break;
125
 
126
+ case "Member Exists":
127
+ title = "😄 Looks you are already subscribed";
128
  break;
129
 
130
  default:
131
  title = "Oops something wen't wrong: ".concat(response.title);
132
  }
133
  } else {
134
+ title = "🎉 You have subscribed. Please check your inbox for confirmation.";
135
  }
136
 
137
  toggleForm(title, form);
138
  }
139
 
140
+ function toggleForm(title, form) {
141
+ var formContainer = form.querySelector(".tumbili-container");
142
+ var responseContainer = form.querySelector(".tumbili-response");
143
+ formContainer.classList.toggle("is-hiding");
144
+ responseContainer.classList.toggle("is-hiding");
 
 
145
  responseContainer.innerHTML = title;
146
  }
147
 
148
+ var formTumbili = document.querySelectorAll(".tumbili-form");
149
 
150
  for (var i = 0; i < formTumbili.length; i++) {
151
+ formTumbili[i].addEventListener("submit", function (evt) {
152
  evt.preventDefault();
153
  tumbiliSubmitForm(evt);
154
  });
155
  }
156
 
157
+ if (document.querySelector(".tumbili-response")) {
158
+ document.querySelector(".tumbili-response").onclick = function (evt) {
159
+ var target = evt.target;
160
+ var form = target.closest("form");
161
+ toggleForm("", form);
162
  };
163
  }
164
  });
plugin.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Easily add a mailchimp signup form to your editor.
6
  * Author: gubbigubbi
7
  * Author URI: https://github.com/gubbigubbi/
8
- * Version: 0.6
9
  * License: GPL2+
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
11
  *
5
  * Description: Easily add a mailchimp signup form to your editor.
6
  * Author: gubbigubbi
7
  * Author URI: https://github.com/gubbigubbi/
8
+ * Version: 0.7
9
  * License: GPL2+
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
11
  *
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: gubbigubbi
3
  Tags: gutenberg, mailchimp, mailchimp signup, mailchimp form
4
  Requires at least: 4.9.6
5
- Tested up to: 5.3
6
- Stable tag: 0.6
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -46,6 +46,10 @@ This plugin is laid out using Flexbox, we do not have plans to support older bro
46
 
47
  == Changelog ==
48
 
 
 
 
 
49
  = 0.6 =
50
  * Added custom field support!
51
 
2
  Contributors: gubbigubbi
3
  Tags: gutenberg, mailchimp, mailchimp signup, mailchimp form
4
  Requires at least: 4.9.6
5
+ Tested up to: 5.4
6
+ Stable tag: 0.7
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
46
 
47
  == Changelog ==
48
 
49
+ = 0.7 =
50
+ * Added extra controls for label color and submit text
51
+ * Fixed bug with form reset
52
+
53
  = 0.6 =
54
  * Added custom field support!
55
 
src/client.js CHANGED
@@ -1,191 +1,193 @@
1
  //
2
  // DOM READY SCRIPT
3
  //
4
- var domIsReady = ( function( domIsReady ) {
5
- const isBrowserIeOrNot = function() {
6
- return ! document.attachEvent || typeof document.attachEvent === 'undefined' ?
7
- 'not-ie' :
8
- 'ie';
9
  };
10
 
11
- domIsReady = function( callback ) {
12
- if ( callback && typeof callback === 'function' ) {
13
- if ( isBrowserIeOrNot() !== 'ie' ) {
14
- document.addEventListener( 'DOMContentLoaded', function() {
15
  return callback();
16
- } );
17
  } else {
18
- document.attachEvent( 'onreadystatechange', function() {
19
- if ( document.readyState === 'complete' ) {
20
  return callback();
21
  }
22
- } );
23
  }
24
  } else {
25
- console.error( 'The callback is not a function!' );
26
  }
27
  };
28
 
29
  return domIsReady;
30
- }( domIsReady || {} ) );
31
 
32
  //
33
  // DOM IS READY
34
  //
35
- ( function( document, window, domIsReady, undefined ) {
36
- domIsReady( function() {
37
- function tumbiliSubmitForm( evt ) {
38
  const form = evt.target;
39
 
40
- const loader = form.querySelector( '.tumbili-loader' );
41
  const data = {};
42
 
43
- data.fname = form.querySelector( '.tumbiliFName' ) ?
44
- form.querySelector( '.tumbiliFName' ).value :
45
- '';
46
 
47
- data.lname = form.querySelector( '.tumbiliLName' ) ?
48
- form.querySelector( '.tumbiliLName' ).value :
49
- '';
50
 
51
- data.email = form.querySelector( '.tumbiliEmail' ) ?
52
- form.querySelector( '.tumbiliEmail' ).value :
53
- '';
54
 
55
- const fields = form.querySelectorAll( '.tumbili-custom-field' ) ?
56
- form.querySelectorAll( '.tumbili-custom-field' ) :
57
- [];
58
 
59
- data.fields = [ ...fields ].map( field => {
60
  const type = field.dataset.type;
61
  const value =
62
- type === 'select' ?
63
- field.options[ field.selectedIndex ].text :
64
- field.value;
65
 
66
  return {
67
  mergeField: field.name,
68
  value,
69
  type,
70
  };
71
- } );
72
 
73
  data.apikey = form.dataset.apikey;
74
  data.listID = form.dataset.listid;
75
- data.dc = form.dataset.apikey.split( '-' )[ 1 ];
76
 
77
- sendRequestViaAJAX( data, form, loader );
78
  }
79
 
80
- function sendRequestViaAJAX( formData, form, loader ) {
81
- let fields = '';
82
 
83
- if ( formData.fields ) {
84
- formData.fields.map( field => {
85
- if ( field.value ) {
86
- fields += `&formCustomFields[${ field.mergeField }]=${ field.value }`;
87
  }
88
- } );
89
  }
90
 
91
- const data = `action=tumbili_mailchimp_add_subscriber&formData[apikey]=${ formData.apikey }&formData[listID]=${ formData.listID }&formData[dc]=${ formData.dc }&formData[fname]=${ formData.fname }&formData[lname]=${ formData.lname }&formData[email]=${ formData.email }${ fields }`;
92
 
93
- const serializedData = encodeURI( data );
94
 
95
  const xhr = new XMLHttpRequest();
96
  const url = tumbili.ajax_url;
97
 
98
- form.classList.toggle( 'isSubmitting' );
99
- loader.classList.toggle( 'is-hiding' );
100
 
101
- xhr.open( 'POST', url, true );
102
  xhr.setRequestHeader(
103
- 'Accept',
104
- 'application/json, text/javascript, */*; q=0.01'
105
  );
106
  xhr.setRequestHeader(
107
- 'Content-Type',
108
- 'application/x-www-form-urlencoded; charset=UTF-8'
109
  );
110
- xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest' );
111
 
112
- xhr.responseType = 'json';
113
- xhr.onerror = function() {
114
- console.log( 'Error: Do something else...' );
115
  };
116
- xhr.onprogress = function() {
117
  console.log(
118
- 'status:LOADING',
119
  xhr.status,
120
- ' STATE',
121
  xhr.readyState,
122
- ' RESPONSE',
123
- JSON.parse( xhr.response )
124
  );
125
  };
126
- xhr.onload = function( response ) {
127
- if ( this.status == 200 ) {
128
- form.classList.toggle( 'isSubmitting' );
129
- loader.classList.toggle( 'is-hiding' );
130
  console.log(
131
- 'status:DONE',
132
  xhr.status,
133
- ' STATE',
134
  xhr.readyState,
135
- 'NoParseResponse',
136
- this.response
137
  ); // JSON response
138
- const mailchimpResponse = this.response;
139
- showApiResult( mailchimpResponse, form );
140
  }
141
  };
142
- xhr.send( serializedData );
143
  }
144
 
145
- function showApiResult( response, form ) {
146
- let title;
147
 
148
- if ( response.status === 400 ) {
149
- switch ( response.title ) {
150
- case 'Forgotten Email Not Subscribed':
151
  title =
152
- 'Looks like you unsubscribed from this list previously, please contact us to resubscribe';
153
  break;
154
- case 'Member Exists':
155
- title = '😄 Looks you are already subscribed';
156
  break;
157
  default:
158
- title = `Oops something wen't wrong: ${ response.title }`;
159
  }
160
  } else {
161
  title =
162
- '🎉 You have subscribed. Please check your inbox for confirmation.';
163
  }
164
 
165
- toggleForm( title, form );
166
  }
167
 
168
- function toggleForm( title = '', form ) {
169
- const formContainer = form.querySelector( '.tumbili-container' );
170
- const responseContainer = form.querySelector( '.tumbili-response' );
171
- formContainer.classList.toggle( 'is-hiding' );
172
- responseContainer.classList.toggle( 'is-hiding' );
173
  responseContainer.innerHTML = title;
174
  }
175
 
176
- const formTumbili = document.querySelectorAll( '.tumbili-form' );
177
 
178
- for ( let i = 0; i < formTumbili.length; i++ ) {
179
- formTumbili[ i ].addEventListener( 'submit', function( evt ) {
180
  evt.preventDefault();
181
- tumbiliSubmitForm( evt );
182
- } );
183
  }
184
 
185
- if ( document.querySelector( '.tumbili-response' ) ) {
186
- document.querySelector( '.tumbili-response' ).onclick = function() {
187
- toggleForm();
 
 
188
  };
189
  }
190
- } );
191
- }( document, window, domIsReady ) );
1
  //
2
  // DOM READY SCRIPT
3
  //
4
+ var domIsReady = (function (domIsReady) {
5
+ const isBrowserIeOrNot = function () {
6
+ return !document.attachEvent || typeof document.attachEvent === "undefined"
7
+ ? "not-ie"
8
+ : "ie";
9
  };
10
 
11
+ domIsReady = function (callback) {
12
+ if (callback && typeof callback === "function") {
13
+ if (isBrowserIeOrNot() !== "ie") {
14
+ document.addEventListener("DOMContentLoaded", function () {
15
  return callback();
16
+ });
17
  } else {
18
+ document.attachEvent("onreadystatechange", function () {
19
+ if (document.readyState === "complete") {
20
  return callback();
21
  }
22
+ });
23
  }
24
  } else {
25
+ console.error("The callback is not a function!");
26
  }
27
  };
28
 
29
  return domIsReady;
30
+ })(domIsReady || {});
31
 
32
  //
33
  // DOM IS READY
34
  //
35
+ (function (document, window, domIsReady, undefined) {
36
+ domIsReady(function () {
37
+ function tumbiliSubmitForm(evt) {
38
  const form = evt.target;
39
 
40
+ const loader = form.querySelector(".tumbili-loader");
41
  const data = {};
42
 
43
+ data.fname = form.querySelector(".tumbiliFName")
44
+ ? form.querySelector(".tumbiliFName").value
45
+ : "";
46
 
47
+ data.lname = form.querySelector(".tumbiliLName")
48
+ ? form.querySelector(".tumbiliLName").value
49
+ : "";
50
 
51
+ data.email = form.querySelector(".tumbiliEmail")
52
+ ? form.querySelector(".tumbiliEmail").value
53
+ : "";
54
 
55
+ const fields = form.querySelectorAll(".tumbili-custom-field")
56
+ ? form.querySelectorAll(".tumbili-custom-field")
57
+ : [];
58
 
59
+ data.fields = [...fields].map((field) => {
60
  const type = field.dataset.type;
61
  const value =
62
+ type === "select"
63
+ ? field.options[field.selectedIndex].text
64
+ : field.value;
65
 
66
  return {
67
  mergeField: field.name,
68
  value,
69
  type,
70
  };
71
+ });
72
 
73
  data.apikey = form.dataset.apikey;
74
  data.listID = form.dataset.listid;
75
+ data.dc = form.dataset.apikey.split("-")[1];
76
 
77
+ sendRequestViaAJAX(data, form, loader);
78
  }
79
 
80
+ function sendRequestViaAJAX(formData, form, loader) {
81
+ let fields = "";
82
 
83
+ if (formData.fields) {
84
+ formData.fields.map((field) => {
85
+ if (field.value) {
86
+ fields += `&formCustomFields[${field.mergeField}]=${field.value}`;
87
  }
88
+ });
89
  }
90
 
91
+ const data = `action=tumbili_mailchimp_add_subscriber&formData[apikey]=${formData.apikey}&formData[listID]=${formData.listID}&formData[dc]=${formData.dc}&formData[fname]=${formData.fname}&formData[lname]=${formData.lname}&formData[email]=${formData.email}${fields}`;
92
 
93
+ const serializedData = encodeURI(data);
94
 
95
  const xhr = new XMLHttpRequest();
96
  const url = tumbili.ajax_url;
97
 
98
+ form.classList.toggle("isSubmitting");
99
+ loader.classList.toggle("is-hiding");
100
 
101
+ xhr.open("POST", url, true);
102
  xhr.setRequestHeader(
103
+ "Accept",
104
+ "application/json, text/javascript, */*; q=0.01"
105
  );
106
  xhr.setRequestHeader(
107
+ "Content-Type",
108
+ "application/x-www-form-urlencoded; charset=UTF-8"
109
  );
110
+ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
111
 
112
+ xhr.responseType = "json";
113
+ xhr.onerror = function () {
114
+ console.log("Error: Do something else...");
115
  };
116
+ xhr.onprogress = function () {
117
  console.log(
118
+ "status:LOADING",
119
  xhr.status,
120
+ " STATE",
121
  xhr.readyState,
122
+ " RESPONSE",
123
+ JSON.parse(xhr.response)
124
  );
125
  };
126
+ xhr.onload = (response) => {
127
+ if (xhr.status == 200) {
128
+ form.classList.toggle("isSubmitting");
129
+ loader.classList.toggle("is-hiding");
130
  console.log(
131
+ "status:DONE",
132
  xhr.status,
133
+ " STATE",
134
  xhr.readyState,
135
+ "NoParseResponse",
136
+ xhr.response
137
  ); // JSON response
138
+ const mailchimpResponse = xhr.response;
139
+ showApiResult(mailchimpResponse, form);
140
  }
141
  };
142
+ xhr.send(serializedData);
143
  }
144
 
145
+ function showApiResult(response, form) {
146
+ let title = "";
147
 
148
+ if (response.status === 400) {
149
+ switch (response.title) {
150
+ case "Forgotten Email Not Subscribed":
151
  title =
152
+ "Looks like you unsubscribed from this list previously, please contact us to resubscribe";
153
  break;
154
+ case "Member Exists":
155
+ title = "😄 Looks you are already subscribed";
156
  break;
157
  default:
158
+ title = `Oops something wen't wrong: ${response.title}`;
159
  }
160
  } else {
161
  title =
162
+ "🎉 You have subscribed. Please check your inbox for confirmation.";
163
  }
164
 
165
+ toggleForm(title, form);
166
  }
167
 
168
+ function toggleForm(title, form) {
169
+ const formContainer = form.querySelector(".tumbili-container");
170
+ const responseContainer = form.querySelector(".tumbili-response");
171
+ formContainer.classList.toggle("is-hiding");
172
+ responseContainer.classList.toggle("is-hiding");
173
  responseContainer.innerHTML = title;
174
  }
175
 
176
+ const formTumbili = document.querySelectorAll(".tumbili-form");
177
 
178
+ for (let i = 0; i < formTumbili.length; i++) {
179
+ formTumbili[i].addEventListener("submit", function (evt) {
180
  evt.preventDefault();
181
+ tumbiliSubmitForm(evt);
182
+ });
183
  }
184
 
185
+ if (document.querySelector(".tumbili-response")) {
186
+ document.querySelector(".tumbili-response").onclick = function (evt) {
187
+ const target = evt.target;
188
+ const form = target.closest("form");
189
+ toggleForm("", form);
190
  };
191
  }
192
+ });
193
+ })(document, window, domIsReady);
src/server.php CHANGED
@@ -129,6 +129,8 @@ function tumbili_render_callback( array $attributes ){
129
  $showLastName = $attributes[ 'showLastName' ];
130
  $buttonBackground = $attributes[ 'buttonBackground' ];
131
  $buttonColor = $attributes[ 'buttonColor' ];
 
 
132
  $fields = $attributes[ 'fields' ];
133
 
134
  $firstName = '';
@@ -138,14 +140,14 @@ function tumbili_render_callback( array $attributes ){
138
  if($showFirstName) {
139
  $firstName .= '
140
  <div class="tumbili-form-control flex-grow">
141
- <label for="firstName">First Name<input name="firstName" class="tumbiliFName" type="text"></label>
142
  </div>';
143
  }
144
 
145
  if($showLastName) {
146
  $lastName .= '
147
  <div class="tumbili-form-control flex-grow">
148
- <label for="lastName">Last Name<input name="lastName" class="tumbiliLName" type="text"></label>
149
  </div>';
150
  }
151
 
@@ -153,7 +155,7 @@ function tumbili_render_callback( array $attributes ){
153
 
154
  $width = $field['fullWidth'] ? 'is-full-width' : '';
155
 
156
- $fieldsHTML .= '<div class="tumbili-form-control flex-grow '.$width.'"><label for="'.$field['value'].'">'.$field['label'];
157
 
158
  if( $field['type'] == 'text' ) {
159
  $fieldsHTML .= '<input name="'.$field['value'].'" class="tumbili-custom-field" type="text" data-type="'.$field['type'].'"></label>';
@@ -177,10 +179,10 @@ function tumbili_render_callback( array $attributes ){
177
 
178
  $markup .= '
179
  <div class="tumbili-form-control flex-grow">
180
- <label for="email">Email<input class="tumbiliEmail" name="email" type="email"></label>
181
  </div>'.$fieldsHTML.'
182
  <div class="flex-grow flex-is-at-bottom tumbili-form-control">
183
- <button style="background-color: '.$buttonBackground.'; color: '.$buttonColor.'; border-color: '.$buttonBackground.'" class="tumbili-submit" value="Submit" type="submit">
184
  <div class="tumbili-loader will-animate is-hiding">
185
  <div class="loader-inner ball-pulse-sync">
186
  <div></div>
@@ -188,7 +190,7 @@ function tumbili_render_callback( array $attributes ){
188
  <div></div>
189
  </div>
190
  </div>
191
- Submit
192
  </button>
193
  </div>
194
  ';
129
  $showLastName = $attributes[ 'showLastName' ];
130
  $buttonBackground = $attributes[ 'buttonBackground' ];
131
  $buttonColor = $attributes[ 'buttonColor' ];
132
+ $buttonText = $attributes[ 'buttonText' ];
133
+ $labelColor = $attributes[ 'labelColor' ];
134
  $fields = $attributes[ 'fields' ];
135
 
136
  $firstName = '';
140
  if($showFirstName) {
141
  $firstName .= '
142
  <div class="tumbili-form-control flex-grow">
143
+ <label for="firstName" style="color: '.$labelColor.'">First Name<input name="firstName" class="tumbiliFName" type="text"></label>
144
  </div>';
145
  }
146
 
147
  if($showLastName) {
148
  $lastName .= '
149
  <div class="tumbili-form-control flex-grow">
150
+ <label for="lastName" style="color: '.$labelColor.'">Last Name<input name="lastName" class="tumbiliLName" type="text"></label>
151
  </div>';
152
  }
153
 
155
 
156
  $width = $field['fullWidth'] ? 'is-full-width' : '';
157
 
158
+ $fieldsHTML .= '<div class="tumbili-form-control flex-grow '.$width.'"><label for="'.$field['value'].'" style="color: '.$labelColor.'">'.$field['label'];
159
 
160
  if( $field['type'] == 'text' ) {
161
  $fieldsHTML .= '<input name="'.$field['value'].'" class="tumbili-custom-field" type="text" data-type="'.$field['type'].'"></label>';
179
 
180
  $markup .= '
181
  <div class="tumbili-form-control flex-grow">
182
+ <label for="email" style="color: '.$labelColor.'">Email<input class="tumbiliEmail" name="email" type="email"></label>
183
  </div>'.$fieldsHTML.'
184
  <div class="flex-grow flex-is-at-bottom tumbili-form-control">
185
+ <button style="background-color: '.$buttonBackground.'; color: '.$buttonColor.'; border-color: '.$buttonBackground.'" class="tumbili-submit" value="'.$buttonText.'" type="submit">
186
  <div class="tumbili-loader will-animate is-hiding">
187
  <div class="loader-inner ball-pulse-sync">
188
  <div></div>
190
  <div></div>
191
  </div>
192
  </div>
193
+ '.$buttonText.'
194
  </button>
195
  </div>
196
  ';