PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.3
Elementor Website Builder – more than just a page builder v4.0.3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / assets / js / design-system-sync.js

design-system-sync.js in Elementor Website Builder – more than just a page builder 4.0.3, at assets/js/design-system-sync.js

73 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ "use strict";
3 /*!*****************************************************************************!*\
4 !*** ../modules/design-system-sync/assets/js/design-system-sync-handler.js ***!
5 \*****************************************************************************/
6
7
8 (function () {
9 'use strict';
10
11 var SYNC_ENDPOINT = wpApiSettings.root + 'elementor/v1/design-system-sync/stylesheet';
12 var SYNC_STYLESHEET_ID = 'elementor-design-system-sync-css';
13 var DEBOUNCE_MS = 500;
14 var syncTimeout;
15 function syncDesignSystem() {
16 fetch(SYNC_ENDPOINT, {
17 method: 'POST',
18 headers: {
19 'X-WP-Nonce': wpApiSettings.nonce
20 }
21 }).then(function (response) {
22 if (!response.ok) {
23 return;
24 }
25 if (204 === response.status) {
26 return;
27 }
28 return response.json();
29 }).then(function (data) {
30 if (!data) {
31 return;
32 }
33 refreshGlobals();
34 reloadCanvasDesignSyncStyles(data);
35 });
36 }
37 function refreshGlobals() {
38 var globals = $e.components.get('globals');
39 globals === null || globals === void 0 || globals.refreshGlobalData();
40 globals === null || globals === void 0 || globals.populateGlobalData();
41 }
42 function reloadCanvasDesignSyncStyles(_ref) {
43 var url = _ref.url;
44 var previewFrame = document.getElementById('elementor-preview-iframe');
45 if (!(previewFrame !== null && previewFrame !== void 0 && previewFrame.contentDocument)) {
46 return;
47 }
48 var link = previewFrame.contentDocument.getElementById(SYNC_STYLESHEET_ID);
49 if (!link) {
50 link = previewFrame.contentDocument.createElement('link');
51 link.id = SYNC_STYLESHEET_ID;
52 link.rel = 'stylesheet';
53 previewFrame.contentDocument.head.appendChild(link);
54 }
55 link.href = url;
56 }
57 function onClassesUpdated(event) {
58 var context = event.detail.context;
59 if (context !== 'frontend') {
60 return;
61 }
62 clearTimeout(syncTimeout);
63 syncTimeout = setTimeout(syncDesignSystem, DEBOUNCE_MS);
64 }
65 window.addEventListener('classes:updated', onClassesUpdated);
66 window.addEventListener('variables:updated', function () {
67 clearTimeout(syncTimeout);
68 syncTimeout = setTimeout(syncDesignSystem, DEBOUNCE_MS);
69 });
70 })();
71 /******/ })()
72 ;
73 //# sourceMappingURL=design-system-sync.js.map