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