wp_back/wp-content/plugins/visual-portfolio/build/gutenberg/custom-post-meta.js
2024-05-20 15:37:46 +03:00

1 line
6.0 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

!function(){"use strict";var e={n:function(t){var o=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(o,{a:o}),o},d:function(t,o){for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t=window.wp.element,o=window.jQuery,n=e.n(o);var a=window.wp.components,r=window.wp.compose,i=window.wp.data,l=window.wp.editPost,s=window.wp.i18n,d=window.wp.plugins;const{ajaxurl:u,VPGutenbergMetaVariables:p}=window;class c extends t.Component{constructor(e){var t,o,n,a,r,i,l,s;super(e),this.state={oembedQuery:"",oembedHTML:""},this.maybePrepareOembed=(t=300,r=this.maybePrepareOembed.bind(this),i=[],l=null,s=function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];i=t,l||(l=requestAnimationFrame((function(){l=null,r.apply(void 0,i)})))},s.cancel=function(){l&&(cancelAnimationFrame(l),l=null)},o=s,a=(n||{}).atBegin,function(e,t,o){var n,a=o||{},r=a.noTrailing,i=void 0!==r&&r,l=a.noLeading,s=void 0!==l&&l,d=a.debounceMode,u=void 0===d?void 0:d,p=!1,c=0;function m(){n&&clearTimeout(n)}function v(){for(var o=arguments.length,a=new Array(o),r=0;r<o;r++)a[r]=arguments[r];var l=this,d=Date.now()-c;function v(){c=Date.now(),t.apply(l,a)}function f(){n=void 0}p||(s||!u||n||v(),m(),void 0===u&&d>e?s?(c=Date.now(),i||(n=setTimeout(u?f:v,e))):v():!0!==i&&(n=setTimeout(u?f:v,void 0===u?e-d:e)))}return v.cancel=function(e){var t=(e||{}).upcomingOnly,o=void 0!==t&&t;m(),p=!o},v}(t,o,{debounceMode:!1!==(void 0!==a&&a)}))}componentDidMount(){this.maybePrepareOembed()}componentDidUpdate(){this.maybePrepareOembed()}maybePrepareOembed(){const{oembedQuery:e,oembedHTML:t}=this.state,{getMeta:o,postFormat:a}=this.props;if("video"!==a)return;const r=o("_vp_format_video_url");e!==r&&(this.oembedAjax&&this.oembedAjax.abort&&this.oembedAjax.abort(),e||!t?this.oembedAjax=n().ajax({url:u,method:"POST",dataType:"json",data:{action:"vp_find_oembed",q:r,nonce:p.nonce},complete:e=>{const t=e.responseJSON,o={oembedQuery:r,oembedHTML:""};t&&void 0!==t.html&&(o.oembedHTML=t.html),this.setState(o),this.oembedAjax=null}}):this.setState({oembedHTML:""}))}render(){const{getMeta:e,postFormat:o,updateMeta:n}=this.props,{oembedHTML:r}=this.state;return"video"!==o?null:(0,t.createElement)(l.PluginDocumentSettingPanel,{name:"VPVideo",title:(0,s.__)("Video","visual-portfolio"),icon:(0,t.createElement)("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,t.createElement)("path",{d:"M19.25 10C19.25 15.1086 15.1086 19.25 10 19.25C4.89137 19.25 0.75 15.1086 0.75 10C0.75 4.89137 4.89137 0.75 10 0.75C15.1086 0.75 19.25 4.89137 19.25 10Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"transparent"}),(0,t.createElement)("path",{d:"M8 12.6326V7.36671C8.00011 7.30082 8.01856 7.23618 8.05342 7.17955C8.08828 7.12293 8.13826 7.0764 8.19812 7.04485C8.25798 7.0133 8.32552 6.99789 8.39367 7.00023C8.46181 7.00257 8.52805 7.02258 8.58544 7.05816L12.8249 9.69035C12.8786 9.72358 12.9228 9.76933 12.9534 9.82337C12.984 9.87742 13 9.93803 13 9.99963C13 10.0612 12.984 10.1218 12.9534 10.1759C12.9228 10.2299 12.8786 10.2757 12.8249 10.3089L8.58544 12.9418C8.52805 12.9774 8.46181 12.9974 8.39367 12.9998C8.32552 13.0021 8.25798 12.9867 8.19812 12.9551C8.13826 12.9236 8.08828 12.8771 8.05342 12.8204C8.01856 12.7638 8.00011 12.6992 8 12.6333V12.6326Z",fill:"currentColor"})),className:"vpf-meta-video-panel"},(0,t.createElement)(a.PanelRow,null,(0,t.createElement)("p",{className:"description"},(0,s.sprintf)((0,s.__)("Video will be used in %s layouts only. Full list of supported links","visual-portfolio"),p.plugin_name)," ",(0,t.createElement)("a",{href:"https://visualportfolio.co/docs/projects/video-project/#supported-video-vendors",target:"_blank",rel:"noopener noreferrer"},(0,s.__)("see here","visual-portfolio")))),(0,t.createElement)(a.PanelRow,null,(0,t.createElement)(a.TextControl,{label:(0,s.__)("Video URL","visual-portfolio"),value:e("_vp_format_video_url")||"",onChange:e=>{n("_vp_format_video_url",e)},type:"url",placeholder:"https://"})),(0,t.createElement)(a.PanelRow,null,(0,t.createElement)("div",{className:"vp-oembed-preview",dangerouslySetInnerHTML:{__html:r}})))}}const m=(0,r.compose)([(0,i.withSelect)((e=>({getMeta(t){return(e("core/editor").getEditedPostAttribute("meta")||{})[t]},postFormat:e("core/editor").getEditedPostAttribute("format")}))),(0,i.withDispatch)((e=>({updateMeta(t,o){e("core/editor").editPost({meta:{[t]:o}})}}))),r.withInstanceId])(c);wp.editPost&&(0,d.registerPlugin)("vp-video",{render:m});var v=window.wp.hooks;const f=a.UnitControl||a.__experimentalUnitControl;class w extends t.Component{render(){const{getMeta:e,featuredImageId:o,updateMeta:n}=this.props;if(!o)return null;let r=e("_vp_image_focal_point");return r&&r.x&&r.y||(r={x:.5,y:.5}),(0,t.createElement)("div",{className:"vpf-post-image-focal-point-panel"},(0,t.createElement)(a.PanelRow,null,(0,t.createElement)("p",{className:"description"},(0,s.__)("Focal point will be used in Visual Portfolio layouts only:","visual-portfolio"))),(0,t.createElement)(a.PanelRow,null,(0,t.createElement)(f,{label:(0,s.__)("Left","visual-portfolio"),value:100*r.x+"%",onChange:e=>{const t={...r};t.x=parseFloat(e)/100,n("_vp_image_focal_point",t)},min:0,max:100,step:1,units:[{value:"%",label:"%"}]}),(0,t.createElement)(f,{label:(0,s.__)("Top","visual-portfolio"),value:100*r.y+"%",onChange:e=>{const t={...r};t.y=parseFloat(e)/100,n("_vp_image_focal_point",t)},min:0,max:100,step:1,units:[{value:"%",label:"%"}]})))}}const h=(0,r.compose)([(0,i.withSelect)((e=>{const{getEditedPostAttribute:t}=e("core/editor"),o=t("featured_media"),n=t("meta")||{};return{featuredImageId:o,getMeta(e){return n[e]}}})),(0,i.withDispatch)((e=>({updateMeta(t,o){e("core/editor").editPost({meta:{[t]:o}})}}))),r.withInstanceId])(w);(0,v.addFilter)("editor.PostFeaturedImage","vpf/post-featured-image-focal-point",(e=>function(o){return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(e,{...o}),(0,t.createElement)(h,null))}))}();