Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/bdthemes-element-pack/assets/js/ep-editor.js
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
(function ($) {
2
+
3
+
'use strict';
4
+
5
+
var ElementPackEditor = {
6
+
7
+
init: function () {
8
+
elementor.channels.editor.on('section:activated', ElementPackEditor.onAnimatedBoxSectionActivated);
9
+
10
+
window.elementor.on('preview:loaded', function () {
11
+
elementor.$preview[0].contentWindow.ElementPackEditor = ElementPackEditor;
12
+
ElementPackEditor.onPreviewLoaded();
13
+
});
14
+
},
15
+
16
+
17
+
onPreviewLoaded: function () {
18
+
var elementorFrontend = $('#elementor-preview-iframe')[0].contentWindow.elementorFrontend;
19
+
20
+
elementorFrontend.hooks.addAction('frontend/element_ready/widget', function ($scope) {
21
+
$scope.find('.bdt-elementor-template-edit-link').on('click', function (event) {
22
+
window.open($(this).attr('href'));
23
+
});
24
+
});
25
+
},
26
+
27
+
28
+
};
29
+
30
+
// Wait for both jQuery and Elementor to be ready
31
+
function waitForDependencies() {
32
+
if (typeof $ !== 'undefined' && typeof elementor !== 'undefined') {
33
+
ElementPackEditor.init();
34
+
} else {
35
+
setTimeout(waitForDependencies, 100);
36
+
}
37
+
}
38
+
39
+
// Start waiting for dependencies
40
+
waitForDependencies();
41
+
42
+
window.ElementPackEditor = ElementPackEditor;
43
+
44
+
elementor.hooks.addFilter("panel/elements/regionViews", function (panel) {
45
+
// Add custom CSS for pro unlock icon
46
+
jQuery(document).ready(function () {
47
+
jQuery('body').append(`<style>.bdt-pro-unlock-icon:after{right: auto !important; left: 5px !important;}</style>`);
48
+
});
49
+
50
+
51
+
// Handle promotional widgets (editor JS responsibility)
52
+
if (ElementPackConfigPromotional.pro_installed || ElementPackConfigPromotional.promotional_widgets <= 0) {
53
+
return panel;
54
+
}
55
+
56
+
// Handle promotional widgets
57
+
var promotionalWidgetHandler,
58
+
promotionalWidgets = ElementPackConfigPromotional.promotional_widgets,
59
+
elementsCollection = panel.elements.options.collection,
60
+
categories = panel.categories.options.collection,
61
+
categoriesView = panel.categories.view,
62
+
elementsView = panel.elements.view,
63
+
freeCategoryIndex, proWidgets = [];
64
+
65
+
_.each(promotionalWidgets, function (widget, index) {
66
+
elementsCollection.add({
67
+
name: widget.name,
68
+
title: widget.title,
69
+
icon: widget.icon,
70
+
categories: widget.categories,
71
+
editable: false
72
+
})
73
+
});
74
+
75
+
elementsCollection.each(function (widget) {
76
+
"element-pack-pro" === widget.get("categories")[0] && proWidgets.push(widget)
77
+
});
78
+
79
+
freeCategoryIndex = categories.findIndex({
80
+
name: "element-pack"
81
+
});
82
+
83
+
freeCategoryIndex && categories.add({
84
+
name: "element-pack-pro",
85
+
title: "Element Pack Pro",
86
+
defaultActive: !1,
87
+
items: proWidgets
88
+
}, {
89
+
at: freeCategoryIndex + 1
90
+
});
91
+
92
+
promotionalWidgetHandler = {
93
+
94
+
getWedgetOption: function (name) {
95
+
return promotionalWidgets.find(function (item) {
96
+
return item.name == name;
97
+
});
98
+
},
99
+
100
+
className: function () {
101
+
var className = 'elementor-element-wrapper';
102
+
103
+
if (!this.isEditable()) {
104
+
className += ' elementor-element--promotion';
105
+
}
106
+
return className;
107
+
},
108
+
109
+
onMouseDown: function () {
110
+
void this.constructor.__super__.onMouseDown.call(this);
111
+
var promotion = this.getWedgetOption(this.model.get("name"));
112
+
elementor.promotion.showDialog({
113
+
title: sprintf(wp.i18n.__('%s', 'elementor'), this.model.get("title")),
114
+
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")),
115
+
targetElement: this.el,
116
+
position: {
117
+
blockStart: '-7'
118
+
},
119
+
actionButton: {
120
+
url: promotion.action_button.url,
121
+
text: promotion.action_button.text,
122
+
classes: promotion.action_button.classes || ['elementor-button', 'elementor-button-success']
123
+
}
124
+
})
125
+
}
126
+
}
127
+
128
+
panel.elements.view = elementsView.extend({
129
+
childView: elementsView.prototype.childView.extend(promotionalWidgetHandler)
130
+
});
131
+
132
+
panel.categories.view = categoriesView.extend({
133
+
childView: categoriesView.prototype.childView.extend({
134
+
childView: categoriesView.prototype.childView.prototype.childView.extend(promotionalWidgetHandler)
135
+
})
136
+
});
137
+
138
+
return panel;
139
+
})
140
+
141
+
// Advanced Google Map - Initialize when document is ready
142
+
$(document).ready(function() {
143
+
initLocationSearch();
144
+
});
145
+
146
+
// Initialize when widget panel opens (for dynamically created elements)
147
+
if (typeof elementor !== "undefined") {
148
+
elementor.hooks.addAction("panel/open_editor/widget", function() {
149
+
setTimeout(initLocationSearch, 300);
150
+
});
151
+
}
152
+
153
+
function initLocationSearch() {
154
+
// Remove any existing handlers first to prevent duplicates
155
+
$(document).off("click", ".ep-location-search-btn");
156
+
$(document).off("click", ".ep-modal-close");
157
+
$(document).off("click", ".ep-search-address-button");
158
+
$(document).off("click", ".ep-select-location-button");
159
+
$(document).off("click", ".ep-search-result-item");
160
+
161
+
// Button click handler
162
+
$(document).on("click", ".ep-location-search-btn", function(e) {
163
+
e.preventDefault();
164
+
e.stopPropagation();
165
+
166
+
var $btn = $(this);
167
+
var $modal = $btn.next(".ep-location-search-modal");
168
+
var $latField = $btn.closest(".elementor-repeater-row-controls").find("input[data-setting=\"marker_lat\"]");
169
+
var $lngField = $btn.closest(".elementor-repeater-row-controls").find("input[data-setting=\"marker_lng\"]");
170
+
171
+
// Store references for later use
172
+
$modal.data("latField", $latField);
173
+
$modal.data("lngField", $lngField);
174
+
175
+
// Clear any previous results
176
+
$modal.find(".ep-search-results").empty();
177
+
$modal.find(".ep-address-search").val("");
178
+
$modal.find(".ep-select-location-button").hide();
179
+
180
+
// Show the modal
181
+
$modal.fadeIn(200);
182
+
183
+
// Focus on search input
184
+
$modal.find(".ep-address-search").focus();
185
+
});
186
+
187
+
// Close button handler
188
+
$(document).on("click", ".ep-modal-close", function() {
189
+
$(this).closest(".ep-location-search-modal").fadeOut(200);
190
+
});
191
+
192
+
// Close on click outside modal content
193
+
$(document).on("click", ".ep-location-search-modal", function(e) {
194
+
if ($(e.target).hasClass("ep-location-search-modal")) {
195
+
$(this).fadeOut(200);
196
+
}
197
+
});
198
+
199
+
// Search button handler
200
+
$(document).on("click", ".ep-search-address-button", function() {
201
+
var $modal = $(this).closest(".ep-location-search-modal");
202
+
var address = $modal.find(".ep-address-search").val().trim();
203
+
204
+
if (address) {
205
+
performSearch(address, $modal);
206
+
}
207
+
});
208
+
209
+
// Enter key in search input
210
+
$(document).on("keypress", ".ep-address-search", function(e) {
211
+
if (e.which === 13) {
212
+
e.preventDefault();
213
+
var $modal = $(this).closest(".ep-location-search-modal");
214
+
var address = $(this).val().trim();
215
+
216
+
if (address) {
217
+
performSearch(address, $modal);
218
+
}
219
+
}
220
+
});
221
+
222
+
// Select location button handler
223
+
$(document).on("click", ".ep-select-location-button", function() {
224
+
var $modal = $(this).closest(".ep-location-search-modal");
225
+
var selectedLocation = $modal.data("selectedLocation");
226
+
var $latField = $modal.data("latField");
227
+
var $lngField = $modal.data("lngField");
228
+
229
+
if (selectedLocation && $latField.length && $lngField.length) {
230
+
$latField.val(selectedLocation.lat).trigger("input");
231
+
$lngField.val(selectedLocation.lng).trigger("input");
232
+
$modal.fadeOut(200);
233
+
}
234
+
});
235
+
}
236
+
237
+
function performSearch(address, $modal) {
238
+
var $results = $modal.find(".ep-search-results");
239
+
$results.html("<p>Searching...</p>");
240
+
$modal.find(".ep-select-location-button").hide();
241
+
242
+
if (typeof google === "undefined" || typeof google.maps === "undefined") {
243
+
$results.html("<p>Google Maps API not loaded. Please check your API key.</p>");
244
+
return;
245
+
}
246
+
247
+
var geocoder = new google.maps.Geocoder();
248
+
249
+
geocoder.geocode({address: address}, function(results, status) {
250
+
$results.empty();
251
+
252
+
if (status === "OK") {
253
+
if (results.length > 0) {
254
+
// Create results list
255
+
var $resultsList = $("<div class=\"ep-search-results-list\" style=\"max-height:200px; overflow-y:auto; margin-bottom:15px; border:1px solid #eee; border-radius:4px;\"></div>");
256
+
$results.append($resultsList);
257
+
258
+
// Create map container
259
+
var mapId = "ep-location-preview-map-" + Date.now();
260
+
var $mapContainer = $("<div id=\"" + mapId + "\" style=\"height:300px; margin-top:15px; border:1px solid #ddd; border-radius:4px;\"></div>");
261
+
$results.append($mapContainer);
262
+
263
+
// Initialize map
264
+
var tempMap = new google.maps.Map(document.getElementById(mapId), {
265
+
zoom: 14,
266
+
center: results[0].geometry.location
267
+
});
268
+
269
+
// Add markers for each result
270
+
results.forEach(function(result, index) {
271
+
var location = {
272
+
lat: result.geometry.location.lat(),
273
+
lng: result.geometry.location.lng(),
274
+
address: result.formatted_address
275
+
};
276
+
277
+
// Create result item
278
+
var $resultItem = $("<div class=\"ep-search-result-item\" style=\"padding:10px; border-bottom:1px solid #eee; cursor:pointer;\"></div>");
279
+
$resultItem.html("<strong>" + location.address + "</strong><br>" +
280
+
"Lat: " + location.lat.toFixed(7) + ", Lng: " + location.lng.toFixed(7));
281
+
282
+
// Add click handler
283
+
$resultItem.on("click", function() {
284
+
// Highlight selected item
285
+
$(".ep-search-result-item").css("background-color", "");
286
+
$(this).css("background-color", "#f0f0f0");
287
+
288
+
// Store selected location
289
+
$modal.data("selectedLocation", location);
290
+
291
+
// Center map on selected location
292
+
tempMap.setCenter(new google.maps.LatLng(location.lat, location.lng));
293
+
294
+
// Show select button
295
+
$modal.find(".ep-select-location-button").show();
296
+
});
297
+
298
+
$resultsList.append($resultItem);
299
+
300
+
// Add marker to map
301
+
var marker = new google.maps.Marker({
302
+
position: new google.maps.LatLng(location.lat, location.lng),
303
+
map: tempMap,
304
+
title: location.address
305
+
});
306
+
307
+
// Select first result by default
308
+
if (index === 0) {
309
+
$resultItem.trigger("click");
310
+
}
311
+
});
312
+
} else {
313
+
$results.html("<p>No results found</p>");
314
+
}
315
+
} else {
316
+
$results.html("<p>Geocode was not successful: " + status + "</p>");
317
+
}
318
+
});
319
+
}
320
+
321
+
// Elementor Editor Pro Locked Extension Management
322
+
var ElementorProLockedExtension = {
323
+
init: function() {
324
+
setInterval(this.hideExtensionControlSections.bind(this), 500);
325
+
},
326
+
327
+
hideExtensionControlSections: function() {
328
+
$('.bdt-ep-pro-badge').closest('.elementor-control').css('pointer-events', 'none');
329
+
},
330
+
};
331
+
332
+
$(document).ready(function() {
333
+
ElementorProLockedExtension.init();
334
+
});
335
+
336
+
}(jQuery));
337
+
338
+
339
+