| 1 |
(function ($) { |
| 2 |
const { |
| 3 |
__, |
| 4 |
} = wp.i18n; |
| 5 |
|
| 6 |
'use strict'; |
| 7 |
|
| 8 |
function wkit_load_save_tempalte(current_route = {}, el = null) { |
| 9 |
var e; |
| 10 |
if (!e) { |
| 11 |
window.WdkitPopup = elementorCommon.dialogsManager.createWidget("lightbox", { |
| 12 |
id: "wdkit-elementor", |
| 13 |
className: 'wkit-contentbox-modal wdkit-elementor', |
| 14 |
headerMessage: !1, |
| 15 |
message: "", |
| 16 |
hide: { |
| 17 |
auto: !1, |
| 18 |
onClick: !1, |
| 19 |
onOutsideClick: !1, |
| 20 |
onOutsideContextMenu: !1, |
| 21 |
onBackgroundClick: !0 |
| 22 |
}, |
| 23 |
position: { |
| 24 |
my: "center", |
| 25 |
at: "center" |
| 26 |
}, |
| 27 |
onShow: function () { |
| 28 |
var e = window.WdkitPopup.getElements("content"); |
| 29 |
window.WdkitPopupToggle.open(current_route, e.get(0), "elementor") |
| 30 |
}, |
| 31 |
onHide: function () { |
| 32 |
var e = window.WdkitPopup.getElements("content"); |
| 33 |
window.WdkitPopupToggle.close(e.get(0)), window.WdkitPopup.destroy() |
| 34 |
} |
| 35 |
}), |
| 36 |
window.WdkitPopup.getElements("header").remove(), window.WdkitPopup.getElements("message").append(window.WdkitPopup.addElement("content")) |
| 37 |
} |
| 38 |
return window.WdkitPopup.show() |
| 39 |
} |
| 40 |
$("document").ready(function () { |
| 41 |
if (typeof elementor === "object" && elementor.$preview) { |
| 42 |
elementor.on("panel:init", (function () { |
| 43 |
$(".elementor-panel-footer-sub-menu").append('<div id="elementor-panel-footer-sub-menu-item-push-wdkit" class="elementor-panel-footer-sub-menu-item"><i class="elementor-icon eicon-folder" aria-hidden="true"></i><span class="elementor-title">' + __("Save Page in WdesignKit", "wdesignkit") + "</span></div>"), $(".elementor-panel-footer-sub-menu").on("click", "#elementor-panel-footer-sub-menu-item-push-wdkit", (function () { |
| 44 |
wkit_load_save_tempalte({ |
| 45 |
route: "/save_template" |
| 46 |
}, null) |
| 47 |
})) |
| 48 |
})); |
| 49 |
|
| 50 |
var e = ["section", "container"], |
| 51 |
b = []; |
| 52 |
elementor.on("preview:loaded", function () { |
| 53 |
e.forEach(function (c, f) { |
| 54 |
elementor.hooks.addFilter("elements/" + e[f] + "/contextMenuGroups", function (c, d) { |
| 55 |
return ( |
| 56 |
b.push(d), |
| 57 |
c.push({ |
| 58 |
name: "wdkit_" + e[f], |
| 59 |
actions: [ |
| 60 |
{ |
| 61 |
name: "wdkit_save_section", |
| 62 |
title: "Save in WDesignKit", |
| 63 |
icon: "eicon-save", |
| 64 |
callback: function () { |
| 65 |
localStorage.setItem("wdkit_section", JSON.stringify(d.model.toJSON({ |
| 66 |
remove: ["default"], |
| 67 |
}))); |
| 68 |
wkit_load_save_tempalte({ |
| 69 |
route: "/save_template/section" |
| 70 |
}, null); |
| 71 |
setTimeout((function () { |
| 72 |
if (window.location && window.location.hash != '#/save_template') { |
| 73 |
window.location.hash = '#/save_template/section'; |
| 74 |
} |
| 75 |
}), 20) |
| 76 |
}, |
| 77 |
}, |
| 78 |
], |
| 79 |
}), |
| 80 |
c |
| 81 |
); |
| 82 |
}); |
| 83 |
}); |
| 84 |
}); |
| 85 |
} |
| 86 |
var eleTempContent = $("#tmpl-elementor-add-section"); |
| 87 |
if (eleTempContent.length > 0) { |
| 88 |
var actionHtml = eleTempContent.html(); |
| 89 |
actionHtml = actionHtml.replace('<div class="elementor-add-section-drag-title', '<div data-mode="dark" class="elementor-add-section-area-button elementor-action-wdkit-button" title="' + __("WdesignKit") + '"><a href="#" class="wkit-main-logo-div"></a></div><div class="elementor-add-section-drag-title'), eleTempContent.html(actionHtml), elementor.on("preview:loaded", (function () { |
| 90 |
$(elementor.$previewContents[0].body).on("click", ".elementor-action-wdkit-button", (function (e) { |
| 91 |
wkit_load_save_tempalte({ |
| 92 |
route: "/dashboard" |
| 93 |
}, null) |
| 94 |
})) |
| 95 |
})) |
| 96 |
} |
| 97 |
}); |
| 98 |
})(jQuery); |