From 25925c11002dadaa090c4fcd4e58613722199cd5 Mon Sep 17 00:00:00 2001 From: Jon Uhlmann Date: Sun, 24 Dec 2023 20:53:21 +0100 Subject: [PATCH] Update: Render files --- Resources/Public/Modules/Methods.js | 2 +- Resources/Public/Plugin/Metadata.js | 2 +- Resources/Public/Scripts/Complete.js | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 Resources/Public/Scripts/Complete.js diff --git a/Resources/Public/Modules/Methods.js b/Resources/Public/Modules/Methods.js index a896df7..e498e59 100644 --- a/Resources/Public/Modules/Methods.js +++ b/Resources/Public/Modules/Methods.js @@ -1 +1 @@ -function i(e){e.magic("prettyembedPause",()=>s),e.magic("prettyembedReset",()=>a)}window.addEventListener("prettyembedReset",({detail:e})=>a(e));window.addEventListener("prettyembedPause",({detail:e})=>s(e));function a(e){return d(e).forEach(n=>{let t=Alpine.$data(n);typeof t.reset=="function"&&t.reset()})}function s(e){return d(e).forEach(n=>{let t=Alpine.$data(n);typeof t.pause=="function"&&t.pause(!0)})}var o="jonnitto-prettyembed";function d(e){if(typeof e=="string"){let n=f(e),t=[];return[...document.querySelectorAll(n)].forEach(u=>{t=[...t,...r(u)]}),t}return r(e)}var c=["youtube","vimeo","video","audio"];function f(e){let n=e.toLowerCase();return c.includes(n)?`.${o}--${n}`:e}function r(e){if(!(e instanceof Element))e=document;else if(e.classList.contains(o))return[e];return[...e.querySelectorAll(`.${o}`)]}window.addEventListener("alpine:init",()=>{window.Alpine.plugin(i)}); +function a(e){e.magic("prettyembedPause",()=>s),e.magic("prettyembedReset",()=>d),e.magic("prettyembedPlay",()=>u)}window.addEventListener("prettyembedReset",({detail:e})=>d(e));window.addEventListener("prettyembedPause",({detail:e})=>s(e));window.addEventListener("prettyembedPlay",({detail:e})=>u(e));function d(e){return o(e).forEach(n=>{let t=Alpine.$data(n);typeof t.reset=="function"&&t.reset()})}function s(e){return o(e).forEach(n=>{let t=Alpine.$data(n);typeof t.pause=="function"&&t.pause(!0)})}function u(e){return o(e).every(n=>{let t=Alpine.$data(n);return typeof t.play=="function"?(t.play(),!1):!0})}var r="jonnitto-prettyembed";function o(e){if(typeof e=="string"){let n=l(e),t=[];return[...document.querySelectorAll(n)].forEach(c=>{t=[...t,...i(c)]}),t}return i(e)}var f=["youtube","vimeo","video","audio"];function l(e){let n=e.toLowerCase();return f.includes(n)?`.${r}--${n}`:e}function i(e){if(!(e instanceof Element))e=document;else if(e.classList.contains(r))return[e];return[...e.querySelectorAll(`.${r}`)]}window.addEventListener("alpine:init",()=>{window.Alpine.plugin(a)}); diff --git a/Resources/Public/Plugin/Metadata.js b/Resources/Public/Plugin/Metadata.js index 02c4f1b..594b0b0 100644 --- a/Resources/Public/Plugin/Metadata.js +++ b/Resources/Public/Plugin/Metadata.js @@ -1 +1 @@ -(()=>{var W=Object.create;var m=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var X=(t,e)=>()=>(t&&(e=t(t=0)),e);var u=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var B=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of x(e))!Z.call(t,r)&&r!==o&&m(t,r,{get:()=>e[r],enumerable:!(i=O(e,r))||i.enumerable});return t};var g=(t,e,o)=>(o=t!=null?W(N(t)):{},B(e||!t||!t.__esModule?m(o,"default",{value:t,enumerable:!0}):o,t));function a(t){return(...e)=>{if(window["@Neos:HostPluginAPI"]&&window["@Neos:HostPluginAPI"][`@${t}`])return window["@Neos:HostPluginAPI"][`@${t}`](...e);throw new Error("You are trying to read from a consumer api that hasn't been initialized yet!")}}var p=X(()=>{});var y=u((st,h)=>{p();h.exports=a("vendor")().React});var A=u((at,I)=>{p();I.exports=a("NeosProjectPackages")().NeosUiDecorators});p();var f=a("manifest");var n=g(y(),1),w=g(A(),1);var d={propertyValue:"jonnitto-prettyembed-00i6NG-propertyValue",propertyLabel:"jonnitto-prettyembed-00i6NG-propertyLabel",infoView:"jonnitto-prettyembed-00i6NG-infoView","--space-between":"--jonnitto-prettyembed-00i6NG-space-between"};var v=(0,w.neos)(t=>({i18nRegistry:t.get("i18n")}));function V(t){let{value:e,options:o,i18nRegistry:i}=t,r=Object.entries(o).map(([s,c])=>{let l=e[s];if(!l)return null;let G=s==="duration"?Y(l):null;return{label:i.translate(c+".label"),value:i.translate(c+".value",l,[l,G])}}).filter(s=>!!s);return r.length?n.default.createElement("dl",{className:d.infoView},r.map(({label:s,value:c})=>n.default.createElement(n.Fragment,null,n.default.createElement("dt",{className:d.propertyLabel},s),n.default.createElement("dd",{className:d.propertyValue,dangerouslySetInnerHTML:{__html:c}})))):n.default.createElement("div",null,i.translate("Jonnitto.PrettyEmbedHelper:NodeTypes.Mixin.Metadata:noMetadataSet"))}var Y=t=>{let e=s=>`0${s}`.slice(-2),o=~~(t/3600),i=~~(t%3600/60),r=t%60;return o?`${o}:${e(i)}:${e(r)}`:i?`${i}:${e(r)}`:r},C=v(V);f("Jonnitto.PrettyEmbed:Metadata",{},t=>{t.get("inspector").get("editors").set("Jonnitto.PrettyEmbed/Metadata",{component:C})});})(); +(()=>{var W=Object.create;var m=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var X=(t,e)=>()=>(t&&(e=t(t=0)),e);var u=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var B=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of x(e))!Z.call(t,r)&&r!==o&&m(t,r,{get:()=>e[r],enumerable:!(i=O(e,r))||i.enumerable});return t};var g=(t,e,o)=>(o=t!=null?W(N(t)):{},B(e||!t||!t.__esModule?m(o,"default",{value:t,enumerable:!0}):o,t));function a(t){return(...e)=>{if(window["@Neos:HostPluginAPI"]&&window["@Neos:HostPluginAPI"][`@${t}`])return window["@Neos:HostPluginAPI"][`@${t}`](...e);throw new Error("You are trying to read from a consumer api that hasn't been initialized yet!")}}var p=X(()=>{});var y=u((st,h)=>{p();h.exports=a("vendor")().React});var A=u((at,I)=>{p();I.exports=a("NeosProjectPackages")().NeosUiDecorators});p();var f=a("manifest");var n=g(y(),1),w=g(A(),1);var d={infoView:"jonnitto-prettyembed-00i6NG-infoView",propertyLabel:"jonnitto-prettyembed-00i6NG-propertyLabel","--space-between":"--jonnitto-prettyembed-00i6NG-space-between",propertyValue:"jonnitto-prettyembed-00i6NG-propertyValue"};var v=(0,w.neos)(t=>({i18nRegistry:t.get("i18n")}));function V(t){let{value:e,options:o,i18nRegistry:i}=t,r=Object.entries(o).map(([s,c])=>{let l=e[s];if(!l)return null;let G=s==="duration"?Y(l):null;return{label:i.translate(c+".label"),value:i.translate(c+".value",l,[l,G])}}).filter(s=>!!s);return r.length?n.default.createElement("dl",{className:d.infoView},r.map(({label:s,value:c})=>n.default.createElement(n.Fragment,null,n.default.createElement("dt",{className:d.propertyLabel},s),n.default.createElement("dd",{className:d.propertyValue,dangerouslySetInnerHTML:{__html:c}})))):n.default.createElement("div",null,i.translate("Jonnitto.PrettyEmbedHelper:NodeTypes.Mixin.Metadata:noMetadataSet"))}var Y=t=>{let e=s=>`0${s}`.slice(-2),o=~~(t/3600),i=~~(t%3600/60),r=t%60;return o?`${o}:${e(i)}:${e(r)}`:i?`${i}:${e(r)}`:r},C=v(V);f("Jonnitto.PrettyEmbed:Metadata",{},t=>{t.get("inspector").get("editors").set("Jonnitto.PrettyEmbed/Metadata",{component:C})});})(); diff --git a/Resources/Public/Scripts/Complete.js b/Resources/Public/Scripts/Complete.js new file mode 100644 index 0000000..5e6bfe5 --- /dev/null +++ b/Resources/Public/Scripts/Complete.js @@ -0,0 +1 @@ +(()=>{function V(t){t.directive("prettyembedconsent",(e,{value:i})=>{if(i==="accept"){K({element:e,Alpine:t});return}z({element:e,Alpine:t})})}function z({element:t,Alpine:e}){e.bind(t,{"x-show"(){return this.gdpr=="isOpen"},"x-transition.opacity"(){}})}function K({element:t,Alpine:e}){e.bind(t,{"@click"(i){i.preventDefault(),this.acceptGdpr()}})}var A=!1,I=!1;function x(t,e){let i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("defer",!0),i.setAttribute("src",t),typeof e=="function"&&i.addEventListener("load",e),document.head.appendChild(i)}function D(t){let e=()=>{P(()=>window.Vimeo,t)};if(I){e();return}I=!0,x("https://player.vimeo.com/api/player.js",e)}function C(t){let e=()=>{P(()=>window.YT?.loaded,t)};if(A){e();return}A=!0,x("https://www.youtube.com/iframe_api",e)}function J(t,e){let i=window.requestAnimationFrame,s=Date.now(),o=!1,a=()=>{Date.now()-so=!0}}function P(t,e,i=100){if(!(typeof t!="function"&&typeof e!="function"||i<=0)){if(t()){e();return}i--,J(()=>P(t,e,i),100)}}function v(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement}var j="prettyembed",B="/_Resources/Static/Packages/Jonnitto.PrettyEmbedHelper/Scripts/Hls.js?v=1.4.13";function Y(t){t.directive("prettyembedmedia",(e,{value:i,modifiers:s,expression:o},{evaluate:a})=>{if(i==="media"){X({element:e,Alpine:t,src:o});return}let d=s.includes("streaming"),n=s.includes("lightbox")?"lightbox":"inline",l={streaming:d,style:n,...a(o||"{}")};Q({element:e,Alpine:t,options:l})})}function Q({element:t,Alpine:e,options:i}){let{style:s,streaming:o}=i,a={type:null,playing:!1,url:null,id:null,autoplay:!1,loaded:!1,lightbox:s==="lightbox"?!1:null,__media:null},d=o?!Z():null;e.bind(t,{"x-data"(){return{...a,play(){if(this.lightbox!==null&&(this.lightbox=!0),!!this.__media?.paused){if(!this.loaded&&o){if(d){if(this.lightbox){setTimeout(()=>{k(this.__media,this.url)},500);return}k(this.__media,this.url);return}this.__media.src=this.url}if(this.lightbox){setTimeout(()=>{this.__media?.play()},500);return}this.__media?.play()}},pause(n=!1){n&&(this.autoplay||this.__media?.muted)||this.__media?.paused||this.__media?.pause()},reset(){this.autoplay||(this.pause(),this.__media?.currentTime&&(this.__media.currentTime=0),this.loaded=!1)},toogle(){if(this.__media.paused){this.play();return}this.pause()},dispatchEvent(n){let l=this.__media.currentTime;l===this.__media.duration&&(n="finished",!this.__media.loop&&!this.lightbox&&!v()&&this.reset()),this.$dispatch(j,{detail:{event:n,currentTime:l,type:this.type,style:s,autoplay:this.autoplay,url:this.url,id:this.id}})},init(){s==="lightbox"&&this.$watch("lightbox",(n,l)=>{!n&&n!==l&&this.pause()})}}},"@prettyembedPauseInternal.window"({detail:n}){n!=this.$root&&this.pause(!0)}})}function X({element:t,Alpine:e,src:i}){let o=t.tagName.toLowerCase()==="video"?"Video":"Audio";e.bind(t,{"x-init"(){this.__media=t,this.url=i||t.currentSrc,this.id=this.url.split("/").pop(),this.autoplay=t.autoplay,this.type=o},"@play"(){this.loaded||(this.loaded=!0),this.playing=!0,!this.autoplay&&!this.muted&&(this.$dispatch("prettyembedPauseInternal",this.$root),this.dispatchEvent("play"))},"@pause"(){this.playing=!1,this.autoplay=!1,this.muted||this.dispatchEvent("pause")}})}function Z(){return!!document.createElement("video").canPlayType("application/vnd.apple.mpegurl")}function k(t,e){if(typeof Hls<"u"){L(t,e);return}x(B,()=>{setTimeout(()=>L(t,e),10)})}function L(t,e){if(!Hls.isSupported())return;let i=new Hls;i.loadSource(e),i.attachMedia(t),i.on(Hls.Events.MEDIA_ATTACHED,()=>t.play())}function F(t){t.magic("prettyembedPause",()=>N),t.magic("prettyembedReset",()=>G),t.magic("prettyembedPlay",()=>R)}window.addEventListener("prettyembedReset",({detail:t})=>G(t));window.addEventListener("prettyembedPause",({detail:t})=>N(t));window.addEventListener("prettyembedPlay",({detail:t})=>R(t));function G(t){return E(t).forEach(e=>{let i=Alpine.$data(e);typeof i.reset=="function"&&i.reset()})}function N(t){return E(t).forEach(e=>{let i=Alpine.$data(e);typeof i.pause=="function"&&i.pause(!0)})}function R(t){return E(t).every(e=>{let i=Alpine.$data(e);return typeof i.play=="function"?(i.play(),!1):!0})}var S="jonnitto-prettyembed";function E(t){if(typeof t=="string"){let e=et(t),i=[];return[...document.querySelectorAll(e)].forEach(s=>{i=[...i,...H(s)]}),i}return H(t)}var tt=["youtube","vimeo","video","audio"];function et(t){let e=t.toLowerCase();return tt.includes(e)?`.${S}--${e}`:t}function H(t){if(!(t instanceof Element))t=document;else if(t.classList.contains(S))return[t];return[...t.querySelectorAll(`.${S}`)]}function M(t){t.directive("prettyembedpopup",(e,{expression:i},{evaluate:s})=>{let o=window.getComputedStyle(e).getPropertyValue("--aspect-ratio")||"16 / 9",{ratio:a}=s(`{ratio:${o}}`),d=i||e.href;t.bind(e,{"@click"(n){n.preventDefault();let l=Math.min(window.innerWidth,1260),h=l/a,w=(screen.width-l)/2,g=(screen.height-h)/2;window.open(d,"_blank",`noopener=yes,directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=${l},height=${h},left=${w},top=${g}`)}})})}var O="prettyembed";function q(t){t.directive("prettyembedvimeo",(e,{modifiers:i,expression:s},{evaluate:o})=>{let a=i.includes("lightbox")?"lightbox":"inline",d=i.includes("slim"),n={style:a,slim:d,...o(s||"{}")};it({element:e,Alpine:t,options:n})})}function it({element:t,Alpine:e,options:i}){let s="Vimeo",{style:o,slim:a,video:d,color:n,loop:l,gdpr:h,background:w}=i,g={id:d,autopip:!0,autoplay:!0,pip:!0,portrait:!1,responsive:!1,title:!1,byline:!1,background:!!w,loop:!!l,autopause:!1,controls:!a};n&&(g.color=n);let _=window.localStorage,u=`jonnittoprettyembed_gdpr_${s.toLowerCase()}`,c={loaded:!1,playing:!1,lightbox:o==="lightbox"?!1:null,gdpr:h&&_.getItem(u)!=="true"?"needCheck":"isAccepted"},r=null;e.bind(t,{"x-data"(){return{...c,init(){this.lightbox!==null&&this.$watch("lightbox",(p,f)=>{!p&&p!==f&&this.pause()})},acceptGdpr(){_.setItem(u,"true"),this.$dispatch("prettyembedAcceptGdpr",s),this.load()},play(){r?.play()},pause(){r?.pause()},load(p){if(p&&p.preventDefault(),this.gdpr!="isAccepted"){this.gdpr="isOpen";return}if(this.lightbox!==null&&(this.lightbox=!0),this.loaded){this.play();return}D(()=>{let f=this.$refs?.vimeo||t;r=new Vimeo.Player(f,g);let y=async m=>{let $=[r.getVideoTitle(),r.getVideoId(),r.getVideoUrl(),r.getCurrentTime(),r.getEnded()],b=await Promise.allSettled($);return b[4].value&&(m="finished",!l&&!this.lightbox&&!v()&&this.reset()),{event:m,type:s,style:o,title:b[0].value,videoID:b[1].value,videoUrl:b[2].value,currentTime:b[3].value}};r.on("play",async()=>{let m=await y("play");this.$dispatch("prettyembedPauseInternal",t),this.loaded=!0,this.playing=!0,this.$dispatch(O,m)}),r.on("pause",async()=>{let m=await y("pause");this.playing=!1,this.$dispatch(O,m)})})},async reset(){r&&(await this.pause(),await r.destroy(),r=null,this.loaded=!1,this.playing=!1)}}},"@prettyembedAcceptGdpr.window"({detail:p}){p==s&&(this.gdpr="isAccepted")},"@prettyembedPauseInternal.window"({detail:p}){p!=this.$root&&this.pause()}})}var T="prettyembed";function U(t){t.directive("prettyembedyoutube",(e,{modifiers:i,expression:s},{evaluate:o})=>{let a=i.includes("lightbox")?"lightbox":"inline",n={slim:i.includes("slim"),style:a,...o(s||"{}")};st({element:e,Alpine:t,options:n})})}function st({element:t,Alpine:e,options:i}){let s="YouTube",{video:o,playlist:a,style:d,slim:n,loop:l}=i,h={playerVars:{autoplay:1,modestbranding:1,playsinline:1,rel:0,showinfo:0,controls:n?0:1,loop:l?1:0}};o&&(h.videoId=o),a&&(a.startsWith("PL")||(a="PL"+a),h.playerVars.listType="playlist",h.playerVars.list=a);let w=window.localStorage,g=`jonnittoprettyembed_gdpr_${s.toLowerCase()}`,_={title:i.title,loaded:!1,playing:!1,lightbox:d==="lightbox"?!1:null,gdpr:i.gdpr&&w.getItem(g)!=="true"?"needCheck":"isAccepted"},u=null;e.bind(t,{"x-data"(){return{..._,init(){this.ligtbox!==null&&this.$watch("lightbox",(c,r)=>{!c&&c!==r&&this.pause()})},acceptGdpr(){w.setItem(g,"true"),this.$dispatch("prettyembedAcceptGdpr",s),this.load()},play(){u?.playVideo()},pause(){u?.pauseVideo()},load(c){if(c&&c.preventDefault(),this.gdpr!="isAccepted"){this.gdpr="isOpen";return}if(this.lightbox!==null&&(this.lightbox=!0),this.loaded){this.play();return}C(()=>{let r=this.$refs?.youtube||t,p=()=>{let f=u.getVideoUrl(),{title:y,author:m,video_id:$,video_quality:b,list:W}=u.getVideoData();return{type:s,style:d,title:y,author:m,videoUrl:f,videoID:$,quality:b,playlistID:W||null}};u=new YT.Player(r,{...h,events:{onStateChange:({data:f})=>{let y=u.getCurrentTime();if(f===YT.PlayerState.PLAYING){this.$dispatch("prettyembedPauseInternal",t),this.loaded=!0,this.playing=!0,this.$dispatch(T,{event:"play",currentTime:y,...p()});return}if(f===YT.PlayerState.PAUSED){this.playing=!1,this.$dispatch(T,{event:"pause",currentTime:y,...p()});return}f===YT.PlayerState.ENDED&&(this.playing=!1,!l&&!this.lightbox&&!v()&&this.reset(),this.$dispatch(T,{event:"finished",currentTime:y,...p()}))}}})})},reset(){u&&(u?.stopVideo(),u.destroy(),u=null,this.loaded=!1,this.playing=!1)}}},"@prettyembedAcceptGdpr.window"({detail:c}){c==s&&(this.gdpr="isAccepted")},"@prettyembedPauseInternal.window"({detail:c}){c!=this.$root&&this.pause()}})}window.addEventListener("alpine:init",()=>{window.Alpine.plugin([V,Y,F,M,q,U])});})();