PageSourceSearch

https://pocosdecaldas.mg.gov.br/wp-content/themes/prefeitura-pocos…/js/menu-especial.js?ver=260924-195744

js pocosdecaldas.mg.gov.br collected 2026-09-24 19:58:32 UTC 10,220 bytes, 367 lines download raw bytes

1(function($) {
2
3	// Funcao para retornar o maior valor de um array
4	Array.max = function(array) {
5	    return Math.max.apply(Math, array);
6	};
7	Array.min = function(array) {
8		return Math.min.apply(Math, array);
9	};
10
11	var Menu = {
12		desktop:{
13			start : function(){
14				// Pega menu do bootstrap e monta de acordo com a necessidade
15				Menu.megaMenu.montaMenu();
16
17				// Controla uma classe para exibição do marcador do menu
18				Menu.megaMenu.hoverMarcador();
19
20				// faz o controle da altura dos itens do megamenu
21				Menu.megaMenu.hoverDrop();
22
23				// adiciona um tamanho em cada item ul do menu
24				Menu.megaMenu.mudaTamnhoUl();
25			}
26		},
27
28		megaMenu:{
29
30			montaMenu:function(){
31
32				// percorre o menu procurando por um menu 'mutnivel' especial
33				 $('#menu-principal .multinivel').each(function() {
34				      var item = $(this).children('a');
35				      var itemTxt = $(item).text();
36
37				      var itemUL = $(item).next();
38				      var retorno = Menu.replaceSlug.replaceText(itemTxt);
39
40				      $(itemUL).attr('data-hover', retorno);
41
42				      $("#monta-menu").append(itemUL);
43				  });
44
45				Menu.megaMenu.start();
46			},
47
48			start:function(){
49
50				$('#menu-principal .multinivel a').mouseenter(function () {
51					setTimeout(function(){
52						$(".menu-item-has-children").removeClass('open');
53					}, 100);
54				});
55
56				$('#menu-principal .multinivel a').hover(function(e) {
57						var sessao = $(this).text();
58						var nameCategory = sessao.toLowerCase();
59
60						var retorno = Menu.replaceSlug.replaceText(nameCategory);
61
62						$("#topo-principal .dropdown-menu").removeClass('visivel-option');
63						$( "[data-hover="+retorno+"]" ).addClass('visivel-option');
64
65						$('#topo-principal').addClass('open-menu');
66						$(this).parents('li').addClass('open');
67						$('.dropdown-mega-menu').show();
68
69						Menu.megaMenu.tamanhoProporcional();
70
71				},
72				function(e) {
73					if (jQuery('.dropdown-mega-menu:visible').length === 1 && !$(e.toElement).hasClass('dropdown-mega-menu')) {
74						$("#header-super li").removeClass('open');
75						$('.dropdown-mega-menu').hide();
76						$('#header-super').removeClass('open-menu');
77					}
78				});
79
80				$('.inner-megamenu').hover(function(e) {
81					$('.dropdown-mega-menu').show();
82				});
83
84				$('.inner-megamenu').mouseleave(function () {
85					$('.dropdown-mega-menu').hide();
86				});
87
88			},
89			hoverMarcador:function(){
90				var objetoHover;
91
92				$('#menu-principal li.dropdown').hover(function(e) {
93					objetoHover = $(this);
94					$(objetoHover).addClass('menu-hover');
95				});
96
97
98				$('#menu-principal li.dropdown').mouseleave(function () {
99					$(objetoHover).removeClass('menu-hover');
100					setTimeout(function(){
101						if($('.dropdown-mega-menu:visible').is(':visible')){
102						$(objetoHover).addClass('menu-hover');
103						}else{
104							$(objetoHover).removeClass('menu-hover');
105						}
106					}, 10);
107				});
108
109				$('.inner-megamenu').mouseleave(function () {
110					$(objetoHover).removeClass('menu-hover');
111				});
112			},
113
114			mudaTamnhoUl:function(){
115				menus = $("#monta-menu").find('ul');
116
117				menus.each(function(index, el) {
118
119					var elementoUL = $(this);
120					var maxHeight  = 0;
121					var item1 = $(this).children("li");
122
123					$(this).children("li").each(function(){
124						var tmpHeight = $(this).height();
125						maxHeight = maxHeight + tmpHeight;
126					});
127
128					 $(elementoUL).height(maxHeight);
129				});
130
131				$("body").removeClass('loadingMenu');
132			},
133
134			hoverDrop:function(){
135				$('#monta-menu a').hover(function(e) {
136
137					setTimeout(function() {
138						Menu.megaMenu.tamanhoProporcional();
139					}, 100);
140				});
141
142				$('#monta-menu a').mouseleave(function () {
143					$("#monta-menu ul").height("auto");
144					$(".inner-megamenu").height("auto");
145					Menu.megaMenu.tamanhoProporcional();
146				});
147			},
148			tamanhoProporcional:function(){
149				arrayTamanhos = [];
150				var maior = 0;
151
152				var tamanhoBanner = $(".col-banner-dropdown").height();
153
154				$('#monta-menu ul').each(function() {
155			      	if ($(this).is(':visible')) {
156			      		var alturaUl = $(this).height();
157			      		arrayTamanhos.push(alturaUl);
158					}
159			 	 });
160
161
162				maior = Array.max(arrayTamanhos);
163
164				if (maior > (tamanhoBanner-20)){
165					$('#monta-menu ul').each(function() {
166				      	if ($(this).is(':visible')) {
167				      		$(this).height(maior);
168						}
169				 	 });
170					$(".inner-megamenu").height(maior + 20);
171				}else{
172					$('#monta-menu ul').each(function() {
173				      	if ($(this).is(':visible')) {
174				      		$(this).height(tamanhoBanner - 20);
175						}
176				 	 });
177					$(".inner-megamenu").height(tamanhoBanner);
178				}
179			}
180		},
181
182		menuMobile:{
183			montaMenuMobile:function(){
184				Menu.menuMobile.montaMenuMobilePrincipal();
185				Menu.menuMobile.montaMenuMobileTopo();
186				Menu.menuMobile.montaMenuMobileRedes();
187			},
188
189			start: function(){
190				$(".bt-hamburguer").click(function () {
191					$("body").addClass('menu-mobile-open1');
192				});
193
194				$("#menu-level1 .collapse .panel-body .dropdown-submenu a").click(function () {
195
196					var sessao = $(this).text();
197					var nameCategory = sessao.toLowerCase();
198
199					var retorno = Menu.replaceSlug.replaceText(nameCategory);
200
201					$("#menu-level2 .dropdown-menu").removeClass('visivel-option');
202					$( "[data-click="+retorno+"]" ).addClass('visivel-option');
203
204					$("#menu-level2").addClass('open');
205
206					$("body").addClass('menu-mobile-open2');
207
208					$("#menu-level1 .active").removeClass('active');
209					$(this).parent().addClass('active');
210
211					$( "#menu-level2" ).scrollTop(0);
212
213				});
214
215				// função que pega o clique em qualquer lugar da tela e fecha o menu
216				$('#tampa-menu, #fecha-menu').on('click', function (e) {
217					Menu.menuMobile.closeMenuMobile();
218				});
219
220				$('#menu-level1 .panel-body a').on('click', function (e) {
221					$("body").removeClass('corpo-clinico-aberto-mobile');
222					$("body").removeClass('unidades-aberto-mobile');
223				});
224
225			},
226			closeMenuMobile:function(){
227				$("#menu-level1 .active").removeClass('active');
228				$("body").removeClass('menu-mobile-open1');
229				$("body").removeClass('menu-mobile-open2');
230				$("body").removeClass('corpo-clinico-aberto-mobile');
231				$("body").removeClass('unidades-aberto-mobile');
232			},
233
234			montaMenuMobilePrincipal:function(){
235				var countMenu = 0;
236
237				var menuClone = $('#menu-principal').clone();
238
239				$(menuClone).find("> ul > li").each(function() {
240
241					// adiciona as classes do accordeon nos primeiros li
242					var item = $(this);
243					$(item).addClass('panel')
244							.addClass('panel-default');
245
246					// pega o primeiro href do li
247				      var ahrefChildren = $(item).children('a');
248
249				      // pega o texto do href do li
250				      var txtChildren = $(ahrefChildren).text();
251
252				      // transforma o texto em minusculo
253					var nameCategory = txtChildren.toLowerCase();
254
255					// transforma o texto em slug
256				      var slugItem = Menu.replaceSlug.replaceText(nameCategory);
257
258				      // cria um slug sem tralha
259				      var slugFinal = "id-"+slugItem;
260
261				      // cria um slug com tralha
262				      var hrefFinal = "#id-"+slugItem;
263
264				      // caso seja um dropdown adiciona classes e parametros para funcionar o accordeon
265				      if ($(this).hasClass('dropdown')){
266				      	 $(ahrefChildren).attr('data-toggle', 'collapse')
267				      				  .attr('data-parent', '#accordionTop')
268				      				  .attr('href', hrefFinal)
269				      				  .attr('aria-expanded', 'false')
270				      				  .attr('aria-controls', slugFinal)
271				      				  .addClass('btMenu');
272				      }
273
274				       // adiciona os itens de accordeon dentro dele
275				      $("#accordionTop").append(item);
276
277				       // Seleciona o UL filho do item
278				      var UlDropLevel1 =  $(this).children(".dropdown-menu");
279
280				       // Monta o accordeon com os filhos do menu
281				      $(UlDropLevel1).wrap(' <div id="'+slugFinal+'" class="panel-collapse collapse" role="tabpanel"></div>').wrap('<div class="panel-body"></div>');
282
283				     var LiDropLevel2 = $(UlDropLevel1).find("> .dropdown-submenu");
284
285				      $(LiDropLevel2).each(function() {
286				      	 var ahrefDropLevel2 = $(this).find("> a");
287				      	 var txtFilho = $(ahrefDropLevel2).text();
288				      	 var nameCategoryFilho = txtFilho.toLowerCase();
289				      	 var slugItemFilho = Menu.replaceSlug.replaceText(nameCategoryFilho);
290
291				      	 var UlDropLevel3 = $(this).find("> .dropdown-menu");
292				      	 $(UlDropLevel3).attr('data-click', slugItemFilho);
293
294				      	 var hrefItem = $(ahrefDropLevel2).attr('href');
295
296					   	if (hrefItem !="#" && hrefItem !="undefined" && hrefItem !=undefined){
297					      	var guardalink = hrefItem;
298					      	$(ahrefDropLevel2).attr('href', "#");
299
300					      	$(UlDropLevel3).prepend('<li class="top-level2"><a href="'+guardalink+'">Página Inicial</a></li>');
301					      }
302
303				      	$("#menu-level2").prepend(UlDropLevel3);
304
305				     });
306				  });
307			},
308
309			montaMenuMobileTopo:function(){
310				var menuCloneTop = $('#menu-faixa').clone();
311				$(menuCloneTop).addClass('menu-mobile-clone-top');
312				$("#menu-level1").append(menuCloneTop);
313			},
314
315			montaMenuMobileRedes:function(){
316				var menuCloneRedes = $('#lista-redes').clone();
317				$("#menu-level1").append(menuCloneRedes);
318			},
319
320		},
321
322		replaceSlug:{
323			replaceText:function(texto){
324				value = texto.toLowerCase();
325			      value = value.replace(/[á|ã|â|à]/gi, "a");
326			      value = value.replace(/[é|ê|è]/gi, "e");
327			      value = value.replace(/[í|ì|î]/gi, "i");
328			      value = value.replace(/[õ|ò|ó|ô]/gi, "o");
329			      value = value.replace(/[ú|ù|û]/gi, "u");
330			      value = value.replace(/[ç]/gi, "c");
331			      value = value.replace(/[ñ]/gi, "n");
332			      value = value.replace(/[á|ã|â]/gi, "a");
333
334			      value = value.replace(/\s/g, '-');
335
336			      value = value.replace(/(-)1+/gi, "-");
337			      return value;
338			}
339		}
340	};
341
342	$(document).ready(function() {
343
344		// a partir da versao original do menu, monta uma versao customizada para o mobile
345		Menu.menuMobile.montaMenuMobile();
346
347		// Faz funcionar o menu mobile
348		Menu.menuMobile.start();
349
350		Menu.desktop.start();
351		//console.log('teste');
352	});
353
354	$( window ).resize(function() {
355	  //Menu.MenuiPad.start();
356	});
357
358
359	$(window).scroll(function(){
360
361	});
362
363	$(window).load(function() {
364
365	});
366
367})(jQuery);

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.