Files
display-featured-image-genesis/includes/js/block.min.js
T
2019-06-23 17:39:57 -04:00

1 line
1.9 KiB
JavaScript

!function(e,t){"use strict";const n={el:e.element.createElement};n.init=function(t){const o=e.blocks.registerBlockType,l=e.components.ServerSideRender,r=e.editor.InspectorControls;o(t.block,{title:t.title,description:t.description,keywords:t.keywords,icon:t.icon,category:t.category,supports:{html:!1},getEditWrapperProps:({blockAlignment:e})=>({"data-align":e}),edit:o=>{const{attributes:i,setAttributes:s}=o,a=e.element.Fragment,c=e.editor.BlockControls,m=e.editor.BlockAlignmentToolbar;return[n.el(l,{block:t.block,attributes:i}),n.el(a,null,n.el(c,null,n.el(m,{value:i.blockAlignment,controls:["wide","full"],onChange:e=>{s({blockAlignment:e})}}))),n.el(r,{},function(t,o){const l=[],r=e.components.PanelBody;return Object.keys(o.panels).forEach(function(i,s){if(o.panels.hasOwnProperty(i)){const a=o.panels[i];l[s]=n.el(r,{title:a.title,initialOpen:a.initialOpen,className:"scriptless-panel-"+i},function(t,o){const l=[];return Object.keys(o).forEach(function(r,i){if(o.hasOwnProperty(r)){if(-1!==["blockAlignment","className"].indexOf(r))return;const s=o[r],a=function(t,n){const{TextControl:o,SelectControl:l,RangeControl:r,CheckboxControl:i,TextareaControl:s}=e.components,a=o;return"select"===t?l:"number"===t&&"number"===n?r:"checkbox"===t?i:"textarea"===t?s:a}(s.method,s.type);l[i]=n.el(a,function(e,t,n){const{attributes:o,setAttributes:l}=n,r={label:t.label,value:o[e],className:"displayfeaturedimagegenesis-"+e,onChange:t=>{l({[e]:t})}};return"select"===t.method?r.options=t.options:"number"===t.method?(r.min=t.min,r.max=t.max,"number"!==t.type?r.type="number":r.initialPosition=t.min):"checkbox"===t.method&&(r.checked=o[e]),r}(r,s,t))}}),l}(t,a.attributes))}}),l}(o,t))]},save:e=>null})},n.params="undefined"==typeof DisplayFeaturedImageBlock?"":DisplayFeaturedImageBlock,void 0!==n.params&&Object.keys(n.params).forEach(function(e,t){n.params.hasOwnProperty(e)&&n.init(n.params[e])})}(wp);