PluginProbe
Extendify / 3.1.5
Extendify v3.1.5
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 3.1.5, at src/Shared/shared.js

64 lines 2.2 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 { ProductAccountActivation } from '@shared/components/ProductAccountActivation/ProductAccountActivation';
6 import { render } from '@shared/lib/dom';
7 import { preFetchImages as preFetchUnsplashImages } from '@shared/lib/unsplash';
8
9 const showAIAgents = window.extSharedData.showAIAgents;
10
11 const isOnLaunch = () => {
12 const query = new URLSearchParams(window.location.search);
13 const page = query.get('page');
14 return page === 'extendify-launch' || page === 'extendify-auto-launch';
15 };
16
17 domReady(() => {
18 if (isOnLaunch()) return;
19
20 preFetchUnsplashImages();
21
22 const urlParams = new URLSearchParams(window.location.search);
23
24 if (!urlParams.has('extendify-launch-success')) return;
25
26 if (window.extSharedData?.showProductActivation?.length) {
27 const container = Object.assign(document.createElement('div'), {
28 id: 'extendify-product-activation-container',
29 });
30
31 document.body.appendChild(container);
32
33 render(<ProductAccountActivation />, container);
34 }
35
36 const currentUrl = new URL(window.location.href);
37 // Remove the query param so it doesn't show again
38 urlParams.delete('extendify-launch-success');
39 const newUrl = `${currentUrl.origin}${currentUrl.pathname}`;
40 window.history.replaceState({}, '', newUrl);
41 // Trigger an event other features can listen to
42 // Give time for others to add listeners
43 requestAnimationFrame(() => {
44 requestAnimationFrame(() => {
45 window.dispatchEvent(new CustomEvent('extendify-launch-success'));
46 // Open the Agent if not open
47 window.dispatchEvent(new CustomEvent('extendify-agent:open'));
48 });
49 });
50 if (showAIAgents) return;
51 // This will show the toolbar for users not using AI Agent
52 // but are redirected to home
53 const homeUrl = new URL(window.extSharedData.homeUrl);
54 const isHomePage =
55 currentUrl.origin === homeUrl.origin &&
56 currentUrl.pathname === homeUrl.pathname;
57 if (!isHomePage) return;
58 const div = Object.assign(document.createElement('div'), {
59 id: 'extendify-edit-page-modal-tooltip',
60 });
61 document.body.appendChild(div);
62 render(<EditPageToolTip />, div);
63 });
64