(function ($) {
	"use strict";
	var WidgetGlobalhandle = function ($scope, $) {
		if( $scope.find('.eca-isotope').length ){
			var elements = $scope[0].querySelectorAll('.eca-isotope');
			Array.prototype.forEach.call(elements, function(el, i){
				var settings = el.getAttribute('data-settings');
				settings = JSON.parse(settings);
				var innerEl = $('.' + settings.id + ' .eca-post-listing-inner');
				var grid_isotope = innerEl.imagesLoaded(function() {
					grid_isotope.isotope({
						itemSelector: ".ec-grid-wrap",
						layoutMode: settings.postLayout,
						originLeft: settings.ecrtl,
					});

					// layout gal, while images are loading
					setTimeout(function() {
						grid_isotope.isotope("layout");
					}, 1000);

					$('.ec-grid-wrap', innerEl).on('resize', function() {
						grid_isotope.isotope('layout');
					});
				});

				if ($scope.find('.eca-isotope .terms-filters-wrap').length > 0) {
					// List Isotope Filter Item
					$scope.find('.eca-isotope .terms-filters-wrap').find(".term-filter-list").on('click', function(event) {
						event.preventDefault();
						var post_wrap = $(this).closest(".eca-isotope"),
							settings = post_wrap.data("settings"),
							uid = settings.id;
						
						var filter = $(this).attr("data-filter");
						$(this).parent().parent().find(".active").removeClass("active");
						$(this).addClass("active");
						$('.' + uid).find(".eca-post-listing-inner").isotope({
							filter: filter
						});
						$("body").trigger("isotope-sorted");
					});
				}
			});
		}

		var lax_element = $scope[0].querySelectorAll('.lax');
		if (lax_element.length) {
			lax.init();
			lax.addDriver('scrollY', function() {
				return window.scrollY;
			});
		}
	};

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

"use strict";
document.addEventListener('DOMContentLoaded', (event) => {
	setTimeout(function() {
		var element = document.querySelectorAll('.eca-lax');
		if (element.length) {
			var elemode = document.querySelector('body').getAttribute('data-elementor-device-mode');
			Array.prototype.forEach.call(element, function(el, i) {
				if (elemode == 'desktop') {
					var mdClass = el.getAttribute('data-lax-md');
					el.className += mdClass;
					lax.init();
				}
				if (elemode == 'tablet') {
					var smClass = el.getAttribute('data-lax-sm');
					el.className += smClass;
					lax.init();
				}
				if (elemode == 'mobile') {
					var xsClass = el.getAttribute('data-lax-xs');
					el.className += xsClass;
					lax.init();
				}
			});
		}
	}, 30);
});
