(function ($) { 'use strict'; var ElementPackEditor = { init: function () { elementor.channels.editor.on('section:activated', ElementPackEditor.onAnimatedBoxSectionActivated); window.elementor.on('preview:loaded', function () { elementor.$preview[0].contentWindow.ElementPackEditor = ElementPackEditor; ElementPackEditor.onPreviewLoaded(); }); }, onPreviewLoaded: function () { var elementorFrontend = $('#elementor-preview-iframe')[0].contentWindow.elementorFrontend; elementorFrontend.hooks.addAction('frontend/element_ready/widget', function ($scope) { $scope.find('.bdt-elementor-template-edit-link').on('click', function (event) { window.open($(this).attr('href')); }); }); }, }; // Wait for both jQuery and Elementor to be ready function waitForDependencies() { if (typeof $ !== 'undefined' && typeof elementor !== 'undefined') { ElementPackEditor.init(); } else { setTimeout(waitForDependencies, 100); } } // Start waiting for dependencies waitForDependencies(); window.ElementPackEditor = ElementPackEditor; elementor.hooks.addFilter("panel/elements/regionViews", function (panel) { // Add custom CSS for pro unlock icon jQuery(document).ready(function () { jQuery('body').append(``); }); // Handle promotional widgets (editor JS responsibility) if (ElementPackConfigPromotional.pro_installed || ElementPackConfigPromotional.promotional_widgets <= 0) { return panel; } // Handle promotional widgets var promotionalWidgetHandler, promotionalWidgets = ElementPackConfigPromotional.promotional_widgets, elementsCollection = panel.elements.options.collection, categories = panel.categories.options.collection, categoriesView = panel.categories.view, elementsView = panel.elements.view, freeCategoryIndex, proWidgets = []; _.each(promotionalWidgets, function (widget, index) { elementsCollection.add({ name: widget.name, title: widget.title, icon: widget.icon, categories: widget.categories, editable: false }) }); elementsCollection.each(function (widget) { "element-pack-pro" === widget.get("categories")[0] && proWidgets.push(widget) }); freeCategoryIndex = categories.findIndex({ name: "element-pack" }); freeCategoryIndex && categories.add({ name: "element-pack-pro", title: "Element Pack Pro", defaultActive: !1, items: proWidgets }, { at: freeCategoryIndex + 1 }); promotionalWidgetHandler = { getWedgetOption: function (name) { return promotionalWidgets.find(function (item) { return item.name == name; }); }, className: function () { var className = 'elementor-element-wrapper'; if (!this.isEditable()) { className += ' elementor-element--promotion'; } return className; }, onMouseDown: function () { void this.constructor.__super__.onMouseDown.call(this); var promotion = this.getWedgetOption(this.model.get("name")); elementor.promotion.showDialog({ title: sprintf(wp.i18n.__('%s', 'elementor'), this.model.get("title")), content: sprintf(wp.i18n.__('Use %s widget and dozens more pro features to extend your toolbox and build sites faster and better.', 'elementor'), this.model.get("title")), targetElement: this.el, position: { blockStart: '-7' }, actionButton: { url: promotion.action_button.url, text: promotion.action_button.text, classes: promotion.action_button.classes || ['elementor-button', 'elementor-button-success'] } }) } } panel.elements.view = elementsView.extend({ childView: elementsView.prototype.childView.extend(promotionalWidgetHandler) }); panel.categories.view = categoriesView.extend({ childView: categoriesView.prototype.childView.extend({ childView: categoriesView.prototype.childView.prototype.childView.extend(promotionalWidgetHandler) }) }); return panel; }) // Advanced Google Map - Initialize when document is ready $(document).ready(function() { initLocationSearch(); }); // Initialize when widget panel opens (for dynamically created elements) if (typeof elementor !== "undefined") { elementor.hooks.addAction("panel/open_editor/widget", function() { setTimeout(initLocationSearch, 300); }); } function initLocationSearch() { // Remove any existing handlers first to prevent duplicates $(document).off("click", ".ep-location-search-btn"); $(document).off("click", ".ep-modal-close"); $(document).off("click", ".ep-search-address-button"); $(document).off("click", ".ep-select-location-button"); $(document).off("click", ".ep-search-result-item"); // Button click handler $(document).on("click", ".ep-location-search-btn", function(e) { e.preventDefault(); e.stopPropagation(); var $btn = $(this); var $modal = $btn.next(".ep-location-search-modal"); var $latField = $btn.closest(".elementor-repeater-row-controls").find("input[data-setting=\"marker_lat\"]"); var $lngField = $btn.closest(".elementor-repeater-row-controls").find("input[data-setting=\"marker_lng\"]"); // Store references for later use $modal.data("latField", $latField); $modal.data("lngField", $lngField); // Clear any previous results $modal.find(".ep-search-results").empty(); $modal.find(".ep-address-search").val(""); $modal.find(".ep-select-location-button").hide(); // Show the modal $modal.fadeIn(200); // Focus on search input $modal.find(".ep-address-search").focus(); }); // Close button handler $(document).on("click", ".ep-modal-close", function() { $(this).closest(".ep-location-search-modal").fadeOut(200); }); // Close on click outside modal content $(document).on("click", ".ep-location-search-modal", function(e) { if ($(e.target).hasClass("ep-location-search-modal")) { $(this).fadeOut(200); } }); // Search button handler $(document).on("click", ".ep-search-address-button", function() { var $modal = $(this).closest(".ep-location-search-modal"); var address = $modal.find(".ep-address-search").val().trim(); if (address) { performSearch(address, $modal); } }); // Enter key in search input $(document).on("keypress", ".ep-address-search", function(e) { if (e.which === 13) { e.preventDefault(); var $modal = $(this).closest(".ep-location-search-modal"); var address = $(this).val().trim(); if (address) { performSearch(address, $modal); } } }); // Select location button handler $(document).on("click", ".ep-select-location-button", function() { var $modal = $(this).closest(".ep-location-search-modal"); var selectedLocation = $modal.data("selectedLocation"); var $latField = $modal.data("latField"); var $lngField = $modal.data("lngField"); if (selectedLocation && $latField.length && $lngField.length) { $latField.val(selectedLocation.lat).trigger("input"); $lngField.val(selectedLocation.lng).trigger("input"); $modal.fadeOut(200); } }); } function performSearch(address, $modal) { var $results = $modal.find(".ep-search-results"); $results.html("
Searching...
"); $modal.find(".ep-select-location-button").hide(); if (typeof google === "undefined" || typeof google.maps === "undefined") { $results.html("Google Maps API not loaded. Please check your API key.
"); return; } var geocoder = new google.maps.Geocoder(); geocoder.geocode({address: address}, function(results, status) { $results.empty(); if (status === "OK") { if (results.length > 0) { // Create results list var $resultsList = $(""); $results.append($resultsList); // Create map container var mapId = "ep-location-preview-map-" + Date.now(); var $mapContainer = $(""); $results.append($mapContainer); // Initialize map var tempMap = new google.maps.Map(document.getElementById(mapId), { zoom: 14, center: results[0].geometry.location }); // Add markers for each result results.forEach(function(result, index) { var location = { lat: result.geometry.location.lat(), lng: result.geometry.location.lng(), address: result.formatted_address }; // Create result item var $resultItem = $(""); $resultItem.html("" + location.address + "No results found
"); } } else { $results.html("Geocode was not successful: " + status + "
"); } }); } // Elementor Editor Pro Locked Extension Management var ElementorProLockedExtension = { init: function() { setInterval(this.hideExtensionControlSections.bind(this), 500); }, hideExtensionControlSections: function() { $('.bdt-ep-pro-badge').closest('.elementor-control').css('pointer-events', 'none'); }, }; $(document).ready(function() { ElementorProLockedExtension.init(); }); }(jQuery));