OwlCyberSecurity - MANAGER
Edit File: elfsight-block.js
/* Elfsight Contact Form Version: 2.2.0 Release date: Wed Jul 24 2019 https://elfsight.com Copyright (c) 2019 Elfsight, LLC. ALL RIGHTS RESERVED */ !function(wp,$){"use strict";let IconBlock=function(t){return wp.element.createElement("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",width:"20",height:"20",viewBox:"0 0 20 20",class:"dashicon"},[wp.element.createElement("path",{id:"a",d:"M14.21 4.179l-3.912 2.259a.524.524 0 0 1-.292.07.524.524 0 0 1-.291-.07L5.789 4.172v3.826c0 .234.19.423.424.423h7.574c.234 0 .424-.19.424-.423V4.179zm-.008-1.21a.423.423 0 0 0-.415-.337H6.213a.423.423 0 0 0-.413.33l4.206 2.429 4.196-2.422zM4.85 0h10.3c.934 0 1.692.758 1.692 1.692v16.616c0 .934-.758 1.692-1.692 1.692H4.85a1.692 1.692 0 0 1-1.692-1.692V1.692C3.158.758 3.916 0 4.85 0zm-.113 11.053v6.522c0 .467.379.846.846.846h8.834a.846.846 0 0 0 .846-.846v-6.522H4.737zm2.368 1.579h5.79a.79.79 0 0 1 0 1.579h-5.79a.79.79 0 1 1 0-1.58zm0 2.631h5.79a.79.79 0 1 1 0 1.58h-5.79a.79.79 0 1 1 0-1.58z"})])};if(void 0===wp.components||void 0===wp.blocks||void 0===wp.element||void 0===wp.i18n)return!1;const{__:__}=wp.i18n,el=wp.element.createElement,registerBlockType=wp.blocks.registerBlockType,ServerSideRender=wp.components.ServerSideRender;let initTimeout;function initWidget(){clearTimeout(initTimeout),initTimeout=setTimeout(function(){let widgets=document.querySelectorAll("[data-elfsight-contact-form-options]");Array.prototype.slice.call(widgets).forEach(function(widget){let options=widget.getAttribute("data-elfsight-contact-form-options"),data=JSON.parse(decodeURIComponent(options));eval("eappsContactForm(widget, data)"),widget.removeAttribute("data-elfsight-contact-form-options"),widget.removeAttribute("data-elfsight-contact-form-version"),widget.closest(".elfsight-block-widget-container").classList.add("elfsight-block-widget-initialized")})},1500)}async function getWidgets(){const t=await $.get(ajaxurl,{action:"elfsight-contact-form".replace(/-/g,"_")+"_widgets_api",endpoint:"list"});return t.status?[t.data,t.data.reduce(function(t,e){return t[e.id]=e,t},{})]:[]}function getWidgetId(t){let e;return t.some(function(t){if("1"===t.active)return e=t.id}),e}class Widget extends React.Component{componentDidMount(){initWidget()}componentDidUpdate(){initWidget()}render(){return this.props.id?el("div",{className:"elfsight-block-widget-container"},el(ServerSideRender,{block:"elfsight-contact-form/block",attributes:{id:this.props.id||"1"}}),el("div",{className:"elfsight-block-widget-placeholder"},el(IconBlock,{}),el("span",{},"Elfsight Contact Form"))):[]}}class Button extends React.Component{render(){let t=document.location.origin+document.location.pathname.replace("post.php","admin.php")+"?page=elfsight-contact-form#";return el("a",{href:t+this.props.href,target:"_blank",className:this.props.className},this.props.text)}}class WidgetSelect extends React.Component{constructor(){super(),this.state={widgets:[]}}setWidget(t){t.preventDefault();let e=t.target.querySelector("option:checked");this.props.setAttributes({id:e.value.toString()})}componentDidMount(){getWidgets().then(t=>{const[e,i]=t;this.setState({widgets:e});const o=this.props.id,s=!(!i[o]||"1"!==i[o].active);!s&&i?this.props.setAttributes({id:getWidgetId(e),exist:!0}):this.props.setAttributes({id:o,exist:s})})}render(){return this.state.widgets.length>0?el("div",{className:"components-base-control"},el("div",{className:"components-base-control__field"},el("select",{className:"components-select-control__input",id:"elfsight-contact-form-block-control-id",value:this.props.id,onChange:this.setWidget.bind(this)},this.state.widgets.map(t=>wp.element.createElement("option",{value:t.id},[t.name]))))):[]}}registerBlockType("elfsight-contact-form/block",{title:"Elfsight Contact Form",description:"Get more leads and feedback with easy-to-fill contact form",icon:{src:IconBlock},category:"widgets",keywords:["Elfsight Contact Form","Elfsight"],supports:{html:!1},attributes:{id:{type:"number"},exist:{type:"bool",default:!1}},edit:function(t){const{attributes:{id:e,exist:i},setAttributes:o}=t;return getWidgets().then(t=>{const[s,n]=t;o(!i&&s?{id:getWidgetId(s),exist:!0}:{id:e,exist:i})}),el(wp.element.Fragment,{},el(wp.editor.InspectorControls,{},el(wp.components.PanelBody,{className:"elfsight-block-panel",title:"Select widget"},el(WidgetSelect,{id:e,setAttributes:function(e){t.setAttributes(e)}}),i?el("div",{className:"elfsight-block-panel-group"},el(Button,{href:"/edit-widget/"+e,className:"components-button is-button is-default is-large elfsight-block-panel-button",text:__("Edit Widget")}),el(Button,{href:"/add-widget/",className:"elfsight-block-panel-link",text:__("Create new widget")})):el("div",{className:"elfsight-block-panel-group"},el("span",{},__("No widgets yet")),el(Button,{href:"/add-widget/",className:"components-button is-button is-default is-primary is-large elfsight-block-panel-button",text:__("Create Widget")})))),i?el(Widget,{id:e,exist:i}):null,i?null:el("div",{className:"elfsight-block-form"},el("div",{className:"elfsight-block-form-header"},el(IconBlock,{}),el("span",{},"Elfsight Contact Form")),el("div",{className:"elfsight-block-form-text"},__("Get more leads and feedback with easy-to-fill contact form"),el("br"),el("strong",{},__("Let's create your first widget!"))),el(Button,{href:"/add-widget/",className:"components-button is-button is-default is-primary is-large elfsight-block-form-button",text:__("Create Widget")})))},save:function(){return null}})}(wp,jQuery);