| 1 |
(function ($) { |
| 2 |
$(window).on('elementor/frontend/init', function () { |
| 3 |
var isEditMode = false; |
| 4 |
if (elementorFrontend.isEditMode()) { |
| 5 |
isEditMode = true; |
| 6 |
} |
| 7 |
if (isEditMode) { |
| 8 |
parent.document.addEventListener("mousedown", function (e) { |
| 9 |
var widgets = parent.document.querySelectorAll(".elementor-element--promotion"); |
| 10 |
if (widgets.length > 0) { |
| 11 |
for (var i = 0; i < widgets.length; i++) { |
| 12 |
if (widgets[i].contains(e.target)) { |
| 13 |
var dialog = parent.document.querySelector("#elementor-element--promotion__dialog"); |
| 14 |
var icon = widgets[i].querySelector(".icon > i"); |
| 15 |
|
| 16 |
if (icon.classList.toString().indexOf("betterdocs-icon") >= 0) { |
| 17 |
var dialogSelector = dialog.querySelectorAll(".dialog-buttons-action"); |
| 18 |
if (dialogSelector.length > 0) { |
| 19 |
for (var i = 0; i < dialogSelector.length; i++) { |
| 20 |
dialogSelector[i].style.display = "none"; |
| 21 |
} |
| 22 |
} |
| 23 |
e.stopImmediatePropagation(); |
| 24 |
if (dialog.querySelector(".betterdocs-dialog-buttons-action") === null) { |
| 25 |
var button = document.createElement("a"); |
| 26 |
var buttonText = document.createTextNode("Upgrade BetterDocs"); |
| 27 |
|
| 28 |
button.setAttribute("href", "https://betterdocs.co/upgrade"); |
| 29 |
button.setAttribute("target", "_blank"); |
| 30 |
button.classList.add( |
| 31 |
"dialog-button", |
| 32 |
"dialog-action", |
| 33 |
"dialog-buttons-action", |
| 34 |
"elementor-button", |
| 35 |
"elementor-button-success", |
| 36 |
"betterdocs-dialog-buttons-action" |
| 37 |
); |
| 38 |
button.appendChild(buttonText); |
| 39 |
|
| 40 |
dialog.querySelector(".dialog-buttons-action").insertAdjacentHTML("afterend", button.outerHTML); |
| 41 |
} else { |
| 42 |
dialog.querySelector(".betterdocs-dialog-buttons-action").style.display = ""; |
| 43 |
} |
| 44 |
} else { |
| 45 |
dialog.querySelector(".dialog-buttons-action").style.display = ""; |
| 46 |
|
| 47 |
if (dialog.querySelector(".betterdocs-dialog-buttons-action") !== null) { |
| 48 |
dialog.querySelector(".betterdocs-dialog-buttons-action").style.display = "none"; |
| 49 |
} |
| 50 |
} |
| 51 |
// stop loop |
| 52 |
break; |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
}); |
| 57 |
} |
| 58 |
}); |
| 59 |
}(jQuery)); |
| 60 |
|
| 61 |
|