PluginProbe
Extendify / 2.2.0
Extendify v2.2.0
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 0.7.0 All 126 releases
extendify / src / Shared / shared.js

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

48 lines 1.6 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/app.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 return query.get('page') === 'extendify-launch';
13 };
14
15 domReady(() => {
16 if (isOnLaunch()) return;
17
18 preFetchUnsplashImages();
19
20 const urlParams = new URLSearchParams(window.location.search);
21 if (!urlParams.has('extendify-launch-success')) return;
22 const currentUrl = new URL(window.location.href);
23 // Remove the query param so it doesn't show again
24 urlParams.delete('extendify-launch-success');
25 const newUrl = `${currentUrl.origin}${currentUrl.pathname}`;
26 window.history.replaceState({}, '', newUrl);
27 // Trigger an event other features can listen to
28 // Give time for others to add listeners
29 requestAnimationFrame(() => {
30 requestAnimationFrame(() => {
31 window.dispatchEvent(new CustomEvent('extendify-launch-success'));
32 });
33 });
34 if (showAIAgents) return;
35 // This will show the toolbar for users not using AI Agent
36 // but are redirected to home
37 const homeUrl = new URL(window.extSharedData.homeUrl);
38 const isHomePage =
39 currentUrl.origin === homeUrl.origin &&
40 currentUrl.pathname === homeUrl.pathname;
41 if (!isHomePage) return;
42 const div = Object.assign(document.createElement('div'), {
43 id: 'extendify-edit-page-modal-tooltip',
44 });
45 document.body.appendChild(div);
46 render(<EditPageToolTip />, div);
47 });
48