PageSourceSearch

https://www.montelobos.com/app/themes/campari-wdf/includes/extensions/js/extension.js

js montelobos.com collected 2026-09-26 10:07:06 UTC 4,235 bytes, 145 lines download raw bytes

1document.addEventListener("DOMContentLoaded", function(){
2
3	const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
4
5	if (vw < 1023){
6		
7		const hasProductsSlider = document.querySelector('.ml-products-slider');
8	
9		if (hasProductsSlider){
10			// get product slider items
11			const psItems = hasProductsSlider.querySelectorAll('.swiper-slide');
12			
13			if (psItems.length){
14				psItems.forEach(function(psItem){
15					// find image
16					const psImage = psItem.querySelector('.sn_slider_full_sl_image');
17					const psContent = psItem.querySelector('.sn_slider_full_sl_content');
18					const parentDiv = psContent.parentNode;
19					parentDiv.insertBefore(psImage,psContent);
20				});
21			}
22		}
23	}
24
25  	// manage menu items onclick events
26	let menuOpenTimer;
27	
28	function closeSubmenus(){
29		const allMenuItems = document.querySelectorAll('.sn_header_nav._full .menu-item-has-children');
30		allMenuItems.forEach(function(otherMenuItem){
31			otherMenuItem.classList.remove('open');
32		});	
33	}
34	
35	document.addEventListener("click",function(el){
36		const clickedItem = el.target;
37		if (!clickedItem.classList.contains('menu-item-has-children')){
38			closeSubmenus();
39		}
40	
41	});
42	
43	
44	document.querySelectorAll('.sn_header_nav._full .menu-item-has-children').forEach(function(el){
45		el.addEventListener("click",function(subEl){
46			const menuItem = subEl.target.closest('.menu-item');
47			if (menuItem) {
48				if (menuItem.classList.contains('_sub')){
49					return true;
50				}
51				subEl.preventDefault();
52				clearTimeout(menuOpenTimer);
53				if (!menuItem.classList.contains('open')) {
54					closeSubmenus(); // close other menus
55					menuOpenTimer = setTimeout(function(){
56						menuItem.classList.add('open');
57					}, 350);
58					
59				} else {
60					closeSubmenus(); // close other menus
61				}
62			}
63		}, false)
64	});
65
66
67  // move CTA on teaser skyscraper sliders
68	
69	const sliderCtas = document.querySelectorAll('.sn_block_teaser_skyscraper .swiper-slide .sn_btn');
70	
71	if (sliderCtas.length){
72		sliderCtas.forEach(function(cta){
73			const pagination = cta.closest('.sn_block_teaser_skyscraper_sl_wr').querySelector('.sn_swiper_pagination');
74			const trgtContainer = pagination.parentNode;
75			if (trgtContainer){
76				trgtContainer.insertBefore(cta,pagination);
77			}
78		});
79	}
80
81	// move breadcrumbs out of product taste skyscraper sliders
82
83	const ssBreadcrumbs = document.querySelectorAll('.ml-product-taste .sn_block_teaser_skyscraper_full .wpseo_breadcrumb');
84
85	if (ssBreadcrumbs.length){
86		ssBreadcrumbs.forEach(function(ssBreadcrumb){
87			const trgtContainer = ssBreadcrumb.closest('.ml-product-taste');
88			if (trgtContainer){
89				trgtContainer.insertBefore(ssBreadcrumb,trgtContainer.firstChild);
90			}
91		});
92	}
93
94
95  	// detect scroll direction
96	var prevScroll = 0;
97	
98	window.addEventListener("scroll", function(){
99		var curScroll = window.pageYOffset || document.documentElement.scrollTop;
100		var disableSnap = false;
101
102		// disable scroll snap for specific pages
103		if ( document.body.classList.contains('page-template-tpl-disclaimer') ||
104		document.body.classList.contains('ml-parent-cocktails') ){
105			disableSnap = true;
106		}
107		if (!disableSnap){
108			
109			document.documentElement.classList.add('scroll-snap'); // add class to HTML tag
110			document.body.classList.add('scroll-snap');
111		} else {
112			document.documentElement.classList.remove('scroll-snap'); // remove class from HTML tag
113			document.body.classList.remove('scroll-snap');
114		}
115		prevScroll = curScroll <= 0 ? 0 : curScroll;
116	}, false);
117
118
119	const ctaBtns = document.querySelectorAll('._ctb_wr .sn_btn');
120	
121	if (ctaBtns.length){
122
123		ctaBtns.forEach(ctaBtn => {
124			// wrap text in a span
125			let wrap = document.createElement("span");
126			wrap.className = "btn_label";
127			ctaBtn.insertBefore(wrap, ctaBtn.firstChild);
128			wrap.appendChild(ctaBtn.childNodes[1]);
129
130			// replace sprite class
131			const sprite = ctaBtn.querySelector('.sn_sprite._tick');
132
133			if (sprite){
134				sprite.classList.remove('_tick');
135				sprite.classList.add('_arrow_right');
136
137				// replace icon
138				let iconUrl = sprite.querySelector('use').getAttribute('xlink:href');
139				iconUrl = iconUrl.replace('#tick','#arrow-right');
140				sprite.querySelector('use').setAttribute('xlink:href', iconUrl);
141			}
142		});
143	}
144
145});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.