PluginProbe
Elementor Website Builder – more than just a page builder / 3.26.1
Elementor Website Builder – more than just a page builder v3.26.1
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 All 457 releases
elementor / assets / js / floating-bars.d7a4725c8d2b0c4da40a.bundle.js

floating-bars.d7a4725c8d2b0c4da40a.bundle.js in Elementor Website Builder – more than just a page builder 3.26.1, at assets/js/floating-bars.d7a4725c8d2b0c4da40a.bundle.js

375 lines 14.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*! elementor - v3.26.0 - 19-12-2024 */
2 "use strict";
3 (self["webpackChunkelementor"] = self["webpackChunkelementor"] || []).push([["floating-bars"],{
4
5 /***/ "../modules/floating-buttons/assets/js/floating-bars/frontend/classes/floatin-bar-dom.js":
6 /*!***********************************************************************************************!*\
7 !*** ../modules/floating-buttons/assets/js/floating-bars/frontend/classes/floatin-bar-dom.js ***!
8 \***********************************************************************************************/
9 /***/ ((__unused_webpack_module, exports) => {
10
11
12
13 Object.defineProperty(exports, "__esModule", ({
14 value: true
15 }));
16 exports["default"] = void 0;
17 class FloatingBarDomHelper {
18 constructor($element) {
19 this.$element = $element;
20 }
21 maybeMoveToTop() {
22 const el = this.$element[0];
23 const widget = el.querySelector('.e-floating-bars');
24 if (elementorFrontend.isEditMode()) {
25 widget.classList.add('is-sticky');
26 return;
27 }
28 if (el.dataset.widget_type.startsWith('floating-bars') && widget.classList.contains('has-vertical-position-top') && !widget.classList.contains('is-sticky')) {
29 const wpAdminBar = document.getElementById('wpadminbar');
30 const elementToInsert = el.closest('.elementor');
31 if (wpAdminBar) {
32 wpAdminBar.after(elementToInsert);
33 } else {
34 document.body.prepend(elementToInsert);
35 }
36 }
37 }
38 }
39 exports["default"] = FloatingBarDomHelper;
40
41 /***/ }),
42
43 /***/ "../modules/floating-buttons/assets/js/floating-bars/frontend/handlers/floating-bars.js":
44 /*!**********************************************************************************************!*\
45 !*** ../modules/floating-buttons/assets/js/floating-bars/frontend/handlers/floating-bars.js ***!
46 \**********************************************************************************************/
47 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
48
49
50
51 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
52 Object.defineProperty(exports, "__esModule", ({
53 value: true
54 }));
55 exports["default"] = void 0;
56 __webpack_require__(/*! core-js/modules/es.array.includes.js */ "../node_modules/core-js/modules/es.array.includes.js");
57 var _base = _interopRequireDefault(__webpack_require__(/*! elementor-frontend/handlers/base */ "../assets/dev/js/frontend/handlers/base.js"));
58 var _floatinBarDom = _interopRequireDefault(__webpack_require__(/*! ../classes/floatin-bar-dom */ "../modules/floating-buttons/assets/js/floating-bars/frontend/classes/floatin-bar-dom.js"));
59 var _clickTracking = _interopRequireDefault(__webpack_require__(/*! ../../../shared/frontend/handlers/click-tracking */ "../modules/floating-buttons/assets/js/shared/frontend/handlers/click-tracking.js"));
60 class FloatingBarsHandler extends _base.default {
61 getDefaultSettings() {
62 return {
63 selectors: {
64 main: '.e-floating-bars',
65 closeButton: '.e-floating-bars__close-button',
66 ctaButton: '.e-floating-bars__cta-button'
67 },
68 constants: {
69 ctaEntranceAnimation: 'style_cta_button_animation',
70 ctaEntranceAnimationDelay: 'style_cta_button_animation_delay',
71 hasEntranceAnimation: 'has-entrance-animation',
72 visible: 'visible',
73 isSticky: 'is-sticky',
74 hasVerticalPositionTop: 'has-vertical-position-top',
75 hasVerticalPositionBottom: 'has-vertical-position-bottom',
76 isHidden: 'is-hidden',
77 animated: 'animated'
78 }
79 };
80 }
81 getDefaultElements() {
82 const selectors = this.getSettings('selectors');
83 return {
84 main: this.$element[0].querySelector(selectors.main),
85 mainAll: this.$element[0].querySelectorAll(selectors.main),
86 closeButton: this.$element[0].querySelector(selectors.closeButton),
87 ctaButton: this.$element[0].querySelector(selectors.ctaButton)
88 };
89 }
90 onElementChange(property) {
91 const changedProperties = ['advanced_vertical_position'];
92 if (changedProperties.includes(property)) {
93 this.initDefaultState();
94 }
95 }
96 getResponsiveSetting(controlName) {
97 const currentDevice = elementorFrontend.getCurrentDeviceMode();
98 return elementorFrontend.utils.controls.getResponsiveControlValue(this.getElementSettings(), controlName, '', currentDevice);
99 }
100 bindEvents() {
101 if (this.elements.closeButton) {
102 this.elements.closeButton.addEventListener('click', this.closeFloatingBar.bind(this));
103 }
104 if (this.elements.ctaButton) {
105 this.elements.ctaButton.addEventListener('animationend', this.handleAnimationEnd.bind(this));
106 }
107 if (this.elements.main) {
108 window.addEventListener('keyup', this.onDocumentKeyup.bind(this));
109 }
110 if (this.hasStickyElements()) {
111 window.addEventListener('resize', this.handleStickyElements.bind(this));
112 }
113 }
114 isStickyTop() {
115 const {
116 isSticky,
117 hasVerticalPositionTop
118 } = this.getSettings('constants');
119 return this.elements.main.classList.contains(isSticky) && this.elements.main.classList.contains(hasVerticalPositionTop);
120 }
121 isStickyBottom() {
122 const {
123 isSticky,
124 hasVerticalPositionBottom
125 } = this.getSettings('constants');
126 return this.elements.main.classList.contains(isSticky) && this.elements.main.classList.contains(hasVerticalPositionBottom);
127 }
128 hasStickyElements() {
129 const stickyElements = document.querySelectorAll('.elementor-sticky');
130 return stickyElements.length > 0;
131 }
132 focusOnLoad() {
133 this.elements.main.setAttribute('tabindex', '0');
134 this.elements.main.focus({
135 focusVisible: true
136 });
137 }
138 applyBodyPadding() {
139 const mainHeight = this.elements.main.offsetHeight;
140 document.body.style.paddingTop = `${mainHeight}px`;
141 }
142 removeBodyPadding() {
143 document.body.style.paddingTop = '0';
144 }
145 handleWPAdminBar() {
146 const wpAdminBar = elementorFrontend.elements.$wpAdminBar;
147 if (wpAdminBar.length) {
148 this.elements.main.style.top = `${wpAdminBar.height()}px`;
149 }
150 }
151 handleStickyElements() {
152 const mainHeight = this.elements.main.offsetHeight;
153 const wpAdminBar = elementorFrontend.elements.$wpAdminBar;
154 const stickyElements = document.querySelectorAll('.elementor-sticky:not(.elementor-sticky__spacer)');
155 if (0 === stickyElements.length) {
156 return;
157 }
158 stickyElements.forEach(stickyElement => {
159 const dataSettings = stickyElement.getAttribute('data-settings');
160 const stickyPosition = JSON.parse(dataSettings)?.sticky;
161 const isTop = '0px' === stickyElement.style.top || 'top' === stickyPosition;
162 const isBottom = '0px' === stickyElement.style.bottom || 'bottom' === stickyPosition;
163 if (this.isStickyTop() && isTop) {
164 if (wpAdminBar.length) {
165 stickyElement.style.top = `${mainHeight + wpAdminBar.height()}px`;
166 } else {
167 stickyElement.style.top = `${mainHeight}px`;
168 }
169 } else if (this.isStickyBottom() && isBottom) {
170 stickyElement.style.bottom = `${mainHeight}px`;
171 }
172 if (elementorFrontend.isEditMode()) {
173 if (isTop) {
174 stickyElement.style.top = this.isStickyTop() ? `${mainHeight}px` : '0px';
175 } else if (isBottom) {
176 stickyElement.style.bottom = this.isStickyBottom() ? `${mainHeight}px` : '0px';
177 }
178 }
179 });
180 document.querySelectorAll('.elementor-sticky__spacer').forEach(stickySpacer => {
181 const dataSettings = stickySpacer.getAttribute('data-settings');
182 const stickyPosition = JSON.parse(dataSettings)?.sticky;
183 const isTop = '0px' === stickySpacer.style.top || 'top' === stickyPosition;
184 if (this.isStickyTop() && isTop) {
185 stickySpacer.style.marginBottom = `${mainHeight}px`;
186 }
187 });
188 }
189 closeFloatingBar() {
190 const {
191 isHidden
192 } = this.getSettings('constants');
193 if (!elementorFrontend.isEditMode()) {
194 this.elements.main.classList.add(isHidden);
195 if (this.hasStickyElements()) {
196 this.handleStickyElements();
197 } else if (this.isStickyTop()) {
198 this.removeBodyPadding();
199 }
200 }
201 }
202 initEntranceAnimation() {
203 const {
204 animated,
205 ctaEntranceAnimation,
206 ctaEntranceAnimationDelay,
207 hasEntranceAnimation
208 } = this.getSettings('constants');
209 const entranceAnimationClass = this.getResponsiveSetting(ctaEntranceAnimation);
210 const entranceAnimationDelay = this.getResponsiveSetting(ctaEntranceAnimationDelay) || 0;
211 const setTimeoutDelay = entranceAnimationDelay + 500;
212 this.elements.ctaButton.classList.add(animated);
213 this.elements.ctaButton.classList.add(entranceAnimationClass);
214 setTimeout(() => {
215 this.elements.ctaButton.classList.remove(hasEntranceAnimation);
216 }, setTimeoutDelay);
217 }
218 handleAnimationEnd() {
219 this.removeEntranceAnimationClasses();
220 this.focusOnLoad();
221 }
222 removeEntranceAnimationClasses() {
223 if (!this.elements.ctaButton) {
224 return;
225 }
226 const {
227 animated,
228 ctaEntranceAnimation,
229 visible
230 } = this.getSettings('constants');
231 const entranceAnimationClass = this.getResponsiveSetting(ctaEntranceAnimation);
232 this.elements.ctaButton.classList.remove(animated);
233 this.elements.ctaButton.classList.remove(entranceAnimationClass);
234 this.elements.ctaButton.classList.add(visible);
235 }
236 onDocumentKeyup(event) {
237 // Bail if not ESC key
238 if (event.keyCode !== 27 || !this.elements.main) {
239 return;
240 }
241
242 /* eslint-disable @wordpress/no-global-active-element */
243 if (this.elements.main.contains(document.activeElement)) {
244 this.closeFloatingBar();
245 }
246 /* eslint-enable @wordpress/no-global-active-element */
247 }
248 initDefaultState() {
249 const {
250 hasEntranceAnimation
251 } = this.getSettings('constants');
252 if (this.isStickyTop()) {
253 this.handleWPAdminBar();
254 }
255 if (this.hasStickyElements()) {
256 this.handleStickyElements();
257 } else if (this.isStickyTop()) {
258 this.applyBodyPadding();
259 }
260 if (this.elements.main && !this.elements.ctaButton.classList.contains(hasEntranceAnimation) && !elementorFrontend.isEditMode()) {
261 this.focusOnLoad();
262 }
263 }
264 setupInnerContainer() {
265 this.elements.main.closest('.e-con-inner').classList.add('e-con-inner--floating-bars');
266 this.elements.main.closest('.e-con').classList.add('e-con--floating-bars');
267 }
268 onInit() {
269 const {
270 hasEntranceAnimation
271 } = this.getSettings('constants');
272 super.onInit(...arguments);
273 this.clickTrackingHandler = new _clickTracking.default({
274 $element: this.$element
275 });
276 const domHelper = new _floatinBarDom.default(this.$element);
277 domHelper.maybeMoveToTop();
278 if (this.elements.ctaButton && this.elements.ctaButton.classList.contains(hasEntranceAnimation)) {
279 this.initEntranceAnimation();
280 }
281 this.initDefaultState();
282 this.setupInnerContainer();
283 }
284 }
285 exports["default"] = FloatingBarsHandler;
286
287 /***/ }),
288
289 /***/ "../modules/floating-buttons/assets/js/shared/frontend/handlers/click-tracking.js":
290 /*!****************************************************************************************!*\
291 !*** ../modules/floating-buttons/assets/js/shared/frontend/handlers/click-tracking.js ***!
292 \****************************************************************************************/
293 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
294
295
296
297 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
298 Object.defineProperty(exports, "__esModule", ({
299 value: true
300 }));
301 exports["default"] = void 0;
302 __webpack_require__(/*! core-js/modules/es.array.push.js */ "../node_modules/core-js/modules/es.array.push.js");
303 var _base = _interopRequireDefault(__webpack_require__(/*! elementor-frontend/handlers/base */ "../assets/dev/js/frontend/handlers/base.js"));
304 class ClickTrackingHandler extends _base.default {
305 clicks = [];
306 getDefaultSettings() {
307 return {
308 selectors: {
309 contentWrapper: '.e-contact-buttons__content-wrapper',
310 contactButtonCore: '.e-contact-buttons__send-button',
311 contentWrapperFloatingBars: '.e-floating-bars',
312 floatingBarCTAButton: '.e-floating-bars__cta-button',
313 elementorWrapper: '[data-elementor-type="floating-buttons"]'
314 }
315 };
316 }
317 getDefaultElements() {
318 const selectors = this.getSettings('selectors');
319 return {
320 contentWrapper: this.$element[0].querySelector(selectors.contentWrapper),
321 contentWrapperFloatingBars: this.$element[0].querySelector(selectors.contentWrapperFloatingBars)
322 };
323 }
324 bindEvents() {
325 if (this.elements.contentWrapper) {
326 this.elements.contentWrapper.addEventListener('click', this.onChatButtonTrackClick.bind(this));
327 }
328 if (this.elements.contentWrapperFloatingBars) {
329 this.elements.contentWrapperFloatingBars.addEventListener('click', this.onChatButtonTrackClick.bind(this));
330 }
331 window.addEventListener('beforeunload', () => {
332 if (this.clicks.length > 0) {
333 this.sendClicks();
334 }
335 });
336 }
337 onChatButtonTrackClick(event) {
338 const targetElement = event.target || event.srcElement;
339 const selectors = this.getSettings('selectors');
340 if (targetElement.matches(selectors.contactButtonCore) || targetElement.closest(selectors.contactButtonCore) || targetElement.matches(selectors.floatingBarCTAButton) || targetElement.closest(selectors.floatingBarCTAButton)) {
341 this.getDocumentIdAndTrack(targetElement, selectors);
342 }
343 }
344 getDocumentIdAndTrack(targetElement, selectors) {
345 const documentId = targetElement.closest(selectors.elementorWrapper).dataset.elementorId;
346 this.trackClick(documentId);
347 }
348 trackClick(documentId) {
349 if (!documentId) {
350 return;
351 }
352 this.clicks.push(documentId);
353 if (this.clicks.length >= 10) {
354 this.sendClicks();
355 }
356 }
357 sendClicks() {
358 const formData = new FormData();
359 formData.append('action', 'elementor_send_clicks');
360 formData.append('_nonce', elementorFrontendConfig?.nonces?.floatingButtonsClickTracking);
361 this.clicks.forEach(documentId => formData.append('clicks[]', documentId));
362 fetch(elementorFrontendConfig?.urls?.ajaxurl, {
363 method: 'POST',
364 body: formData
365 }).then(() => {
366 this.clicks = [];
367 });
368 }
369 }
370 exports["default"] = ClickTrackingHandler;
371
372 /***/ })
373
374 }]);
375 //# sourceMappingURL=floating-bars.d7a4725c8d2b0c4da40a.bundle.js.map