# easy-elements/1.2.9/assets/js/custom.js

Easy Elements for Elementor – Addons &amp; Website Templates, version 1.2.9. 628 lines.

- Page: https://pluginprobe.com/plugins/easy-elements/1.2.9/code/assets/js/custom.js
- Raw: https://pluginprobe.com/plugins/easy-elements/1.2.9/raw/assets/js/custom.js
- Modified: 2026-01-06T13:07:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/easy-elements/1.2.9/code/assets/js/custom.js#L10-L20`.

```javascript
(function($) {
    "use strict";
  	function initBackPostSlider($scope) {
  	    var $slider = $scope.find('.eel-all-slider');
  	    if (!$slider.length) {
  	        return;
  	    }
  	    var loop = $slider.data('loop') === true || $slider.data('loop') === 'true';
  	    var autoplay = $slider.data('autoplay') === true || $slider.data('autoplay') === 'true';
  	    var autoplayDelay = parseInt($slider.data('autoplay-delay'), 10) || 3000;
  	    var slidesPerView = parseInt($slider.data('slides-per-view'), 10) || 3;
  	    var speed = parseInt($slider.data('speed'), 10) || 600;
  	    var centeredSlides = $slider.data('centered-slides') === true || $slider.data('centered-slides') === 'true';
  	    var freeMode = $slider.data('free-mode') === true || $slider.data('free-mode') === 'true';
  	    var spaceBetween = parseInt($slider.data('space-between'), 10) || 0;
  	    var slidesPerViewTablet = parseInt($slider.data('slides-per-view-tablet'), 10) || 2;
  	    var slidesPerViewMobile = parseInt($slider.data('slides-per-view-mobile'), 10) || 1;
  	    var paginationType = $slider.data('pagination') !== 'none' ? $slider.data('pagination') : false;
	    var navigation = $slider.data('navigation') === true || $slider.data('navigation') === 'true';
	    var effect = $slider.data('effect') || 'slide';
	    var cubeShadow = $slider.data('cube-shadow') === true || $slider.data('cube-shadow') === 'true';
	    var coverflowRotate = parseInt($slider.data('coverflow-rotate'), 10) || 50;
	    var coverflowStretch = parseInt($slider.data('coverflow-stretch'), 10) || 0;
	    
	    // Find navigation elements within the scope
	    var $nextButton = $scope.find('.swiper-next');
	    var $prevButton = $scope.find('.swiper-prev');
	    var $pagination = $scope.find('.swiper-pagination');
	    
	    // Prevent multiple instances and duplicated handlers if Elementor re-runs init
	    if ($slider[0] && $slider[0].swiper) {
	        try { $slider[0].swiper.destroy(true, true); } catch (e) {}
	    }
	    if ($nextButton.length) { $nextButton.off('click.easyStopAuto click.easyFadeNav'); }
	    if ($prevButton.length) { $prevButton.off('click.easyStopAuto click.easyFadeNav'); }
	    
	    var hasProgressBar = $pagination.hasClass('swiper-pagination-progressbar');
  	    
  	    var effectOptions = {};
  	    
  	    if (effect === 'cube') {
  	        effectOptions = {
  	            cubeEffect: {
  	                shadow: cubeShadow,
  	                slideShadows: cubeShadow,
  	                shadowOffset: 20,
  	                shadowScale: 0.94,
  	            }
  	        };
  	    } else if (effect === 'coverflow') {
  	        effectOptions = {
  	            coverflowEffect: {
  	                rotate: coverflowRotate,
  	                stretch: coverflowStretch,
  	                depth: 100,
  	                modifier: 1,
  	                slideShadows: true,
  	            }
  	        };
  	    } else if (effect === 'flip') {
  	        effectOptions = {
  	            flipEffect: {
  	                slideShadows: true,
  	                limitRotation: true,
  	            }
  	        };
  	    } else if (effect === 'cards') {
  	        effectOptions = {
  	            cardsEffect: {
  	                slideShadows: true,
  	                rotate: true,
  	                perSlideOffset: 8,
  	            }
  	        };
	    } else if (effect === 'creative') {
			var creativeStyle = $slider.data('creative-style') || 'default';
			if (creativeStyle === 'zoom') {
				effectOptions = {
					creativeEffect: {
						limitProgress: true,
						prev: { scale: 1.1, opacity: 0, translate: [0, 0, 0] },
						next: { scale: 1.6, opacity: 0, translate: [0, 0, 0] },
					},
				};
			} else {
				effectOptions = {
					creativeEffect: {
						limitProgress: true,
						prev: { shadow: true, translate: [0, 0, -400] },
						next: { translate: ['100%', 0, 0] },
					},
				};
			}
		} else if (effect === 'fade') {
			effectOptions = {
				fadeEffect: { crossFade: true }
			};
		}
	    
	    // Loop handling tuned to avoid double-advance on loop edges
	    var totalSlides = $slider.find('.swiper-slide').length;
	    var isFade = effect === 'fade';
	    var visibleSlides = isFade ? 1 : slidesPerView;
	    var canLoop = totalSlides > visibleSlides;
	    var loopConfig = {};
	    if (loop && (canLoop || isFade)) {
	        loopConfig = {
	            loop: true,
	            loopAdditionalSlides: isFade ? totalSlides : 20,
	            loopedSlides: isFade ? totalSlides : Math.max(Math.ceil(visibleSlides), Math.min(totalSlides, 10))
	        };
	    } else {
	        loopConfig = { loop: false, rewind: !!loop };
	    }
  	    
	    var swiper = new Swiper($slider[0], {
	        ...loopConfig,
  	        speed: speed,
  	        effect: effect,
	        normalizeSlideIndex: true,
	        preventInteractionOnTransition: true,
  	        simulateTouch: true,    
  	        touchRatio: 1, 
  	        grabCursor: true,
  	        mousewheel: hasProgressBar ? {
	            enabled: true,
	            sensitivity: 1,
	            thresholdDelta: 50,
	            thresholdTime: 200,
	            releaseOnEdges: true,
	            invert: false,
	            forceToAxis: false,
	            eventsTarget: 'container'
	        } : false,
	        autoplay: autoplay ? {
  	            delay: autoplayDelay,
	            disableOnInteraction: isFade ? true : false,
  	        } : false,
	        slidesPerView: visibleSlides,
	        spaceBetween: isFade ? 0 : spaceBetween,
	        centeredSlides: isFade ? false : centeredSlides,
  	        freeMode: freeMode,            
  	        pagination: paginationType && $pagination.length ? {
				el: $pagination[0],
				clickable: true,
				type: paginationType,
				renderBullet: function (index, className) {
					let num = (index + 1).toString().padStart(2, '0');
					return `<span class="${className}">${num}</span>`;
				}
			} : false,
			
        // Progress bar for mouse scroll - only when swiper-pagination-progressbar class is present
        progressbar: hasProgressBar ? {
            el: '.swiper-progressbar',
            type: 'progressbar',
        } : false,			
			
	        navigation: (!isFade) && navigation && ($nextButton.length || $prevButton.length) ? {
  	            nextEl: $nextButton.length ? $nextButton[0] : null,
  	            prevEl: $prevButton.length ? $prevButton[0] : null,
  	        } : false,
  	        breakpoints: {
  	            0: {
	                slidesPerView: isFade ? 1 : slidesPerViewMobile,
  	            },
  	            768: {
	                slidesPerView: isFade ? 1 : slidesPerViewTablet,
  	            },
  	            1024: {
	                slidesPerView: isFade ? 1 : slidesPerView,
  	            },
  	        },
  	        ...effectOptions,
	    });
	    
	    // Fade: attach custom navigation so Next/Prev work
	    if (isFade && ($nextButton.length || $prevButton.length)) {
	        var isTransitioning = false;
	        swiper.on('transitionStart', function () { isTransitioning = true; });
	        swiper.on('transitionEnd', function () { isTransitioning = false; });
	        if ($nextButton.length) {
	            $nextButton.off('click.easyFadeNav').on('click.easyFadeNav', function (e) {
	                e.preventDefault();
	                e.stopPropagation();
	                if (swiper && swiper.autoplay && swiper.autoplay.stop) { swiper.autoplay.stop(); }
	                if (isTransitioning || (swiper && swiper.animating)) return;
	                swiper.slideNext();
	            });
	        }
	        if ($prevButton.length) {
	            $prevButton.off('click.easyFadeNav').on('click.easyFadeNav', function (e) {
	                e.preventDefault();
	                e.stopPropagation();
	                if (swiper && swiper.autoplay && swiper.autoplay.stop) { swiper.autoplay.stop(); }
	                if (isTransitioning || (swiper && swiper.animating)) return;
	                swiper.slidePrev();
	            });
	        }
	    }

	    // Non-fade: if loop+autoplay, stop autoplay on manual nav to avoid double-advance
	    if (!isFade && loop && autoplay) {
	        if ($nextButton.length) {
	            $nextButton.on('click.easyStopAuto', function () {
	                if (swiper && swiper.autoplay && swiper.autoplay.stop) {
	                    swiper.autoplay.stop();
	                }
	            });
	        }
	        if ($prevButton.length) {
	            $prevButton.on('click.easyStopAuto', function () {
	                if (swiper && swiper.autoplay && swiper.autoplay.stop) {
	                    swiper.autoplay.stop();
	                }
	            });
	        }
	    }
  	}

    function addWidgetTypeToBody($scope) {
        var widgetType = $scope.data('widget_type');
        if (widgetType) {
            var className = 'easy-eel-has-widget-' + widgetType.replace(/[^a-z0-9_-]/gi, '-').toLowerCase();
            document.body.classList.add(className);
        }
    }

	$(window).on('elementor/frontend/init', function () {

        function checkStickySection() {
            const stickySection = document.querySelector('.eel-sticky-section');
            if (stickySection) {
                document.body.classList.add('sticky-enabled-overlap');
            } else {
                document.body.classList.remove('sticky-enabled-overlap');
            }
        }

        checkStickySection();

        const observer = new MutationObserver(checkStickySection);
        observer.observe(document.body, { childList: true, subtree: true });
    });

	
	function initReveal() {
		const revealElements = document.querySelectorAll(".eel-img-reveal-wrap, .eel-img-advance-wrap");

		const revealAnimate = (el) => {
			const target = el.querySelector(".eel-reveal-img-main, .eel-advance-img-main");
			if(target) target.classList.add("el-reveal-animate");
		};

		const isEditor = window.elementorFrontend && elementorFrontend.isEditMode && elementorFrontend.isEditMode();

		if(isEditor){
			
			revealElements.forEach(el => revealAnimate(el));
		} else {
			
			const observer = new IntersectionObserver((entries, obs) => {
					entries.forEach(entry => {
						if(entry.isIntersecting){
							revealAnimate(entry.target);
							obs.unobserve(entry.target);
						}
					});
			}, { threshold: 0.3 });

			revealElements.forEach(el => observer.observe(el));
		}
	}

   $(window).on('elementor/frontend/init', function () {
      elementorFrontend.hooks.addAction('frontend/element_ready/global', initBackPostSlider);
      elementorFrontend.hooks.addAction('frontend/element_ready/global', addWidgetTypeToBody);
		elementorFrontend.hooks.addAction('frontend/element_ready/global', initReveal);
   });

	document.addEventListener('DOMContentLoaded', function () {
		// Remove motion effects inline styles
		document.querySelectorAll('[data-settings]').forEach(function (element) {
			let settings = element.getAttribute('data-settings');
			if (settings.includes('motion_effects')) {
				element.removeAttribute('data-settings');
			}
		});

		// Remove any animation-related stylesheets
		document.querySelectorAll('link').forEach(function (link) {
			if (link.href.includes('animations') || link.href.includes('motion')) {
				link.parentNode.removeChild(link);
			}
		});
	});


	$(window).on("elementor/frontend/init", function ($) {
		var EasyJarallax = function ($scope, $) {
			var $wrappers = $scope.hasClass('eele-has-jarallax') ? $scope : $scope.find('.eele-has-jarallax, .eele-inner-jarallax');
			if (!$wrappers.length) return;
			$wrappers.each(function () {
				var $wrapper = $(this);
				var bg = $wrapper.data('jarallax-bg');
				var speed = $wrapper.data('jarallax-speed') || 0.5;
				if (!bg) return;
				// Check if jarallax div already exists
				var $jarallaxDiv = $wrapper.find('.jarallax');
				if ($jarallaxDiv.length === 0) {
					var jarallaxMarkup = '<div class="jarallax eele-jarallax-bg" data-speed="' + speed + '">\
											<img class="jarallax-img" src="' + bg + '" alt="">\
										</div>';
					$wrapper.append(jarallaxMarkup);
					$jarallaxDiv = $wrapper.find('.jarallax');
				}

				// Initialize jarallax
				$jarallaxDiv.each(function () {
					jarallax(this, {
						speed: $(this).data('speed')
					});
				});
			});
		};
		elementorFrontend.hooks.addAction("frontend/element_ready/global", EasyJarallax);
	});


	
	jQuery(window).on('elementor/frontend/init', function() {

		elementorFrontend.hooks.addAction('frontend/element_ready/eel-video-popup.default', function($scope, $) {
			
			const wrapper = $scope.find('.eel-video-popup-wrapper');
			const overlay = wrapper.find('.eel-video-overlay');
			// Find video element (try with class first, then without)
			let videoEl = wrapper.find('video.eel-normal-video');
			if (!videoEl.length) {
				videoEl = wrapper.find('video');
			}
			// Find iframe element (try with class first, then without)
			let iframeEl = wrapper.find('iframe.eel-normal-video');
			if (!iframeEl.length) {
				iframeEl = wrapper.find('iframe');
			}

			// Helper function to get YouTube embed URL
			function getYouTubeEmbedUrl(url) {
				const regExp = /(?:v=|\/)([0-9A-Za-z_-]{11}).*/;
				const match = url.match(regExp);
				if (match && match[1]) {
					return 'https://www.youtube.com/embed/' + match[1] + '?autoplay=1';
				}
				return null;
			}

			// Helper function to get Vimeo embed URL
			function getVimeoEmbedUrl(url) {
				const match = url.match(/(\d+)/);
				if (match && match[1]) {
					return 'https://player.vimeo.com/video/' + match[1] + '?autoplay=1';
				}
				return null;
			}

			// Helper function to open lightbox
			function openLightbox(videoType, videoUrl, popupId, animation) {
				const lightboxOverlay = $('#' + popupId);
				const iframeWrapper = lightboxOverlay.find('.eel-video-popup-iframe-wrapper');
				const lightboxContent = lightboxOverlay.find('.eel-video-popup-content');
				
				if (!lightboxOverlay.length) return;
				
				// Prevent duplicate opening if already active
				if (lightboxOverlay.hasClass('active')) {
					return;
				}
				
				let embedHtml = '';
				
				if (videoType === 'youtube') {
					const embedUrl = getYouTubeEmbedUrl(videoUrl);
					if (embedUrl) {
						embedHtml = '<iframe src="' + embedUrl + '" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>';
					}
				} else if (videoType === 'vimeo') {
					const embedUrl = getVimeoEmbedUrl(videoUrl);
					if (embedUrl) {
						embedHtml = '<iframe src="' + embedUrl + '" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>';
					}
				} else if (videoType === 'self_hosted') {
					embedHtml = '<video src="' + videoUrl + '" controls autoplay></video>';
				}
				
				if (embedHtml) {
					iframeWrapper.html(embedHtml);
					
					// Apply animation if set
					if (animation && animation.trim() !== '') {
						// Remove any existing animation classes
						const currentClasses = lightboxContent.attr('class') || '';
						const animationClasses = currentClasses.match(/\banimated\s+\S+/g);
						if (animationClasses) {
							lightboxContent.removeClass(animationClasses.join(' '));
						}
						// Add new animation classes
						lightboxContent.addClass('animated ' + animation.trim());
					} else {
						// Remove animation classes if no animation
						const currentClasses = lightboxContent.attr('class') || '';
						const animationClasses = currentClasses.match(/\banimated\s+\S+/g);
						if (animationClasses) {
							lightboxContent.removeClass(animationClasses.join(' '));
						}
					}
					
					lightboxOverlay.addClass('active');
					$('body').css('overflow', 'hidden');
				}
			}

			// Close lightbox handler
			$(document).on('click', '.eel-video-popup-close', function(e) {
				e.preventDefault();
				const lightboxOverlay = $(this).closest('.eel-video-popup-overlay');
				const lightboxContent = lightboxOverlay.find('.eel-video-popup-content');
				lightboxOverlay.removeClass('active');
				lightboxContent.removeClass('animated');
				lightboxOverlay.find('.eel-video-popup-iframe-wrapper').html('');
				$('body').css('overflow', '');
			});

			// Close lightbox on overlay click
			$(document).on('click', '.eel-video-popup-overlay', function(e) {
				if ($(e.target).hasClass('eel-video-popup-overlay')) {
					const lightboxContent = $(this).find('.eel-video-popup-content');
					$(this).removeClass('active');
					lightboxContent.removeClass('animated');
					$(this).find('.eel-video-popup-iframe-wrapper').html('');
					$('body').css('overflow', '');
				}
			});

			// Close lightbox on ESC key
			$(document).on('keydown', function(e) {
				if (e.keyCode === 27) { // ESC key
					$('.eel-video-popup-overlay.active').each(function() {
						const lightboxContent = $(this).find('.eel-video-popup-content');
						$(this).removeClass('active');
						lightboxContent.removeClass('animated');
						$(this).find('.eel-video-popup-iframe-wrapper').html('');
						$('body').css('overflow', '');
					});
				}
			});

			if (overlay.length) {
				// Remove existing handler to prevent duplicate
				overlay.off('click.eelVideoOverlay');
				overlay.on('click.eelVideoOverlay', function(e) {
					e.preventDefault();
					e.stopPropagation();
					
					const $overlay = $(this);
					const useLightbox = $overlay.data('lightbox') === 'yes';
					const videoType = $overlay.data('video-type');
					const videoUrl = $overlay.data('video-url');
					const popupId = $overlay.data('popup-id');
					const animation = $overlay.data('animation') || '';
					
					// If lightbox is enabled, open lightbox
					if (useLightbox && videoType && videoUrl && popupId) {
						// Check if lightbox is already open to prevent duplicate
						const lightboxOverlay = $('#' + popupId);
						if (lightboxOverlay.hasClass('active')) {
							return;
						}
						openLightbox(videoType, videoUrl, popupId, animation);
						return;
					}
					
					// Otherwise, play inline (original behavior)
					// Self-hosted video play
					if (videoEl.length) {
						const video = videoEl.get(0);
						
						// Function to play video
						const playVideo = function() {
							const playPromise = video.play();
							if (playPromise !== undefined) {
								playPromise.catch(function(error) {
									console.log('Video play failed:', error);
									// If play fails due to autoplay policy, try with muted
									if (error.name === 'NotAllowedError' && !video.muted) {
										video.muted = true;
										video.play().then(function() {
											// Unmute after play starts (if user wants sound)
											setTimeout(function() {
												video.muted = false;
											}, 100);
										}).catch(function(err) {
											console.log('Video play with mute also failed:', err);
										});
									}
								});
							}
						};
						
						// Always try to load and play
						if (video.readyState >= 2) {
							// Video is already loaded, play immediately
							playVideo();
						} else {
							// Video not loaded, load it first then play
							video.load();
							// Wait for video to be ready to play
							const tryPlay = function() {
								if (video.readyState >= 2) {
									playVideo();
								} else {
									video.addEventListener('canplay', playVideo, { once: true });
									video.addEventListener('loadeddata', playVideo, { once: true });
								}
							};
							tryPlay();
						}
					}

					// YouTube / Vimeo iframe autoplay
					if (iframeEl.length) {
						let src = iframeEl.attr('src');
						if (src) {
							// Check if it's YouTube or Vimeo
							const isYouTube = src.indexOf('youtube.com') !== -1 || src.indexOf('youtu.be') !== -1;
							const isVimeo = src.indexOf('vimeo.com') !== -1;
							
							if (isYouTube || isVimeo) {
								try {
									// Use URL object for proper parsing
									const url = new URL(src);
									
									if (isYouTube) {
										// YouTube: add autoplay, preserve original mute setting
										url.searchParams.set('autoplay', '1');
										// Only set mute=1 if it was already in the URL (preserve original setting)
										// If mute was not in original URL, don't add it
										if (!url.searchParams.has('mute')) {
											// Don't add mute if it wasn't there originally
										} else {
											// Keep the original mute value
										}
										// Reload iframe with new src
										iframeEl.attr('src', url.toString());
									} else if (isVimeo) {
										// Vimeo: add autoplay (Vimeo doesn't need mute for autoplay)
										url.searchParams.set('autoplay', '1');
										// Reload iframe with new src
										iframeEl.attr('src', url.toString());
									}
								} catch (e) {
									// Fallback for browsers that don't support URL constructor
									// Remove existing autoplay parameter if present
									src = src.replace(/[?&]autoplay=[^&]*/g, '');
									
									if (isYouTube) {
										// Check if mute parameter exists in original URL
										const hasMute = /[?&]mute=/.test(src);
										// Add autoplay=1
										const separator = src.indexOf('?') === -1 ? '?' : '&';
										src += separator + 'autoplay=1';
										// Only add mute if it was already there (preserve original setting)
										// Don't add mute if it wasn't in original URL
									} else if (isVimeo) {
										// Vimeo: just add autoplay=1
										const separator = src.indexOf('?') === -1 ? '?' : '&';
										src += separator + 'autoplay=1';
									}
									
									// Update src without clearing first
									iframeEl.attr('src', src);
								}
							}
						}
					}
					
					// Remove overlay after a small delay to ensure video starts
					setTimeout(function() {
						overlay.fadeOut(300, function() {
							$(this).remove();
						});
					}, 200);
				});
			}

			// Handle popup button clicks (for display_type = 'popup')
			const popupBtn = wrapper.find('.entro-all-video-popup');
			if (popupBtn.length) {
				// Remove existing handler to prevent duplicate
				popupBtn.off('click.eelVideoPopup');
				popupBtn.on('click.eelVideoPopup', function(e) {
					e.preventDefault();
					e.stopPropagation();
					const $btn = $(this);
					const videoType = $btn.data('video-type');
					const videoUrl = $btn.data('video-src');
					const popupId = $btn.data('popup-id');
					const lightboxOverlay = $('#' + popupId);
					const animation = lightboxOverlay.data('animation') || '';
					
					if (videoType && videoUrl && popupId) {
						// Check if lightbox is already open to prevent duplicate
						if (lightboxOverlay.hasClass('active')) {
							return;
						}
						openLightbox(videoType, videoUrl, popupId, animation);
					}
				});
			}
		});

	});

})(jQuery);




```
