?AlkantarClanX12
| Current Path : /home/rankinh/saintgilleslesbains/wp-content/plugins/elfsight-weather-cc/assets/ |
| Current File : /home/rankinh/saintgilleslesbains/wp-content/plugins/elfsight-weather-cc/assets/elfsight-block.js |
/*
Weather
Version: 1.3.1
Release date: Fri Nov 12 2021
https://elfsight.com
Copyright (c) 2021 Elfsight, LLC. ALL RIGHTS RESERVED
*/
!function(wp,$){"use strict";let IconBlock=function(e){return wp.element.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",class:"dashicon"},[wp.element.createElement("path",{d:"M3.53 11.349a.599.599 0 0 1 .848-.012c.23.23.225.61-.013.847l-1.289 1.289a.599.599 0 0 1-.847.012.599.599 0 0 1 .013-.847l1.289-1.289zM2.4 7.309c.336 0 .608.264.608.59 0 .326-.272.59-.608.59H.577A.599.599 0 0 1-.03 7.9c0-.326.272-.59.607-.59H2.4zm1.965-3.694a.599.599 0 0 1 .013.847.599.599 0 0 1-.847-.012L2.24 3.16a.599.599 0 0 1-.012-.846.6.6 0 0 1 .847.012l1.29 1.29zm3.91-1.184a.599.599 0 0 1-.59.607.599.599 0 0 1-.59-.607V.608c0-.336.264-.608.59-.608.326 0 .59.272.59.608V2.43zm3.563 2.019a.599.599 0 0 1-.846.012.599.599 0 0 1 .012-.847l1.289-1.289a.599.599 0 0 1 .847-.012c.23.23.225.61-.013.847L11.838 4.45zm-5.017 6.88c-1.483-.393-2.578-1.78-2.578-3.43 0-1.957 1.54-3.544 3.442-3.544 1.397 0 2.6.857 3.14 2.09a3.673 3.673 0 0 0-1.466 3.179 3.535 3.535 0 0 0-2.538 1.707zM20 12.502c0 1.728-1.331 3.159-3.084 3.364l-7.161-.002c-1.363-.039-2.471-1.216-2.471-2.63 0-1.453 1.144-2.63 2.554-2.63.094 0 .14 0 .192.004a.622.622 0 0 1 .149.025l.442.152-.128-.461c-.107-.386-.158-.656-.158-.92 0-1.453 1.144-2.631 2.555-2.631 1.307 0 2.396 1.074 2.513 2.437l.028.32.295-.102a3.274 3.274 0 0 1 1.093-.202c1.76 0 3.181 1.451 3.181 3.276zm-8.443 4.9c.048-.275.333-.455.635-.402.302.054.508.32.46.595l-.353 1.995c-.048.276-.332.456-.635.402-.302-.053-.507-.32-.459-.595l.352-1.994zm2.901-.267c.049-.275.333-.455.635-.402.302.053.508.32.46.595l-.352 1.995c-.049.275-.333.455-.635.402-.303-.053-.508-.32-.46-.595l.352-1.995z"})])};if(void 0===wp.components||void 0===wp.blocks||void 0===wp.element||void 0===wp.i18n)return!1;const{Component:Component}=window.React,{__:__}=wp.i18n,el=wp.element.createElement,registerBlockType=wp.blocks.registerBlockType,ServerSideRender=wp.components.ServerSideRender,restApiUrl=window.wpApiSettings.root+"/elfsight-weather/admin",restApiNonce=window.wpApiSettings.nonce;let initTimeout;function initWidget(){clearTimeout(initTimeout),initTimeout=setTimeout(function(){const widgets=document.querySelectorAll("[data-elfsight-weather-options]");Array.prototype.slice.call(widgets).forEach(function(widget){const options=widget.getAttribute("data-elfsight-weather-options"),data=JSON.parse(decodeURIComponent(options));eval("eappsWeather(widget, data)"),widget.removeAttribute("data-elfsight-weather-options"),widget.removeAttribute("data-elfsight-weather-version"),widget.closest(".elfsight-block-widget-container").classList.add("elfsight-block-widget-initialized")})},1500)}async function getWidgets(){const e=await $.ajax({type:"GET",url:restApiUrl+"/widgets/list/",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",restApiNonce)}});return e.status?[e.data,e.data.reduce(function(e,t){return e[t.id]=t,e},{})]:[]}function getWidgetId(e){let t;return e.some(function(e){return"1"===e.active&&(t=parseInt(e.id),!0)}),t}class Widget extends Component{componentDidMount(){initWidget()}componentDidUpdate(){initWidget()}render(){const{id:e}=this.props;return e?el("div",{className:"elfsight-block-widget-container"},el(ServerSideRender,{block:"elfsight-weather/block",attributes:{id:e}}),el("div",{className:"elfsight-block-widget-placeholder"},el(IconBlock,{}),el("span",{},"Weather"))):null}}class Button extends Component{render(){const{href:e,className:t,text:i}=this.props,s=document.location.origin+document.location.pathname.replace("post.php","admin.php")+"?page=elfsight-weather#";return el("a",{href:s+e,target:"_blank",className:t},i)}}class WidgetSelect extends Component{constructor(){super(),this.state={widgets:[]}}setWidget(e){e.preventDefault();const{setAttributes:t}=this.props,i=e.target.querySelector("option:checked");t({id:parseInt(i.value)})}componentDidMount(){const{id:e,setAttributes:t}=this.props;getWidgets().then(i=>{const[s,n]=i;this.setState({widgets:s});const o=!(!n[e]||"1"!==n[e].active);t(!o&&n?{id:getWidgetId(s),exist:!0}:{id:e,exist:o})})}render(){const{widgets:e}=this.state,{id:t}=this.props;return e.length>0?el("div",{className:"components-base-control"},el("div",{className:"components-base-control__field"},el("select",{className:"components-select-control__input",id:"elfsight-weather-block-control-id",value:t,onChange:this.setWidget.bind(this)},e.map(({id:e,name:t})=>el("option",{value:e},t))))):null}}registerBlockType("elfsight-weather/block",{title:"Weather",description:"Weather for any location in a simple widget on your site.",icon:{src:IconBlock},category:"widgets",keywords:["Weather","Elfsight"],supports:{html:!1},attributes:{id:{type:"number"},exist:{type:"bool",default:!1}},edit:function(e){const{attributes:{id:t,exist:i},setAttributes:s}=e;return getWidgets().then(e=>{const[n,o]=e;s(!i&&n?{id:getWidgetId(n),exist:!0}:{id:t,exist:i})}),el(wp.element.Fragment,{},el(wp.editor.InspectorControls,{},el(wp.components.PanelBody,{className:"elfsight-block-panel",title:"Select widget"},el(WidgetSelect,{id:t,setAttributes:function(t){e.setAttributes(t)}}),i?el("div",{className:"elfsight-block-panel-group"},el(Button,{href:"/edit-widget/"+t,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:t,exist:i}):null,i?null:el("div",{className:"elfsight-block-form"},el("div",{className:"elfsight-block-form-header"},el(IconBlock,{}),el("span",{},"Weather")),el("div",{className:"elfsight-block-form-text"},__("Weather for any location in a simple widget on your site."),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);