PluginProbe
Elementor Website Builder – more than just a page builder / 3.33.0-dev1
Elementor Website Builder – more than just a page builder v3.33.0-dev1
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 / import-export-admin.js

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

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