/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ({
/***/ "./assets/blocks/accordion/block.jsx":
/*!*******************************************!*\
!*** ./assets/blocks/accordion/block.jsx ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _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; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _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; }
function _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; }
(function (wpI18n, wpBlocks, wpElement, wpEditor, wpComponents) {
var __ = wpI18n.__;
var Component = wpElement.Component,
Fragment = wpElement.Fragment;
var registerBlockType = wpBlocks.registerBlockType;
var InspectorControls = wpEditor.InspectorControls,
RichText = wpEditor.RichText,
PanelColorSettings = wpEditor.PanelColorSettings,
InnerBlocks = wpEditor.InnerBlocks;
var RangeControl = wpComponents.RangeControl,
PanelBody = wpComponents.PanelBody,
BaseControl = wpComponents.BaseControl,
SelectControl = wpComponents.SelectControl,
ToggleControl = wpComponents.ToggleControl;
var HEADER_ICONS = {
plus: React.createElement(
Fragment,
null,
React.createElement("path", { fill: "none", d: "M0,0h24v24H0V0z" }),
React.createElement("path", { d: "M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6V13z" })
),
plusCircle: React.createElement(
Fragment,
null,
React.createElement("path", { fill: "none", d: "M0,0h24v24H0V0z" }),
React.createElement("path", { d: "M12,2C6.48,2,2,6.48,2,12s4.48,10,10,10s10-4.48,10-10S17.52,2,12,2z M17,13h-4v4h-2v-4H7v-2h4V7h2v4h4V13z" })
),
plusCircleOutline: React.createElement(
Fragment,
null,
React.createElement("path", { fill: "none", d: "M0,0h24v24H0V0z" }),
React.createElement("path", { d: "M13,7h-2v4H7v2h4v4h2v-4h4v-2h-4V7z M12,2C6.48,2,2,6.48,2,12s4.48,10,10,10s10-4.48,10-10S17.52,2,12,2z M12,20 c-4.41,0-8-3.59-8-8s3.59-8,8-8s8,3.59,8,8S16.41,20,12,20z" })
),
plusBox: React.createElement(
Fragment,
null,
React.createElement("path", { fill: "none", d: "M0,0h24v24H0V0z" }),
React.createElement("path", { d: "M19,3H5C3.89,3,3,3.9,3,5v14c0,1.1,0.89,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M19,19H5V5h14V19z" }),
React.createElement("polygon", { points: "11,17 13,17 13,13 17,13 17,11 13,11 13,7 11,7 11,11 7,11 7,13 11,13" })
),
unfold: React.createElement(
Fragment,
null,
React.createElement("path", { fill: "none", d: "M0,0h24v24H0V0z" }),
React.createElement("path", { d: "M12,5.83L15.17,9l1.41-1.41L12,3L7.41,7.59L8.83,9L12,5.83z M12,18.17L8.83,15l-1.41,1.41L12,21l4.59-4.59L15.17,15 L12,18.17z" })
),
threeDots: React.createElement(
Fragment,
null,
React.createElement("path", { fill: "none", d: "M0,0h24v24H0V0z" }),
React.createElement("path", { d: "M6,10c-1.1,0-2,0.9-2,2s0.9,2,2,2s2-0.9,2-2S7.1,10,6,10z M18,10c-1.1,0-2,0.9-2,2s0.9,2,2,2s2-0.9,2-2S19.1,10,18,10z M12,10c-1.1,0-2,0.9-2,2s0.9,2,2,2s2-0.9,2-2S13.1,10,12,10z" })
),
arrowDown: React.createElement(
Fragment,
null,
React.createElement("path", { opacity: "0.87", fill: "none", d: "M24,24H0L0,0l24,0V24z" }),
React.createElement("path", { d: "M16.59,8.59L12,13.17L7.41,8.59L6,10l6,6l6-6L16.59,8.59z" })
)
};
var AdvAccordion = function (_Component) {
_inherits(AdvAccordion, _Component);
function AdvAccordion() {
_classCallCheck(this, AdvAccordion);
var _this = _possibleConstructorReturn(this, (AdvAccordion.__proto__ || Object.getPrototypeOf(AdvAccordion)).apply(this, arguments));
_this.state = {
currentAccordion: null
};
return _this;
}
_createClass(AdvAccordion, [{
key: "componentWillMount",
value: function componentWillMount() {
var _props = this.props,
attributes = _props.attributes,
setAttributes = _props.setAttributes;
var currentBlockConfig = advgbDefaultConfig['advgb-accordion'];
// No override attributes of blocks inserted before
if (attributes.changed !== true) {
if ((typeof currentBlockConfig === "undefined" ? "undefined" : _typeof(currentBlockConfig)) === 'object' && currentBlockConfig !== null) {
Object.keys(currentBlockConfig).map(function (attribute) {
if (typeof attributes[attribute] === 'boolean') {
attributes[attribute] = !!currentBlockConfig[attribute];
} else {
attributes[attribute] = currentBlockConfig[attribute];
}
});
}
// Finally set changed attribute to true, so we don't modify anything again
setAttributes({ changed: true });
}
}
}, {
key: "render",
value: function render() {
var _props2 = this.props,
isSelected = _props2.isSelected,
attributes = _props2.attributes,
setAttributes = _props2.setAttributes;
var header = attributes.header,
headerBgColor = attributes.headerBgColor,
headerTextColor = attributes.headerTextColor,
headerIcon = attributes.headerIcon,
headerIconColor = attributes.headerIconColor,
bodyBgColor = attributes.bodyBgColor,
bodyTextColor = attributes.bodyTextColor,
borderStyle = attributes.borderStyle,
borderWidth = attributes.borderWidth,
borderColor = attributes.borderColor,
borderRadius = attributes.borderRadius,
marginBottom = attributes.marginBottom,
collapsedAll = attributes.collapsedAll;
return React.createElement(
Fragment,
null,
React.createElement(
InspectorControls,
null,
React.createElement(
PanelBody,
{ title: __('Accordion Settings') },
React.createElement(RangeControl, {
label: __('Bottom spacing'),
value: marginBottom,
help: __('Define space to next block. This will override Block spacing option (Frontend view only)'),
min: 0,
max: 50,
onChange: function onChange(value) {
return setAttributes({ marginBottom: value });
}
})
),
React.createElement(
PanelBody,
{ title: __('Header Settings') },
React.createElement(
BaseControl,
{ label: __('Header Icon Style') },
React.createElement(
"div",
{ className: "advgb-icon-items-wrapper" },
Object.keys(HEADER_ICONS).map(function (key, index) {
return React.createElement(
"div",
{ className: "advgb-icon-item", key: index },
React.createElement(
"span",
{ className: key === headerIcon ? 'active' : '',
onClick: function onClick() {
return setAttributes({ headerIcon: key });
} },
React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24" },
HEADER_ICONS[key]
)
)
);
})
)
),
React.createElement(PanelColorSettings, {
title: __('Color Settings'),
initialOpen: false,
colorSettings: [{
label: __('Background Color'),
value: headerBgColor,
onChange: function onChange(value) {
return setAttributes({ headerBgColor: value === undefined ? '#000' : value });
}
}, {
label: __('Text Color'),
value: headerTextColor,
onChange: function onChange(value) {
return setAttributes({ headerTextColor: value === undefined ? '#eee' : value });
}
}, {
label: __('Icon Color'),
value: headerIconColor,
onChange: function onChange(value) {
return setAttributes({ headerIconColor: value === undefined ? '#fff' : value });
}
}]
})
),
React.createElement(PanelColorSettings, {
title: __('Body Color Settings'),
initialOpen: false,
colorSettings: [{
label: __('Background Color'),
value: bodyBgColor,
onChange: function onChange(value) {
return setAttributes({ bodyBgColor: value });
}
}, {
label: __('Text Color'),
value: bodyTextColor,
onChange: function onChange(value) {
return setAttributes({ bodyTextColor: value });
}
}]
}),
React.createElement(
PanelBody,
{ title: __('Border Settings'), initialOpen: false },
React.createElement(SelectControl, {
label: __('Border Style'),
value: borderStyle,
options: [{ label: __('Solid'), value: 'solid' }, { label: __('Dashed'), value: 'dashed' }, { label: __('Dotted'), value: 'dotted' }],
onChange: function onChange(value) {
return setAttributes({ borderStyle: value });
}
}),
React.createElement(PanelColorSettings, {
title: __('Color Settings'),
initialOpen: false,
colorSettings: [{
label: __('Border Color'),
value: borderColor,
onChange: function onChange(value) {
return setAttributes({ borderColor: value });
}
}]
}),
React.createElement(RangeControl, {
label: __('Border width'),
value: borderWidth,
min: 0,
max: 10,
onChange: function onChange(value) {
return setAttributes({ borderWidth: value });
}
}),
React.createElement(RangeControl, {
label: __('Border radius'),
value: borderRadius,
min: 0,
max: 100,
onChange: function onChange(value) {
return setAttributes({ borderRadius: value });
}
})
),
React.createElement(
PanelBody,
{ title: __('Accordions State'), initialOpen: false },
React.createElement(ToggleControl, {
label: __('Initial Collapsed'),
help: __('Make all accordions collapsed by default, enable this setting to apply to all accordions.'),
checked: collapsedAll,
onChange: function onChange() {
return setAttributes({ collapsedAll: !collapsedAll });
}
})
)
),
React.createElement(
"div",
{ className: "advgb-accordion-block" },
React.createElement(
"div",
{ className: "advgb-accordion-header",
style: {
backgroundColor: headerBgColor,
color: headerTextColor,
borderStyle: borderStyle,
borderWidth: borderWidth + 'px',
borderColor: borderColor,
borderRadius: borderRadius + 'px'
}
},
React.createElement(
"span",
{ className: "advgb-accordion-header-icon" },
React.createElement(
"svg",
{ fill: headerIconColor, xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24" },
HEADER_ICONS[headerIcon]
)
),
React.createElement(RichText, {
tagName: "h4",
value: header,
onChange: function onChange(value) {
return setAttributes({ header: value });
},
unstableOnSplit: function unstableOnSplit() {
return null;
},
className: "advgb-accordion-header-title",
placeholder: __('Enter header…')
})
),
React.createElement(
"div",
{ className: "advgb-accordion-body",
style: {
backgroundColor: bodyBgColor,
color: bodyTextColor,
borderStyle: borderStyle,
borderWidth: borderWidth + 'px',
borderColor: borderColor,
borderRadius: borderRadius + 'px'
}
},
React.createElement(InnerBlocks, null)
)
)
);
}
}]);
return AdvAccordion;
}(Component);
var accordionBlockIcon = React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "2 2 22 22" },
React.createElement("path", { fill: "none", d: "M0,0h24v24H0V0z" }),
React.createElement("rect", { x: "3", y: "17", width: "18", height: "2" }),
React.createElement("path", { d: "M19,12v1H5v-1H19 M21,10H3v5h18V10L21,10z" }),
React.createElement("rect", { x: "3", y: "6", width: "18", height: "2" })
);
var accordionAttrs = {
header: {
type: 'string',
default: __('Header text')
},
headerBgColor: {
type: 'string',
default: '#000'
},
headerTextColor: {
type: 'string',
default: '#eee'
},
headerIcon: {
type: 'string',
default: 'unfold'
},
headerIconColor: {
type: 'string',
default: '#fff'
},
bodyBgColor: {
type: 'string'
},
bodyTextColor: {
type: 'string'
},
borderStyle: {
type: 'string',
default: 'solid'
},
borderWidth: {
type: 'number',
default: 0
},
borderColor: {
type: 'string'
},
borderRadius: {
type: 'number',
default: 2
},
marginBottom: {
type: 'number',
default: 15
},
collapsedAll: {
type: 'boolean',
default: false
},
changed: {
type: 'boolean',
default: false
}
};
registerBlockType('advgb/accordion', {
title: __('Accordion'),
description: __('Easy to create an accordion for your post/page.'),
icon: {
src: accordionBlockIcon,
foreground: typeof advgbBlocks !== 'undefined' ? advgbBlocks.color : undefined
},
category: 'advgb-category',
keywords: [__('accordion'), __('list'), __('faq')],
attributes: accordionAttrs,
edit: AdvAccordion,
save: function save(_ref) {
var attributes = _ref.attributes;
var header = attributes.header,
headerBgColor = attributes.headerBgColor,
headerTextColor = attributes.headerTextColor,
headerIcon = attributes.headerIcon,
headerIconColor = attributes.headerIconColor,
bodyBgColor = attributes.bodyBgColor,
bodyTextColor = attributes.bodyTextColor,
borderStyle = attributes.borderStyle,
borderWidth = attributes.borderWidth,
borderColor = attributes.borderColor,
borderRadius = attributes.borderRadius,
marginBottom = attributes.marginBottom,
collapsedAll = attributes.collapsedAll;
return React.createElement(
"div",
{ className: "advgb-accordion-block", style: { marginBottom: marginBottom }, "data-collapsed": collapsedAll ? collapsedAll : undefined },
React.createElement(
"div",
{ className: "advgb-accordion-header",
style: {
backgroundColor: headerBgColor,
color: headerTextColor,
borderStyle: borderStyle,
borderWidth: borderWidth + 'px',
borderColor: borderColor,
borderRadius: borderRadius + 'px'
}
},
React.createElement(
"span",
{ className: "advgb-accordion-header-icon" },
React.createElement(
"svg",
{ fill: headerIconColor, xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24" },
HEADER_ICONS[headerIcon]
)
),
React.createElement(
"h4",
{ className: "advgb-accordion-header-title" },
header
)
),
React.createElement(
"div",
{ className: "advgb-accordion-body",
style: {
backgroundColor: bodyBgColor,
color: bodyTextColor,
borderStyle: borderStyle,
borderWidth: borderWidth + 'px',
borderColor: borderColor,
borderRadius: borderRadius + 'px'
}
},
React.createElement(InnerBlocks.Content, null)
)
);
}
});
})(wp.i18n, wp.blocks, wp.element, wp.editor, wp.components);
/***/ }),
/***/ "./assets/blocks/advbutton/block.jsx":
/*!*******************************************!*\
!*** ./assets/blocks/advbutton/block.jsx ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _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; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _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; }
function _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; }
(function (wpI18n, wpBlocks, wpElement, wpEditor, wpComponents) {
var __ = wpI18n.__;
var Component = wpElement.Component,
Fragment = wpElement.Fragment;
var registerBlockType = wpBlocks.registerBlockType,
createBlock = wpBlocks.createBlock;
var InspectorControls = wpEditor.InspectorControls,
BlockControls = wpEditor.BlockControls,
BlockAlignmentToolbar = wpEditor.BlockAlignmentToolbar,
RichText = wpEditor.RichText,
PanelColorSettings = wpEditor.PanelColorSettings;
var RangeControl = wpComponents.RangeControl,
PanelBody = wpComponents.PanelBody,
TextControl = wpComponents.TextControl,
ToggleControl = wpComponents.ToggleControl,
SelectControl = wpComponents.SelectControl,
IconButton = wpComponents.IconButton,
Toolbar = wpComponents.Toolbar;
var AdvButton = function (_Component) {
_inherits(AdvButton, _Component);
function AdvButton() {
_classCallCheck(this, AdvButton);
return _possibleConstructorReturn(this, (AdvButton.__proto__ || Object.getPrototypeOf(AdvButton)).apply(this, arguments));
}
_createClass(AdvButton, [{
key: 'componentWillMount',
value: function componentWillMount() {
var _props = this.props,
attributes = _props.attributes,
setAttributes = _props.setAttributes;
var currentBlockConfig = advgbDefaultConfig['advgb-button'];
// No override attributes of blocks inserted before
if (attributes.changed !== true) {
if ((typeof currentBlockConfig === 'undefined' ? 'undefined' : _typeof(currentBlockConfig)) === 'object' && currentBlockConfig !== null) {
Object.keys(currentBlockConfig).map(function (attribute) {
if (typeof attributes[attribute] === 'boolean') {
attributes[attribute] = !!currentBlockConfig[attribute];
} else {
attributes[attribute] = currentBlockConfig[attribute];
}
});
}
// Finally set changed attribute to true, so we don't modify anything again
setAttributes({ changed: true });
}
}
}, {
key: 'componentDidMount',
value: function componentDidMount() {
var _props2 = this.props,
attributes = _props2.attributes,
setAttributes = _props2.setAttributes,
clientId = _props2.clientId;
if (!attributes.id) {
setAttributes({ id: 'advgbbtn-' + clientId });
}
}
}, {
key: 'render',
value: function render() {
var listBorderStyles = [{ label: __('None'), value: 'none' }, { label: __('Solid'), value: 'solid' }, { label: __('Dotted'), value: 'dotted' }, { label: __('Dashed'), value: 'dashed' }, { label: __('Double'), value: 'double' }, { label: __('Groove'), value: 'groove' }, { label: __('Ridge'), value: 'ridge' }, { label: __('Inset'), value: 'inset' }, { label: __('Outset'), value: 'outset' }];
var _props3 = this.props,
attributes = _props3.attributes,
setAttributes = _props3.setAttributes,
isSelected = _props3.isSelected,
className = _props3.className,
blockID = _props3.clientId;
var id = attributes.id,
align = attributes.align,
url = attributes.url,
urlOpenNewTab = attributes.urlOpenNewTab,
title = attributes.title,
text = attributes.text,
bgColor = attributes.bgColor,
textColor = attributes.textColor,
textSize = attributes.textSize,
paddingTop = attributes.paddingTop,
paddingRight = attributes.paddingRight,
paddingBottom = attributes.paddingBottom,
paddingLeft = attributes.paddingLeft,
borderWidth = attributes.borderWidth,
borderColor = attributes.borderColor,
borderRadius = attributes.borderRadius,
borderStyle = attributes.borderStyle,
hoverTextColor = attributes.hoverTextColor,
hoverBgColor = attributes.hoverBgColor,
hoverShadowColor = attributes.hoverShadowColor,
hoverShadowH = attributes.hoverShadowH,
hoverShadowV = attributes.hoverShadowV,
hoverShadowBlur = attributes.hoverShadowBlur,
hoverShadowSpread = attributes.hoverShadowSpread,
transitionSpeed = attributes.transitionSpeed;
return React.createElement(
Fragment,
null,
React.createElement(
BlockControls,
null,
React.createElement(BlockAlignmentToolbar, { value: align, onChange: function onChange(align) {
return setAttributes({ align: align });
} }),
React.createElement(
Toolbar,
null,
React.createElement(IconButton, {
label: __('Refresh this button when it conflict with other buttons styles'),
icon: 'update',
className: 'components-toolbar__control',
onClick: function onClick() {
return setAttributes({ id: 'advgbbutton-' + blockID });
}
})
)
),
React.createElement(
'span',
{ style: { display: 'inline-block' } },
React.createElement(RichText, {
placeholder: __('Add text…'),
value: text,
onChange: function onChange(value) {
return setAttributes({ text: value });
},
formattingControls: ['bold', 'italic', 'strikethrough'],
isSelected: isSelected,
className: 'wp-block-advgb-button_link ' + id,
keepPlaceholderOnFocus: true
})
),
React.createElement(
'style',
null,
'.' + id + ' {\n font-size: ' + textSize + 'px;\n color: ' + textColor + ';\n background-color: ' + bgColor + ';\n padding: ' + paddingTop + 'px ' + paddingRight + 'px ' + paddingBottom + 'px ' + paddingLeft + 'px;\n border-width: ' + borderWidth + 'px;\n border-color: ' + borderColor + ';\n border-radius: ' + borderRadius + 'px;\n border-style: ' + borderStyle + ';\n }\n .' + id + ':hover {\n color: ' + hoverTextColor + ';\n background-color: ' + hoverBgColor + ';\n box-shadow: ' + hoverShadowH + 'px ' + hoverShadowV + 'px ' + hoverShadowBlur + 'px ' + hoverShadowSpread + 'px ' + hoverShadowColor + ';\n transition: all ' + transitionSpeed + 's ease;\n }'
),
React.createElement(
InspectorControls,
null,
React.createElement(
PanelBody,
{ title: __('Button link') },
React.createElement(TextControl, {
label: [__('Link URL'), url && React.createElement(
'a',
{ href: url || '#', key: 'link_url', target: '_blank', style: { float: 'right' } },
__('Preview')
)],
value: url || '',
placeholder: __('Enter URL…'),
onChange: function onChange(text) {
return setAttributes({ url: text });
}
}),
React.createElement(ToggleControl, {
label: __('Open in new tab'),
checked: !!urlOpenNewTab,
onChange: function onChange() {
return setAttributes({ urlOpenNewTab: !attributes.urlOpenNewTab });
}
})
),
React.createElement(
PanelBody,
{ title: __('Text/Color') },
React.createElement(RangeControl, {
label: __('Text size'),
value: textSize || '',
onChange: function onChange(size) {
return setAttributes({ textSize: size });
},
min: 10,
max: 100,
beforeIcon: 'editor-textcolor',
allowReset: true
}),
React.createElement(PanelColorSettings, {
title: __('Color Settings'),
initialOpen: false,
colorSettings: [{
label: __('Background Color'),
value: bgColor,
onChange: function onChange(value) {
return setAttributes({ bgColor: value === undefined ? '#2196f3' : value });
}
}, {
label: __('Text Color'),
value: textColor,
onChange: function onChange(value) {
return setAttributes({ textColor: value === undefined ? '#fff' : value });
}
}]
})
),
React.createElement(
PanelBody,
{ title: __('Border'), initialOpen: false },
React.createElement(RangeControl, {
label: __('Border radius'),
value: borderRadius || '',
onChange: function onChange(value) {
return setAttributes({ borderRadius: value });
},
min: 0,
max: 100
}),
React.createElement(SelectControl, {
label: __('Border style'),
value: borderStyle,
options: listBorderStyles,
onChange: function onChange(value) {
return setAttributes({ borderStyle: value });
}
}),
borderStyle !== 'none' && React.createElement(
Fragment,
null,
React.createElement(PanelColorSettings, {
title: __('Border Color'),
initialOpen: false,
colorSettings: [{
label: __('Border Color'),
value: borderColor,
onChange: function onChange(value) {
return setAttributes({ borderColor: value === undefined ? '#2196f3' : value });
}
}]
}),
React.createElement(RangeControl, {
label: __('Border width'),
value: borderWidth || '',
onChange: function onChange(value) {
return setAttributes({ borderWidth: value });
},
min: 0,
max: 100
})
)
),
React.createElement(
PanelBody,
{ title: __('Padding'), initialOpen: false },
React.createElement(RangeControl, {
label: __('Padding top'),
value: paddingTop || '',
onChange: function onChange(value) {
return setAttributes({ paddingTop: value });
},
min: 0,
max: 100
}),
React.createElement(RangeControl, {
label: __('Padding right'),
value: paddingRight || '',
onChange: function onChange(value) {
return setAttributes({ paddingRight: value });
},
min: 0,
max: 100
}),
React.createElement(RangeControl, {
label: __('Padding bottom'),
value: paddingBottom || '',
onChange: function onChange(value) {
return setAttributes({ paddingBottom: value });
},
min: 0,
max: 100
}),
React.createElement(RangeControl, {
label: __('Padding left'),
value: paddingLeft || '',
onChange: function onChange(value) {
return setAttributes({ paddingLeft: value });
},
min: 0,
max: 100
})
),
React.createElement(
PanelBody,
{ title: __('Hover'), initialOpen: false },
React.createElement(PanelColorSettings, {
title: __('Color Settings'),
initialOpen: false,
colorSettings: [{
label: __('Background Color'),
value: hoverBgColor,
onChange: function onChange(value) {
return setAttributes({ hoverBgColor: value === undefined ? '#2196f3' : value });
}
}, {
label: __('Text Color'),
value: hoverTextColor,
onChange: function onChange(value) {
return setAttributes({ hoverTextColor: value === undefined ? '#fff' : value });
}
}, {
label: __('Shadow Color'),
value: hoverShadowColor,
onChange: function onChange(value) {
return setAttributes({ hoverShadowColor: value === undefined ? '#ccc' : value });
}
}]
}),
React.createElement(
PanelBody,
{ title: __('Shadow'), initialOpen: false },
React.createElement(RangeControl, {
label: __('Shadow H offset'),
value: hoverShadowH || '',
onChange: function onChange(value) {
return setAttributes({ hoverShadowH: value });
},
min: -50,
max: 50
}),
React.createElement(RangeControl, {
label: __('Shadow V offset'),
value: hoverShadowV || '',
onChange: function onChange(value) {
return setAttributes({ hoverShadowV: value });
},
min: -50,
max: 50
}),
React.createElement(RangeControl, {
label: __('Shadow blur'),
value: hoverShadowBlur || '',
onChange: function onChange(value) {
return setAttributes({ hoverShadowBlur: value });
},
min: 0,
max: 50
}),
React.createElement(RangeControl, {
label: __('Shadow spread'),
value: hoverShadowSpread || '',
onChange: function onChange(value) {
return setAttributes({ hoverShadowSpread: value });
},
min: 0,
max: 50
})
),
React.createElement(RangeControl, {
label: __('Transition speed'),
value: transitionSpeed || '',
onChange: function onChange(value) {
return setAttributes({ transitionSpeed: value });
},
min: 0,
max: 3
})
)
)
);
}
}]);
return AdvButton;
}(Component);
var buttonBlockIcon = React.createElement(
'svg',
{ height: '20', viewBox: '2 2 22 22', width: '20', xmlns: 'http://www.w3.org/2000/svg' },
React.createElement('path', { d: 'M0 0h24v24H0V0z', fill: 'none' }),
React.createElement('path', { d: 'M5 14.5h14v-6H5v6zM11 .55V3.5h2V.55h-2zm8.04 2.5l-1.79 1.79 1.41 1.41 1.8-1.79-1.42-1.41zM13 22.45V19.5h-2v2.95h2zm7.45-3.91l-1.8-1.79-1.41 1.41 1.79 1.8 1.42-1.42zM3.55 4.46l1.79 1.79 1.41-1.41-1.79-1.79-1.41 1.41zm1.41 15.49l1.79-1.8-1.41-1.41-1.79 1.79 1.41 1.42z' })
);
var blockAttrs = {
id: {
type: 'string'
},
url: {
type: 'string'
},
urlOpenNewTab: {
type: 'boolean',
default: true
},
title: {
type: 'string'
},
text: {
source: 'children',
selector: 'a'
},
bgColor: {
type: 'string',
default: '#2196f3'
},
textColor: {
type: 'string',
default: '#fff'
},
textSize: {
type: 'number',
default: 18
},
paddingTop: {
type: 'number',
default: 6
},
paddingRight: {
type: 'number',
default: 12
},
paddingBottom: {
type: 'number',
default: 6
},
paddingLeft: {
type: 'number',
default: 12
},
borderWidth: {
type: 'number',
default: 1
},
borderColor: {
type: 'string',
default: '#2196f3'
},
borderStyle: {
type: 'string',
default: 'solid'
},
borderRadius: {
type: 'number',
default: 50
},
hoverTextColor: {
type: 'string',
default: '#fff'
},
hoverBgColor: {
type: 'string',
default: '#2196f3'
},
hoverShadowColor: {
type: 'string',
default: '#ccc'
},
hoverShadowH: {
type: 'number',
default: 3
},
hoverShadowV: {
type: 'number',
default: 3
},
hoverShadowBlur: {
type: 'number',
default: 1
},
hoverShadowSpread: {
type: 'number',
default: 0
},
transitionSpeed: {
type: 'number',
default: 0.2
},
align: {
type: 'string',
default: 'none'
},
changed: {
type: 'boolean',
default: false
}
};
registerBlockType('advgb/button', {
title: __('Advanced Button'),
description: __('New button with more styles.'),
icon: {
src: buttonBlockIcon,
foreground: typeof advgbBlocks !== 'undefined' ? advgbBlocks.color : undefined
},
category: 'advgb-category',
keywords: [__('button'), __('link')],
attributes: blockAttrs,
transforms: {
from: [{
type: 'block',
blocks: ['core/button'],
transform: function transform(attributes) {
return createBlock('advgb/button', _extends({}, attributes, {
bgColor: attributes.color
}));
}
}],
to: [{
type: 'block',
blocks: ['core/button'],
transform: function transform(attributes) {
return createBlock('core/button', _extends({}, attributes, {
color: attributes.bgColor
}));
}
}]
},
edit: AdvButton,
save: function save(_ref) {
var attributes = _ref.attributes;
var id = attributes.id,
align = attributes.align,
url = attributes.url,
urlOpenNewTab = attributes.urlOpenNewTab,
title = attributes.title,
text = attributes.text;
return React.createElement(
'div',
{ className: 'align' + align },
React.createElement(RichText.Content, {
tagName: 'a',
className: 'wp-block-advgb-button_link ' + id,
href: url || '#',
title: title,
target: !urlOpenNewTab ? '_self' : '_blank',
value: text,
rel: 'noopener noreferrer'
})
);
},
getEditWrapperProps: function getEditWrapperProps(attributes) {
var align = attributes.align;
var props = { 'data-resized': true };
if ('left' === align || 'right' === align || 'center' === align) {
props['data-align'] = align;
}
return props;
},
deprecated: [{
attributes: blockAttrs,
save: function save(_ref2) {
var attributes = _ref2.attributes;
var id = attributes.id,
align = attributes.align,
url = attributes.url,
urlOpenNewTab = attributes.urlOpenNewTab,
title = attributes.title,
text = attributes.text,
bgColor = attributes.bgColor,
textColor = attributes.textColor,
textSize = attributes.textSize,
paddingTop = attributes.paddingTop,
paddingRight = attributes.paddingRight,
paddingBottom = attributes.paddingBottom,
paddingLeft = attributes.paddingLeft,
borderWidth = attributes.borderWidth,
borderColor = attributes.borderColor,
borderRadius = attributes.borderRadius,
borderStyle = attributes.borderStyle,
hoverTextColor = attributes.hoverTextColor,
hoverBgColor = attributes.hoverBgColor,
hoverShadowColor = attributes.hoverShadowColor,
hoverShadowH = attributes.hoverShadowH,
hoverShadowV = attributes.hoverShadowV,
hoverShadowBlur = attributes.hoverShadowBlur,
hoverShadowSpread = attributes.hoverShadowSpread,
transitionSpeed = attributes.transitionSpeed;
return React.createElement(
'div',
{ className: 'align' + align },
React.createElement(RichText.Content, {
tagName: 'a',
className: 'wp-block-advgb-button_link ' + id,
href: url || '#',
title: title,
target: !urlOpenNewTab ? '_self' : '_blank',
value: text,
rel: 'noopener noreferrer'
}),
React.createElement(
'style',
null,
'.' + id + ' {\n font-size: ' + textSize + 'px;\n color: ' + textColor + ';\n background-color: ' + bgColor + ';\n padding: ' + paddingTop + 'px ' + paddingRight + 'px ' + paddingBottom + 'px ' + paddingLeft + 'px;\n border-width: ' + borderWidth + 'px;\n border-color: ' + borderColor + ';\n border-radius: ' + borderRadius + 'px;\n border-style: ' + borderStyle + ';\n }\n .' + id + ':hover {\n color: ' + hoverTextColor + ';\n background-color: ' + hoverBgColor + ';\n box-shadow: ' + hoverShadowH + 'px ' + hoverShadowV + 'px ' + hoverShadowBlur + 'px ' + hoverShadowSpread + 'px ' + hoverShadowColor + ';\n transition: all ' + transitionSpeed + 's ease;\n }'
)
);
}
}, {
attributes: blockAttrs,
save: function save(_ref3) {
var attributes = _ref3.attributes;
var id = attributes.id,
align = attributes.align,
url = attributes.url,
urlOpenNewTab = attributes.urlOpenNewTab,
title = attributes.title,
text = attributes.text,
bgColor = attributes.bgColor,
textColor = attributes.textColor,
textSize = attributes.textSize,
paddingTop = attributes.paddingTop,
paddingRight = attributes.paddingRight,
paddingBottom = attributes.paddingBottom,
paddingLeft = attributes.paddingLeft,
borderWidth = attributes.borderWidth,
borderColor = attributes.borderColor,
borderRadius = attributes.borderRadius,
borderStyle = attributes.borderStyle,
hoverTextColor = attributes.hoverTextColor,
hoverBgColor = attributes.hoverBgColor,
hoverShadowColor = attributes.hoverShadowColor,
hoverShadowH = attributes.hoverShadowH,
hoverShadowV = attributes.hoverShadowV,
hoverShadowBlur = attributes.hoverShadowBlur,
hoverShadowSpread = attributes.hoverShadowSpread,
transitionSpeed = attributes.transitionSpeed;
return React.createElement(
'div',
{ className: 'align' + align },
React.createElement(RichText.Content, {
tagName: 'a',
className: 'wp-block-advgb-button_link ' + id,
href: url || '#',
title: title,
target: !urlOpenNewTab ? '_self' : '_blank',
value: text
}),
React.createElement(
'style',
null,
'.' + id + ' {\n font-size: ' + textSize + 'px;\n color: ' + textColor + ';\n background-color: ' + bgColor + ';\n padding: ' + paddingTop + 'px ' + paddingRight + 'px ' + paddingBottom + 'px ' + paddingLeft + 'px;\n border-width: ' + borderWidth + 'px;\n border-color: ' + borderColor + ';\n border-radius: ' + borderRadius + 'px;\n border-style: ' + borderStyle + ';\n }\n .' + id + ':hover {\n color: ' + hoverTextColor + ';\n background-color: ' + hoverBgColor + ';\n box-shadow: ' + hoverShadowH + 'px ' + hoverShadowV + 'px ' + hoverShadowBlur + 'px ' + hoverShadowSpread + 'px ' + hoverShadowColor + ';\n transition: all ' + transitionSpeed + 's ease;\n }'
)
);
}
}]
});
})(wp.i18n, wp.blocks, wp.element, wp.editor, wp.components);
/***/ }),
/***/ "./assets/blocks/advimage/block.jsx":
/*!******************************************!*\
!*** ./assets/blocks/advimage/block.jsx ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _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; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _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; }
function _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; }
(function (wpI18n, wpBlocks, wpElement, wpEditor, wpComponents) {
var __ = wpI18n.__;
var Component = wpElement.Component,
Fragment = wpElement.Fragment;
var registerBlockType = wpBlocks.registerBlockType;
var InspectorControls = wpEditor.InspectorControls,
BlockControls = wpEditor.BlockControls,
RichText = wpEditor.RichText,
PanelColorSettings = wpEditor.PanelColorSettings,
MediaUpload = wpEditor.MediaUpload;
var RangeControl = wpComponents.RangeControl,
PanelBody = wpComponents.PanelBody,
ToggleControl = wpComponents.ToggleControl,
SelectControl = wpComponents.SelectControl,
TextControl = wpComponents.TextControl,
IconButton = wpComponents.IconButton,
Button = wpComponents.Button,
Toolbar = wpComponents.Toolbar;
var AdvImage = function (_Component) {
_inherits(AdvImage, _Component);
function AdvImage() {
_classCallCheck(this, AdvImage);
var _this = _possibleConstructorReturn(this, (AdvImage.__proto__ || Object.getPrototypeOf(AdvImage)).apply(this, arguments));
_this.state = {
currentEdit: ''
};
return _this;
}
_createClass(AdvImage, [{
key: 'componentWillMount',
value: function componentWillMount() {
var _props = this.props,
attributes = _props.attributes,
setAttributes = _props.setAttributes;
var currentBlockConfig = advgbDefaultConfig['advgb-image'];
// No override attributes of blocks inserted before
if (attributes.changed !== true) {
if ((typeof currentBlockConfig === 'undefined' ? 'undefined' : _typeof(currentBlockConfig)) === 'object' && currentBlockConfig !== null) {
Object.keys(currentBlockConfig).map(function (attribute) {
if (typeof attributes[attribute] === 'boolean') {
attributes[attribute] = !!currentBlockConfig[attribute];
} else {
attributes[attribute] = currentBlockConfig[attribute];
}
});
}
// Finally set changed attribute to true, so we don't modify anything again
setAttributes({ changed: true });
}
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
var currentEdit = this.state.currentEdit;
var _props2 = this.props,
attributes = _props2.attributes,
setAttributes = _props2.setAttributes,
isSelected = _props2.isSelected;
var openOnClick = attributes.openOnClick,
openUrl = attributes.openUrl,
linkInNewTab = attributes.linkInNewTab,
imageUrl = attributes.imageUrl,
imageID = attributes.imageID,
title = attributes.title,
titleColor = attributes.titleColor,
subtitle = attributes.subtitle,
subtitleColor = attributes.subtitleColor,
overlayColor = attributes.overlayColor,
fullWidth = attributes.fullWidth,
width = attributes.width,
height = attributes.height,
vAlign = attributes.vAlign,
hAlign = attributes.hAlign;
var blockClassName = ['advgb-image-block', fullWidth && 'full-width'].filter(Boolean).join(' ');
return React.createElement(
Fragment,
null,
imageID && React.createElement(
BlockControls,
null,
React.createElement(
Toolbar,
null,
React.createElement(MediaUpload, {
allowedTypes: ['image'],
value: imageID,
onSelect: function onSelect(image) {
return setAttributes({ imageUrl: image.url, imageID: image.id });
},
render: function render(_ref) {
var open = _ref.open;
return React.createElement(IconButton, {
className: 'components-toolbar__control',
label: __('Change image'),
icon: 'edit',
onClick: open
});
}
}),
React.createElement(IconButton, {
className: 'components-toolbar__control',
label: __('Remove image'),
icon: 'no',
onClick: function onClick() {
return setAttributes({ imageUrl: undefined, imageID: undefined });
}
})
)
),
React.createElement(
InspectorControls,
null,
React.createElement(
PanelBody,
{ title: __('Advanced Image') },
React.createElement(SelectControl, {
label: __('Action on click'),
value: openOnClick,
options: [{ label: __('None'), value: 'none' }, { label: __('Open image in lightbox'), value: 'lightbox' }, { label: __('Open custom URL'), value: 'url' }],
onChange: function onChange(value) {
return setAttributes({ openOnClick: value });
}
}),
openOnClick === 'url' && React.createElement(
Fragment,
null,
React.createElement(TextControl, {
label: [__('Link URL'), openUrl && React.createElement(
'a',
{ href: openUrl || '#', key: 'advgb_image_link_url', target: '_blank', style: { float: 'right' } },
__('Preview')
)],
value: openUrl,
placeholder: __('Enter URL…'),
onChange: function onChange(text) {
return setAttributes({ openUrl: text });
}
}),
React.createElement(ToggleControl, {
label: __('Open link in new tab'),
checked: linkInNewTab,
onChange: function onChange() {
return setAttributes({ linkInNewTab: !linkInNewTab });
}
})
),
React.createElement(
PanelBody,
{ title: __('Image Size') },
React.createElement(ToggleControl, {
label: __('Full width'),
checked: fullWidth,
onChange: function onChange() {
return setAttributes({ fullWidth: !fullWidth });
}
}),
React.createElement(RangeControl, {
label: __('Height'),
value: height,
min: 100,
max: 1000,
onChange: function onChange(value) {
return setAttributes({ height: value });
}
}),
!fullWidth && React.createElement(RangeControl, {
label: __('Width'),
value: width,
min: 200,
max: 1300,
onChange: function onChange(value) {
return setAttributes({ width: value });
}
})
),
React.createElement(PanelColorSettings, {
title: __('Color Settings'),
initialOpen: false,
colorSettings: [{
label: __('Title Color'),
value: titleColor,
onChange: function onChange(value) {
return setAttributes({ titleColor: value === undefined ? '#fff' : value });
}
}, {
label: __('Subtitle Color'),
value: subtitleColor,
onChange: function onChange(value) {
return setAttributes({ subtitleColor: value === undefined ? '#fff' : value });
}
}, {
label: __('Overlay Color'),
value: overlayColor,
onChange: function onChange(value) {
return setAttributes({ overlayColor: value === undefined ? '#2196f3' : value });
}
}]
}),
React.createElement(
PanelBody,
{ title: __('Text Alignment'), initialOpen: false },
React.createElement(SelectControl, {
label: __('Vertical Alignment'),
value: vAlign,
options: [{ label: __('Top'), value: 'flex-start' }, { label: __('Center'), value: 'center' }, { label: __('Bottom'), value: 'flex-end' }],
onChange: function onChange(value) {
return setAttributes({ vAlign: value });
}
}),
React.createElement(SelectControl, {
label: __('Horizontal Alignment'),
value: hAlign,
options: [{ label: __('Left'), value: 'flex-start' }, { label: __('Center'), value: 'center' }, { label: __('Right'), value: 'flex-end' }],
onChange: function onChange(value) {
return setAttributes({ hAlign: value });
}
})
)
)
),
React.createElement(
'div',
{ className: blockClassName,
style: {
backgroundImage: 'url( ' + imageUrl + ')',
height: height,
width: width,
justifyContent: vAlign,
alignItems: hAlign
}
},
React.createElement('span', { className: 'advgb-image-overlay',
style: { backgroundColor: overlayColor }
}),
!imageID && React.createElement(MediaUpload, {
allowedTypes: ['image'],
value: imageID,
onSelect: function onSelect(image) {
return setAttributes({ imageUrl: image.url, imageID: image.id });
},
render: function render(_ref2) {
var open = _ref2.open;
return React.createElement(
Button,
{
className: 'button button-large',
onClick: open
},
__('Choose image')
);
}
}),
React.createElement(RichText, {
tagName: 'h4',
className: 'advgb-image-title',
value: title,
onChange: function onChange(value) {
return setAttributes({ title: value.trim() });
},
style: { color: titleColor },
isSelected: isSelected && currentEdit === 'title',
unstableOnFocus: function unstableOnFocus() {
return _this2.setState({ currentEdit: 'title' });
},
unstableOnSplit: function unstableOnSplit() {
return null;
},
placeholder: __('Enter title…')
}),
React.createElement(RichText, {
tagName: 'p',
className: 'advgb-image-subtitle',
value: subtitle,
onChange: function onChange(value) {
return setAttributes({ subtitle: value.trim() });
},
style: { color: subtitleColor },
isSelected: isSelected && currentEdit === 'subtitle',
unstableOnFocus: function unstableOnFocus() {
return _this2.setState({ currentEdit: 'subtitle' });
},
unstableOnSplit: function unstableOnSplit() {
return null;
},
placeholder: __('Enter subtitle…')
})
)
);
}
}]);
return AdvImage;
}(Component);
var advImageBlockIcon = React.createElement(
'svg',
{ height: '20', viewBox: '2 2 22 22', width: '20', xmlns: 'http://www.w3.org/2000/svg' },
React.createElement('path', { d: 'M0 0h24v24H0V0z', fill: 'none' }),
React.createElement('path', { d: 'M1 5h2v14H1zm4 0h2v14H5zm17 0H10c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zM11 17l2.5-3.15L15.29 16l2.5-3.22L21 17H11z' })
);
var blockAttrs = {
openOnClick: {
type: 'string',
default: 'none'
},
linkInNewTab: {
type: 'boolean',
default: true
},
openUrl: {
type: 'string'
},
imageUrl: {
type: 'string'
},
imageID: {
type: 'number'
},
title: {
type: 'string',
default: __('Image title')
},
titleColor: {
type: 'string',
default: '#fff'
},
subtitle: {
type: 'string',
default: __('Your subtitle here')
},
subtitleColor: {
type: 'string',
default: '#fff'
},
overlayColor: {
type: 'string',
default: '#2196f3'
},
fullWidth: {
type: 'boolean',
default: false
},
width: {
type: 'number',
default: 500
},
height: {
type: 'number',
default: 500
},
vAlign: {
type: 'string',
default: 'center'
},
hAlign: {
type: 'string',
default: 'center'
},
changed: {
type: 'boolean',
default: false
}
};
registerBlockType('advgb/image', {
title: __('Advanced Image'),
description: __('Advanced image/photo block with more options and styles.'),
icon: {
src: advImageBlockIcon,
foreground: typeof advgbBlocks !== 'undefined' ? advgbBlocks.color : undefined
},
category: 'advgb-category',
keywords: [__('image'), __('photo'), __('box')],
attributes: blockAttrs,
edit: AdvImage,
save: function save(_ref3) {
var attributes = _ref3.attributes;
var openOnClick = attributes.openOnClick,
openUrl = attributes.openUrl,
linkInNewTab = attributes.linkInNewTab,
imageUrl = attributes.imageUrl,
title = attributes.title,
titleColor = attributes.titleColor,
subtitle = attributes.subtitle,
subtitleColor = attributes.subtitleColor,
overlayColor = attributes.overlayColor,
fullWidth = attributes.fullWidth,
width = attributes.width,
height = attributes.height,
vAlign = attributes.vAlign,
hAlign = attributes.hAlign;
var linkURL = openOnClick === 'url' && !!openUrl ? openUrl : undefined;
var blockClassName = ['advgb-image-block', fullWidth && 'full-width', openOnClick === 'lightbox' && !!imageUrl && 'advgb-lightbox'].filter(Boolean).join(' ');
return React.createElement(
'div',
{ className: blockClassName,
style: {
backgroundImage: 'url( ' + imageUrl + ')',
height: height,
width: width,
justifyContent: vAlign,
alignItems: hAlign
},
'data-image': imageUrl
},
React.createElement('a', { className: 'advgb-image-overlay',
style: { backgroundColor: overlayColor },
target: linkInNewTab ? '_blank' : '_self',
rel: 'noopener noreferrer',
href: linkURL
}),
React.createElement(
'h4',
{ className: 'advgb-image-title', style: { color: titleColor } },
title
),
React.createElement(
'p',
{ className: 'advgb-image-subtitle', style: { color: subtitleColor } },
subtitle
)
);
},
deprecated: [{
attributes: blockAttrs,
save: function save(_ref4) {
var attributes = _ref4.attributes;
var openOnClick = attributes.openOnClick,
openUrl = attributes.openUrl,
linkInNewTab = attributes.linkInNewTab,
imageUrl = attributes.imageUrl,
title = attributes.title,
titleColor = attributes.titleColor,
subtitle = attributes.subtitle,
subtitleColor = attributes.subtitleColor,
overlayColor = attributes.overlayColor,
fullWidth = attributes.fullWidth,
width = attributes.width,
height = attributes.height,
vAlign = attributes.vAlign,
hAlign = attributes.hAlign;
var linkURL = openOnClick === 'url' && !!openUrl ? openUrl : undefined;
var blockClassName = ['advgb-image-block', fullWidth && 'full-width', openOnClick === 'lightbox' && !!imageUrl && 'advgb-lightbox'].filter(Boolean).join(' ');
return React.createElement(
'div',
{ className: blockClassName,
style: {
backgroundImage: 'url( ' + imageUrl + ')',
height: height,
width: width,
justifyContent: vAlign,
alignItems: hAlign
},
'data-image': imageUrl
},
React.createElement('a', { className: 'advgb-image-overlay',
style: { backgroundColor: overlayColor },
target: linkInNewTab ? '_blank' : '_self',
href: linkURL
}),
React.createElement(
'h4',
{ className: 'advgb-image-title', style: { color: titleColor } },
title
),
React.createElement(
'p',
{ className: 'advgb-image-subtitle', style: { color: subtitleColor } },
subtitle
)
);
}
}]
});
})(wp.i18n, wp.blocks, wp.element, wp.editor, wp.components);
/***/ }),
/***/ "./assets/blocks/advlist/block.jsx":
/*!*****************************************!*\
!*** ./assets/blocks/advlist/block.jsx ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _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; }; }();
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _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; }
function _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; }
(function (wpI18n, wpBlocks, wpElement, wpEditor, wpComponents) {
var __ = wpI18n.__;
var Component = wpElement.Component,
Fragment = wpElement.Fragment;
var registerBlockType = wpBlocks.registerBlockType,
createBlock = wpBlocks.createBlock;
var InspectorControls = wpEditor.InspectorControls,
RichText = wpEditor.RichText,
ColorPalette = wpEditor.ColorPalette,
BlockControls = wpEditor.BlockControls;
var BaseControl = wpComponents.BaseControl,
RangeControl = wpComponents.RangeControl,
PanelBody = wpComponents.PanelBody,
IconButton = wpComponents.IconButton,
Dashicon = wpComponents.Dashicon,
Toolbar = wpComponents.Toolbar;
var AdvList = function (_Component) {
_inherits(AdvList, _Component);
function AdvList() {
_classCallCheck(this, AdvList);
return _possibleConstructorReturn(this, (AdvList.__proto__ || Object.getPrototypeOf(AdvList)).apply(this, arguments));
}
_createClass(AdvList, [{
key: 'componentWillMount',
value: function componentWillMount() {
var _props = this.props,
attributes = _props.attributes,
setAttributes = _props.setAttributes;
var currentBlockConfig = advgbDefaultConfig['advgb-list'];
// No override attributes of blocks inserted before
if (attributes.changed !== true) {
if ((typeof currentBlockConfig === 'undefined' ? 'undefined' : _typeof(currentBlockConfig)) === 'object' && currentBlockConfig !== null) {
Object.keys(currentBlockConfig).map(function (attribute) {
if (typeof attributes[attribute] === 'boolean') {
attributes[attribute] = !!currentBlockConfig[attribute];
} else {
attributes[attribute] = currentBlockConfig[attribute];
}
});
}
// Finally set changed attribute to true, so we don't modify anything again
setAttributes({ changed: true });
}
}
}, {
key: 'componentDidMount',
value: function componentDidMount() {
var _props2 = this.props,
attributes = _props2.attributes,
setAttributes = _props2.setAttributes,
clientId = _props2.clientId;
if (!attributes.id) {
setAttributes({
id: 'advgblist-' + clientId
});
}
}
}, {
key: 'render',
value: function render() {
var listIcons = [{ label: __('None'), value: '' }, { label: __('Pushpin'), value: 'admin-post' }, { label: __('Configuration'), value: 'admin-generic' }, { label: __('Flag'), value: 'flag' }, { label: __('Star'), value: 'star-filled' }, { label: __('Checkmark'), value: 'yes' }, { label: __('Minus'), value: 'minus' }, { label: __('Plus'), value: 'plus' }, { label: __('Play'), value: 'controls-play' }, { label: __('Arrow right'), value: 'arrow-right-alt' }, { label: __('X Cross'), value: 'dismiss' }, { label: __('Warning'), value: 'warning' }, { label: __('Help'), value: 'editor-help' }, { label: __('Info'), value: 'info' }, { label: __('Circle'), value: 'marker' }];
var _props3 = this.props,
attributes = _props3.attributes,
isSelected = _props3.isSelected,
insertBlocksAfter = _props3.insertBlocksAfter,
mergeBlocks = _props3.mergeBlocks,
setAttributes = _props3.setAttributes,
onReplace = _props3.onReplace,
className = _props3.className,
blockID = _props3.clientId;
var id = attributes.id,
values = attributes.values,
icon = attributes.icon,
iconSize = attributes.iconSize,
iconColor = attributes.iconColor,
margin = attributes.margin,
padding = attributes.padding,
lineHeight = attributes.lineHeight,
fontSize = attributes.fontSize;
var listClassName = [className, id, icon && 'advgb-list', icon && 'advgb-list-' + icon].filter(Boolean).join(' ');
var size = typeof iconSize != 'undefined' ? parseInt(iconSize) : 16;
var marg = typeof margin != 'undefined' ? parseInt(margin) : 2;
var padd = typeof padding != 'undefined' ? parseInt(padding) * 2 : 4;
return React.createElement(
Fragment,
null,
React.createElement(
BlockControls,
null,
React.createElement(
Toolbar,
null,
React.createElement(IconButton, {
label: __('Refresh this list when it conflict with other lists styles'),
icon: 'update',
className: 'components-toolbar__control',
onClick: function onClick() {
return setAttributes({ id: 'advgblist-' + blockID });
}
})
)
),
React.createElement(
InspectorControls,
null,
React.createElement(
PanelBody,
{ title: __('Text Settings'), initialOpen: false },
React.createElement(RangeControl, {
label: __('Text size'),
value: fontSize || '',
onChange: function onChange(size) {
return setAttributes({ fontSize: size });
},
min: 10,
max: 100,
beforeIcon: 'editor-textcolor',
allowReset: true
})
),
React.createElement(
PanelBody,
{ title: __('Icon Settings') },
React.createElement(
BaseControl,
{ label: __('List icon') },
React.createElement(
'div',
{ className: 'advgb-icon-items-wrapper' },
listIcons.map(function (item, index) {
return React.createElement(
'div',
{ className: 'advgb-icon-item h20', key: index },
React.createElement(
'span',
{ onClick: function onClick() {
return setAttributes({ icon: item.value });
},
className: [item.value === icon && 'active', item.value === '' && 'remove-icon'].filter(Boolean).join(' ')
},
React.createElement(Dashicon, { icon: item.value })
)
);
})
)
),
icon && React.createElement(
Fragment,
null,
React.createElement(
PanelBody,
{
title: [__('Icon color'), React.createElement('span', { key: 'advgb-list-icon-color', className: 'dashicons dashicons-' + icon, style: { color: iconColor, marginLeft: '10px' } })],
initialOpen: false
},
React.createElement(ColorPalette, {
value: iconColor,
onChange: function onChange(value) {
return setAttributes({ iconColor: value === undefined ? '#000' : value });
}
})
),
React.createElement(RangeControl, {
label: __('Icon size'),
value: iconSize || '',
onChange: function onChange(size) {
return setAttributes({ iconSize: size });
},
min: 10,
max: 100,
allowReset: true
}),
React.createElement(RangeControl, {
label: __('Line height'),
value: lineHeight || '',
onChange: function onChange(size) {
return setAttributes({ lineHeight: size });
},
min: 0,
max: 100,
allowReset: true
}),
React.createElement(RangeControl, {
label: __('Margin'),
value: margin || '',
onChange: function onChange(size) {
return setAttributes({ margin: size });
},
min: 0,
max: 100,
allowReset: true
}),
React.createElement(RangeControl, {
label: __('Padding'),
value: padding || '',
onChange: function onChange(size) {
return setAttributes({ padding: size });
},
min: 0,
max: 100,
allowReset: true
})
)
)
),
React.createElement(RichText, {
multiline: 'li',
tagName: 'ul',
onChange: function onChange(value) {
return setAttributes({ values: value });
},
value: values,
wrapperClassName: 'advgb-list-item',
className: listClassName,
placeholder: __('Write advanced list…'),
onMerge: mergeBlocks,
unstableOnSplit: insertBlocksAfter ? function (before, after) {
for (var _len = arguments.length, blocks = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
blocks[_key - 2] = arguments[_key];
}
if (!blocks.length) {
blocks.push(createBlock('core/paragraph'));
}
if (after.length) {
blocks.push(createBlock('advgb/list', _extends({}, attributes, {
values: after,
id: undefined
})));
}
setAttributes({ values: before });
insertBlocksAfter(blocks);
} : undefined,
onRemove: function onRemove() {
return onReplace([]);
},
isSelected: isSelected
}),
React.createElement(
'div',
null,
React.createElement(
'style',
null,
'.' + id + ' li { font-size: ' + fontSize + 'px; margin-left: ' + (size + padd) + 'px }'
),
icon && React.createElement(
'style',
null,
'.' + id + ' li:before {\n font-size: ' + iconSize + 'px;\n color: ' + iconColor + ';\n line-height: ' + lineHeight + 'px;\n margin: ' + margin + 'px;\n padding: ' + padding + 'px;\n margin-left: -' + (size + padd + marg) + 'px\n }'
)
)
);
}
}]);
return AdvList;
}(Component);
var listBlockIcon = React.createElement(
'svg',
{ height: '20', viewBox: '2 2 22 22', width: '20', xmlns: 'http://www.w3.org/2000/svg' },
React.createElement('path', { d: 'M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z' }),
React.createElement('path', { d: 'M0 0h24v24H0z', fill: 'none' })
);
var listBlockAttrs = {
id: {
type: 'string'
},
icon: {
type: 'string'
},
iconSize: {
type: 'number',
default: 16
},
iconColor: {
type: 'string',
default: '#000'
},
fontSize: {
type: 'number',
default: 16
},
lineHeight: {
type: 'number',
default: 18
},
margin: {
type: 'number',
default: 2
},
padding: {
type: 'number',
default: 2
},
values: {
type: 'array',
source: 'children',
selector: 'ul',
default: []
},
changed: {
type: 'boolean',
default: false
}
};
registerBlockType('advgb/list', {
title: __('Advanced List'),
description: __('List block with custom icons and styles.'),
icon: {
src: listBlockIcon,
foreground: typeof advgbBlocks !== 'undefined' ? advgbBlocks.color : undefined
},
category: 'advgb-category',
keywords: [__('list'), __('icon')],
attributes: listBlockAttrs,
transforms: {
from: [{
type: 'block',
blocks: ['core/list'],
transform: function transform(_ref) {
var values = _ref.values;
return createBlock('advgb/list', {
values: values,
icon: 'controls-play',
iconColor: '#ff0000'
});
}
}],
to: [{
type: 'block',
blocks: ['core/list'],
transform: function transform(_ref2) {
var values = _ref2.values;
return createBlock('core/list', {
nodeName: 'UL',
values: values
});
}
}]
},
merge: function merge(attributes, attributesToMerge) {
var valuesToMerge = attributesToMerge.values || [];
// Standard text-like block attribute.
if (attributesToMerge.content) {
valuesToMerge.push(attributesToMerge.content);
}
return _extends({}, attributes, {
values: [].concat(_toConsumableArray(attributes.values), _toConsumableArray(valuesToMerge))
});
},
edit: AdvList,
save: function save(_ref3) {
var attributes = _ref3.attributes;
var id = attributes.id,
values = attributes.values,
icon = attributes.icon;
var listClassName = [id, icon && 'advgb-list', icon && 'advgb-list-' + icon].filter(Boolean).join(' ');
return React.createElement(
'div',
null,
React.createElement(
'ul',
{ className: listClassName },
values
)
);
},
deprecated: [{
attributes: listBlockAttrs,
save: function save(_ref4) {
var attributes = _ref4.attributes;
var id = attributes.id,
values = attributes.values,
icon = attributes.icon,
iconSize = attributes.iconSize,
iconColor = attributes.iconColor,
margin = attributes.margin,
padding = attributes.padding,
lineHeight = attributes.lineHeight,
fontSize = attributes.fontSize;
var listClassName = [id, icon && 'advgb-list', icon && 'advgb-list-' + icon].filter(Boolean).join(' ');
var size = typeof iconSize != 'undefined' ? parseInt(iconSize) : 16;
var marg = typeof margin != 'undefined' ? parseInt(margin) : 2;
var padd = typeof padding != 'undefined' ? parseInt(padding) * 2 : 4;
return React.createElement(
'div',
null,
React.createElement(
'ul',
{ className: listClassName },
values
),
React.createElement(
'style',
null,
'.' + id + ' li { font-size: ' + fontSize + 'px; margin-left: ' + (size + padd) + 'px }'
),
icon && React.createElement(
'style',
null,
'.' + id + ' li:before {\n font-size: ' + iconSize + 'px;\n color: ' + iconColor + ';\n line-height: ' + lineHeight + 'px;\n margin: ' + margin + 'px;\n padding: ' + padding + 'px;\n margin-left: -' + (size + padd + marg) + 'px;\n }'
)
);
}
}, {
attributes: listBlockAttrs,
save: function save(_ref5) {
var attributes = _ref5.attributes;
var id = attributes.id,
values = attributes.values,
icon = attributes.icon,
iconSize = attributes.iconSize,
iconColor = attributes.iconColor,
margin = attributes.margin,
padding = attributes.padding,
lineHeight = attributes.lineHeight,
fontSize = attributes.fontSize;
var listClassName = [id, icon && 'advgb-list', icon && 'advgb-list-' + icon].filter(Boolean).join(' ');
return React.createElement(
'div',
null,
React.createElement(
'ul',
{ className: listClassName },
values
),
React.createElement(
'style',
null,
'.' + id + ' li { font-size: ' + fontSize + 'px }'
),
icon && React.createElement(
'style',
null,
'.' + id + ' li:before {\n font-size: ' + iconSize + 'px;\n color: ' + iconColor + ';\n line-height: ' + lineHeight + 'px;\n margin: ' + margin + 'px;\n padding: ' + padding + 'px;\n }'
)
);
}
}]
});
})(wp.i18n, wp.blocks, wp.element, wp.editor, wp.components);
/***/ }),
/***/ "./assets/blocks/advtable/block.jsx":
/*!******************************************!*\
!*** ./assets/blocks/advtable/block.jsx ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _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; }; }();
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _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; }
function _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; }
(function (wpI18n, wpBlocks, wpElement, wpEditor, wpComponents) {
var __ = wpI18n.__;
var Component = wpElement.Component,
Fragment = wpElement.Fragment;
var registerBlockType = wpBlocks.registerBlockType,
createBlock = wpBlocks.createBlock;
var InspectorControls = wpEditor.InspectorControls,
BlockControls = wpEditor.BlockControls,
RichText = wpEditor.RichText,
PanelColorSettings = wpEditor.PanelColorSettings;
var PanelBody = wpComponents.PanelBody,
BaseControl = wpComponents.BaseControl,
RangeControl = wpComponents.RangeControl,
SelectControl = wpComponents.SelectControl,
ToggleControl = wpComponents.ToggleControl,
TextControl = wpComponents.TextControl,
IconButton = wpComponents.IconButton,
Button = wpComponents.Button,
Toolbar = wpComponents.Toolbar,
DropdownMenu = wpComponents.DropdownMenu,
Tooltip = wpComponents.Tooltip;
var _lodash = lodash,
times = _lodash.times;
var tableBlockIcon = React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "2 2 22 22" },
React.createElement("path", { d: "M3 3v18h18V3H3zm8 16H5v-6h6v6zm0-8H5V5h6v6zm8 8h-6v-6h6v6zm0-8h-6V5h6v6z" }),
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" })
);
var willSetContent = null;
var lastValue = '';
var AdvTable = function (_Component) {
_inherits(AdvTable, _Component);
function AdvTable() {
_classCallCheck(this, AdvTable);
var _this = _possibleConstructorReturn(this, (AdvTable.__proto__ || Object.getPrototypeOf(AdvTable)).apply(this, arguments));
_this.state = {
initRow: 3,
initCol: 3,
selectedCell: null,
rangeSelected: null,
multiSelected: null,
sectionSelected: null,
updated: false
};
_this.calculateRealColIndex = _this.calculateRealColIndex.bind(_this);
_this.isMultiSelected = _this.isMultiSelected.bind(_this);
_this.isRangeSelected = _this.isRangeSelected.bind(_this);
return _this;
}
_createClass(AdvTable, [{
key: "componentWillMount",
value: function componentWillMount() {
var _props = this.props,
attributes = _props.attributes,
setAttributes = _props.setAttributes;
var currentBlockConfig = advgbDefaultConfig['advgb-table'];
// No override attributes of blocks inserted before
if (attributes.changed !== true) {
if ((typeof currentBlockConfig === "undefined" ? "undefined" : _typeof(currentBlockConfig)) === 'object' && currentBlockConfig !== null) {
Object.keys(currentBlockConfig).map(function (attribute) {
if (typeof attributes[attribute] === 'boolean') {
attributes[attribute] = !!currentBlockConfig[attribute];
} else {
attributes[attribute] = currentBlockConfig[attribute];
}
});
}
// Finally set changed attribute to true, so we don't modify anything again
setAttributes({ changed: true });
}
}
}, {
key: "componentDidMount",
value: function componentDidMount() {
this.calculateRealColIndex('head');
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate() {
var isSelected = this.props.isSelected;
var _state = this.state,
selectedCell = _state.selectedCell,
updated = _state.updated;
if (!isSelected && selectedCell) {
this.setState({
selectedCell: null,
rangeSelected: null,
multiSelected: null
});
}
if (updated) {
this.calculateRealColIndex();
this.setState({ updated: false });
}
}
}, {
key: "createTable",
value: function createTable() {
var setAttributes = this.props.setAttributes;
var _state2 = this.state,
initRow = _state2.initRow,
initCol = _state2.initCol;
this.setState({ updated: true });
return setAttributes({
body: times(parseInt(initRow), function () {
return {
cells: times(parseInt(initCol), function () {
return {
content: ''
};
})
};
})
});
}
// Check if is multi cells selected
}, {
key: "isMultiSelected",
value: function isMultiSelected() {
var multiSelected = this.state.multiSelected;
return multiSelected && multiSelected.length > 1;
}
// Check if is range cells selected
}, {
key: "isRangeSelected",
value: function isRangeSelected() {
var rangeSelected = this.state.rangeSelected;
return rangeSelected && rangeSelected.toCell;
}
}, {
key: "calculateRealColIndex",
value: function calculateRealColIndex() {
var _props2 = this.props,
attributes = _props2.attributes,
setAttributes = _props2.setAttributes;
['head', 'body', 'foot'].forEach(function (section) {
if (!attributes[section].length) return null;
var newSection = attributes[section].map(function (row, cRow) {
return {
cells: row.cells.map(function (cell, cCol) {
cell.cI = cCol;
for (var i = 0; i < cRow; i++) {
for (var j = 0; j < attributes[section][i].cells.length; j++) {
if (attributes[section][i].cells[j] && attributes[section][i].cells[j].colSpan) {
if (attributes[section][i].cells[j].rowSpan && i + parseInt(attributes[section][i].cells[j].rowSpan) > cRow) {
if (cCol === 0) {
if (attributes[section][i].cells[j].cI <= cell.cI) {
cell.cI += parseInt(attributes[section][i].cells[j].colSpan);
}
} else {
var lastColSpan = !isNaN(parseInt(row.cells[cCol - 1].colSpan)) ? parseInt(row.cells[cCol - 1].colSpan) : 0;
if (attributes[section][i].cells[j].cI === row.cells[cCol - 1].cI + 1 || attributes[section][i].cells[j].cI <= row.cells[cCol - 1].cI + lastColSpan) {
cell.cI += parseInt(attributes[section][i].cells[j].colSpan);
}
}
}
}
}
}
for (var _j = 0; _j < cCol; _j++) {
if (row.cells[_j]) {
if (row.cells[_j].colSpan) {
cell.cI += parseInt(row.cells[_j].colSpan) - 1;
}
}
}
return cell;
})
};
});
setAttributes(_defineProperty({}, section, newSection));
});
}
}, {
key: "insertRow",
value: function insertRow(offset) {
var _state3 = this.state,
selectedCell = _state3.selectedCell,
sectionSelected = _state3.sectionSelected;
if (!selectedCell) {
return null;
}
var _props3 = this.props,
attributes = _props3.attributes,
setAttributes = _props3.setAttributes;
var currentSection = attributes[sectionSelected];
var rowIndex = selectedCell.rowIndex;
var newRow = jQuery.extend(true, {}, currentSection[rowIndex]);
newRow.cells.map(function (cell) {
cell.content = '';
return cell;
});
newRow.cells = newRow.cells.filter(function (cCell) {
return !cCell.rowSpan;
});
var newSection = [].concat(_toConsumableArray(currentSection.slice(0, rowIndex + offset)), [newRow], _toConsumableArray(currentSection.slice(rowIndex + offset))).map(function (row, rowIdx) {
return {
cells: row.cells.map(function (cell) {
if (cell.rowSpan) {
if (rowIdx <= rowIndex && rowIdx + parseInt(cell.rowSpan) - 1 >= rowIndex) {
cell.rowSpan = parseInt(cell.rowSpan) + 1;
}
}
return cell;
})
};
});
this.setState({
selectedCell: null,
sectionSelected: null,
updated: true
});
setAttributes(_defineProperty({}, sectionSelected, newSection));
}
}, {
key: "deleteRow",
value: function deleteRow() {
var _state4 = this.state,
selectedCell = _state4.selectedCell,
sectionSelected = _state4.sectionSelected;
if (!selectedCell) {
return null;
}
var _props4 = this.props,
attributes = _props4.attributes,
setAttributes = _props4.setAttributes;
var currentSection = attributes[sectionSelected];
var rowIndex = selectedCell.rowIndex;
var newSection = currentSection.map(function (row, cRowIdx) {
return {
cells: row.cells.map(function (cell) {
if (cell.rowSpan) {
if (cRowIdx <= rowIndex && parseInt(cell.rowSpan) + cRowIdx > rowIndex) {
cell.rowSpan = parseInt(cell.rowSpan) - 1;
if (cRowIdx === rowIndex) {
var findColIdx = currentSection[cRowIdx + 1].cells.findIndex(function (elm) {
return elm.cI === cell.cI || elm.cI > cell.cI;
});
currentSection[cRowIdx + 1].cells.splice(findColIdx, 0, cell);
}
}
}
return cell;
})
};
});
this.setState({
selectedCell: null,
sectionSelected: null,
updated: true
});
if (newSection.length < 2) {
alert(__('At least 1 row of current section must present.'));
return false;
}
setAttributes(_defineProperty({}, sectionSelected, newSection.filter(function (row, index) {
return index !== rowIndex;
})));
}
}, {
key: "insertColumn",
value: function insertColumn(offset) {
var selectedCell = this.state.selectedCell;
if (!selectedCell) {
return null;
}
var _props5 = this.props,
attributes = _props5.attributes,
setAttributes = _props5.setAttributes;
var cI = selectedCell.cI;
var countRowSpan = 0;
this.setState({ selectedCell: null, updated: true });
['head', 'body', 'foot'].forEach(function (section) {
return setAttributes(_defineProperty({}, section, attributes[section].map(function (row) {
if (countRowSpan > 0) {
// Skip if previous cell has row span
countRowSpan--;
return row;
}
var findColIdx = row.cells.findIndex(function (cell, idx) {
return cell.cI === cI || row.cells[idx + 1] && row.cells[idx + 1].cI > cI;
});
if (findColIdx === -1) {
findColIdx = row.cells.length - 1;
}
if (row.cells[findColIdx].colSpan && row.cells[findColIdx].cI < cI + offset && row.cells[findColIdx].cI + parseInt(row.cells[findColIdx].colSpan) > cI + offset) {
row.cells[findColIdx].colSpan++;
if (row.cells[findColIdx].rowSpan) {
countRowSpan = parseInt(row.cells[findColIdx].rowSpan) - 1;
}
return row;
} else {
var realOffset = offset;
if (row.cells[findColIdx].cI > cI && offset === 1) {
realOffset = 0;
} else if (row.cells[findColIdx].cI < cI && offset === 0) {
realOffset = 1;
}
return {
cells: [].concat(_toConsumableArray(row.cells.slice(0, findColIdx + realOffset)), [{ content: '' }], _toConsumableArray(row.cells.slice(findColIdx + realOffset)))
};
}
})));
});
}
}, {
key: "deleteColumn",
value: function deleteColumn() {
var selectedCell = this.state.selectedCell;
if (!selectedCell) {
return null;
}
var _props6 = this.props,
attributes = _props6.attributes,
setAttributes = _props6.setAttributes;
var cI = selectedCell.cI;
var countRowSpan = 0;
this.setState({ selectedCell: null, updated: true });
['head', 'body', 'foot'].forEach(function (section) {
return setAttributes(_defineProperty({}, section, attributes[section].map(function (row) {
if (countRowSpan > 0) {
countRowSpan--;
return row;
}
var findColIdx = row.cells.findIndex(function (cell, idx) {
return cell.cI === cI || row.cells[idx + 1] && row.cells[idx + 1].cI > cI;
});
if (row.cells[findColIdx].rowSpan) {
countRowSpan = parseInt(row.cells[findColIdx].rowSpan) - 1;
}
if (row.cells[findColIdx].colSpan) {
row.cells[findColIdx].colSpan--;
if (row.cells[findColIdx].colSpan <= 1) {
delete row.cells[findColIdx].colSpan;
}
return row;
}
return {
cells: row.cells.filter(function (cell, index) {
return index !== findColIdx;
})
};
})));
});
}
}, {
key: "mergeCells",
value: function mergeCells() {
var _state5 = this.state,
rangeSelected = _state5.rangeSelected,
sectionSelected = _state5.sectionSelected;
if (!this.isRangeSelected()) {
return null;
}
var _props7 = this.props,
attributes = _props7.attributes,
setAttributes = _props7.setAttributes;
var fromCell = rangeSelected.fromCell,
toCell = rangeSelected.toCell;
var currentSection = attributes[sectionSelected];
var fCell = currentSection[fromCell.rowIdx].cells[fromCell.colIdx];
var tCell = currentSection[toCell.rowIdx].cells[toCell.colIdx];
var fcSpan = typeof fCell.colSpan === 'undefined' ? 0 : parseInt(fCell.colSpan) - 1;
var frSpan = typeof fCell.rowSpan === 'undefined' ? 0 : parseInt(fCell.rowSpan) - 1;
var tcSpan = typeof tCell.colSpan === 'undefined' ? 0 : parseInt(tCell.colSpan) - 1;
var trSpan = typeof tCell.rowSpan === 'undefined' ? 0 : parseInt(tCell.rowSpan) - 1;
var minRowIdx = Math.min(fromCell.rowIdx, toCell.rowIdx);
var maxRowIdx = Math.max(fromCell.rowIdx + frSpan, toCell.rowIdx + trSpan);
var minColIdx = Math.min(fromCell.RCI, toCell.RCI);
var maxColIdx = Math.max(fromCell.RCI + fcSpan, toCell.RCI + tcSpan);
var newSection = currentSection.map(function (row, curRowIndex) {
if (curRowIndex < minRowIdx || curRowIndex > maxRowIdx) {
return row;
}
return {
cells: row.cells.map(function (cell, curColIndex) {
if (curColIndex === Math.min(fromCell.colIdx, toCell.colIdx) && curRowIndex === Math.min(fromCell.rowIdx, toCell.rowIdx)) {
var rowSpan = Math.abs(maxRowIdx - minRowIdx) + 1;
var colSpan = Math.abs(maxColIdx - minColIdx) + 1;
return _extends({}, cell, {
rowSpan: rowSpan > 1 ? rowSpan : undefined,
colSpan: colSpan > 1 ? colSpan : undefined
});
}
return cell;
}).filter(function (cell, cCol) {
return cell.cI < minColIdx || cCol === Math.min(fromCell.colIdx, toCell.colIdx) && curRowIndex === Math.min(fromCell.rowIdx, toCell.rowIdx) || cell.cI > maxColIdx;
})
};
});
setAttributes(_defineProperty({}, sectionSelected, newSection));
this.setState({
selectedCell: null,
sectionSelected: null,
rangeSelected: null,
updated: true
});
}
}, {
key: "splitMergedCells",
value: function splitMergedCells() {
var _state6 = this.state,
selectedCell = _state6.selectedCell,
sectionSelected = _state6.sectionSelected;
if (!selectedCell) {
return null;
}
var _props8 = this.props,
attributes = _props8.attributes,
setAttributes = _props8.setAttributes;
var colIndex = selectedCell.colIndex,
rowIndex = selectedCell.rowIndex,
cI = selectedCell.cI;
var cellColSpan = attributes[sectionSelected][rowIndex].cells[colIndex].colSpan ? parseInt(attributes[sectionSelected][rowIndex].cells[colIndex].colSpan) : 1;
var cellRowSpan = attributes[sectionSelected][rowIndex].cells[colIndex].rowSpan ? parseInt(attributes[sectionSelected][rowIndex].cells[colIndex].rowSpan) : 1;
attributes[sectionSelected][rowIndex].cells[colIndex].colSpan = undefined;
attributes[sectionSelected][rowIndex].cells[colIndex].rowSpan = undefined;
var newSection = attributes[sectionSelected].map(function (row, curRowIndex) {
if (curRowIndex >= rowIndex && curRowIndex < rowIndex + cellRowSpan) {
var findColIdx = row.cells.findIndex(function (cell) {
return cell.cI >= cI;
});
var startRowFix = 0;
if (curRowIndex === rowIndex) {
startRowFix = 1;
}
return {
cells: [].concat(_toConsumableArray(row.cells.slice(0, findColIdx + startRowFix)), _toConsumableArray(times(cellColSpan - startRowFix, function () {
return { content: '' };
})), _toConsumableArray(row.cells.slice(findColIdx + startRowFix)))
};
}
return row;
});
setAttributes(_defineProperty({}, sectionSelected, newSection));
this.setState({
selectedCell: null,
sectionSelected: null,
updated: true
});
}
// Parse styles from HTML form to React styles object
}, {
key: "getCellStyles",
value: function getCellStyles(style) {
var _state7 = this.state,
selectedCell = _state7.selectedCell,
sectionSelected = _state7.sectionSelected;
var section = this.props.attributes[sectionSelected];
if (!selectedCell) return undefined;
var rowIndex = selectedCell.rowIndex,
colIndex = selectedCell.colIndex;
if (style === 'borderColor') {
return section[rowIndex].cells[colIndex].borderColorSaved;
}
var styles = AdvTable.parseStyles(section[rowIndex].cells[colIndex].styles);
if ((typeof styles === "undefined" ? "undefined" : _typeof(styles)) === 'object') {
var _convertedStyles = styles[style];
if (_convertedStyles && typeof _convertedStyles !== 'number' && _convertedStyles.indexOf('px')) {
_convertedStyles = styles[style].replace(/px/g, '');
}
return typeof _convertedStyles === 'undefined' && style === 'borderStyle' ? 'solid' : _convertedStyles;
} else {
if (typeof styles !== 'undefined') {
var _convertedStyles2 = styles[style];
}
return typeof convertedStyles === 'undefined' && style === 'borderStyle' ? 'solid' : undefined;
}
}
}, {
key: "updateCellsStyles",
value: function updateCellsStyles(style) {
var _this2 = this;
var _state8 = this.state,
selectedCell = _state8.selectedCell,
rangeSelected = _state8.rangeSelected,
multiSelected = _state8.multiSelected,
sectionSelected = _state8.sectionSelected;
if (!selectedCell && !this.isRangeSelected() && !this.isMultiSelected()) {
return null;
}
var _props9 = this.props,
attributes = _props9.attributes,
setAttributes = _props9.setAttributes;
var rowIndex = selectedCell.rowIndex,
colIndex = selectedCell.colIndex;
var section = attributes[sectionSelected];
var minRowIdx = void 0,
maxRowIdx = void 0,
minColIdx = void 0,
maxColIdx = void 0;
if (this.isRangeSelected()) {
var fromCell = rangeSelected.fromCell,
toCell = rangeSelected.toCell;
var fCell = section[fromCell.rowIdx].cells[fromCell.colIdx];
var tCell = section[toCell.rowIdx].cells[toCell.colIdx];
var fcSpan = typeof fCell.colSpan === 'undefined' ? 0 : parseInt(fCell.colSpan) - 1;
var frSpan = typeof fCell.rowSpan === 'undefined' ? 0 : parseInt(fCell.rowSpan) - 1;
var tcSpan = typeof tCell.colSpan === 'undefined' ? 0 : parseInt(tCell.colSpan) - 1;
var trSpan = typeof tCell.rowSpan === 'undefined' ? 0 : parseInt(tCell.rowSpan) - 1;
minRowIdx = Math.min(fromCell.rowIdx, toCell.rowIdx);
maxRowIdx = Math.max(fromCell.rowIdx + frSpan, toCell.rowIdx + trSpan);
minColIdx = Math.min(fromCell.RCI, toCell.RCI);
maxColIdx = Math.max(fromCell.RCI + fcSpan, toCell.RCI + tcSpan);
}
var newSection = section.map(function (row, curRowIndex) {
if (!_this2.isRangeSelected() && !_this2.isMultiSelected() && curRowIndex !== rowIndex || _this2.isRangeSelected() && (curRowIndex < minRowIdx || curRowIndex > maxRowIdx) || _this2.isMultiSelected() && multiSelected.findIndex(function (c) {
return c.rowIndex === curRowIndex;
}) === -1) {
return row;
}
return {
cells: row.cells.map(function (cell, curColIndex) {
if (!_this2.isRangeSelected() && !_this2.isMultiSelected() && curColIndex === colIndex || _this2.isRangeSelected() && cell.cI >= minColIdx && cell.cI <= maxColIdx || _this2.isMultiSelected() && multiSelected.findIndex(function (c) {
return c.colIndex === curColIndex && c.rowIndex === curRowIndex;
}) > -1) {
cell.styles = AdvTable.parseStyles(cell.styles);
if (style.borderColor) {
// Set border color
if (cell.styles.borderTopColor) {
cell.styles = _extends({}, cell.styles, { borderTopColor: style.borderColor });
}
if (cell.styles.borderRightColor) {
cell.styles = _extends({}, cell.styles, { borderRightColor: style.borderColor });
}
if (cell.styles.borderBottomColor) {
cell.styles = _extends({}, cell.styles, { borderBottomColor: style.borderColor });
}
if (cell.styles.borderLeftColor) {
cell.styles = _extends({}, cell.styles, { borderLeftColor: style.borderColor });
}
cell.borderColorSaved = style.borderColor;
} else if (style.setBorder) {
// Set border
var cellBorderColor = cell.borderColorSaved || '#000';
var cellColSpan = !cell.colSpan ? 0 : parseInt(cell.colSpan) - 1;
var cellRowSpan = !cell.rowSpan ? 0 : parseInt(cell.rowSpan) - 1;
switch (style.setBorder) {
case 'top':
cell.styles = _extends({}, cell.styles, { borderTopColor: cellBorderColor });
break;
case 'right':
cell.styles = _extends({}, cell.styles, { borderRightColor: cellBorderColor });
break;
case 'bottom':
cell.styles = _extends({}, cell.styles, { borderBottomColor: cellBorderColor });
break;
case 'left':
cell.styles = _extends({}, cell.styles, { borderLeftColor: cellBorderColor });
break;
case 'all':
cell.styles = _extends({}, cell.styles, {
borderTopColor: cellBorderColor,
borderRightColor: cellBorderColor,
borderBottomColor: cellBorderColor,
borderLeftColor: cellBorderColor
});
break;
case 'none':
cell.styles = _extends({}, cell.styles, {
borderTopColor: undefined,
borderRightColor: undefined,
borderBottomColor: undefined,
borderLeftColor: undefined
});
break;
case 'vert':
if (cell.cI === minColIdx) {
cell.styles = _extends({}, cell.styles, {
borderRightColor: cellBorderColor
});
} else if (cell.cI + cellColSpan === maxColIdx) {
cell.styles = _extends({}, cell.styles, {
borderLeftColor: cellBorderColor
});
} else {
cell.styles = _extends({}, cell.styles, {
borderRightColor: cellBorderColor,
borderLeftColor: cellBorderColor
});
}
break;
case 'horz':
if (curRowIndex === minRowIdx) {
cell.styles = _extends({}, cell.styles, {
borderBottomColor: cellBorderColor
});
} else if (curRowIndex + cellRowSpan === maxRowIdx) {
cell.styles = _extends({}, cell.styles, {
borderTopColor: cellBorderColor
});
} else {
cell.styles = _extends({}, cell.styles, {
borderTopColor: cellBorderColor,
borderBottomColor: cellBorderColor
});
}
break;
case 'inner':
if (curRowIndex === minRowIdx) {
cell.styles = _extends({}, cell.styles, {
borderBottomColor: cellBorderColor
});
} else if (curRowIndex + cellRowSpan === maxRowIdx) {
cell.styles = _extends({}, cell.styles, {
borderTopColor: cellBorderColor
});
} else {
cell.styles = _extends({}, cell.styles, {
borderTopColor: cellBorderColor,
borderBottomColor: cellBorderColor
});
}
if (cell.cI === minColIdx) {
cell.styles = _extends({}, cell.styles, {
borderRightColor: cellBorderColor
});
} else if (cell.cI + cellColSpan === maxColIdx) {
cell.styles = _extends({}, cell.styles, {
borderLeftColor: cellBorderColor
});
} else {
cell.styles = _extends({}, cell.styles, {
borderRightColor: cellBorderColor,
borderLeftColor: cellBorderColor
});
}
break;
case 'outer':
if (curRowIndex === minRowIdx) {
cell.styles = _extends({}, cell.styles, {
borderTopColor: cellBorderColor
});
} else if (curRowIndex + cellRowSpan === maxRowIdx) {
cell.styles = _extends({}, cell.styles, {
borderBottomColor: cellBorderColor
});
}
if (cell.cI === minColIdx) {
cell.styles = _extends({}, cell.styles, {
borderLeftColor: cellBorderColor
});
} else if (cell.cI + cellColSpan === maxColIdx) {
cell.styles = _extends({}, cell.styles, {
borderRightColor: cellBorderColor
});
}
break;
default:
// Nothing
break;
}
} else {
cell.styles = _extends({}, cell.styles, style);
}
}
return cell;
})
};
});
setAttributes(_defineProperty({}, section, newSection));
}
}, {
key: "updateCellContent",
value: function updateCellContent(content) {
var cell = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var _state9 = this.state,
selectedCell = _state9.selectedCell,
sectionSelected = _state9.sectionSelected;
if (!selectedCell && !cell) {
return null;
}
var rowIndex = void 0,
colIndex = void 0;
if (cell) {
rowIndex = cell.rowIndex;
colIndex = cell.colIndex;
} else {
rowIndex = selectedCell.rowIndex;
colIndex = selectedCell.colIndex;
}
var _props10 = this.props,
attributes = _props10.attributes,
setAttributes = _props10.setAttributes;
var newSection = attributes[sectionSelected].map(function (row, curRowIndex) {
if (curRowIndex !== rowIndex) {
return row;
}
return {
cells: row.cells.map(function (cell, curColIndex) {
if (curColIndex !== colIndex) {
return cell;
}
return _extends({}, cell, {
content: content
});
})
};
});
setAttributes(_defineProperty({}, sectionSelected, newSection));
}
}, {
key: "toggleSection",
value: function toggleSection(section) {
var _props11 = this.props,
attributes = _props11.attributes,
setAttributes = _props11.setAttributes;
var sectionSelected = this.state.sectionSelected;
var body = attributes.body;
var cellsToAdd = [{ cells: body[0].cells.map(function (cell) {
return { cI: cell.cI, colSpan: cell.colSpan };
}) }];
if (sectionSelected === section) {
this.setState({
selectedCell: null,
sectionSelected: null
});
}
if (!attributes[section].length) {
return setAttributes(_defineProperty({}, section, cellsToAdd));
}
return setAttributes(_defineProperty({}, section, []));
}
}, {
key: "renderSection",
value: function renderSection(section) {
var _this3 = this;
var attributes = this.props.attributes;
var _state10 = this.state,
selectedCell = _state10.selectedCell,
multiSelected = _state10.multiSelected,
rangeSelected = _state10.rangeSelected,
sectionSelected = _state10.sectionSelected;
return attributes[section].map(function (_ref, rowIndex) {
var cells = _ref.cells;
return React.createElement(
"tr",
{ key: rowIndex },
cells.map(function (_ref2, colIndex) {
var content = _ref2.content,
styles = _ref2.styles,
colSpan = _ref2.colSpan,
rowSpan = _ref2.rowSpan,
cI = _ref2.cI;
var cell = { rowIndex: rowIndex, colIndex: colIndex, cI: cI, section: section };
var isSelected = selectedCell && selectedCell.rowIndex === rowIndex && selectedCell.colIndex === colIndex && sectionSelected === section;
if (_this3.isRangeSelected()) {
var fromCell = rangeSelected.fromCell,
toCell = rangeSelected.toCell;
var fCell = attributes[sectionSelected][fromCell.rowIdx].cells[fromCell.colIdx];
var tCell = attributes[sectionSelected][toCell.rowIdx].cells[toCell.colIdx];
var fcSpan = typeof fCell.colSpan === 'undefined' ? 0 : parseInt(fCell.colSpan) - 1;
var frSpan = typeof fCell.rowSpan === 'undefined' ? 0 : parseInt(fCell.rowSpan) - 1;
var tcSpan = typeof tCell.colSpan === 'undefined' ? 0 : parseInt(tCell.colSpan) - 1;
var trSpan = typeof tCell.rowSpan === 'undefined' ? 0 : parseInt(tCell.rowSpan) - 1;
isSelected = rowIndex >= Math.min(fromCell.rowIdx, toCell.rowIdx) && rowIndex <= Math.max(fromCell.rowIdx + frSpan, toCell.rowIdx + trSpan) && cI >= Math.min(fromCell.RCI, toCell.RCI) && cI <= Math.max(fromCell.RCI + fcSpan, toCell.RCI + tcSpan) && section === sectionSelected;
}
if (_this3.isMultiSelected()) {
isSelected = multiSelected.findIndex(function (c) {
return c.rowIndex === rowIndex && c.colIndex === colIndex;
}) > -1 && multiSelected[0].section === section;
}
var cellClassName = [isSelected && 'cell-selected'].filter(Boolean).join(' ');
styles = AdvTable.parseStyles(styles);
return React.createElement(
"td",
{ key: colIndex,
className: cellClassName,
style: styles,
colSpan: colSpan,
rowSpan: rowSpan,
onClick: function onClick(e) {
if (e.shiftKey) {
if (!rangeSelected) return;
if (!rangeSelected.fromCell) return;
var _fromCell = rangeSelected.fromCell;
if (section !== _fromCell.section) {
alert(__('Cannot select multi cells from difference section!'));
return;
}
var _toCell = {
rowIdx: rowIndex,
colIdx: colIndex,
RCI: cI,
section: section
};
_this3.setState({
rangeSelected: { fromCell: _fromCell, toCell: _toCell },
multiSelected: null
});
} else if (e.ctrlKey || e.metaKey) {
var multiCells = multiSelected ? multiSelected : [];
var existCell = multiCells.findIndex(function (cel) {
return cel.rowIndex === rowIndex && cel.colIndex === colIndex;
});
if (multiCells.length && section !== multiCells[0].section) {
alert(__('Cannot select multi cells from difference section!'));
return;
}
if (existCell === -1) {
multiCells.push(cell);
} else {
multiCells.splice(existCell, 1);
}
_this3.setState({
multiSelected: multiCells,
rangeSelected: null
});
} else {
_this3.setState({
rangeSelected: {
fromCell: {
rowIdx: rowIndex,
colIdx: colIndex,
RCI: cI,
section: section
}
},
multiSelected: [cell]
});
}
}
},
React.createElement(RichText, {
className: "wp-block-table__cell-content",
value: content,
onChange: function onChange(value) {
if (willSetContent) clearTimeout(willSetContent);
lastValue = value;
willSetContent = setTimeout(function () {
return _this3.updateCellContent(value, selectedCell);
}, 1000);
},
unstableOnFocus: function unstableOnFocus() {
if (willSetContent) {
_this3.updateCellContent(lastValue, selectedCell);
clearTimeout(willSetContent);
willSetContent = null;
}
_this3.setState({
selectedCell: cell,
sectionSelected: section
});
}
})
);
})
);
});
}
}, {
key: "render",
value: function render() {
var _this4 = this;
var _props12 = this.props,
attributes = _props12.attributes,
setAttributes = _props12.setAttributes,
className = _props12.className;
var head = attributes.head,
body = attributes.body,
foot = attributes.foot,
maxWidth = attributes.maxWidth,
tableCollapsed = attributes.tableCollapsed,
hasFixedLayout = attributes.hasFixedLayout;
var _state11 = this.state,
initRow = _state11.initRow,
initCol = _state11.initCol,
selectedCell = _state11.selectedCell,
rangeSelected = _state11.rangeSelected,
multiSelected = _state11.multiSelected;
var maxWidthVal = !!maxWidth ? maxWidth : undefined;
var currentCell = selectedCell ? body[selectedCell.rowIndex].cells[selectedCell.colIndex] : null;
// First time insert block, let user determine the table
if (!body.length) {
return React.createElement(
Fragment,
null,
React.createElement(
"div",
{ className: "advgb-init-table" },
React.createElement(TextControl, {
type: "number",
label: __('Column Count'),
value: initCol,
onChange: function onChange(value) {
return _this4.setState({ initCol: value });
},
min: "1"
}),
React.createElement(TextControl, {
type: "number",
label: __('Row Count'),
value: initRow,
onChange: function onChange(value) {
return _this4.setState({ initRow: value });
},
min: "1"
}),
React.createElement(
Button,
{ isPrimary: true, onClick: function onClick() {
return _this4.createTable();
} },
__('Create')
),
React.createElement(
"div",
{ style: { marginTop: 10 } },
React.createElement(
"small",
null,
__('Hint: Hold CTRL key for multi cells selection. Hold SHIFT key for range cells selection.')
)
)
)
);
}
var TABLE_CONTROLS = [{
icon: 'table-row-before',
title: __('Add Row Before'),
isDisabled: !selectedCell || this.isRangeSelected() || this.isMultiSelected(),
onClick: function onClick() {
return _this4.insertRow(0);
}
}, {
icon: 'table-row-after',
title: __('Add Row After'),
isDisabled: !selectedCell || this.isRangeSelected() || this.isMultiSelected(),
onClick: function onClick() {
return _this4.insertRow(1);
}
}, {
icon: 'table-row-delete',
title: __('Delete Row'),
isDisabled: !selectedCell || this.isRangeSelected() || this.isMultiSelected(),
onClick: function onClick() {
return _this4.deleteRow();
}
}, {
icon: 'table-col-before',
title: __('Add Column Before'),
isDisabled: !selectedCell || this.isRangeSelected() || this.isMultiSelected(),
onClick: function onClick() {
return _this4.insertColumn(0);
}
}, {
icon: 'table-col-after',
title: __('Add Column After'),
isDisabled: !selectedCell || this.isRangeSelected() || this.isMultiSelected(),
onClick: function onClick() {
return _this4.insertColumn(1);
}
}, {
icon: 'table-col-delete',
title: __('Delete Column'),
isDisabled: !selectedCell || this.isRangeSelected() || this.isMultiSelected(),
onClick: function onClick() {
return _this4.deleteColumn();
}
}, {
icon: React.createElement(
"svg",
{ width: "20", height: "20", viewBox: "4 2 18 18", className: "dashicon" },
React.createElement("path", { fill: "none", d: "M0,0h24v24H0V0z" }),
React.createElement("path", { d: "M4,5v13h17V5H4z M14,7v9h-3V7H14z M6,7h3v9H6V7z M19,16h-3V7h3V16z" })
),
title: __('Split Merged Cells'),
isDisabled: !selectedCell || currentCell && !currentCell.rowSpan && !currentCell.colSpan || this.isRangeSelected() || this.isMultiSelected(),
onClick: function onClick() {
return _this4.splitMergedCells();
}
}, {
icon: React.createElement(
"svg",
{ width: "20", height: "20", className: "dashicon", viewBox: "2 2 22 22" },
React.createElement("path", { fill: "none", d: "M0,0h24v24H0V0z" }),
React.createElement("polygon", { points: "21,18 2,18 2,20 21,20 21,18" }),
React.createElement("path", { d: "M19,10v4H4v-4H19 M20,8H3C2.45,8,2,8.45,2,9v6c0,0.55,0.45,1,1,1h17c0.55,0,1-0.45,1-1V9C21,8.45,20.55,8,20,8L20,8z" }),
React.createElement("polygon", { points: "21,4 2,4 2,6 21,6 21,4" })
),
title: __('Merge Cells'),
isDisabled: !this.isRangeSelected(),
onClick: function onClick() {
return _this4.mergeCells();
}
}];
var BORDER_SELECT = [{
title: __('Border Top'),
icon: React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24" },
React.createElement("path", { d: "M7 21h2v-2H7v2zm0-8h2v-2H7v2zm4 0h2v-2h-2v2zm0 8h2v-2h-2v2zm-8-4h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2v-2H3v2zm0-4h2V7H3v2zm8 8h2v-2h-2v2zm8-8h2V7h-2v2zm0 4h2v-2h-2v2zM3 3v2h18V3H3zm16 14h2v-2h-2v2zm-4 4h2v-2h-2v2zM11 9h2V7h-2v2zm8 12h2v-2h-2v2zm-4-8h2v-2h-2v2z" }),
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" })
),
onClick: function onClick() {
return _this4.updateCellsStyles({ setBorder: 'top' });
}
}, {
title: __('Border Right'),
icon: React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24" },
React.createElement("path", { d: "M7 21h2v-2H7v2zM3 5h2V3H3v2zm4 0h2V3H7v2zm0 8h2v-2H7v2zm-4 8h2v-2H3v2zm8 0h2v-2h-2v2zm-8-8h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm8 8h2v-2h-2v2zm4-4h2v-2h-2v2zm4-10v18h2V3h-2zm-4 18h2v-2h-2v2zm0-16h2V3h-2v2zm-4 8h2v-2h-2v2zm0-8h2V3h-2v2zm0 4h2V7h-2v2z" }),
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" })
),
onClick: function onClick() {
return _this4.updateCellsStyles({ setBorder: 'right' });
}
}, {
title: __('Border Bottom'),
icon: React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24" },
React.createElement("path", { d: "M9 11H7v2h2v-2zm4 4h-2v2h2v-2zM9 3H7v2h2V3zm4 8h-2v2h2v-2zM5 3H3v2h2V3zm8 4h-2v2h2V7zm4 4h-2v2h2v-2zm-4-8h-2v2h2V3zm4 0h-2v2h2V3zm2 10h2v-2h-2v2zm0 4h2v-2h-2v2zM5 7H3v2h2V7zm14-4v2h2V3h-2zm0 6h2V7h-2v2zM5 11H3v2h2v-2zM3 21h18v-2H3v2zm2-6H3v2h2v-2z" }),
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" })
),
onClick: function onClick() {
return _this4.updateCellsStyles({ setBorder: 'bottom' });
}
}, {
title: __('Border Left'),
icon: React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24" },
React.createElement("path", { d: "M11 21h2v-2h-2v2zm0-4h2v-2h-2v2zm0-12h2V3h-2v2zm0 4h2V7h-2v2zm0 4h2v-2h-2v2zm-4 8h2v-2H7v2zM7 5h2V3H7v2zm0 8h2v-2H7v2zm-4 8h2V3H3v18zM19 9h2V7h-2v2zm-4 12h2v-2h-2v2zm4-4h2v-2h-2v2zm0-14v2h2V3h-2zm0 10h2v-2h-2v2zm0 8h2v-2h-2v2zm-4-8h2v-2h-2v2zm0-8h2V3h-2v2z" }),
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" })
),
onClick: function onClick() {
return _this4.updateCellsStyles({ setBorder: 'left' });
}
}, {
title: __('Border All'),
icon: React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24" },
React.createElement("path", { d: "M3 3v18h18V3H3zm8 16H5v-6h6v6zm0-8H5V5h6v6zm8 8h-6v-6h6v6zm0-8h-6V5h6v6z" }),
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" })
),
onClick: function onClick() {
return _this4.updateCellsStyles({ setBorder: 'all' });
}
}, {
title: __('Border None'),
icon: React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24" },
React.createElement("path", { d: "M7 5h2V3H7v2zm0 8h2v-2H7v2zm0 8h2v-2H7v2zm4-4h2v-2h-2v2zm0 4h2v-2h-2v2zm-8 0h2v-2H3v2zm0-4h2v-2H3v2zm0-4h2v-2H3v2zm0-4h2V7H3v2zm0-4h2V3H3v2zm8 8h2v-2h-2v2zm8 4h2v-2h-2v2zm0-4h2v-2h-2v2zm0 8h2v-2h-2v2zm0-12h2V7h-2v2zm-8 0h2V7h-2v2zm8-6v2h2V3h-2zm-8 2h2V3h-2v2zm4 16h2v-2h-2v2zm0-8h2v-2h-2v2zm0-8h2V3h-2v2z" }),
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" })
),
onClick: function onClick() {
return _this4.updateCellsStyles({ setBorder: 'none' });
}
}];
if (this.isRangeSelected()) {
var EXTRA_BORDER_SELECT = [{
title: __('Border Vertical'),
icon: React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24" },
React.createElement("path", { d: "M3 9h2V7H3v2zm0-4h2V3H3v2zm4 16h2v-2H7v2zm0-8h2v-2H7v2zm-4 0h2v-2H3v2zm0 8h2v-2H3v2zm0-4h2v-2H3v2zM7 5h2V3H7v2zm12 12h2v-2h-2v2zm-8 4h2V3h-2v18zm8 0h2v-2h-2v2zm0-8h2v-2h-2v2zm0-10v2h2V3h-2zm0 6h2V7h-2v2zm-4-4h2V3h-2v2zm0 16h2v-2h-2v2zm0-8h2v-2h-2v2z" }),
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" })
),
onClick: function onClick() {
return _this4.updateCellsStyles({ setBorder: 'vert' });
}
}, {
title: __('Border Horizontal'),
icon: React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24" },
React.createElement("path", { d: "M3 21h2v-2H3v2zM5 7H3v2h2V7zM3 17h2v-2H3v2zm4 4h2v-2H7v2zM5 3H3v2h2V3zm4 0H7v2h2V3zm8 0h-2v2h2V3zm-4 4h-2v2h2V7zm0-4h-2v2h2V3zm6 14h2v-2h-2v2zm-8 4h2v-2h-2v2zm-8-8h18v-2H3v2zM19 3v2h2V3h-2zm0 6h2V7h-2v2zm-8 8h2v-2h-2v2zm4 4h2v-2h-2v2zm4 0h2v-2h-2v2z" }),
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" })
),
onClick: function onClick() {
return _this4.updateCellsStyles({ setBorder: 'horz' });
}
}, {
title: __('Border Inner'),
icon: React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24" },
React.createElement("path", { d: "M3 21h2v-2H3v2zm4 0h2v-2H7v2zM5 7H3v2h2V7zM3 17h2v-2H3v2zM9 3H7v2h2V3zM5 3H3v2h2V3zm12 0h-2v2h2V3zm2 6h2V7h-2v2zm0-6v2h2V3h-2zm-4 18h2v-2h-2v2zM13 3h-2v8H3v2h8v8h2v-8h8v-2h-8V3zm6 18h2v-2h-2v2zm0-4h2v-2h-2v2z" }),
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" })
),
onClick: function onClick() {
return _this4.updateCellsStyles({ setBorder: 'inner' });
}
}, {
title: __('Border Outer'),
icon: React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24" },
React.createElement("path", { d: "M13 7h-2v2h2V7zm0 4h-2v2h2v-2zm4 0h-2v2h2v-2zM3 3v18h18V3H3zm16 16H5V5h14v14zm-6-4h-2v2h2v-2zm-4-4H7v2h2v-2z" }),
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" })
),
onClick: function onClick() {
return _this4.updateCellsStyles({ setBorder: 'outer' });
}
}];
BORDER_SELECT = [].concat(_toConsumableArray(BORDER_SELECT), EXTRA_BORDER_SELECT);
}
var HORZ_ALIGNMENT_CONTROLS = [{
icon: 'editor-alignleft',
title: __('Align left'),
align: 'left'
}, {
icon: 'editor-aligncenter',
title: __('Align center'),
align: 'center'
}, {
icon: 'editor-alignright',
title: __('Align right'),
align: 'right'
}, {
icon: 'editor-justify',
title: __('Align justify'),
align: 'justify'
}];
var VERT_ALIGNMENT_CONTROLS = [{
icon: React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24" },
React.createElement("path", { d: "M8 11h3v10h2V11h3l-4-4-4 4zM4 3v2h16V3H4z" }),
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" })
),
title: __('Align top'),
align: 'top'
}, {
icon: React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24" },
React.createElement("path", { d: "M8 19h3v4h2v-4h3l-4-4-4 4zm8-14h-3V1h-2v4H8l4 4 4-4zM4 11v2h16v-2H4z" }),
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" })
),
title: __('Align middle'),
align: 'middle'
}, {
icon: React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24" },
React.createElement("path", { d: "M16 13h-3V3h-2v10H8l4 4 4-4zM4 19v2h16v-2H4z" }),
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" })
),
title: __('Align bottom'),
align: 'bottom'
}];
return React.createElement(
Fragment,
null,
React.createElement(
BlockControls,
null,
React.createElement(
Toolbar,
null,
React.createElement(DropdownMenu, {
icon: "editor-table",
label: __('Edit Table'),
controls: TABLE_CONTROLS
}),
React.createElement(IconButton, {
icon: "update",
label: __('Refresh table (Use this after using undo or redo)'),
onClick: function onClick() {
return _this4.calculateRealColIndex();
}
})
)
),
React.createElement(
InspectorControls,
null,
React.createElement(
PanelBody,
{ title: __('Table Settings') },
React.createElement(RangeControl, {
label: __('Max width (px)'),
help: __('Set this to 0 to make max-width is 100%'),
min: 0,
max: 1999,
value: maxWidth,
onChange: function onChange(value) {
return setAttributes({ maxWidth: value });
}
}),
React.createElement(ToggleControl, {
label: __('Fixed width table cells'),
checked: hasFixedLayout,
onChange: function onChange() {
return setAttributes({ hasFixedLayout: !hasFixedLayout });
}
}),
React.createElement(ToggleControl, {
label: __('Table header'),
checked: head && head.length,
onChange: function onChange() {
return _this4.toggleSection('head');
}
}),
React.createElement(ToggleControl, {
label: __('Table footer'),
checked: foot && foot.length,
onChange: function onChange() {
return _this4.toggleSection('foot');
}
}),
React.createElement(ToggleControl, {
label: __('Border collapsed'),
checked: tableCollapsed,
onChange: function onChange() {
return setAttributes({ tableCollapsed: !tableCollapsed });
}
})
),
React.createElement(
PanelBody,
{ title: __('Cell Settings') },
React.createElement(PanelColorSettings, {
title: __('Color Settings'),
colorSettings: [{
label: __('Background Color'),
value: this.getCellStyles('backgroundColor'),
onChange: function onChange(value) {
return _this4.updateCellsStyles({ backgroundColor: value });
}
}, {
label: __('Text Color'),
value: this.getCellStyles('color'),
onChange: function onChange(value) {
return _this4.updateCellsStyles({ color: value });
}
}]
}),
React.createElement(
PanelBody,
{ title: __('Border'), initialOpen: false },
React.createElement(
"div",
{ className: "advgb-border-item-wrapper" },
BORDER_SELECT.map(function (item, index) {
return React.createElement(
"div",
{ className: "advgb-border-item", key: index },
React.createElement(
Tooltip,
{ text: item.title },
React.createElement(
"span",
{ onClick: item.onClick },
item.icon
)
)
);
})
),
React.createElement(SelectControl, {
label: __('Border Style'),
value: this.getCellStyles('borderStyle'),
options: [{ label: __('Solid'), value: 'solid' }, { label: __('Dashed'), value: 'dashed' }, { label: __('Dotted'), value: 'dotted' }, { label: __('None'), value: 'none' }],
onChange: function onChange(value) {
return _this4.updateCellsStyles({ borderStyle: value });
}
}),
React.createElement(RangeControl, {
label: __('Border width'),
value: this.getCellStyles('borderWidth') || 0,
min: 0,
max: 10,
onChange: function onChange(value) {
return _this4.updateCellsStyles({ borderWidth: value });
}
}),
React.createElement(PanelColorSettings, {
title: __('Border Color'),
colorSettings: [{
label: __('Border Color'),
value: this.getCellStyles('borderColor'),
onChange: function onChange(value) {
return _this4.updateCellsStyles({ borderColor: value });
}
}]
})
),
React.createElement(
PanelBody,
{ title: __('Padding'), initialOpen: false },
React.createElement(RangeControl, {
label: __('Padding Top'),
value: this.getCellStyles('paddingTop') || 0,
min: 0,
max: 100,
onChange: function onChange(value) {
return _this4.updateCellsStyles({ paddingTop: value });
}
}),
React.createElement(RangeControl, {
label: __('Padding Right'),
value: this.getCellStyles('paddingRight') || 0,
min: 0,
max: 100,
onChange: function onChange(value) {
return _this4.updateCellsStyles({ paddingRight: value });
}
}),
React.createElement(RangeControl, {
label: __('Padding Bottom'),
value: this.getCellStyles('paddingBottom') || 0,
min: 0,
max: 100,
onChange: function onChange(value) {
return _this4.updateCellsStyles({ paddingBottom: value });
}
}),
React.createElement(RangeControl, {
label: __('Padding Left'),
value: this.getCellStyles('paddingLeft') || 0,
min: 0,
max: 100,
onChange: function onChange(value) {
return _this4.updateCellsStyles({ paddingLeft: value });
}
})
),
React.createElement(
PanelBody,
{ title: __('Text Alignment'), initialOpen: false },
React.createElement(
BaseControl,
{ label: __('Horizontal Align') },
React.createElement(Toolbar, {
controls: HORZ_ALIGNMENT_CONTROLS.map(function (control) {
var isActive = _this4.getCellStyles('textAlign') === control.align;
return _extends({}, control, {
isActive: isActive,
onClick: function onClick() {
return _this4.updateCellsStyles({ textAlign: isActive ? undefined : control.align });
}
});
})
})
),
React.createElement(
BaseControl,
{ label: __('Vertical Align') },
React.createElement(Toolbar, {
controls: VERT_ALIGNMENT_CONTROLS.map(function (control) {
var isActive = _this4.getCellStyles('verticalAlign') === control.align;
return _extends({}, control, {
isActive: isActive,
onClick: function onClick() {
return _this4.updateCellsStyles({ verticalAlign: isActive ? undefined : control.align });
}
});
})
})
)
)
)
),
React.createElement(
"table",
{ className: className,
style: {
maxWidth: maxWidthVal,
borderCollapse: tableCollapsed ? 'collapse' : undefined,
tableLayout: hasFixedLayout ? 'fixed' : undefined
}
},
!!head.length && React.createElement(
"thead",
null,
this.renderSection('head')
),
React.createElement(
"tbody",
null,
this.renderSection('body')
),
!!foot.length && React.createElement(
"tfoot",
null,
this.renderSection('foot')
)
)
);
}
}], [{
key: "parseStyles",
value: function parseStyles(styles) {
if (typeof styles !== 'string') {
return styles;
}
return styles.split(';').filter(function (style) {
return style.split(':')[0] && style.split(':')[1];
}).map(function (style) {
return [style.split(':')[0].trim().replace(/-./g, function (c) {
return c.substr(1).toUpperCase();
}), style.split(':')[1].trim()];
}).reduce(function (styleObj, style) {
return _extends({}, styleObj, _defineProperty({}, style[0], style[1]));
}, {});
}
}]);
return AdvTable;
}(Component);
registerBlockType('advgb/table', {
title: __('Advanced Table'),
description: __('Advanced table block with more styles and functions.'),
icon: {
src: tableBlockIcon,
foreground: typeof advgbBlocks !== 'undefined' ? advgbBlocks.color : undefined
},
category: 'advgb-category',
keywords: [__('table'), __('cell'), __('data')],
attributes: {
head: {
type: 'array',
default: [],
source: 'query',
selector: 'thead tr',
query: {
cells: {
type: 'array',
default: [],
source: 'query',
selector: 'td, th',
query: {
content: {
source: 'html'
},
styles: {
type: 'string',
source: 'attribute',
attribute: 'style'
},
colSpan: {
type: 'string',
source: 'attribute',
attribute: 'colspan'
},
borderColorSaved: {
type: 'string',
source: 'attribute',
attribute: 'data-border-color'
}
}
}
}
},
body: {
type: 'array',
default: [],
source: 'query',
selector: 'tbody tr',
query: {
cells: {
type: 'array',
default: [],
source: 'query',
selector: 'td',
query: {
content: {
source: 'html'
},
styles: {
type: 'string',
source: 'attribute',
attribute: 'style'
},
colSpan: {
type: 'string',
source: 'attribute',
attribute: 'colspan'
},
rowSpan: {
type: 'string',
source: 'attribute',
attribute: 'rowspan'
},
borderColorSaved: {
type: 'string',
source: 'attribute',
attribute: 'data-border-color'
}
}
}
}
},
foot: {
type: 'array',
default: [],
source: 'query',
selector: 'tfoot tr',
query: {
cells: {
type: 'array',
default: [],
source: 'query',
selector: 'td, th',
query: {
content: {
source: 'html'
},
styles: {
type: 'string',
source: 'attribute',
attribute: 'style'
},
colSpan: {
type: 'string',
source: 'attribute',
attribute: 'colspan'
},
borderColorSaved: {
type: 'string',
source: 'attribute',
attribute: 'data-border-color'
}
}
}
}
},
maxWidth: {
type: 'number',
default: 0
},
hasFixedLayout: {
type: 'boolean',
default: false
},
tableCollapsed: {
type: 'boolean',
default: false
},
changed: {
type: 'boolean',
default: false
}
},
supports: {
align: true
},
styles: [{ name: 'default', label: __('Default'), isDefault: true }, { name: 'stripes', label: __('Stripes') }],
edit: AdvTable,
save: function save(_ref3) {
var attributes = _ref3.attributes;
var head = attributes.head,
body = attributes.body,
foot = attributes.foot,
maxWidth = attributes.maxWidth,
tableCollapsed = attributes.tableCollapsed,
hasFixedLayout = attributes.hasFixedLayout;
var maxWidthVal = !!maxWidth ? maxWidth : undefined;
function renderSection(section) {
return attributes[section].map(function (_ref4, rowIndex) {
var cells = _ref4.cells;
return React.createElement(
"tr",
{ key: rowIndex },
cells.map(function (_ref5, colIndex) {
var content = _ref5.content,
styles = _ref5.styles,
colSpan = _ref5.colSpan,
rowSpan = _ref5.rowSpan,
borderColorSaved = _ref5.borderColorSaved;
return React.createElement(RichText.Content, {
tagName: "td",
value: content,
key: colIndex,
style: styles,
colSpan: colSpan,
rowSpan: rowSpan,
"data-border-color": borderColorSaved
});
})
);
});
}
return React.createElement(
"table",
{ className: "advgb-table-frontend",
style: {
maxWidth: maxWidthVal,
borderCollapse: tableCollapsed ? 'collapse' : undefined,
tableLayout: hasFixedLayout ? 'fixed' : undefined
}
},
!!head.length && React.createElement(
"thead",
null,
renderSection('head')
),
React.createElement(
"tbody",
null,
renderSection('body')
),
!!foot.length && React.createElement(
"tfoot",
null,
renderSection('foot')
)
);
},
transforms: {
from: [{
type: 'block',
blocks: ['core/table'],
transform: function transform(attributes) {
return createBlock('advgb/table', {
body: attributes.body
});
}
}]
}
});
})(wp.i18n, wp.blocks, wp.element, wp.editor, wp.components);
/***/ }),
/***/ "./assets/blocks/advvideo/block.jsx":
/*!******************************************!*\
!*** ./assets/blocks/advvideo/block.jsx ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _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; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _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; }
function _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; }
(function (wpI18n, wpBlocks, wpElement, wpEditor, wpComponents) {
var __ = wpI18n.__;
var Component = wpElement.Component,
Fragment = wpElement.Fragment;
var registerBlockType = wpBlocks.registerBlockType;
var InspectorControls = wpEditor.InspectorControls,
BlockControls = wpEditor.BlockControls,
PanelColorSettings = wpEditor.PanelColorSettings,
MediaUpload = wpEditor.MediaUpload;
var RangeControl = wpComponents.RangeControl,
PanelBody = wpComponents.PanelBody,
ToggleControl = wpComponents.ToggleControl,
BaseControl = wpComponents.BaseControl,
TextControl = wpComponents.TextControl,
Button = wpComponents.Button,
IconButton = wpComponents.IconButton,
Dashicon = wpComponents.Dashicon,
Spinner = wpComponents.Spinner,
Toolbar = wpComponents.Toolbar;
var PLAY_BUTTON_STYLE = {
normal: [React.createElement("path", { key: "x", d: "M8 5v14l11-7z" }), React.createElement("path", { key: "y", d: "M0 0h24v24H0z", fill: "none" })],
circleFill: [React.createElement("path", { key: "x", d: "M0 0h24v24H0z", fill: "none" }), React.createElement("path", { key: "y", d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 14.5v-9l6 4.5-6 4.5z" })],
circleOutline: [React.createElement("path", { key: "x", d: "M0 0h24v24H0z", fill: "none" }), React.createElement("path", { key: "y", d: "M10 16.5l6-4.5-6-4.5v9zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z" })],
videoCam: [React.createElement("path", { key: "x", d: "M0 0h24v24H0z", fill: "none" }), React.createElement("path", { key: "y", d: "M17 10.5V7c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11l-4 4z" })],
squareCurved: [React.createElement("path", { key: "x", d: "M20 8H4V6h16v2zm-2-6H6v2h12V2zm4 10v8c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2v-8c0-1.1.9-2 2-2h16c1.1 0 2 .9 2 2zm-6 4l-6-3.27v6.53L16 16z" }), React.createElement("path", { key: "y", fill: "none", d: "M0 0h24v24H0z" })],
starSticker: [React.createElement("path", { key: "x", d: "M0 0h24v24H0z", fill: "none" }), React.createElement("path", { key: "y", d: "M20 12c0-1.1.9-2 2-2V6c0-1.1-.9-2-2-2H4c-1.1 0-1.99.9-1.99 2v4c1.1 0 1.99.9 1.99 2s-.89 2-2 2v4c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2v-4c-1.1 0-2-.9-2-2zm-4.42 4.8L12 14.5l-3.58 2.3 1.08-4.12-3.29-2.69 4.24-.25L12 5.8l1.54 3.95 4.24.25-3.29 2.69 1.09 4.11z" })]
};
var AdvVideo = function (_Component) {
_inherits(AdvVideo, _Component);
function AdvVideo() {
_classCallCheck(this, AdvVideo);
var _this = _possibleConstructorReturn(this, (AdvVideo.__proto__ || Object.getPrototypeOf(AdvVideo)).apply(this, arguments));
_this.state = {
fetching: false
};
_this.fetchVideoInfo = _this.fetchVideoInfo.bind(_this);
return _this;
}
_createClass(AdvVideo, [{
key: "componentWillMount",
value: function componentWillMount() {
var _props = this.props,
attributes = _props.attributes,
setAttributes = _props.setAttributes;
var currentBlockConfig = advgbDefaultConfig['advgb-video'];
// No override attributes of blocks inserted before
if (attributes.changed !== true) {
if ((typeof currentBlockConfig === "undefined" ? "undefined" : _typeof(currentBlockConfig)) === 'object' && currentBlockConfig !== null) {
Object.keys(currentBlockConfig).map(function (attribute) {
if (typeof attributes[attribute] === 'boolean') {
attributes[attribute] = !!currentBlockConfig[attribute];
} else {
attributes[attribute] = currentBlockConfig[attribute];
}
});
}
// Finally set changed attribute to true, so we don't modify anything again
setAttributes({ changed: true });
}
}
}, {
key: "fetchVideoInfo",
value: function fetchVideoInfo() {
var _this2 = this;
var _props2 = this.props,
attributes = _props2.attributes,
setAttributes = _props2.setAttributes;
var videoID = attributes.videoID,
poster = attributes.poster,
posterID = attributes.posterID;
var realID = videoID;
if (!!videoID) {
this.setState({ fetching: true });
var url = '';
if (videoID.match(/^\d+$/g)) {
url = "https://vimeo.com/" + videoID;
} else {
url = "https://www.youtube.com/watch?v=" + videoID;
}
if (videoID.indexOf('http') > -1) {
url = videoID;
}
if (videoID.match(/youtube.com/)) {
realID = videoID.split('v=');
realID = realID[1];
} else if (videoID.match(/youtu.be|vimeo.com/)) {
realID = videoID.split('/');
realID = realID[realID.length - 1];
}
if (!realID) realID = '';
if (realID.indexOf('&') > -1) realID = realID.substring(0, realID.indexOf('&'));
wp.apiFetch({ path: wp.url.addQueryArgs("/oembed/1.0/proxy?url=" + encodeURIComponent(url)) }).then(function (obj) {
_this2.setState({ fetching: false });
if (!!obj.title && !!obj.provider_name) {
setAttributes({
videoTitle: obj.title,
poster: !!posterID ? poster : obj.thumbnail_url
});
switch (obj.provider_name) {
case 'YouTube':
setAttributes({
videoSourceType: 'youtube',
videoURL: "https://www.youtube.com/embed/" + realID + "?rel=0&wmode=transparent"
});
break;
case 'Vimeo':
setAttributes({
videoSourceType: 'vimeo',
videoURL: "https://player.vimeo.com/video/" + realID
});
break;
default:
break;
}
} else {
setAttributes({
videoTitle: 'ADVGB_FAIL_TO_LOAD',
poster: ''
});
}
}).catch(function (error) {
_this2.setState({ fetching: false });
setAttributes({
videoTitle: 'ADVGB_FAIL_TO_LOAD',
poster: ''
});
});
}
}
}, {
key: "render",
value: function render() {
var _props3 = this.props,
isSelected = _props3.isSelected,
attributes = _props3.attributes,
setAttributes = _props3.setAttributes;
var videoURL = attributes.videoURL,
videoID = attributes.videoID,
videoSourceType = attributes.videoSourceType,
videoTitle = attributes.videoTitle,
videoFullWidth = attributes.videoFullWidth,
videoWidth = attributes.videoWidth,
videoHeight = attributes.videoHeight,
playButtonIcon = attributes.playButtonIcon,
playButtonSize = attributes.playButtonSize,
playButtonColor = attributes.playButtonColor,
overlayColor = attributes.overlayColor,
poster = attributes.poster,
posterID = attributes.posterID,
openInLightbox = attributes.openInLightbox;
var blockClassName = ['advgb-video-block', !!openInLightbox && !!videoURL && 'advgb-video-lightbox'].filter(Boolean).join(' ');
var videoWrapperClass = ['advgb-video-wrapper', !!videoFullWidth && 'full-width', !openInLightbox && 'no-lightbox'].filter(Boolean).join(' ');
var videoHostIcon = {
youtube: React.createElement(
"svg",
{ id: "Social_Icons", version: "1.1", viewBox: "0 0 128 128", xmlns: "http://www.w3.org/2000/svg" },
React.createElement(
"g",
{ id: "_x34__stroke" },
React.createElement(
"g",
{ id: "Youtube_1_" },
React.createElement("rect", { clipRule: "evenodd", fill: "none", height: "128", width: "128" }),
React.createElement("path", { clipRule: "evenodd", d: "M126.72,38.224c0,0-1.252-8.883-5.088-12.794 c-4.868-5.136-10.324-5.16-12.824-5.458c-17.912-1.305-44.78-1.305-44.78-1.305h-0.056c0,0-26.868,0-44.78,1.305 c-2.504,0.298-7.956,0.322-12.828,5.458C2.528,29.342,1.28,38.224,1.28,38.224S0,48.658,0,59.087v9.781 c0,10.433,1.28,20.863,1.28,20.863s1.248,8.883,5.084,12.794c4.872,5.136,11.268,4.975,14.116,5.511 c10.24,0.991,43.52,1.297,43.52,1.297s26.896-0.04,44.808-1.345c2.5-0.302,7.956-0.326,12.824-5.462 c3.836-3.912,5.088-12.794,5.088-12.794S128,79.302,128,68.868v-9.781C128,48.658,126.72,38.224,126.72,38.224z M50.784,80.72 L50.78,44.501l34.584,18.172L50.784,80.72z", fill: "#CE1312", fillRule: "evenodd", id: "Youtube" })
)
)
),
vimeo: React.createElement(
"svg",
{ height: "25", viewBox: "0 0 32 32", width: "25", xmlns: "http://www.w3.org/2000/svg" },
React.createElement(
"g",
null,
React.createElement("circle", { cx: "16", cy: "16", id: "BG", r: "16", fill: "#5FCCFF" }),
React.createElement("path", { d: "M24,12.4c-0.1,1.6-1.2,3.7-3.3,6.4c-2.2,2.8-4,4.2-5.5,4.2 c-0.9,0-1.7-0.9-2.4-2.6c-0.4-1.6-0.9-3.2-1.3-4.7c-0.5-1.7-1-2.6-1.5-2.6c-0.1,0-0.5,0.3-1.3,0.8l-0.8-1 c0.8-0.7,1.6-1.4,2.3-2.1c1.1-0.9,1.8-1.4,2.4-1.4c1.2-0.1,2,0.7,2.3,2.5c0.3,2,0.5,3.2,0.6,3.7c0.4,1.6,0.8,2.4,1.2,2.4 c0.3,0,0.8-0.5,1.5-1.6c0.7-1.1,1-1.9,1.1-2.4c0.1-0.9-0.3-1.4-1.1-1.4c-0.4,0-0.8,0.1-1.2,0.3c0.8-2.6,2.3-3.8,4.5-3.7 C23.3,9.2,24.1,10.3,24,12.4", id: "Vimeo", fill: "#FFFFFF" })
)
),
local: React.createElement(
"svg",
{ height: "25", id: "Layer_1", version: "1.1", viewBox: "0 0 24 24", width: "25", xmlns: "http://www.w3.org/2000/svg" },
React.createElement("path", { clipRule: "evenodd", d: "M22.506,21v0.016L17,15.511V19c0,1.105-0.896,2-2,2h-1.5H3H2c-1.104,0-2-0.895-2-2 v-1l0,0V6l0,0V5c0-1.104,0.896-1.999,2-1.999h1l0,0h10.5l0,0H15c1.104,0,2,0.895,2,1.999v3.516l5.5-5.5V3.001 c0.828,0,1.5,0.671,1.5,1.499v15C24,20.327,23.331,20.996,22.506,21z", fillRule: "evenodd" })
)
};
return React.createElement(
Fragment,
null,
(!!poster && openInLightbox || !openInLightbox && videoSourceType === 'local') && React.createElement(
BlockControls,
null,
React.createElement(
Toolbar,
null,
React.createElement(MediaUpload, {
allowedTypes: ["image"],
value: posterID,
onSelect: function onSelect(image) {
return setAttributes({ poster: image.url, posterID: image.id });
},
render: function render(_ref) {
var open = _ref.open;
return React.createElement(IconButton, {
className: "components-toolbar__control",
label: __('Change image preview'),
icon: "edit",
onClick: open
});
}
}),
React.createElement(IconButton, {
className: "components-toolbar__control",
label: __('Remove image preview'),
icon: "no",
onClick: function onClick() {
return setAttributes({ poster: undefined, posterID: undefined });
}
})
)
),
React.createElement(
InspectorControls,
null,
React.createElement(
PanelBody,
{ title: __('Advanced Video Settings') },
React.createElement(ToggleControl, {
label: __('Open video in light box'),
help: __('Lightbox offers additional display options.'),
checked: openInLightbox,
onChange: function onChange() {
return setAttributes({ openInLightbox: !openInLightbox });
}
}),
React.createElement(ToggleControl, {
label: __('Full width'),
checked: videoFullWidth,
onChange: function onChange() {
return setAttributes({ videoFullWidth: !videoFullWidth });
}
}),
!videoFullWidth && React.createElement(RangeControl, {
label: __('Video width'),
value: videoWidth,
min: 100,
max: 1000,
onChange: function onChange(value) {
return setAttributes({ videoWidth: value });
}
}),
React.createElement(RangeControl, {
label: __('Video height'),
value: videoHeight,
min: 300,
max: 700,
onChange: function onChange(value) {
return setAttributes({ videoHeight: value });
}
}),
!!openInLightbox && React.createElement(
Fragment,
null,
React.createElement(PanelColorSettings, {
title: __('Color Settings'),
initialOpen: false,
colorSettings: [{
label: __('Overlay Color'),
value: overlayColor,
onChange: function onChange(value) {
return setAttributes({ overlayColor: value === undefined ? '#EEEEEE' : value });
}
}, {
label: __('Play Button Color'),
value: playButtonColor,
onChange: function onChange(value) {
return setAttributes({ playButtonColor: value === undefined ? '#fff' : value });
}
}]
}),
React.createElement(
PanelBody,
{ title: __('Play Button') },
React.createElement(
BaseControl,
{ label: __('Icon Style') },
React.createElement(
"div",
{ className: "advgb-icon-items-wrapper" },
Object.keys(PLAY_BUTTON_STYLE).map(function (key, index) {
return React.createElement(
"div",
{ className: "advgb-icon-item", key: index },
React.createElement(
"span",
{ className: key === playButtonIcon ? 'active' : '',
onClick: function onClick() {
return setAttributes({ playButtonIcon: key });
} },
React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24" },
PLAY_BUTTON_STYLE[key]
)
)
);
})
)
),
React.createElement(RangeControl, {
label: __('Play Button Size'),
value: playButtonSize,
min: 40,
max: 200,
onChange: function onChange(value) {
return setAttributes({ playButtonSize: value });
}
})
)
)
)
),
React.createElement(
"div",
{ className: blockClassName },
!!openInLightbox && React.createElement(
"div",
{ className: videoWrapperClass, style: { backgroundColor: overlayColor, width: videoWidth } },
React.createElement("div", { className: "advgb-video-poster", style: { backgroundImage: "url(" + poster + ")" } }),
React.createElement(
"div",
{ className: "advgb-button-wrapper", style: { height: videoHeight } },
!poster && React.createElement(MediaUpload, {
allowedTypes: ["image"],
onSelect: function onSelect(media) {
return setAttributes({ poster: media.url, posterID: media.id });
},
value: posterID,
render: function render(_ref2) {
var open = _ref2.open;
return React.createElement(
Button,
{
className: "button button-large",
onClick: open
},
__('Select image preview')
);
}
}),
React.createElement(
"div",
{ className: "advgb-play-button", style: { color: playButtonColor } },
React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg",
width: playButtonSize,
height: playButtonSize,
viewBox: "0 0 24 24"
},
PLAY_BUTTON_STYLE[playButtonIcon]
)
)
)
),
!openInLightbox && React.createElement(
"div",
{ className: videoWrapperClass },
(videoSourceType === 'youtube' || videoSourceType === 'vimeo') && React.createElement("iframe", { src: videoURL,
frameBorder: "0",
allowFullScreen: true,
style: { width: videoWidth, height: videoHeight }
}) || videoSourceType === 'local' && React.createElement(
"video",
{ width: videoWidth,
height: videoHeight,
poster: poster,
controls: true
},
React.createElement("source", { src: videoURL }),
__('Your browser does not support HTML5 video.')
) || !videoSourceType && React.createElement("div", { style: { width: videoWidth, height: videoHeight } })
),
isSelected && React.createElement(
"div",
{ className: "advgb-video-input-block" },
React.createElement(
"div",
{ className: "advgb-video-input" },
React.createElement(Dashicon, { className: "advgb-video-link-icon", icon: "admin-links" }),
React.createElement(TextControl, {
placeholder: __('Youtube/Vimeo video URL/ID…'),
value: videoID,
onChange: function onChange(value) {
setAttributes({ videoID: value, videoURL: '', videoTitle: undefined, videoSourceType: '' });
}
}),
React.createElement(
Button,
{
className: "button button-large",
disabled: !videoID || videoSourceType === 'local',
style: { height: '31px' },
onClick: this.fetchVideoInfo
},
__('Fetch')
),
React.createElement(
"span",
{ style: { margin: 'auto 10px' } },
__('or use')
),
React.createElement(MediaUpload, {
allowedTypes: ["video"],
value: videoID,
onSelect: function onSelect(video) {
return setAttributes({ videoURL: video.url, videoID: video.id, videoTitle: video.title, videoSourceType: 'local' });
},
render: function render(_ref3) {
var open = _ref3.open;
return React.createElement(
Button,
{
className: "button button-large is-primary",
onClick: open
},
__('Local video')
);
}
})
),
React.createElement(
"div",
{ className: "advgb-current-video-desc",
style: { minWidth: '50%', margin: '10px auto', textAlign: 'center' }
},
React.createElement(
"strong",
null,
__('Current Video'),
":"
),
React.createElement(
"span",
{ title: videoSourceType,
style: {
width: '25px',
height: '25px',
display: 'inline-block',
verticalAlign: 'text-bottom',
margin: 'auto 7px' }
},
videoHostIcon[videoSourceType] || this.state.fetching && React.createElement(Spinner, null)
),
React.createElement(
"span",
null,
videoTitle === 'ADVGB_FAIL_TO_LOAD' && React.createElement(
"strong",
{ style: { color: 'red' } },
__('Wrong video URL/ID. Please try another.')
) || videoTitle || __('Not selected yet.')
)
)
)
)
);
}
}]);
return AdvVideo;
}(Component);
var advVideoBlockIcon = React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "2 2 22 22" },
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" }),
React.createElement("path", { d: "M10 16.5l6-4.5-6-4.5v9zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z" })
);
var blockAttrs = {
videoURL: {
type: 'string'
},
videoID: {
type: 'string'
},
videoSourceType: {
type: 'string'
},
videoTitle: {
type: 'string'
},
videoFullWidth: {
type: 'boolean',
default: true
},
videoWidth: {
type: 'number'
},
videoHeight: {
type: 'number',
default: 450
},
playButtonIcon: {
type: 'string',
default: 'normal'
},
playButtonSize: {
type: 'number',
default: 80
},
playButtonColor: {
type: 'string',
default: '#fff'
},
overlayColor: {
type: 'string',
default: '#EEEEEE'
},
poster: {
type: 'string'
},
posterID: {
type: 'number'
},
openInLightbox: {
type: 'boolean',
default: true
},
changed: {
type: 'boolean',
default: false
}
};
registerBlockType('advgb/video', {
title: __('Advanced Video'),
description: __('Powerful block for insert and embed video.'),
icon: {
src: advVideoBlockIcon,
foreground: typeof advgbBlocks !== 'undefined' ? advgbBlocks.color : undefined
},
category: 'advgb-category',
keywords: [__('video'), __('embed'), __('media')],
attributes: blockAttrs,
edit: AdvVideo,
save: function save(_ref4) {
var attributes = _ref4.attributes;
var videoURL = attributes.videoURL,
videoSourceType = attributes.videoSourceType,
videoTitle = attributes.videoTitle,
videoFullWidth = attributes.videoFullWidth,
videoWidth = attributes.videoWidth,
videoHeight = attributes.videoHeight,
playButtonIcon = attributes.playButtonIcon,
playButtonSize = attributes.playButtonSize,
playButtonColor = attributes.playButtonColor,
overlayColor = attributes.overlayColor,
poster = attributes.poster,
openInLightbox = attributes.openInLightbox;
var blockClassName = ['advgb-video-block', !!videoFullWidth && 'full-width', !!openInLightbox && !!videoURL && 'advgb-video-lightbox'].filter(Boolean).join(' ');
var videoWrapperClass = ['advgb-video-wrapper', !!videoFullWidth && 'full-width', !openInLightbox && 'no-lightbox'].filter(Boolean).join(' ');
return React.createElement(
"div",
{ className: blockClassName,
"data-video": videoURL,
"data-source": videoSourceType
},
!openInLightbox && React.createElement(
"div",
{ className: videoWrapperClass },
(videoSourceType === 'youtube' || videoSourceType === 'vimeo') && React.createElement("iframe", { src: videoURL,
width: videoWidth,
height: videoHeight,
frameBorder: "0",
allowFullScreen: true
}) || videoSourceType === 'local' && React.createElement(
"video",
{ className: videoFullWidth && 'full-width',
width: videoWidth,
height: videoHeight,
poster: poster,
controls: true
},
React.createElement("source", { src: videoURL }),
__('Your browser does not support HTML5 video.')
) || !videoSourceType && React.createElement("div", { style: { width: videoWidth, height: videoHeight } })
),
!!openInLightbox && React.createElement(
"div",
{ className: videoWrapperClass, style: { backgroundColor: overlayColor, width: videoWidth } },
React.createElement("div", { className: "advgb-video-poster", style: { backgroundImage: "url(" + poster + ")" } }),
React.createElement(
"div",
{ className: "advgb-button-wrapper", style: { height: videoHeight } },
React.createElement(
"div",
{ className: "advgb-play-button", style: { color: playButtonColor } },
React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg",
width: playButtonSize,
height: playButtonSize,
viewBox: "0 0 24 24"
},
PLAY_BUTTON_STYLE[playButtonIcon]
)
)
)
)
);
},
deprecated: [{
attributes: blockAttrs,
save: function save(_ref5) {
var attributes = _ref5.attributes;
var videoURL = attributes.videoURL,
videoSourceType = attributes.videoSourceType,
videoTitle = attributes.videoTitle,
videoFullWidth = attributes.videoFullWidth,
videoWidth = attributes.videoWidth,
videoHeight = attributes.videoHeight,
playButtonIcon = attributes.playButtonIcon,
playButtonSize = attributes.playButtonSize,
playButtonColor = attributes.playButtonColor,
overlayColor = attributes.overlayColor,
poster = attributes.poster,
openInLightbox = attributes.openInLightbox;
var blockClassName = ['advgb-video-block', !!videoFullWidth && 'full-width', !!openInLightbox && !!videoURL && 'advgb-video-lightbox'].filter(Boolean).join(' ');
var videoWrapperClass = ['advgb-video-wrapper', !!videoFullWidth && 'full-width'].filter(Boolean).join(' ');
return React.createElement(
"div",
{ className: blockClassName,
"data-video": videoURL,
"data-source": videoSourceType
},
!openInLightbox && ((videoSourceType === 'youtube' || videoSourceType === 'vimeo') && React.createElement("iframe", { src: videoURL,
width: videoWidth,
height: videoHeight,
frameBorder: "0",
allowFullScreen: true
}) || videoSourceType === 'local' && React.createElement(
"video",
{ className: videoFullWidth && 'full-width',
width: videoWidth,
height: videoHeight,
poster: poster,
controls: true
},
React.createElement("source", { src: videoURL }),
__('Your browser does not support HTML5 video.')
) || !videoSourceType && React.createElement("div", { style: { width: videoWidth, height: videoHeight } })),
!!openInLightbox && React.createElement(
"div",
{ className: videoWrapperClass, style: { backgroundColor: overlayColor, width: videoWidth } },
React.createElement("div", { className: "advgb-video-poster", style: { backgroundImage: "url(" + poster + ")" } }),
React.createElement(
"div",
{ className: "advgb-button-wrapper", style: { height: videoHeight } },
React.createElement(
"div",
{ className: "advgb-play-button", style: { color: playButtonColor } },
React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg",
width: playButtonSize,
height: playButtonSize,
viewBox: "0 0 24 24"
},
PLAY_BUTTON_STYLE[playButtonIcon]
)
)
)
)
);
}
}]
});
})(wp.i18n, wp.blocks, wp.element, wp.editor, wp.components);
/***/ }),
/***/ "./assets/blocks/contact-form/block.jsx":
/*!**********************************************!*\
!*** ./assets/blocks/contact-form/block.jsx ***!
\**********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _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; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _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; }
function _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; }
(function (wpI18n, wpBlocks, wpElement, wpEditor, wpComponents) {
var __ = wpI18n.__;
var Component = wpElement.Component,
Fragment = wpElement.Fragment;
var registerBlockType = wpBlocks.registerBlockType;
var InspectorControls = wpEditor.InspectorControls,
PanelColorSettings = wpEditor.PanelColorSettings;
var PanelBody = wpComponents.PanelBody,
RangeControl = wpComponents.RangeControl,
SelectControl = wpComponents.SelectControl,
TextControl = wpComponents.TextControl;
var contactBlockIcon = React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24" },
React.createElement("path", { fill: "none", d: "M0 0h24v24H0V0z" }),
React.createElement("path", { d: "M22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6zm-2 0l-8 4.99L4 6h16zm0 12H4V8l8 5 8-5v10z" })
);
var AdvContactForm = function (_Component) {
_inherits(AdvContactForm, _Component);
function AdvContactForm() {
_classCallCheck(this, AdvContactForm);
return _possibleConstructorReturn(this, (AdvContactForm.__proto__ || Object.getPrototypeOf(AdvContactForm)).apply(this, arguments));
}
_createClass(AdvContactForm, [{
key: "componentWillMount",
value: function componentWillMount() {
var _props = this.props,
attributes = _props.attributes,
setAttributes = _props.setAttributes;
var currentBlockConfig = advgbDefaultConfig['advgb-contact-form'];
// No override attributes of blocks inserted before
if (attributes.changed !== true) {
if ((typeof currentBlockConfig === "undefined" ? "undefined" : _typeof(currentBlockConfig)) === 'object' && currentBlockConfig !== null) {
Object.keys(currentBlockConfig).map(function (attribute) {
if (typeof attributes[attribute] === 'boolean') {
attributes[attribute] = !!currentBlockConfig[attribute];
} else {
attributes[attribute] = currentBlockConfig[attribute];
}
});
}
// Finally set changed attribute to true, so we don't modify anything again
setAttributes({ changed: true });
}
}
}, {
key: "render",
value: function render() {
var _props2 = this.props,
attributes = _props2.attributes,
setAttributes = _props2.setAttributes;
var nameLabel = attributes.nameLabel,
emailLabel = attributes.emailLabel,
msgLabel = attributes.msgLabel,
submitLabel = attributes.submitLabel,
successLabel = attributes.successLabel,
alertLabel = attributes.alertLabel,
bgColor = attributes.bgColor,
textColor = attributes.textColor,
borderColor = attributes.borderColor,
borderStyle = attributes.borderStyle,
borderRadius = attributes.borderRadius,
submitColor = attributes.submitColor,
submitBgColor = attributes.submitBgColor,
submitRadius = attributes.submitRadius,
submitPosition = attributes.submitPosition;
return React.createElement(
Fragment,
null,
React.createElement(
InspectorControls,
null,
React.createElement(
PanelBody,
{ title: __('Form Settings') },
typeof advgbBlocks !== 'undefined' && !parseInt(advgbBlocks.captchaEnabled) && React.createElement(
PanelBody,
{ title: __('Notice') },
React.createElement(
"p",
{ style: { fontStyle: 'italic' } },
__('We strongly recommend to enable Google reCaptcha to avoid spam bot. You can enable it in Form Recaptcha in'),
React.createElement(
"a",
{ href: advgbBlocks.config_url + '#email-form', target: "_blank" },
" ",
__('settings'),
"."
)
)
),
React.createElement(
PanelBody,
{ title: __('Email sender'), initialOpen: false },
React.createElement(
"p",
{ style: { fontStyle: 'italic' } },
__('An email will be sent to the admin email (by default) whenever a contact form is submitted. You can change it in '),
React.createElement(
"a",
{ href: advgbBlocks.config_url + '#settings', target: "_blank" },
" ",
__('settings'),
"."
)
)
),
React.createElement(
PanelBody,
{ title: __('Text Label') },
React.createElement(TextControl, {
label: __('Name input placeholder'),
value: nameLabel,
onChange: function onChange(value) {
return setAttributes({ nameLabel: value });
}
}),
React.createElement(TextControl, {
label: __('Email input placeholder'),
value: emailLabel,
onChange: function onChange(value) {
return setAttributes({ emailLabel: value });
}
}),
React.createElement(TextControl, {
label: __('Message input placeholder'),
value: msgLabel,
onChange: function onChange(value) {
return setAttributes({ msgLabel: value });
}
}),
React.createElement(TextControl, {
label: __('Submit text'),
value: submitLabel,
onChange: function onChange(value) {
return setAttributes({ submitLabel: value });
}
}),
React.createElement(TextControl, {
label: __('Empty field warning text'),
value: alertLabel,
onChange: function onChange(value) {
return setAttributes({ alertLabel: value });
}
}),
React.createElement(TextControl, {
label: __('Submit success text'),
value: successLabel,
onChange: function onChange(value) {
return setAttributes({ successLabel: value });
}
})
),
React.createElement(PanelColorSettings, {
title: __('Input Color'),
colorSettings: [{
label: __('Background color'),
value: bgColor,
onChange: function onChange(value) {
return setAttributes({ bgColor: value });
}
}, {
label: __('Text color'),
value: textColor,
onChange: function onChange(value) {
return setAttributes({ textColor: value });
}
}]
}),
React.createElement(
PanelBody,
{ title: __('Border Settings'), initialOpen: false },
React.createElement(PanelColorSettings, {
title: __('Border Color'),
initialOpen: false,
colorSettings: [{
label: __('Border color'),
value: borderColor,
onChange: function onChange(value) {
return setAttributes({ borderColor: value });
}
}]
}),
React.createElement(SelectControl, {
label: __('Border Style'),
value: borderStyle,
options: [{ label: __('Solid'), value: 'solid' }, { label: __('Dashed'), value: 'dashed' }, { label: __('Dotted'), value: 'dotted' }],
onChange: function onChange(value) {
return setAttributes({ borderStyle: value });
}
}),
React.createElement(RangeControl, {
label: __('Border radius (px)'),
value: borderRadius,
onChange: function onChange(value) {
return setAttributes({ borderRadius: value });
},
min: 0,
max: 50
})
),
React.createElement(
PanelBody,
{ title: __('Submit Button Settings') },
React.createElement(PanelColorSettings, {
title: __('Color Settings'),
initialOpen: false,
colorSettings: [{
label: __('Border and Text'),
value: submitColor,
onChange: function onChange(value) {
return setAttributes({ submitColor: value });
}
}, {
label: __('Background'),
value: submitBgColor,
onChange: function onChange(value) {
return setAttributes({ submitBgColor: value });
}
}]
}),
React.createElement(RangeControl, {
label: __('Button border radius'),
value: submitRadius,
onChange: function onChange(value) {
return setAttributes({ submitRadius: value });
},
min: 0,
max: 50
}),
React.createElement(SelectControl, {
label: __('Button position'),
value: submitPosition,
options: [{ label: __('Center'), value: 'center' }, { label: __('Left'), value: 'left' }, { label: __('Right'), value: 'right' }],
onChange: function onChange(value) {
return setAttributes({ submitPosition: value });
}
})
)
)
),
React.createElement(
"div",
{ className: "advgb-contact-form" },
React.createElement(
"div",
{ className: "advgb-form-field advgb-form-field-half" },
React.createElement("input", { type: "text", disabled: true,
className: "advgb-form-input",
value: nameLabel ? nameLabel : __('Name'),
style: {
backgroundColor: bgColor,
color: textColor,
borderColor: borderColor,
borderStyle: borderStyle,
borderRadius: borderRadius
}
})
),
React.createElement(
"div",
{ className: "advgb-form-field advgb-form-field-half" },
React.createElement("input", { type: "text", disabled: true,
className: "advgb-form-input",
value: emailLabel ? emailLabel : __('Email address'),
style: {
backgroundColor: bgColor,
color: textColor,
borderColor: borderColor,
borderStyle: borderStyle,
borderRadius: borderRadius
}
})
),
React.createElement(
"div",
{ className: "advgb-form-field advgb-form-field-full" },
React.createElement("textarea", { className: "advgb-form-input",
disabled: true,
value: msgLabel ? msgLabel : __('Message'),
style: {
backgroundColor: bgColor,
color: textColor,
borderColor: borderColor,
borderStyle: borderStyle,
borderRadius: borderRadius
}
})
),
React.createElement(
"div",
{ className: "advgb-form-submit-wrapper",
style: { textAlign: submitPosition }
},
React.createElement(
"button",
{ className: "advgb-form-submit",
style: {
borderColor: submitColor,
color: submitColor,
backgroundColor: submitBgColor,
borderRadius: submitRadius
}
},
submitLabel ? submitLabel : __('Submit')
)
)
)
);
}
}]);
return AdvContactForm;
}(Component);
var contactBlockAttrs = {
nameLabel: {
type: 'string'
},
emailLabel: {
type: 'string'
},
msgLabel: {
type: 'string'
},
submitLabel: {
type: 'string'
},
successLabel: {
type: 'string'
},
alertLabel: {
type: 'string'
},
bgColor: {
type: 'string'
},
textColor: {
type: 'string'
},
borderStyle: {
type: 'string'
},
borderColor: {
type: 'string'
},
borderRadius: {
type: 'number'
},
submitColor: {
type: 'string'
},
submitBgColor: {
type: 'string'
},
submitRadius: {
type: 'number'
},
submitPosition: {
type: 'string',
default: 'right'
},
changed: {
type: 'boolean',
default: false
}
};
registerBlockType('advgb/contact-form', {
title: __('Contact Form'),
description: __('Fastest way to create a contact form for your page.'),
icon: {
src: contactBlockIcon,
foreground: typeof advgbBlocks !== 'undefined' ? advgbBlocks.color : undefined
},
category: 'advgb-category',
keywords: [__('contact'), __('form')],
attributes: contactBlockAttrs,
edit: AdvContactForm,
save: function save(_ref) {
var attributes = _ref.attributes;
var nameLabel = attributes.nameLabel,
emailLabel = attributes.emailLabel,
msgLabel = attributes.msgLabel,
submitLabel = attributes.submitLabel,
successLabel = attributes.successLabel,
alertLabel = attributes.alertLabel,
bgColor = attributes.bgColor,
textColor = attributes.textColor,
borderColor = attributes.borderColor,
borderStyle = attributes.borderStyle,
borderRadius = attributes.borderRadius,
submitColor = attributes.submitColor,
submitBgColor = attributes.submitBgColor,
submitRadius = attributes.submitRadius,
submitPosition = attributes.submitPosition;
return React.createElement(
"div",
{ className: "advgb-contact-form" },
React.createElement(
"form",
{ method: "POST" },
React.createElement(
"div",
{ className: "advgb-form-field advgb-form-field-half" },
React.createElement("input", { type: "text",
className: "advgb-form-input advgb-form-input-name",
placeholder: nameLabel ? nameLabel : __('Name'),
name: "contact_name",
style: {
backgroundColor: bgColor,
color: textColor,
borderColor: borderColor,
borderStyle: borderStyle,
borderRadius: borderRadius
}
})
),
React.createElement(
"div",
{ className: "advgb-form-field advgb-form-field-half" },
React.createElement("input", { type: "email",
className: "advgb-form-input advgb-form-input-email",
placeholder: emailLabel ? emailLabel : __('Email address'),
name: "contact_email",
style: {
backgroundColor: bgColor,
color: textColor,
borderColor: borderColor,
borderStyle: borderStyle,
borderRadius: borderRadius
}
})
),
React.createElement(
"div",
{ className: "advgb-form-field advgb-form-field-full" },
React.createElement("textarea", { className: "advgb-form-input advgb-form-input-msg",
placeholder: msgLabel ? msgLabel : __('Message'),
name: "contact_message",
style: {
backgroundColor: bgColor,
color: textColor,
borderColor: borderColor,
borderStyle: borderStyle,
borderRadius: borderRadius
}
})
),
React.createElement("div", { className: "advgb-grecaptcha clearfix position-" + submitPosition }),
React.createElement(
"div",
{ className: "advgb-form-submit-wrapper",
style: { textAlign: submitPosition }
},
React.createElement(
"button",
{ className: "advgb-form-submit",
type: "submit",
"data-success": successLabel ? successLabel : undefined,
"data-alert": alertLabel ? alertLabel : undefined,
style: {
borderColor: submitColor,
color: submitColor,
backgroundColor: submitBgColor,
borderRadius: submitRadius
}
},
submitLabel ? submitLabel : __('Submit')
)
)
)
);
},
deprecated: [{
attributes: contactBlockAttrs,
save: function save(_ref2) {
var attributes = _ref2.attributes;
var nameLabel = attributes.nameLabel,
emailLabel = attributes.emailLabel,
msgLabel = attributes.msgLabel,
submitLabel = attributes.submitLabel,
successLabel = attributes.successLabel,
bgColor = attributes.bgColor,
textColor = attributes.textColor,
borderColor = attributes.borderColor,
borderStyle = attributes.borderStyle,
borderRadius = attributes.borderRadius,
submitColor = attributes.submitColor,
submitBgColor = attributes.submitBgColor,
submitRadius = attributes.submitRadius,
submitPosition = attributes.submitPosition;
return React.createElement(
"div",
{ className: "advgb-contact-form" },
React.createElement(
"form",
{ method: "POST" },
React.createElement(
"div",
{ className: "advgb-form-field advgb-form-field-half" },
React.createElement("input", { type: "text",
className: "advgb-form-input advgb-form-input-name",
placeholder: nameLabel ? nameLabel : __('Name'),
name: "contact_name",
style: {
backgroundColor: bgColor,
color: textColor,
borderColor: borderColor,
borderStyle: borderStyle,
borderRadius: borderRadius
}
})
),
React.createElement(
"div",
{ className: "advgb-form-field advgb-form-field-half" },
React.createElement("input", { type: "email",
className: "advgb-form-input advgb-form-input-email",
placeholder: emailLabel ? emailLabel : __('Email address'),
name: "contact_email",
style: {
backgroundColor: bgColor,
color: textColor,
borderColor: borderColor,
borderStyle: borderStyle,
borderRadius: borderRadius
}
})
),
React.createElement(
"div",
{ className: "advgb-form-field advgb-form-field-full" },
React.createElement("textarea", { className: "advgb-form-input advgb-form-input-msg",
placeholder: msgLabel ? msgLabel : __('Message'),
name: "contact_message",
style: {
backgroundColor: bgColor,
color: textColor,
borderColor: borderColor,
borderStyle: borderStyle,
borderRadius: borderRadius
}
})
),
React.createElement(
"div",
{ className: "advgb-form-submit-wrapper",
style: { textAlign: submitPosition }
},
React.createElement(
"button",
{ className: "advgb-form-submit",
type: "submit",
"data-success": successLabel ? successLabel : undefined,
style: {
borderColor: submitColor,
color: submitColor,
backgroundColor: submitBgColor,
borderRadius: submitRadius
}
},
submitLabel ? submitLabel : __('Submit')
)
)
)
);
}
}, {
attributes: contactBlockAttrs,
save: function save(_ref3) {
var attributes = _ref3.attributes;
var nameLabel = attributes.nameLabel,
emailLabel = attributes.emailLabel,
msgLabel = attributes.msgLabel,
submitLabel = attributes.submitLabel,
successLabel = attributes.successLabel,
bgColor = attributes.bgColor,
textColor = attributes.textColor,
borderColor = attributes.borderColor,
borderStyle = attributes.borderStyle,
borderRadius = attributes.borderRadius,
submitColor = attributes.submitColor,
submitBgColor = attributes.submitBgColor,
submitRadius = attributes.submitRadius,
submitPosition = attributes.submitPosition;
return React.createElement(
"div",
{ className: "advgb-contact-form" },
React.createElement(
"form",
{ method: "POST" },
React.createElement(
"div",
{ className: "advgb-form-field advgb-form-field-half" },
React.createElement("input", { type: "text",
className: "advgb-form-input advgb-form-input-name",
placeholder: nameLabel ? nameLabel : __('Name'),
name: "contact_name",
style: {
backgroundColor: bgColor,
color: textColor,
borderColor: borderColor,
borderStyle: borderStyle,
borderRadius: borderRadius
}
})
),
React.createElement(
"div",
{ className: "advgb-form-field advgb-form-field-half" },
React.createElement("input", { type: "email",
className: "advgb-form-input advgb-form-input-email",
placeholder: emailLabel ? emailLabel : __('Email address'),
name: "contact_email",
style: {
backgroundColor: bgColor,
color: textColor,
borderColor: borderColor,
borderStyle: borderStyle,
borderRadius: borderRadius
}
})
),
React.createElement(
"div",
{ className: "advgb-form-field advgb-form-field-full" },
React.createElement("textarea", { className: "advgb-form-input advgb-form-input-msg",
placeholder: msgLabel ? msgLabel : __('Message'),
name: "contact_message",
style: {
backgroundColor: bgColor,
color: textColor,
borderColor: borderColor,
borderStyle: borderStyle,
borderRadius: borderRadius
}
})
),
React.createElement(
"div",
{ className: "advgb-form-submit-wrapper",
style: { textAlign: submitPosition }
},
React.createElement(
"button",
{ className: "advgb-form-submit",
type: "submit",
"data-success": successLabel ? successLabel : undefined,
style: {
borderColor: submitColor,
color: submitColor,
backgroundColor: submitBgColor,
borderRadius: submitRadius
}
},
submitLabel ? submitLabel : __('Submit')
)
),
React.createElement("div", { className: "advgb-grecaptcha clearfix" })
)
);
}
}]
});
})(wp.i18n, wp.blocks, wp.element, wp.editor, wp.components);
/***/ }),
/***/ "./assets/blocks/container/block.jsx":
/*!*******************************************!*\
!*** ./assets/blocks/container/block.jsx ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
(function (wpI18n, wpBlocks, wpEditor) {
var __ = wpI18n.__;
var registerBlockType = wpBlocks.registerBlockType;
var InnerBlocks = wpEditor.InnerBlocks;
var containerBlockIcon = React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "2 2 22 22" },
React.createElement("path", { fill: "none", d: "M0 0h24v24H0V0z" }),
React.createElement("path", { d: "M3 5v14h19V5H3zm2 2h15v4H5V7zm0 10v-4h4v4H5zm6 0v-4h9v4h-9z" })
);
registerBlockType('advgb/container', {
title: __('Container'),
description: __('Block for containing other blocks.'),
icon: {
src: containerBlockIcon,
foreground: typeof advgbBlocks !== 'undefined' ? advgbBlocks.color : undefined
},
category: 'advgb-category',
keywords: [__('container'), __('row'), __('box')],
attributes: {},
supports: {
align: true
},
edit: function edit() {
return React.createElement(
"div",
{ className: "advgb-blocks-container" },
React.createElement(InnerBlocks, null)
);
},
save: function save() {
return React.createElement(
"div",
{ className: "advgb-blocks-container" },
React.createElement(InnerBlocks.Content, null)
);
}
});
})(wp.i18n, wp.blocks, wp.editor);
/***/ }),
/***/ "./assets/blocks/count-up/block.jsx":
/*!******************************************!*\
!*** ./assets/blocks/count-up/block.jsx ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _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; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _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; }
function _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; }
(function (wpI18n, wpBlocks, wpElement, wpEditor, wpComponents) {
var __ = wpI18n.__;
var Component = wpElement.Component,
Fragment = wpElement.Fragment;
var registerBlockType = wpBlocks.registerBlockType;
var InspectorControls = wpEditor.InspectorControls,
RichText = wpEditor.RichText,
PanelColorSettings = wpEditor.PanelColorSettings;
var RangeControl = wpComponents.RangeControl,
PanelBody = wpComponents.PanelBody,
TextControl = wpComponents.TextControl,
FormToggle = wpComponents.FormToggle;
var AdvCountUp = function (_Component) {
_inherits(AdvCountUp, _Component);
function AdvCountUp() {
_classCallCheck(this, AdvCountUp);
var _this = _possibleConstructorReturn(this, (AdvCountUp.__proto__ || Object.getPrototypeOf(AdvCountUp)).apply(this, arguments));
_this.state = {
currentEdit: ''
};
return _this;
}
_createClass(AdvCountUp, [{
key: 'componentWillMount',
value: function componentWillMount() {
var _props = this.props,
attributes = _props.attributes,
setAttributes = _props.setAttributes;
var currentBlockConfig = advgbDefaultConfig['advgb-count-up'];
// No override attributes of blocks inserted before
if (attributes.changed !== true) {
if ((typeof currentBlockConfig === 'undefined' ? 'undefined' : _typeof(currentBlockConfig)) === 'object' && currentBlockConfig !== null) {
Object.keys(currentBlockConfig).map(function (attribute) {
if (typeof attributes[attribute] === 'boolean') {
attributes[attribute] = !!currentBlockConfig[attribute];
} else {
attributes[attribute] = currentBlockConfig[attribute];
}
});
}
// Finally set changed attribute to true, so we don't modify anything again
setAttributes({ changed: true });
}
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
var currentEdit = this.state.currentEdit;
var _props2 = this.props,
attributes = _props2.attributes,
setAttributes = _props2.setAttributes,
isSelected = _props2.isSelected;
var headerText = attributes.headerText,
headerText2 = attributes.headerText2,
headerText3 = attributes.headerText3,
headerTextColor = attributes.headerTextColor,
countUpNumber = attributes.countUpNumber,
countUpNumber2 = attributes.countUpNumber2,
countUpNumber3 = attributes.countUpNumber3,
countUpNumberColor = attributes.countUpNumberColor,
countUpNumberSize = attributes.countUpNumberSize,
countUpSymbol = attributes.countUpSymbol,
countUpSymbol2 = attributes.countUpSymbol2,
countUpSymbol3 = attributes.countUpSymbol3,
countUpSymbolAfter = attributes.countUpSymbolAfter,
countUpSymbolAfter2 = attributes.countUpSymbolAfter2,
countUpSymbolAfter3 = attributes.countUpSymbolAfter3,
descText = attributes.descText,
descText2 = attributes.descText2,
descText3 = attributes.descText3,
descTextColor = attributes.descTextColor,
columns = attributes.columns;
return React.createElement(
Fragment,
null,
React.createElement(
InspectorControls,
null,
React.createElement(
PanelBody,
{ title: __('Count Up Settings') },
React.createElement(PanelColorSettings, {
title: __('Color Settings'),
initialOpen: false,
colorSettings: [{
label: __('Header Color'),
value: headerTextColor,
onChange: function onChange(value) {
return setAttributes({ headerTextColor: value });
}
}, {
label: __('Count Up Color'),
value: countUpNumberColor,
onChange: function onChange(value) {
return setAttributes({ countUpNumberColor: value });
}
}, {
label: __('Description Color'),
value: descTextColor,
onChange: function onChange(value) {
return setAttributes({ descTextColor: value });
}
}]
}),
React.createElement(RangeControl, {
label: __('Columns'),
min: 1,
max: 3,
value: columns,
onChange: function onChange(value) {
return setAttributes({ columns: value });
}
}),
React.createElement(RangeControl, {
label: __('Counter Number Size'),
min: 10,
max: 100,
value: countUpNumberSize,
onChange: function onChange(value) {
return setAttributes({ countUpNumberSize: value });
}
}),
React.createElement(
'div',
null,
__('Counter Up Symbol')
),
React.createElement(
'div',
{ className: 'advgb-col-3' },
React.createElement(TextControl, {
value: countUpSymbol,
onChange: function onChange(value) {
return setAttributes({ countUpSymbol: value });
}
}),
React.createElement(FormToggle, {
checked: countUpSymbolAfter,
onChange: function onChange() {
return setAttributes({ countUpSymbolAfter: !countUpSymbolAfter });
},
title: !!countUpSymbolAfter ? __('After') : __('Before')
})
),
parseInt(columns) > 1 && React.createElement(
'div',
{ className: 'advgb-col-3' },
React.createElement(TextControl, {
value: countUpSymbol2,
onChange: function onChange(value) {
return setAttributes({ countUpSymbol2: value });
}
}),
React.createElement(FormToggle, {
checked: countUpSymbolAfter2,
onChange: function onChange() {
return setAttributes({ countUpSymbolAfter2: !countUpSymbolAfter2 });
},
title: !!countUpSymbolAfter2 ? __('After') : __('Before')
})
),
parseInt(columns) > 2 && React.createElement(
'div',
{ className: 'advgb-col-3' },
React.createElement(TextControl, {
value: countUpSymbol3,
onChange: function onChange(value) {
return setAttributes({ countUpSymbol3: value });
}
}),
React.createElement(FormToggle, {
checked: countUpSymbolAfter3,
onChange: function onChange() {
return setAttributes({ countUpSymbolAfter3: !countUpSymbolAfter3 });
},
title: !!countUpSymbolAfter3 ? __('After') : __('Before')
})
),
React.createElement(
'p',
{ className: 'components-base-control__help', style: { clear: 'both' } },
__('Use toggle buttons above to define symbol placement before/after the number (toggle on is after).')
)
)
),
React.createElement(
'div',
{ className: 'advgb-count-up advgb-column-' + columns, style: { display: 'flex' } },
React.createElement(
'div',
{ className: 'advgb-count-up-columns-one', style: { textAlign: 'center' } },
React.createElement(RichText, {
tagName: 'h4',
value: headerText,
onChange: function onChange(value) {
return setAttributes({ headerText: value });
},
isSelected: isSelected && currentEdit === 'header',
unstableOnFocus: function unstableOnFocus() {
return _this2.setState({ currentEdit: 'header' });
},
style: { color: headerTextColor },
placeholder: __('Enter text…')
}),
React.createElement(RichText, {
tagName: 'div',
value: countUpNumber,
onChange: function onChange(value) {
return setAttributes({ countUpNumber: value });
},
isSelected: isSelected && currentEdit === 'countUp',
unstableOnFocus: function unstableOnFocus() {
return _this2.setState({ currentEdit: 'countUp' });
},
style: { fontSize: countUpNumberSize + 'px', color: countUpNumberColor }
}),
React.createElement(RichText, {
tagName: 'p',
value: descText,
onChange: function onChange(value) {
return setAttributes({ descText: value });
},
isSelected: isSelected && currentEdit === 'desc',
unstableOnFocus: function unstableOnFocus() {
return _this2.setState({ currentEdit: 'desc' });
},
style: { color: descTextColor },
placeholder: __('Enter text…')
})
),
React.createElement(
'div',
{ className: 'advgb-count-up-columns-two', style: { textAlign: 'center' } },
React.createElement(RichText, {
tagName: 'h4',
value: headerText2,
onChange: function onChange(value) {
return setAttributes({ headerText2: value });
},
isSelected: isSelected && currentEdit === 'header2',
unstableOnFocus: function unstableOnFocus() {
return _this2.setState({ currentEdit: 'header2' });
},
style: { color: headerTextColor },
placeholder: __('Enter text…')
}),
React.createElement(RichText, {
tagName: 'div',
value: countUpNumber2,
onChange: function onChange(value) {
return setAttributes({ countUpNumber2: value });
},
isSelected: isSelected && currentEdit === 'countUp2',
unstableOnFocus: function unstableOnFocus() {
return _this2.setState({ currentEdit: 'countUp2' });
},
style: { fontSize: countUpNumberSize + 'px', color: countUpNumberColor }
}),
React.createElement(RichText, {
tagName: 'p',
value: descText2,
onChange: function onChange(value) {
return setAttributes({ descText2: value });
},
isSelected: isSelected && currentEdit === 'desc2',
unstableOnFocus: function unstableOnFocus() {
return _this2.setState({ currentEdit: 'desc2' });
},
style: { color: descTextColor },
placeholder: __('Enter text…')
})
),
React.createElement(
'div',
{ className: 'advgb-count-up-columns-three', style: { textAlign: 'center' } },
React.createElement(RichText, {
tagName: 'h4',
value: headerText3,
onChange: function onChange(value) {
return setAttributes({ headerText3: value });
},
isSelected: isSelected && currentEdit === 'header3',
unstableOnFocus: function unstableOnFocus() {
return _this2.setState({ currentEdit: 'header3' });
},
style: { color: headerTextColor },
placeholder: __('Enter text…')
}),
React.createElement(RichText, {
tagName: 'div',
value: countUpNumber3,
onChange: function onChange(value) {
return setAttributes({ countUpNumber3: value });
},
isSelected: isSelected && currentEdit === 'countUp3',
unstableOnFocus: function unstableOnFocus() {
return _this2.setState({ currentEdit: 'countUp3' });
},
style: { fontSize: countUpNumberSize + 'px', color: countUpNumberColor }
}),
React.createElement(RichText, {
tagName: 'p',
value: descText3,
onChange: function onChange(value) {
return setAttributes({ descText3: value });
},
isSelected: isSelected && currentEdit === 'desc3',
unstableOnFocus: function unstableOnFocus() {
return _this2.setState({ currentEdit: 'desc3' });
},
style: { color: descTextColor },
placeholder: __('Enter text…')
})
)
)
);
}
}]);
return AdvCountUp;
}(Component);
function AdvCountUpSave(_ref) {
var attributes = _ref.attributes;
var headerText = attributes.headerText,
headerText2 = attributes.headerText2,
headerText3 = attributes.headerText3,
headerTextColor = attributes.headerTextColor,
countUpNumber = attributes.countUpNumber,
countUpNumber2 = attributes.countUpNumber2,
countUpNumber3 = attributes.countUpNumber3,
countUpNumberColor = attributes.countUpNumberColor,
countUpNumberSize = attributes.countUpNumberSize,
countUpSymbol = attributes.countUpSymbol,
countUpSymbol2 = attributes.countUpSymbol2,
countUpSymbol3 = attributes.countUpSymbol3,
countUpSymbolAfter = attributes.countUpSymbolAfter,
countUpSymbolAfter2 = attributes.countUpSymbolAfter2,
countUpSymbolAfter3 = attributes.countUpSymbolAfter3,
descText = attributes.descText,
descText2 = attributes.descText2,
descText3 = attributes.descText3,
descTextColor = attributes.descTextColor,
columns = attributes.columns;
var countSymbolElm = countUpSymbol ? React.createElement(
'span',
{ className: 'advgb-counter-symbol' },
countUpSymbol
) : '';
var countSymbolElm2 = countUpSymbol2 ? React.createElement(
'span',
{ className: 'advgb-counter-symbol' },
countUpSymbol2
) : '';
var countSymbolElm3 = countUpSymbol3 ? React.createElement(
'span',
{ className: 'advgb-counter-symbol' },
countUpSymbol3
) : '';
return React.createElement(
'div',
{ className: 'advgb-count-up', style: { display: 'flex' } },
React.createElement(
'div',
{ className: 'advgb-count-up-columns-one', style: { textAlign: 'center' } },
React.createElement(
'h4',
{ className: 'advgb-count-up-header', style: { color: headerTextColor } },
headerText
),
React.createElement(
'div',
{ className: 'advgb-counter',
style: { color: countUpNumberColor, fontSize: countUpNumberSize + 'px' }
},
!countUpSymbolAfter && countSymbolElm,
React.createElement(
'span',
{ className: 'advgb-counter-number' },
countUpNumber
),
!!countUpSymbolAfter && countSymbolElm
),
React.createElement(
'p',
{ className: 'advgb-count-up-desc', style: { color: descTextColor } },
descText
)
),
parseInt(columns) > 1 && React.createElement(
'div',
{ className: 'advgb-count-up-columns-two', style: { textAlign: 'center' } },
React.createElement(
'h4',
{ className: 'advgb-count-up-header', style: { color: headerTextColor } },
headerText2
),
React.createElement(
'div',
{ className: 'advgb-counter',
style: { color: countUpNumberColor, fontSize: countUpNumberSize + 'px' }
},
!countUpSymbolAfter2 && countSymbolElm2,
React.createElement(
'span',
{ className: 'advgb-counter-number' },
countUpNumber2
),
!!countUpSymbolAfter2 && countSymbolElm2
),
React.createElement(
'p',
{ className: 'advgb-count-up-desc', style: { color: descTextColor } },
descText2
)
),
parseInt(columns) > 2 && React.createElement(
'div',
{ className: 'advgb-count-up-columns-three', style: { textAlign: 'center' } },
React.createElement(
'h4',
{ className: 'advgb-count-up-header', style: { color: headerTextColor } },
headerText3
),
React.createElement(
'div',
{ className: 'advgb-counter',
style: { color: countUpNumberColor, fontSize: countUpNumberSize + 'px' }
},
!countUpSymbolAfter3 && countSymbolElm3,
React.createElement(
'span',
{ className: 'advgb-counter-number' },
countUpNumber3
),
!!countUpSymbolAfter3 && countSymbolElm3
),
React.createElement(
'p',
{ className: 'advgb-count-up-desc', style: { color: descTextColor } },
descText3
)
)
);
}
var countUpBlockIcon = React.createElement(
'svg',
{ height: '20', viewBox: '2 2 22 22', width: '20', xmlns: 'http://www.w3.org/2000/svg' },
React.createElement('path', { d: 'M0 0h24v24H0zm0 0h24v24H0z', fill: 'none' }),
React.createElement('path', { d: 'M16.05 16.29l2.86-3.07c.38-.39.72-.79 1.04-1.18.32-.39.59-.78.82-1.17.23-.39.41-.78.54-1.17.13-.39.19-.79.19-1.18 0-.53-.09-1.02-.27-1.46-.18-.44-.44-.81-.78-1.11-.34-.31-.77-.54-1.26-.71-.51-.16-1.08-.24-1.72-.24-.69 0-1.31.11-1.85.32-.54.21-1 .51-1.36.88-.37.37-.65.8-.84 1.3-.18.47-.27.97-.28 1.5h2.14c.01-.31.05-.6.13-.87.09-.29.23-.54.4-.75.18-.21.41-.37.68-.49.27-.12.6-.18.96-.18.31 0 .58.05.81.15.23.1.43.25.59.43.16.18.28.4.37.65.08.25.13.52.13.81 0 .22-.03.43-.08.65-.06.22-.15.45-.29.7-.14.25-.32.53-.56.83-.23.3-.52.65-.88 1.03l-4.17 4.55V18H22v-1.71h-5.95zM8 7H6v4H2v2h4v4h2v-4h4v-2H8V7z' })
);
registerBlockType('advgb/count-up', {
title: __('Count Up'),
description: __('Make a block with animate counting numbers.'),
icon: {
src: countUpBlockIcon,
foreground: typeof advgbBlocks !== 'undefined' ? advgbBlocks.color : undefined
},
category: 'advgb-category',
keywords: [__('numbers'), __('count'), __('increase')],
attributes: {
headerText: {
type: 'string',
default: __('Header text')
},
headerText2: {
type: 'string',
default: __('Header text')
},
headerText3: {
type: 'string',
default: __('Header text')
},
headerTextColor: {
type: 'string'
},
countUpNumber: {
type: 'string',
default: '56789'
},
countUpNumber2: {
type: 'string',
default: '56789'
},
countUpNumber3: {
type: 'string',
default: '56789'
},
countUpNumberColor: {
type: 'string'
},
countUpNumberSize: {
type: 'number',
default: 55
},
countUpSymbol: {
type: 'string'
},
countUpSymbol2: {
type: 'string'
},
countUpSymbol3: {
type: 'string'
},
countUpSymbolAfter: {
type: 'boolean',
default: false
},
countUpSymbolAfter2: {
type: 'boolean',
default: false
},
countUpSymbolAfter3: {
type: 'boolean',
default: false
},
descText: {
type: 'string',
default: __('and description')
},
descText2: {
type: 'string',
default: __('and description')
},
descText3: {
type: 'string',
default: __('and description')
},
descTextColor: {
type: 'string'
},
columns: {
type: 'number',
default: 1
},
changed: {
type: 'boolean',
default: false
}
},
edit: AdvCountUp,
save: AdvCountUpSave
});
})(wp.i18n, wp.blocks, wp.element, wp.editor, wp.components);
/***/ }),
/***/ "./assets/blocks/custom-columns/columns.jsx":
/*!**************************************************!*\
!*** ./assets/blocks/custom-columns/columns.jsx ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
(function (wpI18n, wpHooks, wpElement, wpEditor, wpComponents) {
var addFilter = wpHooks.addFilter;
var __ = wpI18n.__;
var Fragment = wpElement.Fragment;
var InspectorControls = wpEditor.InspectorControls;
var PanelBody = wpComponents.PanelBody,
Button = wpComponents.Button;
// Register extra attributes
addFilter('blocks.registerBlockType', 'advgb/registerExtraColumnsAttrs', function (settings) {
if (settings.name === 'core/text-columns' || settings.name === 'core/columns') {
settings.attributes = _extends(settings.attributes, {
colMargin: {
type: 'number'
},
colPadding: {
type: 'number'
},
blockID: {
type: 'string'
}
});
}
return settings;
});
// Add options to edit in backend
addFilter('editor.BlockEdit', 'advgb/editColumnsAttrs', function (BlockEdit) {
return function (props) {
if (props.name === "core/text-columns" || props.name === "core/columns") {
var attributes = props.attributes,
clientId = props.clientId;
var colMargin = attributes.colMargin,
colPadding = attributes.colPadding;
return React.createElement(
Fragment,
null,
React.createElement(BlockEdit, props),
React.createElement(
InspectorControls,
null,
React.createElement(
PanelBody,
{ title: __('Custom styles') },
React.createElement(
Button,
{ isPrimary: true,
onClick: function onClick() {
return props.setAttributes({
colMargin: undefined,
colPadding: undefined,
blockID: undefined
});
} },
__('Clear custom styles')
),
React.createElement(
'p',
{ style: { fontStyle: 'italic', marginTop: 10 } },
__('We recommend to clear all custom styles as soon as possible to avoid block error validation,' + ' because we will remove this feature in very next version.')
)
)
),
props.name === 'core/columns' && (!!colMargin || !!colPadding) && React.createElement(
'style',
{ key: 'custom-columns-styles' },
'#block-' + clientId + ' .wp-block-columns .editor-block-list__block:not(:first-child) {margin-left: ' + colMargin + 'px;}',
'#block-' + clientId + ' .wp-block-columns .editor-block-list__block-edit {padding: ' + colPadding + 'px;}'
)
);
}
return React.createElement(BlockEdit, props);
};
});
// Save options to show in frontend
addFilter('blocks.getSaveContent.extraProps', 'advgb/saveColumnsAttrs', function (extraProps, blockType, attributes) {
var colMargin = attributes.colMargin,
colPadding = attributes.colPadding,
blockID = attributes.blockID;
if (blockType.name === 'core/text-columns' || blockType.name === 'core/columns') {
extraProps = _extends(extraProps, {
id: colMargin || colPadding || blockID ? blockID : extraProps.id
});
}
return extraProps;
});
// Save option to show in frontend
addFilter('blocks.getSaveElement', 'advgb/saveTextColumnsElm', function (SaveElm, blockType, attributes) {
if (blockType.name === 'core/text-columns' || blockType.name === 'core/columns') {
var colMargin = attributes.colMargin,
colPadding = attributes.colPadding,
blockID = attributes.blockID;
return React.createElement(
Fragment,
null,
SaveElm,
blockID && (!!colMargin || !!colPadding) && React.createElement(
'style',
null,
'#' + blockID + ' .wp-block-column:not(:first-child) {\n margin-left: ' + colMargin + 'px;\n }\n #' + blockID + ' .wp-block-column {\n padding: ' + colPadding + 'px;\n }'
)
);
}
return SaveElm;
});
})(wp.i18n, wp.hooks, wp.element, wp.editor, wp.components);
/***/ }),
/***/ "./assets/blocks/custom-separator/separator.jsx":
/*!******************************************************!*\
!*** ./assets/blocks/custom-separator/separator.jsx ***!
\******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
(function (wpI18n, wpHooks, wpEditor, wpComponents) {
var addFilter = wpHooks.addFilter;
var __ = wpI18n.__;
var InspectorControls = wpEditor.InspectorControls;
var PanelBody = wpComponents.PanelBody,
Button = wpComponents.Button;
// Register extra attributes to separator blocks
addFilter('blocks.registerBlockType', 'advgb/registerExtraSeparatorAttrs', function (settings) {
if (settings.name === 'core/separator') {
settings.attributes = _extends(settings.attributes, {
borderColor: {
type: 'string'
},
borderSize: {
type: 'number'
},
borderStyle: {
type: 'string'
},
borderWidth: {
type: 'number'
}
});
}
return settings;
});
// Add option to select styles for separator
addFilter('editor.BlockEdit', 'advgb/customSeparatorStyles', function (BlockEdit) {
return function (props) {
if (props.name === "core/separator") {
var attributes = props.attributes,
clientId = props.clientId;
var borderColor = attributes.borderColor,
borderSize = attributes.borderSize,
borderStyle = attributes.borderStyle,
borderWidth = attributes.borderWidth;
return [React.createElement(BlockEdit, _extends({ key: 'block-edit-custom-separator' }, props)), React.createElement(
InspectorControls,
{ key: 'inspector-custom' },
React.createElement(
PanelBody,
{ title: __('Custom styles') },
React.createElement(
Button,
{ isPrimary: true,
onClick: function onClick() {
return props.setAttributes({
borderColor: undefined,
borderSize: undefined,
borderStyle: undefined,
borderWidth: undefined
});
} },
__('Clear custom styles')
),
React.createElement(
'p',
{ style: { fontStyle: 'italic', marginTop: 10 } },
__('We recommend to clear all custom styles as soon as possible to avoid block error validation,' + ' because we will remove this feature in very next version.')
)
)
), React.createElement(
'style',
{ key: 'custom-separator-styles' },
'#block-' + clientId + ' hr {\n border-bottom-color: ' + borderColor + ';\n border-bottom-style: ' + borderStyle + ';\n border-bottom-width: ' + borderWidth + 'px;\n max-width: ' + borderSize + 'px;\n }'
)];
}
return React.createElement(BlockEdit, props);
};
});
// Apply custom styles on front-end
addFilter('blocks.getSaveContent.extraProps', 'advgb/saveSeparatorStyles', function (extraProps, blockType, attributes) {
if (blockType.name === 'core/separator') {
var borderColor = attributes.borderColor,
borderSize = attributes.borderSize,
borderStyle = attributes.borderStyle,
borderWidth = attributes.borderWidth;
extraProps = _extends(extraProps, {
style: {
borderBottomColor: borderColor,
borderBottomWidth: borderWidth ? borderWidth + 'px' : undefined,
borderBottomStyle: borderStyle,
maxWidth: borderSize ? borderSize + 'px' : undefined
}
});
}
return extraProps;
});
})(wp.i18n, wp.hooks, wp.editor, wp.components);
/***/ }),
/***/ "./assets/blocks/customstyles/custom-styles.jsx":
/*!******************************************************!*\
!*** ./assets/blocks/customstyles/custom-styles.jsx ***!
\******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
(function (wpI18n, wpHooks, wpBlocks, wpEditor, wpComponents) {
var addFilter = wpHooks.addFilter;
var __ = wpI18n.__;
var hasBlockSupport = wpBlocks.hasBlockSupport;
var InspectorControls = wpEditor.InspectorControls;
var SelectControl = wpComponents.SelectControl;
// Register custom styles to blocks attributes
addFilter('blocks.registerBlockType', 'advgb/registerCustomStyleClass', function (settings) {
if (settings.name === 'core/paragraph') {
settings.attributes = _extends(settings.attributes, {
customStyle: {
type: 'string'
},
identifyColor: {
type: 'string'
}
});
}
return settings;
});
// Add option to return to default style
if (typeof advgbBlocks.customStyles !== 'undefined' && advgbBlocks.customStyles) {
advgbBlocks.customStyles.unshift({
id: 0,
label: __('Paragraph'),
value: '',
identifyColor: ''
});
}
// Add option to select custom styles for paragraph blocks
addFilter('editor.BlockEdit', 'advgb/customStyles', function (BlockEdit) {
return function (props) {
return [React.createElement(BlockEdit, _extends({ key: 'block-edit-custom-class-name' }, props)), props.isSelected && props.name === "core/paragraph" && React.createElement(
InspectorControls,
{ key: 'advgb-custom-controls' },
React.createElement(SelectControl, {
label: [__('Custom styles'), React.createElement('span', { className: 'components-panel__color-area',
key: 'customstyle-identify',
style: {
background: props.attributes.identifyColor,
verticalAlign: 'text-bottom',
borderRadius: '50%',
border: 'none',
width: '16px',
height: '16px',
display: 'inline-block',
marginLeft: '10px'
} })],
help: __('This option let you add custom style for current paragraph. (Front-end only!)'),
value: props.attributes.customStyle,
options: advgbBlocks.customStyles.map(function (cstyle, index) {
if (cstyle.title) advgbBlocks.customStyles[index].label = cstyle.title;
if (cstyle.name) advgbBlocks.customStyles[index].value = cstyle.name;
return cstyle;
}),
onChange: function onChange(cstyle) {
var identifyColor = advgbBlocks.customStyles.filter(function (style) {
return style.value === cstyle;
})[0].identifyColor;
props.setAttributes({
customStyle: cstyle,
identifyColor: identifyColor,
backgroundColor: undefined,
textColor: undefined,
fontSize: undefined
});
}
})
)];
};
});
// Apply custom styles on front-end
addFilter('blocks.getSaveContent.extraProps', 'advgb/loadFrontendCustomStyles', function (extraProps, blockType, attributes) {
if (hasBlockSupport(blockType, 'customStyle', true) && attributes.customStyle) {
if (typeof extraProps.className === 'undefined') {
extraProps.className = attributes.customStyle;
} else {
extraProps.className += ' ' + attributes.customStyle;
extraProps.className = extraProps.className.trim();
}
}
return extraProps;
});
})(wp.i18n, wp.hooks, wp.blocks, wp.editor, wp.components);
/***/ }),
/***/ "./assets/blocks/images-slider/block.jsx":
/*!***********************************************!*\
!*** ./assets/blocks/images-slider/block.jsx ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _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; }; }();
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _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; }
function _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; }
(function (wpI18n, wpBlocks, wpElement, wpEditor, wpComponents) {
var __ = wpI18n.__;
var Component = wpElement.Component,
Fragment = wpElement.Fragment;
var registerBlockType = wpBlocks.registerBlockType;
var InspectorControls = wpEditor.InspectorControls,
PanelColorSettings = wpEditor.PanelColorSettings,
MediaUpload = wpEditor.MediaUpload;
var PanelBody = wpComponents.PanelBody,
RangeControl = wpComponents.RangeControl,
ToggleControl = wpComponents.ToggleControl,
SelectControl = wpComponents.SelectControl,
TextControl = wpComponents.TextControl,
TextareaControl = wpComponents.TextareaControl,
IconButton = wpComponents.IconButton,
Button = wpComponents.Button,
Placeholder = wpComponents.Placeholder,
Tooltip = wpComponents.Tooltip;
var $ = jQuery;
var imageSliderBlockIcon = React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "2 2 22 22", className: "dashicon" },
React.createElement("path", { fill: "none", d: "M0 0h24v24H0V0z" }),
React.createElement("path", { d: "M20 4h-3.17L15 2H9L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM9.88 4h4.24l1.83 2H20v12H4V6h4.05" }),
React.createElement("path", { d: "M15 11H9V8.5L5.5 12 9 15.5V13h6v2.5l3.5-3.5L15 8.5z" })
);
var AdvImageSlider = function (_Component) {
_inherits(AdvImageSlider, _Component);
function AdvImageSlider() {
_classCallCheck(this, AdvImageSlider);
var _this = _possibleConstructorReturn(this, (AdvImageSlider.__proto__ || Object.getPrototypeOf(AdvImageSlider)).apply(this, arguments));
_this.state = {
currentSelected: 0,
inited: false
};
_this.initSlider = _this.initSlider.bind(_this);
return _this;
}
_createClass(AdvImageSlider, [{
key: "componentWillMount",
value: function componentWillMount() {
var _props = this.props,
attributes = _props.attributes,
setAttributes = _props.setAttributes;
var currentBlockConfig = advgbDefaultConfig['advgb-images-slider'];
// No override attributes of blocks inserted before
if (attributes.changed !== true) {
if ((typeof currentBlockConfig === "undefined" ? "undefined" : _typeof(currentBlockConfig)) === 'object' && currentBlockConfig !== null) {
Object.keys(currentBlockConfig).map(function (attribute) {
if (typeof attributes[attribute] === 'boolean') {
attributes[attribute] = !!currentBlockConfig[attribute];
} else {
attributes[attribute] = currentBlockConfig[attribute];
}
});
}
// Finally set changed attribute to true, so we don't modify anything again
setAttributes({ changed: true });
}
}
}, {
key: "componentDidMount",
value: function componentDidMount() {
var attributes = this.props.attributes;
if (attributes.images.length) {
this.initSlider();
}
}
}, {
key: "componentWillUpdate",
value: function componentWillUpdate(nextProps) {
var _props2 = this.props,
clientId = _props2.clientId,
attributes = _props2.attributes;
var images = attributes.images;
var nextImages = nextProps.attributes.images;
if (images.length !== nextImages.length) {
$("#block-" + clientId + " .advgb-images-slider.slick-initialized").slick('unslick');
$("#block-" + clientId + " .advgb-image-slider-item").removeAttr('tabindex').removeAttr('role').removeAttr('aria-describedby');
}
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
var _this2 = this;
var attributes = this.props.attributes;
var images = attributes.images;
var prevImages = prevProps.attributes.images;
if (images.length !== prevImages.length) {
if (images.length) {
setTimeout(function () {
return _this2.initSlider();
}, 10);
}
}
}
}, {
key: "initSlider",
value: function initSlider() {
var _this3 = this;
var clientId = this.props.clientId;
$("#block-" + clientId + " .advgb-images-slider:not(.slick-initialized)").slick({
dots: true,
adaptiveHeight: true
});
$("#block-" + clientId + " .advgb-images-slider").on('afterChange', function (e, s, currentSlide) {
if (_this3.state.currentSelected !== currentSlide) {
_this3.setState({ currentSelected: currentSlide });
}
});
}
}, {
key: "moveImage",
value: function moveImage(currentIndex, newIndex) {
var _props3 = this.props,
setAttributes = _props3.setAttributes,
attributes = _props3.attributes;
var images = attributes.images;
var image = images[currentIndex];
setAttributes({
images: [].concat(_toConsumableArray(images.filter(function (img, idx) {
return idx !== currentIndex;
}).slice(0, newIndex)), [image], _toConsumableArray(images.filter(function (img, idx) {
return idx !== currentIndex;
}).slice(newIndex)))
});
}
}, {
key: "updateImagesData",
value: function updateImagesData(data) {
var currentSelected = this.state.currentSelected;
if (typeof currentSelected !== 'number') {
return null;
}
var _props4 = this.props,
attributes = _props4.attributes,
setAttributes = _props4.setAttributes;
var images = attributes.images;
var newImages = images.map(function (image, index) {
if (index === currentSelected) {
image = _extends({}, image, data);
}
return image;
});
setAttributes({ images: newImages });
}
}, {
key: "render",
value: function render() {
var _this4 = this;
var _props5 = this.props,
attributes = _props5.attributes,
setAttributes = _props5.setAttributes,
isSelected = _props5.isSelected,
clientId = _props5.clientId;
var currentSelected = this.state.currentSelected;
var images = attributes.images,
actionOnClick = attributes.actionOnClick,
fullWidth = attributes.fullWidth,
autoHeight = attributes.autoHeight,
width = attributes.width,
height = attributes.height,
alwaysShowOverlay = attributes.alwaysShowOverlay,
hoverColor = attributes.hoverColor,
titleColor = attributes.titleColor,
textColor = attributes.textColor,
hAlign = attributes.hAlign,
vAlign = attributes.vAlign;
if (images.length === 0) {
return React.createElement(
Placeholder,
{
icon: imageSliderBlockIcon,
label: __('Image Slider Block'),
instructions: __('No images selected. Adding images to start using this block.')
},
React.createElement(MediaUpload, {
allowedTypes: ['image'],
value: null,
multiple: true,
onSelect: function onSelect(image) {
var imgInsert = image.map(function (img) {
return {
url: img.url,
id: img.id
};
});
setAttributes({
images: [].concat(_toConsumableArray(images), _toConsumableArray(imgInsert))
});
},
render: function render(_ref) {
var open = _ref.open;
return React.createElement(
Button,
{ className: "button button-large button-primary", onClick: open },
__('Add images')
);
}
})
);
}
return React.createElement(
Fragment,
null,
React.createElement(
InspectorControls,
null,
React.createElement(
PanelBody,
{ title: __('Image Settings') },
React.createElement(SelectControl, {
label: __('Action on click'),
value: actionOnClick,
options: [{ label: __('None'), value: '' }, { label: __('Open image in lightbox'), value: 'lightbox' }, { label: __('Open custom link'), value: 'link' }],
onChange: function onChange(value) {
return setAttributes({ actionOnClick: value });
}
}),
React.createElement(ToggleControl, {
label: __('Full width'),
checked: fullWidth,
onChange: function onChange() {
return setAttributes({ fullWidth: !fullWidth });
}
}),
React.createElement(ToggleControl, {
label: __('Auto height'),
checked: autoHeight,
onChange: function onChange() {
return setAttributes({ autoHeight: !autoHeight });
}
}),
!fullWidth && React.createElement(RangeControl, {
label: __('Width'),
value: width,
onChange: function onChange(value) {
return setAttributes({ width: value });
},
min: 200,
max: 1300
}),
!autoHeight && React.createElement(RangeControl, {
label: __('Height'),
value: height,
onChange: function onChange(value) {
return setAttributes({ height: value });
},
min: 100,
max: 1000
}),
React.createElement(ToggleControl, {
label: __('Always show overlay'),
checked: alwaysShowOverlay,
onChange: function onChange() {
return setAttributes({ alwaysShowOverlay: !alwaysShowOverlay });
}
})
),
React.createElement(PanelColorSettings, {
title: __('Color Settings'),
colorSettings: [{
label: __('Hover Color'),
value: hoverColor,
onChange: function onChange(value) {
return setAttributes({ hoverColor: value });
}
}, {
label: __('Title Color'),
value: titleColor,
onChange: function onChange(value) {
return setAttributes({ titleColor: value });
}
}, {
label: __('Text Color'),
value: textColor,
onChange: function onChange(value) {
return setAttributes({ textColor: value });
}
}]
}),
React.createElement(
PanelBody,
{ title: __('Text Alignment'), initialOpen: false },
React.createElement(SelectControl, {
label: __('Vertical Alignment'),
value: vAlign,
options: [{ label: __('Top'), value: 'flex-start' }, { label: __('Center'), value: 'center' }, { label: __('Bottom'), value: 'flex-end' }],
onChange: function onChange(value) {
return setAttributes({ vAlign: value });
}
}),
React.createElement(SelectControl, {
label: __('Horizontal Alignment'),
value: hAlign,
options: [{ label: __('Left'), value: 'flex-start' }, { label: __('Center'), value: 'center' }, { label: __('Right'), value: 'flex-end' }],
onChange: function onChange(value) {
return setAttributes({ hAlign: value });
}
})
)
),
React.createElement(
"div",
{ className: "advgb-images-slider-block" },
React.createElement(
"div",
{ className: "advgb-images-slider" },
images.map(function (image, index) {
return React.createElement(
"div",
{ className: "advgb-image-slider-item", key: index },
React.createElement("img", { src: image.url,
className: "advgb-image-slider-img",
alt: __('Slider image'),
style: {
width: fullWidth ? '100%' : width,
height: autoHeight ? 'auto' : height
}
}),
React.createElement(
"div",
{ className: "advgb-image-slider-item-info",
style: {
justifyContent: vAlign,
alignItems: hAlign
}
},
React.createElement("span", { className: "advgb-image-slider-overlay",
style: {
backgroundColor: hoverColor,
opacity: alwaysShowOverlay ? 0.5 : undefined
}
}),
React.createElement(
"h4",
{ className: "advgb-image-slider-title",
style: { color: titleColor }
},
image.title
),
React.createElement(
"p",
{ className: "advgb-image-slider-text",
style: { color: textColor }
},
image.text
)
)
);
})
),
isSelected && React.createElement(
"div",
{ className: "advgb-image-slider-controls" },
React.createElement(
"div",
{ className: "advgb-image-slider-control" },
React.createElement(TextControl, {
label: __('Title'),
value: images[currentSelected] ? images[currentSelected].title || '' : '',
onChange: function onChange(value) {
return _this4.updateImagesData({ title: value || '' });
}
})
),
React.createElement(
"div",
{ className: "advgb-image-slider-control" },
React.createElement(TextareaControl, {
label: __('Text'),
value: images[currentSelected] ? images[currentSelected].text || '' : '',
onChange: function onChange(value) {
return _this4.updateImagesData({ text: value || '' });
}
})
),
actionOnClick === 'link' && React.createElement(
"div",
{ className: "advgb-image-slider-control" },
React.createElement(TextControl, {
label: __('Link'),
value: images[currentSelected] ? images[currentSelected].link || '' : '',
onChange: function onChange(value) {
return _this4.updateImagesData({ link: value || '' });
}
})
),
React.createElement(
"div",
{ className: "advgb-image-slider-image-list" },
images.map(function (image, index) {
return React.createElement(
"div",
{ className: "advgb-image-slider-image-list-item", key: index },
index > 0 && React.createElement(
Tooltip,
{ text: __('Move Left') },
React.createElement(
"span",
{ className: "advgb-move-arrow advgb-move-left",
onClick: function onClick() {
return _this4.moveImage(index, index - 1);
}
},
React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24" },
React.createElement("path", { fill: "none", d: "M0 0h24v24H0V0z" }),
React.createElement("path", { d: "M15.41 16.59L10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41z" })
)
)
),
React.createElement("img", { src: image.url,
className: "advgb-image-slider-image-list-img",
alt: __('Remove'),
onClick: function onClick() {
$("#block-" + clientId + " .advgb-images-slider").slick('slickGoTo', index, false);
_this4.setState({ currentSelected: index });
}
}),
index + 1 < images.length && React.createElement(
Tooltip,
{ text: __('Move Right') },
React.createElement(
"span",
{ className: "advgb-move-arrow advgb-move-right",
onClick: function onClick() {
return _this4.moveImage(index, index + 1);
}
},
React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24" },
React.createElement("path", { fill: "none", d: "M0 0h24v24H0V0z" }),
React.createElement("path", { d: "M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z" })
)
)
),
React.createElement(
Tooltip,
{ text: __('Remove image') },
React.createElement(IconButton, {
className: "advgb-image-slider-image-list-item-remove",
icon: "no",
onClick: function onClick() {
if (index === currentSelected) _this4.setState({ currentSelected: null });
setAttributes({ images: images.filter(function (img, idx) {
return idx !== index;
}) });
}
})
)
);
}),
React.createElement(
"div",
{ className: "advgb-image-slider-add-item" },
React.createElement(MediaUpload, {
allowedTypes: ['image'],
value: currentSelected,
multiple: true,
onSelect: function onSelect(imgs) {
return setAttributes({
images: [].concat(_toConsumableArray(images), _toConsumableArray(imgs.map(function (img) {
return lodash.pick(img, 'id', 'url');
})))
});
},
render: function render(_ref2) {
var open = _ref2.open;
return React.createElement(IconButton, {
label: __('Add image'),
icon: "plus",
onClick: open
});
}
})
)
)
)
)
);
}
}]);
return AdvImageSlider;
}(Component);
var blockAttrs = {
images: {
type: 'array',
default: [] // [ { id: int, url, title, text, link: string } ]
},
actionOnClick: {
type: 'string'
},
fullWidth: {
type: 'boolean',
default: true
},
autoHeight: {
type: 'boolean',
default: true
},
width: {
type: 'number',
default: 700
},
height: {
type: 'number',
default: 500
},
alwaysShowOverlay: {
type: 'boolean',
default: false
},
hoverColor: {
type: 'string'
},
titleColor: {
type: 'string'
},
textColor: {
type: 'string'
},
vAlign: {
type: 'string',
default: 'center'
},
hAlign: {
type: 'string',
default: 'center'
},
changed: {
type: 'boolean',
default: false
}
};
registerBlockType('advgb/images-slider', {
title: __('Images Slider'),
description: __('Display your images in a slider.'),
icon: {
src: imageSliderBlockIcon,
foreground: typeof advgbBlocks !== 'undefined' ? advgbBlocks.color : undefined
},
category: 'advgb-category',
keywords: [__('slide'), __('gallery'), __('photos')],
attributes: blockAttrs,
edit: AdvImageSlider,
save: function save(_ref3) {
var attributes = _ref3.attributes;
var images = attributes.images,
actionOnClick = attributes.actionOnClick,
fullWidth = attributes.fullWidth,
autoHeight = attributes.autoHeight,
width = attributes.width,
height = attributes.height,
alwaysShowOverlay = attributes.alwaysShowOverlay,
hoverColor = attributes.hoverColor,
titleColor = attributes.titleColor,
textColor = attributes.textColor,
hAlign = attributes.hAlign,
vAlign = attributes.vAlign;
var blockClassName = ['advgb-images-slider-block', actionOnClick === 'lightbox' && 'advgb-images-slider-lightbox'].filter(Boolean).join(' ');
return React.createElement(
"div",
{ className: blockClassName },
React.createElement(
"div",
{ className: "advgb-images-slider" },
images.map(function (image, index) {
return React.createElement(
"div",
{ className: "advgb-image-slider-item", key: index },
React.createElement("img", { src: image.url,
className: "advgb-image-slider-img",
alt: __('Slider image'),
style: {
width: fullWidth ? '100%' : width,
height: autoHeight ? 'auto' : height
}
}),
React.createElement(
"div",
{ className: "advgb-image-slider-item-info",
style: {
justifyContent: vAlign,
alignItems: hAlign
}
},
React.createElement("a", { className: "advgb-image-slider-overlay",
target: "_blank",
rel: "noopener noreferrer",
href: actionOnClick === 'link' && !!image.link ? image.link : undefined,
style: {
backgroundColor: hoverColor,
opacity: alwaysShowOverlay ? 0.5 : undefined
}
}),
React.createElement(
"h4",
{ className: "advgb-image-slider-title",
style: { color: titleColor }
},
image.title
),
React.createElement(
"p",
{ className: "advgb-image-slider-text",
style: { color: textColor }
},
image.text
)
)
);
})
)
);
},
deprecated: [{
attributes: blockAttrs,
save: function save(_ref4) {
var attributes = _ref4.attributes;
var images = attributes.images,
actionOnClick = attributes.actionOnClick,
fullWidth = attributes.fullWidth,
autoHeight = attributes.autoHeight,
width = attributes.width,
height = attributes.height,
alwaysShowOverlay = attributes.alwaysShowOverlay,
hoverColor = attributes.hoverColor,
titleColor = attributes.titleColor,
textColor = attributes.textColor,
hAlign = attributes.hAlign,
vAlign = attributes.vAlign;
var blockClassName = ['advgb-images-slider-block', actionOnClick === 'lightbox' && 'advgb-images-slider-lightbox'].filter(Boolean).join(' ');
return React.createElement(
"div",
{ className: blockClassName },
React.createElement(
"div",
{ className: "advgb-images-slider" },
images.map(function (image, index) {
return React.createElement(
"div",
{ className: "advgb-image-slider-item", key: index },
React.createElement("img", { src: image.url,
className: "advgb-image-slider-img",
alt: __('Slider image'),
style: {
width: fullWidth ? '100%' : width,
height: autoHeight ? 'auto' : height
}
}),
React.createElement(
"div",
{ className: "advgb-image-slider-item-info",
style: {
justifyContent: vAlign,
alignItems: hAlign
}
},
React.createElement("a", { className: "advgb-image-slider-overlay",
target: "_blank",
href: actionOnClick === 'link' && !!image.link ? image.link : undefined,
style: {
backgroundColor: hoverColor,
opacity: alwaysShowOverlay ? 0.5 : undefined
}
}),
React.createElement(
"h4",
{ className: "advgb-image-slider-title",
style: { color: titleColor }
},
image.title
),
React.createElement(
"p",
{ className: "advgb-image-slider-text",
style: { color: textColor }
},
image.text
)
)
);
})
)
);
}
}]
});
})(wp.i18n, wp.blocks, wp.element, wp.editor, wp.components);
/***/ }),
/***/ "./assets/blocks/map/block.jsx":
/*!*************************************!*\
!*** ./assets/blocks/map/block.jsx ***!
\*************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _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; }; }();
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _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; }
function _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; }
(function (wpI18n, wpBlocks, wpElement, wpEditor, wpComponents) {
var __ = wpI18n.__;
var Component = wpElement.Component,
Fragment = wpElement.Fragment;
var registerBlockType = wpBlocks.registerBlockType;
var InspectorControls = wpEditor.InspectorControls,
MediaUpload = wpEditor.MediaUpload;
var PanelBody = wpComponents.PanelBody,
TextControl = wpComponents.TextControl,
TextareaControl = wpComponents.TextareaControl,
RangeControl = wpComponents.RangeControl,
SelectControl = wpComponents.SelectControl,
BaseControl = wpComponents.BaseControl,
Button = wpComponents.Button,
Placeholder = wpComponents.Placeholder,
Spinner = wpComponents.Spinner;
var mapWillUpdate = null;
var mapBlockIcon = React.createElement(
"svg",
{ xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "2 2 22 22", className: "dashicon" },
React.createElement("path", { d: "M20.5 3l-.16.03L15 5.1 9 3 3.36 4.9c-.21.07-.36.25-.36.48V20.5c0 .28.22.5.5.5l.16-.03L9 18.9l6 2.1 5.64-1.9c.21-.07.36-.25.36-.48V3.5c0-.28-.22-.5-.5-.5zM15 19l-6-2.11V5l6 2.11V19z" }),
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" })
);
var MAP_STYLES = {
silver: [{
"elementType": "geometry",
"stylers": [{
"color": "#f5f5f5"
}]
}, {
"elementType": "labels.icon",
"stylers": [{
"visibility": "off"
}]
}, {
"elementType": "labels.text.fill",
"stylers": [{
"color": "#616161"
}]
}, {
"elementType": "labels.text.stroke",
"stylers": [{
"color": "#f5f5f5"
}]
}, {
"featureType": "administrative.land_parcel",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#bdbdbd"
}]
}, {
"featureType": "poi",
"elementType": "geometry",
"stylers": [{
"color": "#eeeeee"
}]
}, {
"featureType": "poi",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#757575"
}]
}, {
"featureType": "poi.park",
"elementType": "geometry",
"stylers": [{
"color": "#e5e5e5"
}]
}, {
"featureType": "poi.park",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#9e9e9e"
}]
}, {
"featureType": "road",
"elementType": "geometry",
"stylers": [{
"color": "#ffffff"
}]
}, {
"featureType": "road.arterial",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#757575"
}]
}, {
"featureType": "road.highway",
"elementType": "geometry",
"stylers": [{
"color": "#dadada"
}]
}, {
"featureType": "road.highway",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#616161"
}]
}, {
"featureType": "road.local",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#9e9e9e"
}]
}, {
"featureType": "transit.line",
"elementType": "geometry",
"stylers": [{
"color": "#e5e5e5"
}]
}, {
"featureType": "transit.station",
"elementType": "geometry",
"stylers": [{
"color": "#eeeeee"
}]
}, {
"featureType": "water",
"elementType": "geometry",
"stylers": [{
"color": "#c9c9c9"
}]
}, {
"featureType": "water",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#9e9e9e"
}]
}],
retro: [{
"elementType": "geometry",
"stylers": [{
"color": "#ebe3cd"
}]
}, {
"elementType": "labels.text.fill",
"stylers": [{
"color": "#523735"
}]
}, {
"elementType": "labels.text.stroke",
"stylers": [{
"color": "#f5f1e6"
}]
}, {
"featureType": "administrative",
"elementType": "geometry.stroke",
"stylers": [{
"color": "#c9b2a6"
}]
}, {
"featureType": "administrative.land_parcel",
"elementType": "geometry.stroke",
"stylers": [{
"color": "#dcd2be"
}]
}, {
"featureType": "administrative.land_parcel",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#ae9e90"
}]
}, {
"featureType": "landscape.natural",
"elementType": "geometry",
"stylers": [{
"color": "#dfd2ae"
}]
}, {
"featureType": "poi",
"elementType": "geometry",
"stylers": [{
"color": "#dfd2ae"
}]
}, {
"featureType": "poi",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#93817c"
}]
}, {
"featureType": "poi.park",
"elementType": "geometry.fill",
"stylers": [{
"color": "#a5b076"
}]
}, {
"featureType": "poi.park",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#447530"
}]
}, {
"featureType": "road",
"elementType": "geometry",
"stylers": [{
"color": "#f5f1e6"
}]
}, {
"featureType": "road.arterial",
"elementType": "geometry",
"stylers": [{
"color": "#fdfcf8"
}]
}, {
"featureType": "road.highway",
"elementType": "geometry",
"stylers": [{
"color": "#f8c967"
}]
}, {
"featureType": "road.highway",
"elementType": "geometry.stroke",
"stylers": [{
"color": "#e9bc62"
}]
}, {
"featureType": "road.highway.controlled_access",
"elementType": "geometry",
"stylers": [{
"color": "#e98d58"
}]
}, {
"featureType": "road.highway.controlled_access",
"elementType": "geometry.stroke",
"stylers": [{
"color": "#db8555"
}]
}, {
"featureType": "road.local",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#806b63"
}]
}, {
"featureType": "transit.line",
"elementType": "geometry",
"stylers": [{
"color": "#dfd2ae"
}]
}, {
"featureType": "transit.line",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#8f7d77"
}]
}, {
"featureType": "transit.line",
"elementType": "labels.text.stroke",
"stylers": [{
"color": "#ebe3cd"
}]
}, {
"featureType": "transit.station",
"elementType": "geometry",
"stylers": [{
"color": "#dfd2ae"
}]
}, {
"featureType": "water",
"elementType": "geometry.fill",
"stylers": [{
"color": "#b9d3c2"
}]
}, {
"featureType": "water",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#92998d"
}]
}],
dark: [{
"elementType": "geometry",
"stylers": [{
"color": "#212121"
}]
}, {
"elementType": "labels.icon",
"stylers": [{
"visibility": "off"
}]
}, {
"elementType": "labels.text.fill",
"stylers": [{
"color": "#757575"
}]
}, {
"elementType": "labels.text.stroke",
"stylers": [{
"color": "#212121"
}]
}, {
"featureType": "administrative",
"elementType": "geometry",
"stylers": [{
"color": "#757575"
}]
}, {
"featureType": "administrative.country",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#9e9e9e"
}]
}, {
"featureType": "administrative.land_parcel",
"stylers": [{
"visibility": "off"
}]
}, {
"featureType": "administrative.locality",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#bdbdbd"
}]
}, {
"featureType": "poi",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#757575"
}]
}, {
"featureType": "poi.park",
"elementType": "geometry",
"stylers": [{
"color": "#181818"
}]
}, {
"featureType": "poi.park",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#616161"
}]
}, {
"featureType": "poi.park",
"elementType": "labels.text.stroke",
"stylers": [{
"color": "#1b1b1b"
}]
}, {
"featureType": "road",
"elementType": "geometry.fill",
"stylers": [{
"color": "#2c2c2c"
}]
}, {
"featureType": "road",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#8a8a8a"
}]
}, {
"featureType": "road.arterial",
"elementType": "geometry",
"stylers": [{
"color": "#373737"
}]
}, {
"featureType": "road.highway",
"elementType": "geometry",
"stylers": [{
"color": "#3c3c3c"
}]
}, {
"featureType": "road.highway.controlled_access",
"elementType": "geometry",
"stylers": [{
"color": "#4e4e4e"
}]
}, {
"featureType": "road.local",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#616161"
}]
}, {
"featureType": "transit",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#757575"
}]
}, {
"featureType": "water",
"elementType": "geometry",
"stylers": [{
"color": "#000000"
}]
}, {
"featureType": "water",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#3d3d3d"
}]
}],
night: [{
"elementType": "geometry",
"stylers": [{
"color": "#242f3e"
}]
}, {
"elementType": "labels.text.fill",
"stylers": [{
"color": "#746855"
}]
}, {
"elementType": "labels.text.stroke",
"stylers": [{
"color": "#242f3e"
}]
}, {
"featureType": "administrative.locality",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#d59563"
}]
}, {
"featureType": "poi",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#d59563"
}]
}, {
"featureType": "poi.park",
"elementType": "geometry",
"stylers": [{
"color": "#263c3f"
}]
}, {
"featureType": "poi.park",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#6b9a76"
}]
}, {
"featureType": "road",
"elementType": "geometry",
"stylers": [{
"color": "#38414e"
}]
}, {
"featureType": "road",
"elementType": "geometry.stroke",
"stylers": [{
"color": "#212a37"
}]
}, {
"featureType": "road",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#9ca5b3"
}]
}, {
"featureType": "road.highway",
"elementType": "geometry",
"stylers": [{
"color": "#746855"
}]
}, {
"featureType": "road.highway",
"elementType": "geometry.stroke",
"stylers": [{
"color": "#1f2835"
}]
}, {
"featureType": "road.highway",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#f3d19c"
}]
}, {
"featureType": "transit",
"elementType": "geometry",
"stylers": [{
"color": "#2f3948"
}]
}, {
"featureType": "transit.station",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#d59563"
}]
}, {
"featureType": "water",
"elementType": "geometry",
"stylers": [{
"color": "#17263c"
}]
}, {
"featureType": "water",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#515c6d"
}]
}, {
"featureType": "water",
"elementType": "labels.text.stroke",
"stylers": [{
"color": "#17263c"
}]
}],
aubergine: [{
"elementType": "geometry",
"stylers": [{
"color": "#1d2c4d"
}]
}, {
"elementType": "labels.text.fill",
"stylers": [{
"color": "#8ec3b9"
}]
}, {
"elementType": "labels.text.stroke",
"stylers": [{
"color": "#1a3646"
}]
}, {
"featureType": "administrative.country",
"elementType": "geometry.stroke",
"stylers": [{
"color": "#4b6878"
}]
}, {
"featureType": "administrative.land_parcel",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#64779e"
}]
}, {
"featureType": "administrative.province",
"elementType": "geometry.stroke",
"stylers": [{
"color": "#4b6878"
}]
}, {
"featureType": "landscape.man_made",
"elementType": "geometry.stroke",
"stylers": [{
"color": "#334e87"
}]
}, {
"featureType": "landscape.natural",
"elementType": "geometry",
"stylers": [{
"color": "#023e58"
}]
}, {
"featureType": "poi",
"elementType": "geometry",
"stylers": [{
"color": "#283d6a"
}]
}, {
"featureType": "poi",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#6f9ba5"
}]
}, {
"featureType": "poi",
"elementType": "labels.text.stroke",
"stylers": [{
"color": "#1d2c4d"
}]
}, {
"featureType": "poi.park",
"elementType": "geometry.fill",
"stylers": [{
"color": "#023e58"
}]
}, {
"featureType": "poi.park",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#3C7680"
}]
}, {
"featureType": "road",
"elementType": "geometry",
"stylers": [{
"color": "#304a7d"
}]
}, {
"featureType": "road",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#98a5be"
}]
}, {
"featureType": "road",
"elementType": "labels.text.stroke",
"stylers": [{
"color": "#1d2c4d"
}]
}, {
"featureType": "road.highway",
"elementType": "geometry",
"stylers": [{
"color": "#2c6675"
}]
}, {
"featureType": "road.highway",
"elementType": "geometry.stroke",
"stylers": [{
"color": "#255763"
}]
}, {
"featureType": "road.highway",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#b0d5ce"
}]
}, {
"featureType": "road.highway",
"elementType": "labels.text.stroke",
"stylers": [{
"color": "#023e58"
}]
}, {
"featureType": "transit",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#98a5be"
}]
}, {
"featureType": "transit",
"elementType": "labels.text.stroke",
"stylers": [{
"color": "#1d2c4d"
}]
}, {
"featureType": "transit.line",
"elementType": "geometry.fill",
"stylers": [{
"color": "#283d6a"
}]
}, {
"featureType": "transit.station",
"elementType": "geometry",
"stylers": [{
"color": "#3a4762"
}]
}, {
"featureType": "water",
"elementType": "geometry",
"stylers": [{
"color": "#0e1626"
}]
}, {
"featureType": "water",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#4e6d70"
}]
}]
};
var AdvMap = function (_Component) {
_inherits(AdvMap, _Component);
function AdvMap() {
_classCallCheck(this, AdvMap);
var _this = _possibleConstructorReturn(this, (AdvMap.__proto__ || Object.getPrototypeOf(AdvMap)).apply(this, arguments));
_this.state = {
currentAddress: '',
currentMap: null,
currentMarker: null,
currentInfo: null,
fetching: false,
invalidStyle: false
};
_this.initMap = _this.initMap.bind(_this);
_this.fetchLocation = _this.fetchLocation.bind(_this);
return _this;
}
_createClass(AdvMap, [{
key: "componentWillMount",
value: function componentWillMount() {
var _props = this.props,
attributes = _props.attributes,
setAttributes = _props.setAttributes;
var currentBlockConfig = advgbDefaultConfig['advgb-map'];
// No override attributes of blocks inserted before
if (attributes.changed !== true) {
if ((typeof currentBlockConfig === "undefined" ? "undefined" : _typeof(currentBlockConfig)) === 'object' && currentBlockConfig !== null) {
Object.keys(currentBlockConfig).map(function (attribute) {
if (typeof attributes[attribute] === 'boolean') {
attributes[attribute] = !!currentBlockConfig[attribute];
} else {
attributes[attribute] = currentBlockConfig[attribute];
}
});
}
// Finally set changed attribute to true, so we don't modify anything again
setAttributes({ changed: true });
}
}
}, {
key: "componentDidMount",
value: function componentDidMount() {
var _props2 = this.props,
attributes = _props2.attributes,
setAttributes = _props2.setAttributes,
clientId = _props2.clientId;
if (!attributes.mapID) {
setAttributes({ mapID: 'advgbmap-' + clientId });
}
this.initMap();
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps, prevState) {
var _prevProps$attributes = prevProps.attributes,
prevAddr = _prevProps$attributes.address,
prevUseLatLng = _prevProps$attributes.useLatLng;
var _props$attributes = this.props.attributes,
address = _props$attributes.address,
useLatLng = _props$attributes.useLatLng;
if (prevAddr !== address || prevUseLatLng !== useLatLng || prevState !== this.state) return null;
if (prevProps.attributes !== this.props.attributes) {
clearTimeout(mapWillUpdate);
mapWillUpdate = setTimeout(this.initMap, 1000);
}
}
}, {
key: "initMap",
value: function initMap() {
if (typeof google === "undefined" || !this.props.attributes.mapID) return null;
var DEFAULT_MARKER = 'https://maps.gstatic.com/mapfiles/api-3/images/spotlight-poi2.png';
var _state = this.state,
currentMap = _state.currentMap,
currentMarker = _state.currentMarker,
currentInfo = _state.currentInfo,
invalidStyle = _state.invalidStyle;
var _props$attributes2 = this.props.attributes,
mapID = _props$attributes2.mapID,
lat = _props$attributes2.lat,
lng = _props$attributes2.lng,
zoom = _props$attributes2.zoom,
markerTitle = _props$attributes2.markerTitle,
markerIcon = _props$attributes2.markerIcon,
markerDesc = _props$attributes2.markerDesc,
mapStyle = _props$attributes2.mapStyle,
mapStyleCustom = _props$attributes2.mapStyleCustom;
var location = { lat: parseFloat(lat), lng: parseFloat(lng) };
var that = this;
var formattedDesc = markerDesc.replace(/\n/g, '
');
var map = currentMap;
var marker = currentMarker;
var infoWindow = currentInfo;
var customStyleParsed = '';
if (mapStyle === 'custom') {
try {
customStyleParsed = JSON.parse(mapStyleCustom);
if (invalidStyle) that.setState({ invalidStyle: false });
} catch (e) {
that.setState({ invalidStyle: true });
}
}
if (!map) {
map = new google.maps.Map(document.getElementById(mapID), {
zoom: zoom,
center: location,
gestureHandling: 'cooperative'
});
this.setState({ currentMap: map });
}
map.setCenter(location);
map.setZoom(zoom);
map.setOptions({ styles: !!mapStyle ? mapStyle !== 'custom' ? MAP_STYLES[mapStyle] : customStyleParsed : undefined });
if (!infoWindow) {
infoWindow = new google.maps.InfoWindow({
content: "
" + (formattedDesc || '') + "
\n" + (formattedDesc || '') + "
\n' + formattedDesc + '
' + '' + formattedDesc + '
' + '" + (formattedDesc || '') + "