1 line
7.7 KiB
JavaScript
1 line
7.7 KiB
JavaScript
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=38)}({38:function(e,t,n){"use strict";window.XdUtils=window.XdUtils||{extend:function(e,t){var n,o=t||{};for(n in e)e.hasOwnProperty(n)&&(o[n]=e[n]);return o}},window.xdLocalStorage=window.xdLocalStorage||function(){function e(e){var t;try{t=JSON.parse(e.data)}catch(e){}t&&t.namespace===l&&("iframe-ready"===t.id?(u=!0,c.initCallback()):function(e){r[e.id]&&(r[e.id](e),delete r[e.id])}(t))}function t(e,t,n,o){s++,r[s]=o;var i={namespace:l,id:s,action:e,key:t,value:n};a.contentWindow.postMessage(JSON.stringify(i),"*")}function n(t){c=XdUtils.extend(t,c);var n=document.createElement("div");window.addEventListener?window.addEventListener("message",e,!1):window.attachEvent("onmessage",e),n.innerHTML='<iframe id="'+c.iframeId+'" src='+c.iframeUrl+' style="display: none;"></iframe>',document.body.appendChild(n),a=document.getElementById(c.iframeId)}function o(){return d?!!u||(console.log("You must wait for iframe ready message before using the api."),!1):(console.log("You must call xdLocalStorage.init() before using it."),!1)}function i(){return"complete"===document.readyState}var a,l="eael-xd-copy-message",c={iframeId:"cross-domain-iframe",iframeUrl:void 0,initCallback:function(){}},s=-1,r={},d=!1,u=!0;return{init:function(e){if(!e.iframeUrl)throw"You must specify iframeUrl";d?console.log("xdLocalStorage was already initialized!"):(d=!0,i()?n(e):document.addEventListener?document.addEventListener("readystatechange",(function(){i()&&n(e)})):document.attachEvent("readystatechange",(function(){i()&&n(e)})))},setItem:function(e,n,i){o()&&t("set",e,n,i)},getItem:function(e,n){o()&&t("get",e,null,n)},removeItem:function(e,n){o()&&t("remove",e,null,n)},key:function(e,n){o()&&t("key",e,null,n)},getSize:function(e){o()&&t("size",null,null,e)},getLength:function(e){o()&&t("length",null,null,e)},clear:function(e){o()&&t("clear",null,null,e)},wasInit:function(){return d}}}(),xdLocalStorage.init({iframeUrl:"https://app.essential-addons.com/cross-domain-copy-paste/",initCallback:function(){}}),function(e){var t=[];function n(e){return e.forEach((function(e){e.id=elementorCommon.helpers.getUniqueId(),0<e.elements.length&&n(e.elements)})),e}["container","section","column","widget"].forEach((function(e,o){elementor.hooks.addFilter("elements/"+e+"/contextMenuGroups",(function(o,i){return o.splice(1,0,{name:"eael_"+e,actions:[{name:"ea_copy",title:eael_xd_copy.i18n.ea_copy,icon:"eicon-copy",shortcut:'<i class="eaicon-badge"></i>',callback:function(){var n={};n.elementtype="widget"===e?i.model.get("widgetType"):null,n.elementcode=i.model.toJSON(),xdLocalStorage.setItem("eael-xd-copy-data",JSON.stringify(n),(function(n){elementor.notifications.showToast({message:eael_xd_copy.i18n[e+"_message"],buttons:t})}))}},{name:"ea_paste",title:eael_xd_copy.i18n.ea_paste,icon:"eicon-import-kit",shortcut:'<i class="eaicon-badge"></i>',callback:function(){xdLocalStorage.getItem("eael-xd-copy-data",(function(e){!function(e,t){var o=t,i=t.model.get("elType"),a=e.elementcode.elType,l=e.elementcode,c=JSON.stringify(l),s=/\.(jpg|png|jpeg|gif|svg|webp|psd|bmp)/gi.test(c),r={elType:a,settings:l.settings},d=null,u={index:0};switch(a){case"container":case"section":r.elements=n(l.elements),d=elementor.getPreviewContainer();break;case"column":r.elements=n(l.elements),"section"===i?d=o.getContainer():"column"===i?(d=o.getContainer().parent,u.index=o.getOption("_index")+1):"widget"===i&&(d=o.getContainer().parent.parent,u.index=o.getContainer().parent.view.getOption("_index")+1);break;case"widget":r.widgetType=e.elementtype,d=o.getContainer(),"section"===i?d=o.children.findByIndex(0).getContainer():"column"===i?d=o.getContainer():"widget"===i&&(d=o.getContainer().parent,u.index=o.getOption("_index")+1)}var m=$e.run("document/elements/create",{model:r,container:d,options:u});s&&jQuery.ajax({url:eael_xd_copy.ajax_url,method:"POST",data:{nonce:eael_xd_copy.nonce,action:"eael_xd_copy_fetch_content",xd_copy_data:c}}).done((function(e){if(e.success){var t=e.data[0];r.elType=t.elType,r.settings=t.settings,"widget"===r.elType?r.widgetType=t.widgetType:r.elements=t.elements,$e.run("document/elements/delete",{container:m}),$e.run("document/elements/create",{model:r,container:d,options:u})}}))}(JSON.parse(e.value),i),elementor.notifications.showToast({message:eael_xd_copy.i18n.paste_message,buttons:t})}))}}]}),o}))})),e(document).on("click",".elementor-context-menu-list__item-ea_copy_all",(function(){e(this).closest(".elementor-context-menu").hide();var n=Object.values(elementor.getPreviewView().children._views).map((function(e){return e.getContainer().model.toJSON()}));xdLocalStorage.setItem("eael-xd-copy-all-data",JSON.stringify(n),(function(e){elementor.notifications.showToast({message:eael_xd_copy.i18n.full_page_message,buttons:t})}))})),e(document).on("click",".elementor-context-menu-list__item-ea_paste_all",(function(){e(this).closest(".elementor-context-menu").hide(),xdLocalStorage.getItem("eael-xd-copy-all-data",(function(n){elementor.notifications.showToast({message:eael_xd_copy.i18n.full_page_pasting_message,buttons:t}),function(n){jQuery.ajax({url:eael_xd_copy.ajax_url,method:"POST",data:{nonce:eael_xd_copy.nonce,action:"eael_xd_copy_fetch_content",xd_copy_data:n}}).done((function(n){n.success&&(elementor.previewView.addChildModel(n.data[0]),elementor.notifications.showToast({message:eael_xd_copy.i18n.full_page_paste_message,buttons:t}),e("#elementor-panel-footer-saver-publish, #elementor-panel-footer-saver-options").find(".elementor-disabled").removeClass("elementor-disabled"))})).fail((function(){elementor.notifications.showToast({message:elementor.translate("Something went wrong!"),buttons:t})}))}(JSON.stringify(JSON.parse(n.value)))}))}));var o=new MutationObserver((function(t){t.forEach((function(t){t.addedNodes.forEach((function(t){e(t).find(".elementor-context-menu-list__group.elementor-context-menu-list__group-paste").length&&(e(".elementor-context-menu-list__group.elementor-context-menu-list__group-paste").closest(".elementor-context-menu-list").prepend('<div class="elementor-context-menu-list__group elementor-context-menu-list__group-ea_copy_all"><div class="elementor-context-menu-list__item elementor-context-menu-list__item-ea_copy_all"><div class="elementor-context-menu-list__item__icon"><i class="eicon-copy"></i></div><div class="elementor-context-menu-list__item__title">'.concat(eael_xd_copy.i18n.ea_copy_all,'</div><div class="elementor-context-menu-list__item__shortcut"><i class="eaicon-badge"></i></div></div><div class="elementor-context-menu-list__item elementor-context-menu-list__item-ea_paste_all"><div class="elementor-context-menu-list__item__icon"><i class="eicon-import-kit"></i></div><div class="elementor-context-menu-list__item__title">').concat(eael_xd_copy.i18n.ea_paste_all,'</div><div class="elementor-context-menu-list__item__shortcut"><i class="eaicon-badge"></i></div></div></div>')),o.disconnect())}))}))}));o.observe(document.querySelector("body"),{subtree:!1,childList:!0})}(jQuery)}}); |