PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 0.8.9
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v0.8.9
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.8.9, at assets/js/iframe-bridge.min.js

2 lines 7.0 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 p=window;if(p.wp?.desktop?.iframe)return;const c=window.location.origin,l={},g=[],m={};let w=null;const M=[],E=n=>{if(!n||w===n)return;w=n;const e=M.splice(0);for(const o of e)try{o(n)}catch{}},h={},O=(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!==""&&E(o),l[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():[]};l[t.id]=t;try{window.parent.postMessage({type:"desktop-mode-bridge-handshake-ack",connectionId:t.id},c)}catch{}for(const r of g)try{r({id:t.id,topics:t.topics.slice()})}catch{}return}if(e.type==="desktop-mode-bridge-publish"&&typeof e.topic=="string"){const o={topic:e.topic,connectionId:e.connectionId},t=m[e.topic];if(t)for(const s of t)try{s(e.payload,o)}catch{}const r=m["*"];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 l[e.connectionId],e.type==="desktop-mode-window-send"&&typeof e.channel=="string"){const o=e,t={channel:o.channel},r=h[o.channel];if(r)for(const a of r.slice())try{a(o.payload,t)}catch{}const s=h["*"];if(s)for(const a of s.slice())try{a(o.payload,t)}catch{}}}});const A={publish(n,e){if(typeof n!="string"||n==="")return;const o=Object.keys(l);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)O(t,n,e)},subscribe(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)}},onConnection(n){if(typeof n!="function")return()=>{};g.push(n);for(const e of Object.keys(l))try{n({id:l[e].id,topics:l[e].topics.slice()})}catch{}return()=>{const e=g.indexOf(n);e>=0&&g.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 a=!1;const b=typeof e.timeoutMs=="number"?e.timeoutMs:5e3,u=(d,i)=>{a||(a=!0,window.removeEventListener("message",I),clearTimeout(f),d?r(i):s(i))},I=d=>{if(d.origin!==c)return;const i=d?.data;if(!(!i||typeof i!="object"||i.type!=="desktop-mode-bridge-connection-ack"||i.requestId!==t))if(i.accepted){const y={id:typeof i.connectionId=="string"?i.connectionId:"",topics:o.slice()};if(typeof e.onOpen=="function")try{e.onOpen(y)}catch{}u(!0,y)}else u(!1,new Error(i.reason||"rejected"))};window.addEventListener("message",I);const f=setTimeout(()=>{u(!1,new Error("timeout"))},b);try{window.parent.postMessage({type:"desktop-mode-bridge-connection-request",requestId:t,topics:o},c)}catch(d){u(!1,d)}})},get windowId(){return w},whenWindowId(){return w!==null?Promise.resolve(w):new Promise(n=>{M.push(n)})},isParentReachable(){if(!window.parent||window.parent===window)return!1;try{return window.parent.location.origin===c}catch{return!1}}};p.wp||(p.wp={}),p.wp.desktop||(p.wp.desktop={}),p.wp.desktop.iframe=A,typeof p.wp.desktop.send!="function"&&(p.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 p.wp.desktop.on!="function"&&(p.wp.desktop.on=(n,e)=>{if(typeof n!="string"||n===""||typeof e!="function")return()=>{};let o=h[n];return o||(o=[],h[n]=o),o.push(e),()=>{const t=o.indexOf(e);t>=0&&o.splice(t,1)}});const k=window;if(k.__desktopModeScreenMetaInstalled||(k.__desktopModeScreenMetaInstalled=!0,x(c)),!k.__desktopModeOsFileDropForwarderInstalled){k.__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 a=0;a<s.length;a++)if(s[a]==="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)}try{window.parent&&window.parent!==window&&window.parent.postMessage({type:"desktop-mode-ready"},c)}catch{}function x(n){const e=()=>{if(!document.getElementById("screen-meta-links"))return;const t=document.getElementById("show-settings-link"),r=document.getElementById("contextual-help-link"),s=[];if(t&&s.push("screen-options"),r&&s.push("help"),s.length===0)return;try{window.parent.postMessage({type:"desktop-mode-screen-meta",panels:s},n)}catch{}const a=()=>t&&t.getAttribute("aria-expanded")==="true"?"screen-options":r&&r.getAttribute("aria-expanded")==="true"?"help":null,b=()=>{try{window.parent.postMessage({type:"desktop-mode-screen-meta-state",open:a()},n)}catch{}};b();const u=new MutationObserver(b);t&&u.observe(t,{attributes:!0,attributeFilter:["aria-expanded"]}),r&&u.observe(r,{attributes:!0,attributeFilter:["aria-expanded"]});const I=f=>{if(!f||f.getAttribute("aria-expanded")!=="true")return;const d=f.getAttribute("aria-controls"),i=d?document.getElementById(d):null;if(!i)return;const y=window.jQuery;if(y)try{y(i).stop(!0,!1)}catch{}i.style.display="none",i.classList.add("hidden"),i.parentElement&&(i.parentElement.style.display="none"),f.classList.remove("screen-meta-active"),f.setAttribute("aria-expanded","false"),document.querySelectorAll(".screen-meta-toggle").forEach(F=>{F.style.visibility=""})};window.addEventListener("message",f=>{if(f.origin!==n)return;const d=f.data;if(!d||d.type!=="desktop-mode-toggle-panel")return;let i=null;d.panel==="screen-options"&&t?i=t:d.panel==="help"&&r&&(i=r),i&&(i.getAttribute("aria-expanded")!=="true"&&I(i===t?r:t),i.click())})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}})()})();
2