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

2 lines 7.5 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 a=window.location.origin,u={},h=[],k={};let g=null;const E=[],x=t=>{if(!t||g===t)return;g=t;const e=E.splice(0);for(const o of e)try{o(t)}catch{}},b={},A=(t,e,o)=>{try{window.parent.postMessage({type:"desktop-mode-bridge-publish",connectionId:t,topic:e,payload:o},a)}catch{}};window.addEventListener("message",t=>{if(t.origin!==a)return;const e=t?.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!==""&&x(o),u[e.connectionId]){try{window.parent.postMessage({type:"desktop-mode-bridge-handshake-ack",connectionId:e.connectionId},a)}catch{}return}const n={id:e.connectionId,topics:Array.isArray(e.topics)?e.topics.slice():[]};u[n.id]=n;try{window.parent.postMessage({type:"desktop-mode-bridge-handshake-ack",connectionId:n.id},a)}catch{}for(const s of h)try{s({id:n.id,topics:n.topics.slice()})}catch{}return}if(e.type==="desktop-mode-bridge-publish"&&typeof e.topic=="string"){const o={topic:e.topic,connectionId:e.connectionId},n=k[e.topic];if(n)for(const r of n)try{r(e.payload,o)}catch{}const s=k["*"];if(s)for(const r of s)try{r(e.payload,o)}catch{}return}if(e.type==="desktop-mode-bridge-disconnect"&&typeof e.connectionId=="string"&&delete u[e.connectionId],e.type==="desktop-mode-window-send"&&typeof e.channel=="string"){const o=e,n={channel:o.channel},s=b[o.channel];if(s)for(const i of s.slice())try{i(o.payload,n)}catch{}const r=b["*"];if(r)for(const i of r.slice())try{i(o.payload,n)}catch{}}}});const S={publish(t,e){if(typeof t!="string"||t==="")return;const o=Object.keys(u);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.',t);return}for(const n of o)A(n,t,e)},subscribe(t,e){if(typeof t!="string"||t===""||typeof e!="function")return()=>{};let o=k[t];return o||(o=[],k[t]=o),o.push(e),()=>{const n=o.indexOf(e);n>=0&&o.splice(n,1)}},onConnection(t){if(typeof t!="function")return()=>{};h.push(t);for(const e of Object.keys(u))try{t({id:u[e].id,topics:u[e].topics.slice()})}catch{}return()=>{const e=h.indexOf(t);e>=0&&h.splice(e,1)}},chrome:{setTheme(t){try{window.parent.postMessage({type:"desktop-mode-chrome-theme",tokens:t??{}},a)}catch{}},setControls(t){try{window.parent.postMessage({type:"desktop-mode-chrome-controls",config:t??null},a)}catch{}},setSlot(t,e){if(!(typeof t!="string"||t===""))try{window.parent.postMessage({type:"desktop-mode-chrome-slot",slot:t,html:typeof e=="string"?e:""},a)}catch{}}},requestConnection(t){const e=t??{},o=Array.isArray(e.topics)?e.topics.slice():[],n="wpdir-"+Math.random().toString(36).slice(2,10);return new Promise((s,r)=>{let i=!1;const w=typeof e.timeoutMs=="number"?e.timeoutMs:5e3,y=(f,c)=>{i||(i=!0,window.removeEventListener("message",m),clearTimeout(M),f?s(c):r(c))},m=f=>{if(f.origin!==a)return;const c=f?.data;if(!(!c||typeof c!="object"||c.type!=="desktop-mode-bridge-connection-ack"||c.requestId!==n))if(c.accepted){const l={id:typeof c.connectionId=="string"?c.connectionId:"",topics:o.slice()};if(typeof e.onOpen=="function")try{e.onOpen(l)}catch{}y(!0,l)}else y(!1,new Error(c.reason||"rejected"))};window.addEventListener("message",m);const M=setTimeout(()=>{y(!1,new Error("timeout"))},w);try{window.parent.postMessage({type:"desktop-mode-bridge-connection-request",requestId:n,topics:o},a)}catch(f){y(!1,f)}})},get windowId(){return g},whenWindowId(){return g!==null?Promise.resolve(g):new Promise(t=>{E.push(t)})},isParentReachable(){if(!window.parent||window.parent===window)return!1;try{return window.parent.location.origin===a}catch{return!1}}};p.wp||(p.wp={}),p.wp.desktop||(p.wp.desktop={}),p.wp.desktop.iframe=S,typeof p.wp.desktop.send!="function"&&(p.wp.desktop.send=(t,e)=>{if(!(typeof t!="string"||t===""))try{window.parent.postMessage({type:"desktop-mode-window-publish",channel:t,payload:e},a)}catch{}}),typeof p.wp.desktop.on!="function"&&(p.wp.desktop.on=(t,e)=>{if(typeof t!="string"||t===""||typeof e!="function")return()=>{};let o=b[t];return o||(o=[],b[t]=o),o.push(e),()=>{const n=o.indexOf(e);n>=0&&o.splice(n,1)}});const I=window;if(I.__desktopModeScreenMetaInstalled||(I.__desktopModeScreenMetaInstalled=!0,F(a)),!I.__desktopModeOsFileDropForwarderInstalled){I.__desktopModeOsFileDropForwarderInstalled=!0;const t=n=>{const s=n.dataTransfer?.types;if(!s)return!1;const r=s;if(typeof r.includes=="function")return r.includes("Files");if(typeof r.contains=="function")return r.contains("Files");for(let i=0;i<r.length;i++)if(r[i]==="Files")return!0;return!1},e=[".components-drop-zone","[data-drop-zone]",".uploader-window",".media-frame-content"],o=n=>{const s=n;if(!s||!s.closest)return!1;for(const r of e)if(s.closest(r))return!0;return!1};document.addEventListener("dragover",n=>{t(n)&&(o(n.target)||n.defaultPrevented||(n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect="copy")))},!1),document.addEventListener("drop",n=>{if(!t(n)||o(n.target)||n.defaultPrevented)return;n.preventDefault(),n.stopPropagation();const s=[];if(n.dataTransfer?.files)for(let r=0;r<n.dataTransfer.files.length;r++)s.push(n.dataTransfer.files[r]);if(s.length!==0)try{window.parent.postMessage({type:"desktop-mode-os-file-drop",files:s,x:n.clientX,y:n.clientY},a)}catch{}},!1)}try{window.parent&&window.parent!==window&&window.parent.postMessage({type:"desktop-mode-ready"},a)}catch{}function F(t){const e=()=>{const s=document.getElementById("screen-options-wrap");return!!s&&!!s.querySelector('input:not([type="hidden"]):not([type="submit"]):not([type="button"]):not([type="reset"]), select, textarea')},o=()=>{const s=document.getElementById("contextual-help-wrap");if(!s)return!1;const r=s.querySelectorAll(".help-tab-content, .contextual-help-sidebar");for(let i=0;i<r.length;i++)if((r[i].textContent||"").trim()!=="")return!0;return!1},n=()=>{const s=document.getElementById("screen-meta-links"),r=s?document.getElementById("show-settings-link"):null,i=s?document.getElementById("contextual-help-link"):null,w=[];r&&e()&&w.push("screen-options"),i&&o()&&w.push("help");try{window.parent.postMessage({type:"desktop-mode-screen-meta",panels:w},t)}catch{}if(w.length===0)return;const y=()=>r&&r.getAttribute("aria-expanded")==="true"?"screen-options":i&&i.getAttribute("aria-expanded")==="true"?"help":null,m=()=>{try{window.parent.postMessage({type:"desktop-mode-screen-meta-state",open:y()},t)}catch{}};m();const M=new MutationObserver(m);r&&M.observe(r,{attributes:!0,attributeFilter:["aria-expanded"]}),i&&M.observe(i,{attributes:!0,attributeFilter:["aria-expanded"]});const f=c=>{if(!c||c.getAttribute("aria-expanded")!=="true")return;const l=c.getAttribute("aria-controls"),d=l?document.getElementById(l):null;if(!d)return;const O=window.jQuery;if(O)try{O(d).stop(!0,!1)}catch{}d.style.display="none",d.classList.add("hidden"),d.parentElement&&(d.parentElement.style.display="none"),c.classList.remove("screen-meta-active"),c.setAttribute("aria-expanded","false"),document.querySelectorAll(".screen-meta-toggle").forEach(L=>{L.style.visibility=""})};window.addEventListener("message",c=>{if(c.origin!==t)return;const l=c.data;if(!l||l.type!=="desktop-mode-toggle-panel")return;let d=null;l.panel==="screen-options"&&r?d=r:l.panel==="help"&&i&&(d=i),d&&(d.getAttribute("aria-expanded")!=="true"&&f(d===r?i:r),d.click())})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",n,{once:!0}):n()}})()})();
2