PageSourceSearch

https://www.naturastore.pt/templates/js/menu_mobile.js?1b

js naturastore.pt collected 2026-09-26 13:15:33 UTC 10,898 bytes, 290 lines download raw bytes

1app.controller("menuMobileController", function($scope, $http, $rootScope, $sce){
2	$rootScope.menu_mobile = {
3		open: false
4	}
5
6	$rootScope.header.icon_menu_mobile.changeIcon = false;
7
8	$scope.createMobileMenu = function(menu) {
9		let _cm = this;
10
11		_cm.formatValues = function(value){
12			value.link_name_formater = $sce.trustAsHtml(value.link_name);
13
14			var link_name_prefix = (value.sublevel == 4 || value.sublevel == 54) ? JSVarsMenuMobile.expressions[231] : JSVarsMenuMobile.expressions[579];
15			value.link_name_cat_formater = $sce.trustAsHtml(link_name_prefix + " " + value.link_name);
16
17			value.custom_url = (value.without_click == 1) ? '' : value.url;
18			return value;
19		}
20
21		_cm.findChilds = function(menu){
22			menu.childs_sub = 0;
23			angular.forEach(menu.childs, function(value, key){
24				menu.childs[key] = _cm.formatValues(value);
25				if(menu.childs.length > 0)
26					menu.childs_sub = 1;
27				if(value.childs.length > 0)
28					menu.childs[key] =_cm.findChilds(menu.childs[key]);
29		    });
30		    return menu;
31		}
32
33		angular.forEach(menu, function(value, key){
34			menu[key] = _cm.formatValues(value);
35			menu[key].childs_sub = 0;
36			if(value.childs.length > 0) menu[key] =_cm.findChilds(menu[key]);
37	    });
38
39	    return menu;
40	}
41
42	$scope.menuMobile = $scope.createMobileMenu($.parseJSON(sys_menu));
43
44	setTimeout(function(){
45		$(".mobile-menu").addClass("loaded");
46		$scope.positionMenuSelected();
47
48		//const menumobileLozad = lozad(".rdc-lozad-menu-mobile");
49		//menumobileLozad.observe();
50	}, 600);
51
52	$scope.positionMenuSelected = function(){
53		if($(".mobile-nav-item.sel").length > 0) {
54			var menuSel = $(".mobile-nav-item.hasSub.sel").first();
55
56			if(JSVarsMenuMobile.templatesParams.menu_levels == 3) {
57				var menuSel2 = $(".mobile-nav-item-2.sel").first();
58			} else {
59				var menuSel2 = $(".mobile-nav-item-2.hasSub.sel").first();
60			}
61
62			if(menuSel.data("menuindex") != undefined) {
63				$(".mobile-main-submenu-group, .mobile-menu-sub").addClass("hidden");
64				$(".mobile-main-submenu-group[data-menuindex="+menuSel.data("menuindex")+"]").removeClass("hidden");
65				$(".mobile-main-submenu-group[data-menuindex="+menuSel.data("menuindex")+"] .mobile-menu-sub:not([data-submenuindex])").removeClass("hidden");
66
67				if(JSVarsMenuMobile.templatesParams.menu_levels == 4) {
68					if(menuSel.hasClass('mobile-accordion-item')) {
69						menuSel.addClass('active');
70						menuSel.parent().next('.mobile-accordion-group').show();
71					}
72				}
73
74				if(menuSel2.data("submenuindex") != undefined || menuSel2.length > 0) {
75					if(JSVarsMenuMobile.templatesParams.menu_levels == 3) {
76						var submenuGroup = $(".mobile-main-submenu-group[data-menuindex="+menuSel.data("menuindex")+"]");
77					} else {
78						var submenuGroup = $(".mobile-main-submenu-group[data-menuindex="+menuSel.data("menuindex")+"] .mobile-menu-sub[data-submenuindex="+menuSel2.data("submenuindex")+"]");
79					}
80					submenuGroup.removeClass("hidden");
81					$('#mobile-holder').addClass("disableTransitionDuration").css('transform', 'translateX(-50%)');
82					$("#menu").addClass("active");
83					
84					var accordionItem = $('.mobile-accordion-item.sel', submenuGroup);
85					if(accordionItem.length > 0) {
86						accordionItem.addClass('active');
87						accordionItem.parent().next('.mobile-accordion-group').show();
88					}
89
90					//var scrollTop = ($(".mobile-nav-item-2.sel").first().offset().top - 150) + $(".mobile-nav-item-2.sel").first().closest('.mobile-menu-sub-scroll').scrollTop();
91					//$(".mobile-nav-item-2.sel").first().closest('.mobile-menu-sub-scroll').scrollTop(scrollTop);
92				}
93			}
94
95			setTimeout(function(){
96				$('#mobile-holder').removeClass("disableTransitionDuration");
97			}, 50);
98		}
99	}
100
101	$rootScope.openMobileMenu = function(){
102		$rootScope.header.headroom.enable = $rootScope.menu_mobile.open;
103		$rootScope.menu_mobile.open = !$rootScope.menu_mobile.open;
104
105		if($rootScope.menu_mobile.open) {
106			lockWindowScroll.lock();
107			$('body').addClass('menu-mobile-opened show-containerSite');
108			if(window.innerWidth >= 768) {
109				$("#containerSite-mask").addClass("overlay");
110			}
111
112			if(window.innerWidth >= 768 && window.innerWidth < 1200) {
113				if($(window).scrollTop() > 0) {
114					if($('body').hasClass('headerCampaignVisibleTopHeader') && $(window).scrollTop() < 36 
115						|| $('body').hasClass('bannerWelcomeGiftVisible') && $(window).scrollTop() < 40) {
116						$(window).scrollTop(0);
117					}
118				}
119			}
120			
121			setTimeout(function(){
122				$("#containerSite-mask, .slideout-menu").addClass('open-menu-css-animation');
123			});
124
125			if(window.innerWidth < 768) {
126				setTimeout(function(){
127					$('#containerSite').addClass('overlay');
128				}, 250);
129			}
130
131			$('.rdc-lozad-menu-mobile').each(function(){
132				$(this).attr('src', $(this).attr('data-src'));
133			});
134			$('.rdc-lozad-menu-mobile').removeClass('rdc-lozad-menu-mobile');
135
136		} else {
137			if(window.innerWidth < 768) {
138				$('#containerSite').removeClass('overlay');
139			}
140			$("#containerSite-mask, .slideout-menu").removeClass('open-menu-css-animation');
141			setTimeout(function(){
142				$("#containerSite-mask").removeClass("overlay");
143				$('body').removeClass('menu-mobile-opened show-containerSite');
144			}, 250);
145			lockWindowScroll.unlock();
146		}
147	}
148
149	$rootScope.closeMobileMenu = function(){
150		$rootScope.header.headroom.enable = $rootScope.menu_mobile.open;
151		$rootScope.menu_mobile.open = !$rootScope.menu_mobile.open;
152
153		if($rootScope.menu_mobile.open) {
154			return 0;
155
156		} else {
157			if(window.innerWidth < 768) {
158				$('#containerSite').removeClass('overlay');
159			}
160			
161			setTimeout(function(){
162				$("#containerSite-mask").removeClass("overlay");
163				$('body').removeClass('menu-mobile-opened show-containerSite');
164			}, 250);
165			setTimeout(function(){
166				$("#containerSite-mask, .slideout-menu").removeClass('open-menu-css-animation');
167			}, 0);
168			lockWindowScroll.unlock();
169		}
170	}
171
172	$("#containerSite-mask").on("click", function(ev){
173		ev.stopPropagation();
174		setTimeout(function(){
175			$rootScope.openMobileMenu();
176			$rootScope.$digest();
177		});
178	});
179
180	$('#mobile-holder').on("click", '.mobile-nav-item.hasSub, .mobile-nav-item-2.hasSub', function(ev) {
181		ev.preventDefault();
182		
183		if($(this).hasClass('mobile-accordion-item')) {
184			var accordionContainer = $(this).closest('.mobile-accordion-wrapper');
185	        if ($(this).hasClass('active')) {
186	            $('.mobile-accordion-item', accordionContainer).removeClass('active');
187	            $('.mobile-accordion-group', accordionContainer).stop(true, true).slideUp('normal');
188	            $('.rdc-icon-arrowup', accordionContainer).addClass('rdc-icon-arrowdown').removeClass('rdc-icon-arrowup');
189	        } else {
190	            $('.mobile-accordion-item', accordionContainer).removeClass('active');
191	            $('.mobile-accordion-item .rdc-icon-arrowup', accordionContainer).removeClass('rdc-icon-arrowup').addClass('rdc-icon-arrowdown');
192	            $('.mobile-accordion-group', accordionContainer).slideUp('normal');
193	            $(this).addClass('active');
194	            this2 = $(this).closest('.mobile-menu-group');
195	            $('.mobile-accordion-group', this2).stop(true, true).slideDown('normal');
196	            $('.rdc-icon-arrowdown', this2).addClass('rdc-icon-arrowup').removeClass('rdc-icon-arrowdown');
197	        }
198
199		} else {
200			var menuindex = $(this).data("menuindex");
201			var submenuindex = $(this).data("submenuindex");
202			if(menuindex != undefined) {
203				$(this).addClass("active");
204				$(".mobile-main-submenu-group, .mobile-menu-sub").addClass("hidden");
205				$(".mobile-main-submenu-group[data-menuindex="+menuindex+"]").removeClass("hidden");
206				$(".mobile-main-submenu-group[data-menuindex="+menuindex+"] .mobile-menu-sub:not([data-submenuindex])").removeClass("hidden");
207				$('.mobile-menu-sub-scroll').scrollTop(0);
208
209				if(submenuindex != undefined) {
210					$(".mobile-main-submenu-group[data-menuindex="+menuindex+"] .mobile-menu-sub[data-submenuindex="+submenuindex+"]").removeClass("hidden");
211				}
212
213				$('#mobile-holder').css('transform', 'translateX(-50%)');
214				$("#menu").addClass("active");
215			}
216		}
217	});
218
219	$('#mobile-main-menu-sub').on("click", '.return', function(ev) {
220		$('.mobile-menu-group .mobile-nav-item').removeClass('active'); //added new
221		$(".mobile-menu-sub .mobile-nav-item.active").removeClass("active");
222		$('#mobile-holder').css('transform', 'translateX(0)');
223		$("#menu").removeClass("active");
224		setTimeout(function(){
225			$(".mobile-main-submenu-group, .mobile-menu-sub").addClass("hidden");
226			$('.mobile-menu-sub .mobile-accordion-item.active').removeClass('active');
227            $('.mobile-menu-sub .mobile-accordion-group').hide();
228            $('.mobile-menu-sub .rdc-icon-arrowup').addClass('rdc-icon-arrowdown').removeClass('rdc-icon-arrowup');
229		}, 200);
230	});
231
232	var reloadmenu_progress = false
233	$scope.reloadmenu = function() {
234		if(reloadmenu_progress) return;
235		reloadmenu_progress = true;
236
237		$('body').removeClass('menu-mobile-opened show-containerSite');
238		$("#containerSite").removeClass("overlay");
239		$("#containerSite-mask").removeClass("overlay").css("padding-top", 0);
240		$(".mobile-menu").removeClass("visible");
241		$('#menu, #mobile-holder, #mobile-main-menu').addClass("disableTransitionDuration");
242		$('#mobile-holder, #mobile-main-menu').addClass("disableTransitionDuration").css('transform', 'translateX(0)');
243		$("#menu").removeClass("active");
244
245		if($rootScope.menu_mobile.open) {
246			$rootScope.openMobileMenu();
247			$rootScope.$digest();
248		}
249
250		setTimeout(function(){
251			$scope.positionMenuSelected();
252			$(".disableTransitionDuration").removeClass("disableTransitionDuration");
253			reloadmenu_progress = false;
254		}, 100);
255	}
256
257	$scope.submitCountryMobile = function(elem) {
258		let form 	= $(elem.currentTarget);
259		let lang 	= $('#lg-mobile').val();
260		let cid 	= $('#country-mobile').val();
261		let code 	= $('#lg-mobile option:selected').attr("data-code");
262		form.find("[type=submit]").addClass("loader");
263		$.get('/api/api.php/setLang/'+lang+'/'+cid).done(function() {
264			location = JSVarsMenuMobile.shop.sLocation;
265		});
266	}
267
268	$('#country-mobile').on('change', function(){
269		var field = $(this);
270		var form = field.closest('form');
271		var flag = $('option:selected', field).attr('data-code');
272		var lg = $('option:selected', field).attr('data-lg');
273		$(field).parents('.select').css('background-image', 'url('+JSVarsMenuMobile.shop.CDN+'plugins/system/sysimgs/flags/'+flag+'.png');
274		if(lg != '') $('#lg', form).val(lg);
275	})
276
277	/*if((navigator.appVersion.indexOf("Win")!=-1) || (navigator.appVersion.indexOf("Mac")!=-1)) {
278		$(window).resize(function(){
279			$scope.reloadmenu();
280		});
281	} else {
282		window.matchMedia('(orientation: landscape)').addListener(function(m){
283			$scope.reloadmenu();
284		});
285	}*/
286});
287
288$(".search-mobile form[name='frm_search']").on("submit", function(){
289	if($(".search-mobile input[name='term']").val() == "" || $(".search-mobile input[name='term']").val().length < 2){return false;}
290});

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.