PluginProbe
Extendify / 3.0.5
Extendify v3.0.5
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / Shared / shared.js

shared.js in Extendify 3.0.5, at src/Shared/shared.js

51 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import domReady from '@wordpress/dom-ready';
2 import '@shared/shared.css';
3 import { EditPageToolTip } from '@shared/components/EditPageToolTip';
4 import '@shared/lib/api-fetch';
5 import { render } from '@shared/lib/dom';
6 import { preFetchImages as preFetchUnsplashImages } from '@shared/lib/unsplash';
7
8 const showAIAgents = window.extSharedData.showAIAgents;
9
10 const isOnLaunch = () => {
11 const query = new URLSearchParams(window.location.search);
12 const page = query.get('page');
13 return page === 'extendify-launch' || page === 'extendify-auto-launch';
14 };
15
16 domReady(() => {
17 if (isOnLaunch()) return;
18
19 preFetchUnsplashImages();
20
21 const urlParams = new URLSearchParams(window.location.search);
22 if (!urlParams.has('extendify-launch-success')) return;
23 const currentUrl = new URL(window.location.href);
24 // Remove the query param so it doesn't show again
25 urlParams.delete('extendify-launch-success');
26 const newUrl = `${currentUrl.origin}${currentUrl.pathname}`;
27 window.history.replaceState({}, '', newUrl);
28 // Trigger an event other features can listen to
29 // Give time for others to add listeners
30 requestAnimationFrame(() => {
31 requestAnimationFrame(() => {
32 window.dispatchEvent(new CustomEvent('extendify-launch-success'));
33 // Open the Agent if not open
34 window.dispatchEvent(new CustomEvent('extendify-agent:open'));
35 });
36 });
37 if (showAIAgents) return;
38 // This will show the toolbar for users not using AI Agent
39 // but are redirected to home
40 const homeUrl = new URL(window.extSharedData.homeUrl);
41 const isHomePage =
42 currentUrl.origin === homeUrl.origin &&
43 currentUrl.pathname === homeUrl.pathname;
44 if (!isHomePage) return;
45 const div = Object.assign(document.createElement('div'), {
46 id: 'extendify-edit-page-modal-tooltip',
47 });
48 document.body.appendChild(div);
49 render(<EditPageToolTip />, div);
50 });
51