PluginProbe
Elementor Website Builder – more than just a page builder / 3.30.0-beta1
Elementor Website Builder – more than just a page builder v3.30.0-beta1
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.7efeeb8b098e55999ff1.bundle.js

floating-bars.7efeeb8b098e55999ff1.bundle.js in Elementor Website Builder – more than just a page builder 3.30.0-beta1, at assets/js/floating-bars.7efeeb8b098e55999ff1.bundle.js

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