PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 0.9.7
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v0.9.7
1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 0.8.7 All 34 releases
desktop-mode / assets / js / iframe-bridge.min.js

iframe-bridge.min.js in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 0.9.7, at assets/js/iframe-bridge.min.js

2 lines 8.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function(){"use strict";(function(){if(!window.parent||window.parent===window)return;const f=window;if(f.wp?.desktop?.iframe)return;const c=window.location.origin,g={},b=[],I={};let k=null;const E=[],O=n=>{if(!n||k===n)return;k=n;const e=E.splice(0);for(const o of e)try{o(n)}catch{}},M={},x=(n,e,o)=>{try{window.parent.postMessage({type:"desktop-mode-bridge-publish",connectionId:n,topic:e,payload:o},c)}catch{}};window.addEventListener("message",n=>{if(n.origin!==c)return;const e=n?.data;if(!(!e||typeof e!="object"||typeof e.type!="string")){if(e.type==="desktop-mode-bridge-handshake"&&typeof e.connectionId=="string"){const o=e.targetWindowId;if(typeof o=="string"&&o!==""&&O(o),g[e.connectionId]){try{window.parent.postMessage({type:"desktop-mode-bridge-handshake-ack",connectionId:e.connectionId},c)}catch{}return}const t={id:e.connectionId,topics:Array.isArray(e.topics)?e.topics.slice():[]};g[t.id]=t;try{window.parent.postMessage({type:"desktop-mode-bridge-handshake-ack",connectionId:t.id},c)}catch{}for(const r of b)try{r({id:t.id,topics:t.topics.slice()})}catch{}return}if(e.type==="desktop-mode-bridge-beforeunload-query"){let o=!1,t="";const r=i=>{const d=i;Object.defineProperty(i,"returnValue",{get(){return d._returnValue||""},set(l){d._returnValue=l}})},s=(i,d)=>{const l=i.returnValue,w=typeof d=="string"&&d!=="",m=typeof l=="string"&&l!=="";(i.defaultPrevented||w||m)&&(o=!0,w?t=d:m&&(t=l))};if(typeof window.onbeforeunload=="function"){const i=new Event("beforeunload",{cancelable:!0});r(i);const d=window.onbeforeunload(i);s(i,d)}if(!o){const i=new Event("beforeunload",{cancelable:!0});r(i),window.dispatchEvent(i),s(i,null)}try{window.parent.postMessage({type:"desktop-mode-bridge-beforeunload-response",prevent:o,message:t},c)}catch{}return}if(e.type==="desktop-mode-bridge-publish"&&typeof e.topic=="string"){const o={topic:e.topic,connectionId:e.connectionId},t=I[e.topic];if(t)for(const s of t)try{s(e.payload,o)}catch{}const r=I["*"];if(r)for(const s of r)try{s(e.payload,o)}catch{}return}if(e.type==="desktop-mode-bridge-disconnect"&&typeof e.connectionId=="string"&&delete g[e.connectionId],e.type==="desktop-mode-window-send"&&typeof e.channel=="string"){const o=e,t={channel:o.channel},r=M[o.channel];if(r)for(const i of r.slice())try{i(o.payload,t)}catch{}const s=M["*"];if(s)for(const i of s.slice())try{i(o.payload,t)}catch{}}}});const _={publish(n,e){if(typeof n!="string"||n==="")return;const o=Object.keys(g);if(o.length===0){console.warn('[desktop-mode] wp.desktop.iframe.publish dropped: no open connection for topic "%s". The parent shell must call `wp.desktop.connect(windowId)` first.',n);return}for(const t of o)x(t,n,e)},subscribe(n,e){if(typeof n!="string"||n===""||typeof e!="function")return()=>{};let o=I[n];return o||(o=[],I[n]=o),o.push(e),()=>{const t=o.indexOf(e);t>=0&&o.splice(t,1)}},onConnection(n){if(typeof n!="function")return()=>{};b.push(n);for(const e of Object.keys(g))try{n({id:g[e].id,topics:g[e].topics.slice()})}catch{}return()=>{const e=b.indexOf(n);e>=0&&b.splice(e,1)}},chrome:{setTheme(n){try{window.parent.postMessage({type:"desktop-mode-chrome-theme",tokens:n??{}},c)}catch{}},setControls(n){try{window.parent.postMessage({type:"desktop-mode-chrome-controls",config:n??null},c)}catch{}},setSlot(n,e){if(!(typeof n!="string"||n===""))try{window.parent.postMessage({type:"desktop-mode-chrome-slot",slot:n,html:typeof e=="string"?e:""},c)}catch{}}},requestConnection(n){const e=n??{},o=Array.isArray(e.topics)?e.topics.slice():[],t="wpdir-"+Math.random().toString(36).slice(2,10);return new Promise((r,s)=>{let i=!1;const d=typeof e.timeoutMs=="number"?e.timeoutMs:5e3,l=(y,a)=>{i||(i=!0,window.removeEventListener("message",w),clearTimeout(m),y?r(a):s(a))},w=y=>{if(y.origin!==c)return;const a=y?.data;if(!(!a||typeof a!="object"||a.type!=="desktop-mode-bridge-connection-ack"||a.requestId!==t))if(a.accepted){const u={id:typeof a.connectionId=="string"?a.connectionId:"",topics:o.slice()};if(typeof e.onOpen=="function")try{e.onOpen(u)}catch{}l(!0,u)}else l(!1,new Error(a.reason||"rejected"))};window.addEventListener("message",w);const m=setTimeout(()=>{l(!1,new Error("timeout"))},d);try{window.parent.postMessage({type:"desktop-mode-bridge-connection-request",requestId:t,topics:o},c)}catch(y){l(!1,y)}})},get windowId(){return k},whenWindowId(){return k!==null?Promise.resolve(k):new Promise(n=>{E.push(n)})},isParentReachable(){if(!window.parent||window.parent===window)return!1;try{return window.parent.location.origin===c}catch{return!1}}};f.wp||(f.wp={}),f.wp.desktop||(f.wp.desktop={}),f.wp.desktop.iframe=_,typeof f.wp.desktop.send!="function"&&(f.wp.desktop.send=(n,e)=>{if(!(typeof n!="string"||n===""))try{window.parent.postMessage({type:"desktop-mode-window-publish",channel:n,payload:e},c)}catch{}}),typeof f.wp.desktop.on!="function"&&(f.wp.desktop.on=(n,e)=>{if(typeof n!="string"||n===""||typeof e!="function")return()=>{};let o=M[n];return o||(o=[],M[n]=o),o.push(e),()=>{const t=o.indexOf(e);t>=0&&o.splice(t,1)}});const h=window;if(h.__desktopModeScreenMetaInstalled||(h.__desktopModeScreenMetaInstalled=!0,F(c)),!h.__desktopModeOsFileDropForwarderInstalled){h.__desktopModeOsFileDropForwarderInstalled=!0;const n=t=>{const r=t.dataTransfer?.types;if(!r)return!1;const s=r;if(typeof s.includes=="function")return s.includes("Files");if(typeof s.contains=="function")return s.contains("Files");for(let i=0;i<s.length;i++)if(s[i]==="Files")return!0;return!1},e=[".components-drop-zone","[data-drop-zone]",".uploader-window",".media-frame-content"],o=t=>{const r=t;if(!r||!r.closest)return!1;for(const s of e)if(r.closest(s))return!0;return!1};document.addEventListener("dragover",t=>{n(t)&&(o(t.target)||t.defaultPrevented||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="copy")))},!1),document.addEventListener("drop",t=>{if(!n(t)||o(t.target)||t.defaultPrevented)return;t.preventDefault(),t.stopPropagation();const r=[];if(t.dataTransfer?.files)for(let s=0;s<t.dataTransfer.files.length;s++)r.push(t.dataTransfer.files[s]);if(r.length!==0)try{window.parent.postMessage({type:"desktop-mode-os-file-drop",files:r,x:t.clientX,y:t.clientY},c)}catch{}},!1)}if(!h.__desktopModeDragHoverForwarderInstalled){h.__desktopModeDragHoverForwarderInstalled=!0;const n=o=>{const t=o.dataTransfer?.types;if(!t)return!1;const r=t;return typeof r.includes=="function"?r.includes("Files"):typeof r.contains=="function"&&r.contains("Files")};let e=0;document.addEventListener("dragover",o=>{const t=Date.now();if(!(t-e<150)){e=t;try{window.parent.postMessage({type:"desktop-mode-drag-hover",payloadType:n(o)?"os-file":"external"},c)}catch{}}},!0)}try{window.parent&&window.parent!==window&&window.parent.postMessage({type:"desktop-mode-ready"},c)}catch{}function F(n){const e=()=>{const r=document.getElementById("screen-options-wrap");return!!r&&!!r.querySelector('input:not([type="hidden"]):not([type="submit"]):not([type="button"]):not([type="reset"]), select, textarea')},o=()=>{const r=document.getElementById("contextual-help-wrap");if(!r)return!1;const s=r.querySelectorAll(".help-tab-content, .contextual-help-sidebar");for(let i=0;i<s.length;i++)if((s[i].textContent||"").trim()!=="")return!0;return!1},t=()=>{const r=document.getElementById("screen-meta-links"),s=r?document.getElementById("show-settings-link"):null,i=r?document.getElementById("contextual-help-link"):null,d=[];s&&e()&&d.push("screen-options"),i&&o()&&d.push("help");try{window.parent.postMessage({type:"desktop-mode-screen-meta",panels:d},n)}catch{}if(d.length===0)return;const l=()=>s&&s.getAttribute("aria-expanded")==="true"?"screen-options":i&&i.getAttribute("aria-expanded")==="true"?"help":null,w=()=>{try{window.parent.postMessage({type:"desktop-mode-screen-meta-state",open:l()},n)}catch{}};w();const m=new MutationObserver(w);s&&m.observe(s,{attributes:!0,attributeFilter:["aria-expanded"]}),i&&m.observe(i,{attributes:!0,attributeFilter:["aria-expanded"]});const y=a=>{if(!a||a.getAttribute("aria-expanded")!=="true")return;const u=a.getAttribute("aria-controls"),p=u?document.getElementById(u):null;if(!p)return;const v=window.jQuery;if(v)try{v(p).stop(!0,!1)}catch{}p.style.display="none",p.classList.add("hidden"),p.parentElement&&(p.parentElement.style.display="none"),a.classList.remove("screen-meta-active"),a.setAttribute("aria-expanded","false"),document.querySelectorAll(".screen-meta-toggle").forEach(A=>{A.style.visibility=""})};window.addEventListener("message",a=>{if(a.origin!==n)return;const u=a.data;if(!u||u.type!=="desktop-mode-toggle-panel")return;let p=null;u.panel==="screen-options"&&s?p=s:u.panel==="help"&&i&&(p=i),p&&(p.getAttribute("aria-expanded")!=="true"&&y(p===s?i:s),p.click())})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}})()})();
2