PageSourceSearch

https://cm-machico.pt/templates/wnpc/js/fpjs.js

js cm-machico.pt collected 2026-10-02 06:49:50 UTC 19,920 bytes, 565 lines download raw bytes

1function toggleAB(){
2  var el = this; // `this` is the "button" Element Obj reference`
3  return [
4    function() {jQuery("div#accessibility-links button#fr_screenreader_highcontrast").css('background-color','#fff')},
5    function() {jQuery("div#accessibility-links button#fr_screenreader_highcontrast").css('background-color','#ff9e3d')}
6  ][el.tog^=1]();
7}
8
9function toggleCD(){
10  var el = this; // `this` is the "button" Element Obj reference`
11  return [
12    function() {jQuery("div#accessibility-links button#fr_screenreader_highcontrast2").css('background-color','#fff')},
13    function() {jQuery("div#accessibility-links button#fr_screenreader_highcontrast2").css('background-color','#58b9ff')}
14  ][el.tog^=1]();
15}
16
17function toggleEF(){
18  var el = this; // `this` is the "button" Element Obj reference`
19  return [
20    function() {jQuery("div#accessibility-links button#fr_screenreader_highcontrast3").css('background-color','#fff')},
21    function() {jQuery("div#accessibility-links button#fr_screenreader_highcontrast3").css('background-color','#00ffff')}
22  ][el.tog^=1]();
23}
24
25function removeActiveClass(){
26	jQuery("#documentos .sideCat .topic").removeClass("active");
27	jQuery("#documentos .itemCat .itemCatBlock").removeClass("active");
28	
29	setTimeout(function() {
30		
31		/*Documentos*/
32		var larguraBlocoDocs = jQuery('#documentos .itemCat .itemCatBlock.active .contentItemCat').width();	
33		jQuery('#documentos .itemCat .itemCatBlock.active .contentItemCat').css('height',larguraBlocoDocs);
34		
35	}, 0);
36	
37	setTimeout(function() {
38		
39		/*Documentos*/
40		var alturaDocs = jQuery('#documentos .itemCat').height();
41		var alturaDocs2 = jQuery('#documentos .sideCat').height();
42		
43		if(alturaDocs > alturaDocs2) {
44			jQuery('#documentos .sideCat').css('height',alturaDocs);
45		} else {
46			jQuery('#documentos .sideCat').css('height',alturaDocs2);
47		}
48		
49		
50	}, 100);
51}
52
53
54jQuery(window).scroll(function (event) {
55    var scroll = jQuery(window).scrollTop();
56    
57    var distanciaToTop = jQuery("#g-container-6998").offset().top - jQuery(window).scrollTop();
58    
59    if (distanciaToTop < 500 ) {
60        
61        jQuery('#g-totop').css( 'opacity','1' );
62        jQuery('#g-totop').css( 'visibility','visible' );
63        
64    } else {
65        
66        jQuery('#g-totop').css( 'opacity','0' );
67        jQuery('#g-totop').css( 'visibility','hidden' );
68    	
69    }
70    
71});
72
73jQuery( window ).resize(function() {
74    /*SLIDERS*/
75    
76    var alturaSlide = jQuery('.hideImage').height();
77	jQuery('.sliderProjects').css('height',alturaSlide);
78	
79	var alturaSlideNormal = jQuery('.hideImageNormal').height();
80	jQuery('.sliderPrincipalNormal').css('height',alturaSlideNormal);
81	
82	var alturaSlideMobile = jQuery('.hideImageMobile').height();
83	jQuery('.sliderPrincipalMobile').css('height',alturaSlideMobile);
84    
85    var alturaEcra = jQuery( window ).height();
86 
87    jQuery('#slide').css('max-height',alturaEcra);
88    jQuery('#slide').css('overflow-y','hidden');
89    
90	var alturaSlidePosition = jQuery('#slide').height();
91	var alturaSemTicker = alturaSlidePosition - 75;
92	
93	if(alturaSemTicker > alturaEcra) {
94	    var positionDots = alturaEcra -120;
95        jQuery('.sliderPrincipalNormal .dots').css('top',positionDots);
96        jQuery('.sliderPrincipalMobile .dots').css('top',positionDots);
97	} else {
98	    var positionDots = alturaSemTicker -50;
99        jQuery('.sliderPrincipalNormal .dots').css('top',positionDots);
100        jQuery('.sliderPrincipalMobile .dots').css('top',positionDots);
101	}
102	
103	/*Atividade Municipal*/
104	var atividadeMunicipal = jQuery('#AtividadeMunicipal .item.main img').height();
105	jQuery('#AtividadeMunicipal .item').css('height',atividadeMunicipal);
106	
107	
108	/*Documentos*/
109	var larguraBlocoDocs = jQuery('#documentos .itemCat .itemCatBlock.active .contentItemCat').width();
110	var alturaDocs = jQuery('#documentos .itemCat').height();
111	var alturaDocs2 = jQuery('#documentos .sideCat').height();
112	
113	jQuery('#documentos .itemCat .itemCatBlock.active .contentItemCat').css('height',larguraBlocoDocs);
114	
115	if(alturaDocs > alturaDocs2) {
116		jQuery('#documentos .sideCat').css('height',alturaDocs);
117	} else {
118		jQuery('#documentos .sideCat').css('height',alturaDocs2);
119	}
120
121	
122});
123
124function menuBarra(botao){
125	revertcolor();
126	jQuery('#content' + botao).css('display','block');
127	jQuery('.' + botao).css('background','#005d7b');
128	jQuery('.' + botao).css('color','#fff');
129}
130
131
132jQuery( window ).on('load', function() {
133    
134    jQuery("#fr_screenreader_highcontrast").click(toggleAB);
135    jQuery("#fr_screenreader_highcontrast2").click( toggleCD );
136    jQuery("#fr_screenreader_highcontrast3").click( toggleEF);
137    
138    jQuery("#fr_screenreader_highcontrast").attr('title', 'Contraste | Acessibilidades | DL 83/2018');
139    jQuery("#fr_screenreader_highcontrast2").attr('title', 'Contraste | Acessibilidades | DL 83/2018');
140    jQuery("#fr_screenreader_highcontrast3").attr('title', 'Contraste | Acessibilidades | DL 83/2018');
141	
142	var alturaSlide = jQuery('.hideImage').height();
143	jQuery('.sliderProjects').css('height',alturaSlide);
144	
145	var alturaSlideNormal = jQuery('.hideImageNormal').height();
146	jQuery('.sliderPrincipalNormal').css('height',alturaSlideNormal);
147	
148	var alturaSlideMobile = jQuery('.hideImageMobile').height();
149	jQuery('.sliderPrincipalMobile').css('height',alturaSlideMobile);
150    
151    var alturaEcra = jQuery( window ).height();
152 
153    jQuery('#slide').css('max-height',alturaEcra);
154    jQuery('#slide').css('overflow-y','hidden');
155    
156	var alturaSlidePosition = jQuery('#slide').height();
157	var alturaSemTicker = alturaSlidePosition - 75;
158	
159	if(alturaSemTicker > alturaEcra) {
160	    var positionDots = alturaEcra -120;
161        jQuery('.sliderPrincipalNormal .dots').css('top',positionDots);
162        jQuery('.sliderPrincipalMobile .dots').css('top',positionDots);
163	} else {
164	    var positionDots = alturaSemTicker -50;
165        jQuery('.sliderPrincipalNormal .dots').css('top',positionDots);
166        jQuery('.sliderPrincipalMobile .dots').css('top',positionDots);
167	}
168    
169    
170    var atividadeMunicipal = jQuery('#AtividadeMunicipal .item.main img').height();
171	jQuery('#AtividadeMunicipal .item').css('height',atividadeMunicipal);
172	
173	
174	/* Selo - Copyright */
175    let s = document.createElement('script');
176    s.src = 'https://seal.atlas.globalsign.com/gss/one/seal?image=seal_100-50_en_t.png';
177    document.body.appendChild(s);
178    
179	jQuery("#ss_gmo_globalsign_img").click(function(){  
180	    ss_open_profile();
181	});
182  
183});
184
185function closeMenuDigital() {
186	jQuery("#MenuSuperior").slideUp("slow");
187	jQuery(".w33.offMenu").css('display','none');
188	jQuery(".w33.turnMenu").css('display','inline-block');
189	jQuery("body").css('overflow-y','scroll');
190    
191    jQuery(".turnMenu .Atalhos").focus();
192}
193
194jQuery(document).ready(function(){
195    
196    // Remove o atributo 'title' do link do logo
197    jQuery('.g-logo ').removeAttr('title');
198    jQuery('.g-logo ').removeAttr('aria-label');
199    
200    jQuery('.dj-megamenu li[role="none"]').removeAttr('role');
201    jQuery('.dj-megamenu-accordion li[role="none"]').removeAttr('role');
202  
203    // 1. Lógica para abrir o submenu APENAS com ENTER ou ESPAÇO (mantida)
204    jQuery('.dj-megamenu > li.parent > a').on('keydown', function(e) {
205        var $menuItem = jQuery(this);
206        var $parentLi = $menuItem.closest('li.parent');
207
208        // Verifica se a tecla pressionada é ENTER (13) ou ESPAÇO (32)
209        if (e.which === 13 || e.which === 32) {
210            e.preventDefault();
211
212            var isAlreadyOpen = $parentLi.hasClass('hover');
213
214            if (isAlreadyOpen) {
215                // Se já estiver aberto e o usuário pressionar Enter/Espaço no link de Nível 1, ignora.
216                return;
217            }
218            
219            var $submenu = $menuItem.siblings('.dj-subwrap');
220
221            // Limpeza: Fecha todos os outros submenus
222            jQuery('.dj-megamenu li.parent').removeClass('hover').children('a').attr('aria-expanded', 'false');
223
224            if ($submenu.length) {
225                $parentLi.addClass('hover');
226                $menuItem.attr('aria-expanded', 'true');
227                
228                // Move o foco para o primeiro link dentro do submenu
229                setTimeout(function() {
230                    $submenu.find('a').first().focus();
231                }, 100);
232            }
233        }
234    });
235
236    // 2. Lógica de Fechamento do Submenu Aprimorada
237    // O menu fecha quando o foco sai de TODO o elemento <li>.
238    jQuery('.dj-megamenu li.parent').on('focusout', function(e) {
239        var $parentLi = jQuery(this);
240        
241        // Verifica se o próximo elemento com foco (e.relatedTarget) NÃO está contido em $parentLi.
242        // Isso cobre a navegação para fora do menu OU o retorno para o link de Nível 1.
243        if (!jQuery(e.relatedTarget).closest($parentLi).length) {
244            
245            // FECHAR O MENU: Remove a classe 'hover' do item pai
246            $parentLi.removeClass('hover');
247            // Define o aria-expanded para 'false'
248            $parentLi.children('a').attr('aria-expanded', 'false');
249            
250        } else if (e.relatedTarget === $parentLi.children('a')[0] && $parentLi.hasClass('hover')) {
251            // === NOVO CONTROLE PARA SHIFT + TAB ===
252            // Condição: Se o foco que está entrando for o link de Nível 1 (e.relatedTarget)
253            // e o menu estiver aberto, FECHA o submenu.
254
255            // Remove a classe 'hover' do item pai para fechar o submenu
256            $parentLi.removeClass('hover');
257            // Define o aria-expanded para 'false'
258            $parentLi.children('a').attr('aria-expanded', 'false');
259        }
260    });
261    
262    
263    
264    if ('serviceWorker' in navigator) {
265        window.addEventListener('load', function() {
266            navigator.serviceWorker.register('/sw.js').then(function(registration) {
267            }, function(err) {
268            });
269        });
270    }
271   
272    var vdUrl2App = 'balcaomunicipal.cm-machico.pt' ; 
273
274  	jQuery('a[href*="https://VDURLAPP/"]').each(function() {
275		var oldUrl = jQuery(this).attr("href"); // Get current url
276        var newUrl = oldUrl.replace("VDURLAPP", "balcaomunicipal.cm-machico.pt"); // Create new url
277        jQuery(this).attr("href", newUrl); // Set herf value
278	});
279
280  	jQuery('a[href*="file=https"]').each(function() {
281		var oldUrl = jQuery(this).attr("href"); // Get current url
282        var newUrl = oldUrl.replace("VDURLAPP", "balcaomunicipal.cm-machico.pt"); // Create new url
283        jQuery(this).attr("href", newUrl); // Set herf value
284	});
285	
286	/*MENU MOBILE*/
287	jQuery("#dj-megamenu1045mobile .dj-mobile-open-btn").click(function(){  
288	    // 1. Verifica se o botão clicado (this) TEM a classe 'active'
289        if (jQuery(this).hasClass('active')) {
290            // Se TEM a classe 'active', significa que o menu está sendo ABERTO
291            // Aplica a altura de 100%
292            jQuery("#menuDJ").css('height', '100%');
293            jQuery("#menuDJ").css('background', '#fff');
294            jQuery("#dj-megamenu1045mobile .dj-mobile-open-btn .dj-mobile-open-icon").css('display', 'none');
295    		jQuery("#mobileBar .botao.hideMenuMobile").css('display','inline-block');
296    		jQuery("#mobileBar .botao.menuMobile").css('display','none');
297        } else {
298            // Se NÃO TEM a classe 'active', significa que o menu está sendo FECHADO
299            // Volta a altura para 'auto'
300            jQuery("#menuDJ").css('height', 'auto');
301            jQuery("#menuDJ").css('background', 'transparent');
302            jQuery("#dj-megamenu1045mobile .dj-mobile-open-btn .dj-mobile-open-icon").css('display', 'block');
303    		jQuery("#mobileBar .botao.hideMenuMobile").css('display','none');
304    		jQuery("#mobileBar .botao.menuMobile").css('display','inline-block');
305        }
306	});
307	
308	/*jQuery("#mobileBar .botao.menuMobile").click(function(){  
309		jQuery("#menuMobile").slideDown("slow");
310		jQuery("#mobileBar .botao.hideMenuMobile").css('display','inline-block');
311		jQuery("#mobileBar .botao.menuMobile").css('display','none');
312	});
313	jQuery("#mobileBar .botao.hideMenuMobile").click(function(){    
314		jQuery("#menuMobile").slideUp("slow");
315		jQuery("#mobileBar .botao.menuMobile").css('display','inline-block');
316		jQuery("#mobileBar .botao.hideMenuMobile").css('display','none');
317	});*/
318	
319	
320	
321	/*Machico Digital*/
322	
323	jQuery(".w33.turnMenu .Atalhos").click(function(){      
324		jQuery("#MenuSuperior").slideDown("slow");
325		jQuery(".w33.offMenu").css('display','inline-block');
326		jQuery(".w33.turnMenu").css('display','none');
327		jQuery("body").css('overflow-y','hidden');
328		jQuery("#menuMobile").css('display','none');
329		jQuery("#mobileBar .botao.menuMobile").css('display','inline-block');
330		jQuery("#mobileBar .botao.hideMenuMobile").css('display','none');
331		
332		jQuery("#MenuSuperior a:visible:first").focus();
333	});
334	
335	jQuery(".w33.offMenu .Atalhos").click(function(){    
336        closeMenuDigital();
337    });
338	
339	jQuery(document).on('keyup', function(e) {
340        // 27 é o código da tecla 'Esc'
341        if (e.key === "Escape" || e.key === "Esc" || e.keyCode === 27) {
342            // Se o menu estiver visível, chame a função de fechar
343            if (jQuery("#MenuSuperior").is(":visible")) {
344        		closeMenuDigital();
345            }
346        }
347    });
348
349    jQuery('#MenuSuperior').on('focusout', function() {
350        // Atraso necessário para que document.activeElement se atualize
351        setTimeout(function() {
352            var menuEstaVisivel = jQuery("#MenuSuperior").is(":visible");
353            var focoSaiuDoMenu = jQuery(document.activeElement).closest('#MenuSuperior').length === 0;
354            
355            if (menuEstaVisivel && focoSaiuDoMenu) {
356                closeMenuDigital();
357            }
358        }, 10);
359    });
360    
361	
362	jQuery("#MenuSuperior .w33 button").click(function(){
363	    var botao = jQuery(this).attr('class');
364	    for(var i=0; i<20; i++){
365	        jQuery("#MenuSuperior .w33 button.pos" + i).removeClass("active");
366	        jQuery("#MenuSuperior .w66 div.pos" + i).removeClass("active");
367	    }
368	    
369	    var botao2 = botao.replace(" active","");
370	    
371	    jQuery(this).addClass("active");
372	    jQuery("#MenuSuperior .w66 div." + botao2).addClass("active");
373    	    
374	});
375    
376    
377    /*SLIDE PRINCIPAL NORMAL*/
378	var alturaSlideNormal = jQuery('.hideImageNormal').height();
379	jQuery('.sliderPrincipalNormal').css('height',alturaSlideNormal);
380	
381	jQuery(".sliderPrincipalNormal").fadeImages({
382        // interval
383        time: 4000,
384        // animation speed
385        fade: 1000,
386        // enable pagination dots
387        dots:true,
388        // enabble navigation
389        arrows:false,
390        // callback
391        complete:function() {}
392    });
393	
394	
395	
396	/*SLIDE PRINCIPAL MOBILE*/
397	var alturaSlideMobile = jQuery('.hideImageMobile').height();
398	jQuery('.sliderPrincipalMobile').css('height',alturaSlideMobile);
399	
400	
401	jQuery(".sliderPrincipalMobile").fadeImages({
402        // interval
403        time: 4000,
404        // animation speed
405        fade: 1000,
406        // enable pagination dots
407        dots:true,
408        // enabble navigation
409        arrows:false,
410        // callback
411        complete:function() {}
412    });
413    
414	
415	
416	/*SLIDE Machico Digital*/
417	var alturaSlide = jQuery('.hideImage').height();
418	jQuery('.sliderProjects').css('height',alturaSlide);
419	
420	jQuery(".sliderProjects").fadeImages({
421        // interval
422        time: 4000,
423        // animation speed
424        fade: 1000,
425        // enable pagination dots
426        dots:true,
427        // enabble navigation
428        arrows:false,
429        // callback
430        complete:function() {}
431    });
432	
433	setTimeout(function() {
434		var alturaSlide = jQuery('.hideImage').height();
435		jQuery('.sliderProjects').css('height',alturaSlide);
436	}, 2000);
437
438
439	if (navigator.userAgent.match(/Trident\//) || navigator.userAgent.match(/Edge\//)) {
440	    document.body.addEventListener("mousewheel", function(evt) {
441	        evt.preventDefault();
442	        var wd = evt.wheelDelta;
443	        var csp = window.pageYOffset;
444	        window.scrollTo(0, csp - wd);
445	    });
446	}
447
448	
449	setTimeout(function() {
450		
451		/*Atividade Municipal*/
452		var atividadeMunicipal = jQuery('#AtividadeMunicipal .item.main img').height();
453		jQuery('#AtividadeMunicipal .item').css('height',atividadeMunicipal);
454		
455		
456		/*Documentos*/
457		var larguraBlocoDocs = jQuery('#documentos .itemCat .itemCatBlock.active .contentItemCat').width();	
458		jQuery('#documentos .itemCat .itemCatBlock.active .contentItemCat').css('height',larguraBlocoDocs);
459		
460	}, 1000);
461	
462	setTimeout(function() {
463		
464		/*Documentos*/
465		var alturaDocs = jQuery('#documentos .itemCat').height();
466		var alturaDocs2 = jQuery('#documentos .sideCat').height();
467		
468		if(alturaDocs > alturaDocs2) {
469			jQuery('#documentos .sideCat').css('height',alturaDocs);
470		} else {
471			jQuery('#documentos .sideCat').css('height',alturaDocs2);
472		}
473		
474		
475	}, 2000);
476	
477	jQuery("#documentos .sideCat .topic:nth-child(1)").click(function() {
478		removeActiveClass();
479		jQuery("#documentos .sideCat .topic:nth-child(1)").addClass("active");
480		jQuery("#documentos .itemCat .itemCatBlock:nth-child(1)").addClass("active");
481	});
482	
483	jQuery("#documentos .sideCat .topic:nth-child(2)").click(function() {
484		removeActiveClass();
485		jQuery("#documentos .sideCat .topic:nth-child(2)").addClass("active");
486		jQuery("#documentos .itemCat .itemCatBlock:nth-child(2)").addClass("active");
487	});
488	
489	jQuery("#documentos .sideCat .topic:nth-child(3)").click(function() {
490		removeActiveClass();
491		jQuery("#documentos .sideCat .topic:nth-child(3)").addClass("active");
492		jQuery("#documentos .itemCat .itemCatBlock:nth-child(3)").addClass("active");
493	});
494	
495	jQuery("#documentos .sideCat .topic:nth-child(4)").click(function() {
496		removeActiveClass();
497		jQuery("#documentos .sideCat .topic:nth-child(4)").addClass("active");
498		jQuery("#documentos .itemCat .itemCatBlock:nth-child(4)").addClass("active");
499	});
500	
501	jQuery("#documentos .sideCat .topic:nth-child(5)").click(function() {
502		removeActiveClass();
503		jQuery("#documentos .sideCat .topic:nth-child(5)").addClass("active");
504		jQuery("#documentos .itemCat .itemCatBlock:nth-child(5)").addClass("active");
505	});
506	
507	
508	
509	// Contador
510	var section = document.querySelector('#contador .texto .legenda');
511	var hasEntered = false;
512	
513	window.addEventListener('scroll', function(e) {
514		var shouldAnimate = (window.scrollY + window.innerHeight) >= section.offsetTop;
515	
516		if (shouldAnimate && !hasEntered) {
517	  	hasEntered = true;
518	    
519	    jQuery('.count').each(function () {
520	    	var $this = jQuery(this);
521          var originalText = $this.text().trim();
522          
523          // Trocar vírgula por ponto e remover pontos de milhar
524          var numericValue = parseFloat(originalText.replace(/\./g, '').replace(',', '.'));
525          
526          $this.prop('Counter', 0).animate({
527            Counter: numericValue
528          }, {
529            duration: 8000,
530            easing: 'swing',
531            step: function (now) {
532              // Formatar com vírgula e milhar
533              var formatted = now.toLocaleString('pt-PT', {
534                minimumFractionDigits: (originalText.includes(',') ? 2 : 0),
535                maximumFractionDigits: 2
536              });
537              $this.text(formatted);
538            }
539          });
540	    });
541	
542	  }
543	});
544	
545	jQuery('#numeros .item .itemNumber .counter').each(function () {
546        var $this = jQuery(this);
547        var finalValue = parseInt($this.text().replace(/\s/g, ''), 10); // Remove espaços e converte para número
548        $this.prop('Counter', 0).animate({
549            Counter: finalValue
550        }, {
551            duration: 7000,
552            easing: 'swing',
553            step: function (now) {
554                var num = Math.ceil(now).toString();
555                if (Number(num) > 999) {
556                    while (/(\d+)(\d{3})/.test(num)) {
557                        num = num.replace(/(\d+)(\d{3})/, '$1' + ' ' + '$2');
558                    }
559                }
560                $this.text(num);
561            }
562        });
563    });
564    
565});

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.