PluginProbe
Elementor Website Builder – more than just a page builder / 3.29.2
Elementor Website Builder – more than just a page builder v3.29.2
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 4.0.7 All 451 releases
elementor / assets / js / import-export-admin.js

import-export-admin.js in Elementor Website Builder – more than just a page builder 3.29.2, at assets/js/import-export-admin.js

414 lines 14.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*! elementor - v3.29.0 - 04-06-2025 */
2 /******/ (() => { // webpackBootstrap
3 /******/ var __webpack_modules__ = ({
4
5 /***/ "@wordpress/i18n":
6 /*!**************************!*\
7 !*** external "wp.i18n" ***!
8 \**************************/
9 /***/ ((module) => {
10
11 "use strict";
12 module.exports = wp.i18n;
13
14 /***/ }),
15
16 /***/ "../node_modules/@babel/runtime/helpers/classCallCheck.js":
17 /*!****************************************************************!*\
18 !*** ../node_modules/@babel/runtime/helpers/classCallCheck.js ***!
19 \****************************************************************/
20 /***/ ((module) => {
21
22 function _classCallCheck(a, n) {
23 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
24 }
25 module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
26
27 /***/ }),
28
29 /***/ "../node_modules/@babel/runtime/helpers/createClass.js":
30 /*!*************************************************************!*\
31 !*** ../node_modules/@babel/runtime/helpers/createClass.js ***!
32 \*************************************************************/
33 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
34
35 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
36 function _defineProperties(e, r) {
37 for (var t = 0; t < r.length; t++) {
38 var o = r[t];
39 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
40 }
41 }
42 function _createClass(e, r, t) {
43 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
44 writable: !1
45 }), e;
46 }
47 module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
48
49 /***/ }),
50
51 /***/ "../node_modules/@babel/runtime/helpers/defineProperty.js":
52 /*!****************************************************************!*\
53 !*** ../node_modules/@babel/runtime/helpers/defineProperty.js ***!
54 \****************************************************************/
55 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
56
57 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
58 function _defineProperty(e, r, t) {
59 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
60 value: t,
61 enumerable: !0,
62 configurable: !0,
63 writable: !0
64 }) : e[r] = t, e;
65 }
66 module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
67
68 /***/ }),
69
70 /***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js":
71 /*!***********************************************************************!*\
72 !*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
73 \***********************************************************************/
74 /***/ ((module) => {
75
76 function _interopRequireDefault(e) {
77 return e && e.__esModule ? e : {
78 "default": e
79 };
80 }
81 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
82
83 /***/ }),
84
85 /***/ "../node_modules/@babel/runtime/helpers/toPrimitive.js":
86 /*!*************************************************************!*\
87 !*** ../node_modules/@babel/runtime/helpers/toPrimitive.js ***!
88 \*************************************************************/
89 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
90
91 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
92 function toPrimitive(t, r) {
93 if ("object" != _typeof(t) || !t) return t;
94 var e = t[Symbol.toPrimitive];
95 if (void 0 !== e) {
96 var i = e.call(t, r || "default");
97 if ("object" != _typeof(i)) return i;
98 throw new TypeError("@@toPrimitive must return a primitive value.");
99 }
100 return ("string" === r ? String : Number)(t);
101 }
102 module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
103
104 /***/ }),
105
106 /***/ "../node_modules/@babel/runtime/helpers/toPropertyKey.js":
107 /*!***************************************************************!*\
108 !*** ../node_modules/@babel/runtime/helpers/toPropertyKey.js ***!
109 \***************************************************************/
110 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
111
112 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
113 var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/toPrimitive.js");
114 function toPropertyKey(t) {
115 var i = toPrimitive(t, "string");
116 return "symbol" == _typeof(i) ? i : i + "";
117 }
118 module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
119
120 /***/ }),
121
122 /***/ "../node_modules/@babel/runtime/helpers/typeof.js":
123 /*!********************************************************!*\
124 !*** ../node_modules/@babel/runtime/helpers/typeof.js ***!
125 \********************************************************/
126 /***/ ((module) => {
127
128 function _typeof(o) {
129 "@babel/helpers - typeof";
130
131 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
132 return typeof o;
133 } : function (o) {
134 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
135 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
136 }
137 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
138
139 /***/ })
140
141 /******/ });
142 /************************************************************************/
143 /******/ // The module cache
144 /******/ var __webpack_module_cache__ = {};
145 /******/
146 /******/ // The require function
147 /******/ function __webpack_require__(moduleId) {
148 /******/ // Check if module is in cache
149 /******/ var cachedModule = __webpack_module_cache__[moduleId];
150 /******/ if (cachedModule !== undefined) {
151 /******/ return cachedModule.exports;
152 /******/ }
153 /******/ // Create a new module (and put it into the cache)
154 /******/ var module = __webpack_module_cache__[moduleId] = {
155 /******/ // no module.id needed
156 /******/ // no module.loaded needed
157 /******/ exports: {}
158 /******/ };
159 /******/
160 /******/ // Execute the module function
161 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
162 /******/
163 /******/ // Return the exports of the module
164 /******/ return module.exports;
165 /******/ }
166 /******/
167 /************************************************************************/
168 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
169 (() => {
170 "use strict";
171 /*!*******************************************************!*\
172 !*** ../app/modules/import-export/assets/js/admin.js ***!
173 \*******************************************************/
174 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
175
176
177 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
178 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
179 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
180 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
181 var Admin = /*#__PURE__*/function () {
182 function Admin() {
183 (0, _classCallCheck2.default)(this, Admin);
184 /**
185 * Session Storage Key
186 *
187 * @type {string}
188 */
189 (0, _defineProperty2.default)(this, "KIT_DATA_KEY", 'elementor-kit-data');
190 /**
191 * Contains the ID of the referrer Kit and the name of the Kit to remove. Stored in session storage.
192 *
193 * @type {Object}
194 */
195 (0, _defineProperty2.default)(this, "cachedKitData", void 0);
196 /**
197 * The 'Remove Kit' revert button
198 *
199 * @type {Element}
200 */
201 (0, _defineProperty2.default)(this, "revertButton", void 0);
202 /**
203 * Name of the kit currently active (last imported)
204 *
205 * @type {string}
206 */
207 (0, _defineProperty2.default)(this, "activeKitName", void 0);
208 this.activeKitName = this.getActiveKitName();
209 this.revertButton = document.getElementById('elementor-import-export__revert_kit');
210 if (this.revertButton) {
211 this.revertButton.addEventListener('click', this.onRevertButtonClick.bind(this));
212 this.maybeAddRevertBtnMargin();
213 }
214 this.maybeShowReferrerKitDialog();
215 }
216
217 /**
218 * Add bottom margin to revert btn if referred from Kit library
219 */
220 return (0, _createClass2.default)(Admin, [{
221 key: "maybeAddRevertBtnMargin",
222 value: function maybeAddRevertBtnMargin() {
223 var referrerKitId = new URLSearchParams(this.revertButton.href).get('referrer_kit');
224 if (!referrerKitId) {
225 return;
226 }
227 this.revertButton.style.marginBottom = this.calculateMargin();
228 this.scrollToBottom();
229 }
230
231 /**
232 * CalculateMargin
233 *
234 * @return {string}
235 */
236 }, {
237 key: "calculateMargin",
238 value: function calculateMargin() {
239 var adminBar = document.getElementById('wpadminbar');
240 var adminBarHeight = adminBar ? adminBar.offsetHeight : 0;
241 var revertKitHeight = this.revertButton.parentElement.offsetHeight;
242 return document.body.clientHeight - adminBarHeight - revertKitHeight - document.getElementById('wpfooter').offsetHeight - 15 // Extra margin at the top
243 + 'px';
244 }
245
246 /**
247 * Scroll to the bottom of the page
248 */
249 }, {
250 key: "scrollToBottom",
251 value: function scrollToBottom() {
252 setTimeout(function () {
253 window.scrollTo(0, document.body.scrollHeight);
254 });
255 }
256
257 /**
258 * RevertBtnOnClick
259 *
260 * @param {Event} event
261 */
262 }, {
263 key: "onRevertButtonClick",
264 value: function onRevertButtonClick(event) {
265 var _this = this;
266 event.preventDefault();
267 elementorCommon.dialogsManager.createWidget('confirm', {
268 headerMessage: __('Are you sure?', 'elementor'),
269 // Translators: %s is the name of the active Kit
270 message: __('Removing %s will permanently delete changes made to the Kit\'s content and site settings', 'elementor').replace('%s', this.activeKitName),
271 strings: {
272 confirm: __('Delete', 'elementor'),
273 cancel: __('Cancel', 'elementor')
274 },
275 onConfirm: function onConfirm() {
276 return _this.onRevertConfirm();
277 }
278 }).show();
279 }
280 }, {
281 key: "onRevertConfirm",
282 value: function onRevertConfirm() {
283 var referrerKitId = new URLSearchParams(this.revertButton.href).get('referrer_kit');
284 this.saveToCache(referrerKitId !== null && referrerKitId !== void 0 ? referrerKitId : '');
285 location.href = this.revertButton.href;
286 }
287 }, {
288 key: "maybeShowReferrerKitDialog",
289 value: function maybeShowReferrerKitDialog() {
290 var _this$getDataFromCach = this.getDataFromCache(),
291 referrerKitId = _this$getDataFromCach.referrerKitId;
292 if (undefined === referrerKitId) {
293 return;
294 }
295 if (0 === referrerKitId.length) {
296 this.createKitDeletedWidget({
297 message: __('Try a different Kit or build your site from scratch.', 'elementor'),
298 strings: {
299 confirm: __('OK', 'elementor'),
300 cancel: __('Kit Library', 'elementor')
301 },
302 onCancel: function onCancel() {
303 location.href = elementorImportExport.appUrl;
304 }
305 });
306 this.clearCache();
307 return;
308 }
309 this.createKitDeletedWidget({
310 message: __('You\'re ready to apply a new Kit!', 'elementor'),
311 strings: {
312 confirm: __('Continue to new Kit', 'elementor'),
313 cancel: __('Close', 'elementor')
314 },
315 onConfirm: function onConfirm() {
316 location.href = elementorImportExport.appUrl + '/preview/' + referrerKitId;
317 }
318 });
319 this.clearCache();
320 }
321
322 /**
323 * CreateKitDeletedWidget
324 *
325 * @param {Object} options
326 */
327 }, {
328 key: "createKitDeletedWidget",
329 value: function createKitDeletedWidget(options) {
330 var _this$getDataFromCach2 = this.getDataFromCache(),
331 activeKitName = _this$getDataFromCach2.activeKitName;
332 elementorCommon.dialogsManager.createWidget('confirm', {
333 id: 'e-revert-kit-deleted-dialog',
334 // Translators: %s is the name of the active Kit
335 headerMessage: __('%s was successfully deleted', 'elementor').replace('%s', activeKitName),
336 message: options.message,
337 strings: {
338 confirm: options.strings.confirm,
339 cancel: options.strings.cancel
340 },
341 onConfirm: options.onConfirm,
342 onCancel: options.onCancel
343 }).show();
344 }
345
346 /**
347 * Retrieving the last imported kit from the elementorAppConfig global
348 *
349 * @return {string}
350 */
351 }, {
352 key: "getActiveKitName",
353 value: function getActiveKitName() {
354 var lastKit = elementorImportExport.lastImportedSession;
355 if (lastKit.kit_title) {
356 return lastKit.kit_title;
357 }
358 if (lastKit.kit_name) {
359 return this.convertNameToTitle(lastKit.kit_name);
360 }
361 return __('Your Kit', 'elementor');
362 }
363
364 /**
365 * ConvertNameToTitle
366 *
367 * @param {string} name
368 *
369 * @return {string}
370 */
371 }, {
372 key: "convertNameToTitle",
373 value: function convertNameToTitle(name) {
374 return name.split(/[-_]+/).map(function (word) {
375 return word[0].toUpperCase() + word.substring(1);
376 }).join(' ');
377 }
378 }, {
379 key: "saveToCache",
380 value: function saveToCache(referrerKitId) {
381 sessionStorage.setItem(this.KIT_DATA_KEY, JSON.stringify({
382 referrerKitId: referrerKitId,
383 activeKitName: this.activeKitName
384 }));
385 }
386 }, {
387 key: "getDataFromCache",
388 value: function getDataFromCache() {
389 var _this$cachedKitData;
390 if (this.cachedKitData) {
391 return this.cachedKitData;
392 }
393 try {
394 this.cachedKitData = JSON.parse(sessionStorage.getItem(this.KIT_DATA_KEY));
395 } catch (e) {
396 return {};
397 }
398 return (_this$cachedKitData = this.cachedKitData) !== null && _this$cachedKitData !== void 0 ? _this$cachedKitData : {};
399 }
400 }, {
401 key: "clearCache",
402 value: function clearCache() {
403 sessionStorage.removeItem(this.KIT_DATA_KEY);
404 }
405 }]);
406 }();
407 window.addEventListener('load', function () {
408 new Admin();
409 });
410 })();
411
412 /******/ })()
413 ;
414 //# sourceMappingURL=import-export-admin.js.map