| 1 |
(function(){ |
| 2 |
(function($, window, document, undefined) { |
| 3 |
$(window).on("elementor:init", function() { |
| 4 |
$(".elementor-editor-active").addClass("master-addons"); |
| 5 |
if (typeof elementorPro == "undefined") elementor.hooks.addFilter("editor/style/styleText", function(css, context) { |
| 6 |
if (!context) return; |
| 7 |
var model = context.model, customCSS = model.get("settings").get("custom_css"); |
| 8 |
var selector = ".elementor-element.elementor-element-" + model.get("id"); |
| 9 |
if ("document" === model.get("elType")) selector = elementor.config.document.settings.cssWrapperSelector; |
| 10 |
if (customCSS) css += customCSS.replace(/selector/g, selector); |
| 11 |
return css; |
| 12 |
}); |
| 13 |
/*! |
| 14 |
* ================== Visual Select Controller =================== |
| 15 |
**/ |
| 16 |
var JltmaControlVisualSelectItemView = elementor.modules.controls.BaseData.extend({ |
| 17 |
onReady: function() { |
| 18 |
this.ui.select.jltmaVisualSelect(); |
| 19 |
}, |
| 20 |
onBeforeDestroy: function() { |
| 21 |
this.ui.select.jltmaVisualSelect("destroy"); |
| 22 |
} |
| 23 |
}); |
| 24 |
elementor.addControlView("jltma-visual-select", JltmaControlVisualSelectItemView); |
| 25 |
function jltmaOnGlobalOpenEditorForTranistions(panel, model, view) { |
| 26 |
view.listenTo(model.get("settings"), "change", function(changedModel) { |
| 27 |
if ("" !== model.getSetting("ma_el_animation_name") && !view.$el.hasClass("jltma-animated")) { |
| 28 |
view.render(); |
| 29 |
view.$el.addClass("jltma-animated"); |
| 30 |
view.$el.addClass("jltma-animated-once"); |
| 31 |
} |
| 32 |
for (settingName in changedModel.changed) if (changedModel.changed.hasOwnProperty(settingName)) { |
| 33 |
if (settingName !== "ma_el_animation_name" && -1 !== settingName.indexOf("ma_el_animation_")) { |
| 34 |
view.$el.removeClass(model.getSetting("ma_el_animation_name")); |
| 35 |
setTimeout(function() { |
| 36 |
view.$el.addClass(model.getSetting("ma_el_animation_name")); |
| 37 |
}, model.getSetting("ma_el_animation_delay") || 300); |
| 38 |
} |
| 39 |
} |
| 40 |
}, view); |
| 41 |
} |
| 42 |
elementor.hooks.addAction("panel/open_editor/section", jltmaOnGlobalOpenEditorForTranistions); |
| 43 |
elementor.hooks.addAction("panel/open_editor/column", jltmaOnGlobalOpenEditorForTranistions); |
| 44 |
elementor.hooks.addAction("panel/open_editor/widget", jltmaOnGlobalOpenEditorForTranistions); |
| 45 |
var JLTMA_Choose_Text = elementor.modules.controls.Choose.extend({ applySavedValue: function applySavedValue() { |
| 46 |
var currentValue = this.getControlValue(); |
| 47 |
if (currentValue || _.isString(currentValue)) this.ui.inputs.filter("[value=\"".concat(currentValue, "\"]")).prop("checked", true); |
| 48 |
else this.ui.inputs.filter(":checked").prop("checked", false); |
| 49 |
} }); |
| 50 |
elementor.hooks.addAction("panel/open_editor/widget", JLTMA_Choose_Text); |
| 51 |
elementor.addControlView("jltma-choose-text", JLTMA_Choose_Text); |
| 52 |
var JLTMA_ControlQuery = elementor.modules.controls.Select2.extend({ |
| 53 |
cache: null, |
| 54 |
isTitlesReceived: false, |
| 55 |
getSelect2Placeholder: function getSelect2Placeholder() { |
| 56 |
return { |
| 57 |
id: "", |
| 58 |
text: "All" |
| 59 |
}; |
| 60 |
}, |
| 61 |
getSelect2DefaultOptions: function getSelect2DefaultOptions() { |
| 62 |
var self = this; |
| 63 |
return jQuery.extend(elementor.modules.controls.Select2.prototype.getSelect2DefaultOptions.apply(this, arguments), { |
| 64 |
ajax: { |
| 65 |
transport: function transport(params, success, failure) { |
| 66 |
var data = { |
| 67 |
q: params.data.q, |
| 68 |
query_type: self.model.get("query_type"), |
| 69 |
object_type: self.model.get("object_type") |
| 70 |
}; |
| 71 |
return elementorCommon.ajax.addRequest("jltma_query_control_filter_autocomplete", { |
| 72 |
data, |
| 73 |
success, |
| 74 |
error: failure |
| 75 |
}); |
| 76 |
}, |
| 77 |
data: function data(params) { |
| 78 |
return { |
| 79 |
q: params.term, |
| 80 |
page: params.page |
| 81 |
}; |
| 82 |
}, |
| 83 |
cache: true |
| 84 |
}, |
| 85 |
escapeMarkup: function escapeMarkup(markup) { |
| 86 |
return markup; |
| 87 |
}, |
| 88 |
minimumInputLength: 1 |
| 89 |
}); |
| 90 |
}, |
| 91 |
getValueTitles: function getValueTitles() { |
| 92 |
var self = this, ids = this.getControlValue(), queryType = this.model.get("query_type"); |
| 93 |
objectType = this.model.get("object_type"); |
| 94 |
if (!ids || !queryType) return; |
| 95 |
if (!_.isArray(ids)) ids = [ids]; |
| 96 |
elementorCommon.ajax.loadObjects({ |
| 97 |
action: "jltma_query_control_value_titles", |
| 98 |
ids, |
| 99 |
data: { |
| 100 |
query_type: queryType, |
| 101 |
object_type: objectType, |
| 102 |
unique_id: "" + self.cid + queryType |
| 103 |
}, |
| 104 |
success: function success(data) { |
| 105 |
self.isTitlesReceived = true; |
| 106 |
self.model.set("options", data); |
| 107 |
self.render(); |
| 108 |
}, |
| 109 |
before: function before() { |
| 110 |
self.addSpinner(); |
| 111 |
} |
| 112 |
}); |
| 113 |
}, |
| 114 |
addSpinner: function addSpinner() { |
| 115 |
this.ui.select.prop("disabled", true); |
| 116 |
this.$el.find(".elementor-control-title").after("<span class=\"elementor-control-spinner ee-control-spinner\"> <i class=\"fa fa-spinner fa-spin\"></i> </span>"); |
| 117 |
}, |
| 118 |
onReady: function onReady() { |
| 119 |
setTimeout(elementor.modules.controls.Select2.prototype.onReady.bind(this)); |
| 120 |
if (!this.isTitlesReceived) this.getValueTitles(); |
| 121 |
} |
| 122 |
}); |
| 123 |
elementor.addControlView("jltma_query", JLTMA_ControlQuery); |
| 124 |
/** |
| 125 |
* Disable Pro-Restricted Switcher Controls |
| 126 |
* Handles switcher controls with .jltma-pro-disabled class in description |
| 127 |
* Uses MutationObserver to watch for DOM changes |
| 128 |
*/ |
| 129 |
function jltmaHandleProRestrictedSwitchers() { |
| 130 |
var processedControls = /* @__PURE__ */ new Set(); |
| 131 |
function disableProSwitchers() { |
| 132 |
jQuery(".elementor-control-type-switcher").each(function() { |
| 133 |
var $control = jQuery(this); |
| 134 |
var controlId = $control.attr("data-control-name") || $control.index(); |
| 135 |
if (processedControls.has(controlId)) return; |
| 136 |
if ($control.find(".elementor-control-field-description").find(".jltma-pro-disabled").length > 0) { |
| 137 |
var $switcherInput = $control.find("input[type=\"checkbox\"]"); |
| 138 |
var $switcherLabel = $control.find(".elementor-switch"); |
| 139 |
$control.addClass("jltma-switcher-disabled"); |
| 140 |
$switcherLabel.addClass("jltma-switcher-disabled"); |
| 141 |
$switcherInput.prop("disabled", true); |
| 142 |
$switcherLabel.off("click.jltma-pro").on("click.jltma-pro", function(e) { |
| 143 |
e.preventDefault(); |
| 144 |
e.stopPropagation(); |
| 145 |
jQuery(".jltma-upgrade-popup").fadeIn(200); |
| 146 |
return false; |
| 147 |
}); |
| 148 |
$control.find("label").off("click.jltma-pro").on("click.jltma-pro", function(e) { |
| 149 |
if ($switcherLabel.hasClass("jltma-switcher-disabled")) { |
| 150 |
e.preventDefault(); |
| 151 |
e.stopPropagation(); |
| 152 |
jQuery(".jltma-upgrade-popup").fadeIn(200); |
| 153 |
return false; |
| 154 |
} |
| 155 |
}); |
| 156 |
processedControls.add(controlId); |
| 157 |
} |
| 158 |
}); |
| 159 |
} |
| 160 |
function setupObserver() { |
| 161 |
var targetNode = document.querySelector("#elementor-panel-content-wrapper"); |
| 162 |
if (!targetNode) { |
| 163 |
setTimeout(setupObserver, 500); |
| 164 |
return; |
| 165 |
} |
| 166 |
new MutationObserver(function(mutations) { |
| 167 |
var shouldProcess = false; |
| 168 |
mutations.forEach(function(mutation) { |
| 169 |
if (mutation.addedNodes.length > 0) shouldProcess = true; |
| 170 |
}); |
| 171 |
if (shouldProcess) disableProSwitchers(); |
| 172 |
}).observe(targetNode, { |
| 173 |
childList: true, |
| 174 |
subtree: true, |
| 175 |
attributes: false |
| 176 |
}); |
| 177 |
disableProSwitchers(); |
| 178 |
} |
| 179 |
function startIntervalCheck() { |
| 180 |
setInterval(function() { |
| 181 |
disableProSwitchers(); |
| 182 |
}, 1e3); |
| 183 |
} |
| 184 |
jQuery(window).on("elementor:init", function() { |
| 185 |
setTimeout(function() { |
| 186 |
setupObserver(); |
| 187 |
startIntervalCheck(); |
| 188 |
}, 1e3); |
| 189 |
}); |
| 190 |
setTimeout(function() { |
| 191 |
setupObserver(); |
| 192 |
startIntervalCheck(); |
| 193 |
}, 2e3); |
| 194 |
} |
| 195 |
jltmaHandleProRestrictedSwitchers(); |
| 196 |
/** |
| 197 |
* Pro Widget Promotion Dialog Handler |
| 198 |
* Customizes the Elementor promotion dialog for Master Addons pro widgets |
| 199 |
*/ |
| 200 |
function jltmaProWidgetPromotionHandler() { |
| 201 |
if (typeof parent.document === "undefined") return false; |
| 202 |
parent.document.addEventListener("mousedown", function(e) { |
| 203 |
var widgets = parent.document.querySelectorAll(".elementor-element--promotion"); |
| 204 |
if (widgets.length > 0) { |
| 205 |
for (var i = 0; i < widgets.length; i++) if (widgets[i].contains(e.target)) { |
| 206 |
var dialog = parent.document.querySelector("#elementor-element--promotion__dialog"); |
| 207 |
var icon = widgets[i].querySelector(".icon > i"); |
| 208 |
if (!dialog || !icon) break; |
| 209 |
if (icon.classList.toString().indexOf("jltma") >= 0) { |
| 210 |
var defaultButton = dialog.querySelector(".dialog-buttons-action"); |
| 211 |
if (defaultButton) defaultButton.style.display = "none"; |
| 212 |
e.stopImmediatePropagation(); |
| 213 |
if (dialog.querySelector(".jltma-dialog-buttons-action") === null) { |
| 214 |
var button = document.createElement("a"); |
| 215 |
var buttonText = document.createTextNode("Upgrade Master Addons"); |
| 216 |
button.setAttribute("href", "https://master-addons.com/pricing/"); |
| 217 |
button.setAttribute("target", "_blank"); |
| 218 |
button.classList.add("dialog-button", "dialog-action", "dialog-buttons-action", "elementor-button", "go-pro", "elementor-button-success", "jltma-dialog-buttons-action"); |
| 219 |
button.style.display = "block"; |
| 220 |
button.style.textAlign = "center"; |
| 221 |
button.appendChild(buttonText); |
| 222 |
if (defaultButton) defaultButton.insertAdjacentHTML("afterend", button.outerHTML); |
| 223 |
} else { |
| 224 |
const btnWrapper = document.querySelector(".dialog-buttons-buttons-wrapper > button"); |
| 225 |
btnWrapper.style.display = "none"; |
| 226 |
dialog.querySelector(".jltma-dialog-buttons-action").style.display = "block"; |
| 227 |
} |
| 228 |
} else { |
| 229 |
var defaultBtn = dialog.querySelector(".dialog-buttons-action:not(.jltma-dialog-buttons-action)"); |
| 230 |
if (defaultBtn) defaultBtn.style.display = ""; |
| 231 |
var jltmaBtn = dialog.querySelector(".jltma-dialog-buttons-action"); |
| 232 |
if (jltmaBtn !== null) jltmaBtn.style.display = "none"; |
| 233 |
} |
| 234 |
break; |
| 235 |
} |
| 236 |
} |
| 237 |
}); |
| 238 |
} |
| 239 |
jltmaProWidgetPromotionHandler(); |
| 240 |
}); |
| 241 |
})(jQuery, window, document); |
| 242 |
//#endregion |
| 243 |
})(); |
| 244 |
|