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