1/*1790294970000*/ 2/** 3 * Copyright (c) 2000-present Liferay, Inc. All rights reserved. 4 * 5/* eslint-disable prefer-arrow-callback */ 6 7(function($) { 8 'use strict'; 9 10 const $body = $('body'); 11 const $document = $(document); 12 13 AUI().ready(function () { }); 14 15 Liferay.Portlet.ready(function (_portletId, _node) { }); 16 17 Liferay.on("allPortletsReady", function () { 18 //acessibilidade alto contraste 19 $("#checkboxAcessibilidade").change(function () { 20 if ($(this).is(":checked")) { 21 $("body").addClass("alto-contraste"); 22 $(".info-contraste").text("Alto contraste ligado"); 23 } else { 24 $("body").removeClass("alto-contraste"); 25 $(".info-contraste").text("Alto contraste desligado"); 26 } 27 }); 28 29 //acessibilidade font-size 30 var accessibilityFontSize = 31 typeof accessibilityFontSize !== "undefined" ? accessibilityFontSize : 4; 32 var originalFontSizes = []; 33 34 // Store original font sizes of elements 35 $("h1, h2, h3, h4, h5, p, a, li").each(function (i, el) { 36 originalFontSizes.push({ el: el, value: $(this).css("font-size") }); 37 }); 38 39 // Handle font size change from the range input 40 $document.on("input change", "#sizeFont", function () { 41 var value = $(this).val(); 42 accessibilityFontSize = value; 43 adjustFontSize(value); 44 $.post( 45 "/", 46 { accessibility: 1, accessibility_font: value }, 47 function (response) { 48 console.log(response); 49 } 50 ); 51 }); 52 53 // Function to adjust font sizes based on the given size value 54 function adjustFontSize(size) {
55 originalFontSizes.forEach(function (item) { 56 var newSize = parseFloat(item.value) * (size / 4); 57 $(item.el).css("font-size", newSize + "px"); 58 }); 59 } 60 61 // Initial setting of font size 62 adjustFontSize(accessibilityFontSize); 63 64 /* VLIBRAS */ 65 if (window.VLibras) { 66 new window.VLibras.Widget("https://vlibras.gov.br/app"); 67 } else { 68 console.warn("VLibras não está disponÃvel"); 69 } 70 71 /* ANIMAÃÃO DA ÃNCORA */ 72 $("#content a[href*='#']:not([data-toggle='tab']").click(function (e) { 73 e.preventDefault(); 74 var aid = $(this).attr("href"); 75 $("html,body").animate({ scrollTop: $(aid).offset().top }, "slow"); 76 }); 77 78 // Limpa URLs de forma mais eficiente 79 $("a").each(function () { 80 const $this = $(this); 81 const href = $this.attr("href"); 82 if (href && href.includes("/web/guest")) { 83 $this.attr("href", href.replace("/web/guest", "")); 84 } 85 }); 86 }); 87 88 // Otimização do dropdown com gerenciamento de eventos mais eficiente 89 $document.ready(function () { 90 const $dropdowns = $(".dropdown[data-dropdown-action='hover']"); 91 92 $dropdowns.each(function() { 93 const $dropdown = $(this); 94 const $dropdownToggle = $dropdown.find('.dropdown-toggle'); 95 const $dropdownMenu = $dropdown.find('.dropdown-menu'); 96 97 let hoverTimeout; 98 99 $dropdown.on('mouseenter', function() { 100 clearTimeout(hoverTimeout); 101 hoverTimeout = setTimeout(() => { 102 $dropdownToggle.trigger('click'); 103 }, 200); 104 }); 105 106 $dropdown.on('mouseleave', function() { 107 clearTimeout(hoverTimeout); 108 setTimeout(() => { 109 if (!$dropdown.is(':hover')) { 110 $dropdownMenu.removeClass('show'); 111 } 112 }, 200); 113 }); 114 115 // Fechar dropdown ao clicar em link sem submenu 116 $dropdownMenu.find('a').on('click', function(e) { 117 if (!$(this).hasClass('has-children')) { 118 $dropdownMenu.removeClass('show'); 119 } 120 e.stopPropagation(); 121 }); 122 123 // Botão de submenu 124 $dropdown.find('button.btn-dropchild').on('click', function(e) { 125 $(this).next('ul.dropdown-menu').toggle(); 126 e.stopPropagation(); 127 e.preventDefault(); 128 }); 129 }); 130 131 // Comportamento de estilo do menu 132 $(".dropdown-menu-item, .dropdown").each(function () { 133 const $this = $(this); 134 const $dropdownMenu = $this.children(".dropdown-menu"); 135 const $navLink = $this.children("a.active, a.has-children"); 136 137 $dropdownMenu.hover( 138 () => $navLink.addClass("blue-background"), 139 () => $navLink.removeClass("blue-background") 140 ); 141 }); 142 143 // --- Menu colapsável (submenus no painel mobile): desktop = hover, mobile = clique --- 144 var NAV_COLLAPSE_BREAKPOINT = 768; 145 var navCollapseCloseTimers = {}; 146 147 function isNavMobile() { 148 return window.innerWidth < NAV_COLLAPSE_BREAKPOINT || $('.responsive-nav-item-with-child').is(':visible'); 149 } 150 151 function setSubmenuOpen($trigger, open) { 152 var id = $trigger.attr('data-nav-target'); 153 if (!id) return; 154 var $target = $(id); 155 if (!$target.length || !$target.hasClass('responsive-dropdown-menu')) return; 156 157 if (open) { 158 $target.addClass('show'); 159 $trigger.attr('aria-expanded', 'true'); 160 } else { 161 $target.removeClass('show'); 162 $trigger.attr('aria-expanded', 'false'); 163 } 164 } 165 166 function clearCloseTimer(key) { 167 if (navCollapseCloseTimers[key]) { 168 clearTimeout(navCollapseCloseTimers[key]); 169 navCollapseCloseTimers[key] = null; 170 } 171 } 172 173 // Clique no toggle de submenu: sempre previne navegação (o <a> tem href mas não deve navegar). 174 // No mobile faz o toggle do submenu; no desktop o submenu já é controlado por hover. 175 $(document).on('click', '#navigationCollapse [data-nav-toggle="submenu"]', function (e) { 176 e.preventDefault(); 177 e.stopPropagation(); 178 179 // Lock global para evitar múltiplos cliques disparados pelo Lifford SPA 180 if (window.__dropdownClickLocked) { 181 return; 182 }
183 window.__dropdownClickLocked = true; 184 setTimeout(function() { window.__dropdownClickLocked = false; }, 600); 185 186 if (!isNavMobile()) return; 187 188 var $trigger = $(this); 189 var id = $trigger.attr('data-nav-target'); 190 if (!id) return; 191 var $target = $(id); 192 if (!$target.length) return; 193 194 // Verifica estado real do dropdown (classe show OU aria-expanded) 195 var hasShowClass = $target.hasClass('show'); 196 var isAriaExpanded = $trigger.attr('aria-expanded') === 'true'; 197 var isOpen = hasShowClass || isAriaExpanded; 198 199 var open = !isOpen; 200 setSubmenuOpen($trigger, open); 201 clearCloseTimer($target.attr('id')); 202 }); 203 204 // Desktop: hover abre ao entrar, fecha ao sair (delay 220ms) 205 $('#navigationCollapse').on('mouseenter', '.responsive-nav-item-with-child, .responsive-dropdown-menu-item.has-children', function () { 206 if (isNavMobile()) return; 207 var $li = $(this); 208 var $ul = $li.children('ul.responsive-dropdown-menu.collapse'); 209 var key = $ul.attr('id'); 210 if (key) clearCloseTimer(key); 211 $ul.addClass('show'); 212 $li.find('[data-nav-toggle="submenu"]').first().attr('aria-expanded', 'true'); 213 }); 214 215 $('#navigationCollapse').on('mouseenter', 'ul.responsive-dropdown-menu.collapse', function () { 216 if (isNavMobile()) return; 217 var $ul = $(this); 218 var $li = $ul.parent(); 219 var key = $ul.attr('id'); 220 if (key) clearCloseTimer(key); 221 $ul.addClass('show'); 222 $li.find('[data-nav-toggle="submenu"]').first().attr('aria-expanded', 'true'); 223 }); 224 225 $('#navigationCollapse').on('mouseleave', '.responsive-nav-item-with-child, .responsive-dropdown-menu-item.has-children', function () { 226 if (isNavMobile()) return; 227 var $li = $(this); 228 var $ul = $li.children('ul.responsive-dropdown-menu.collapse'); 229 var key = $ul.attr('id'); 230 if (key) clearCloseTimer(key); 231 navCollapseCloseTimers[key] = setTimeout(function () { 232 $ul.removeClass('show'); 233 $li.find('[data-nav-toggle="submenu"]').first().attr('aria-expanded', 'false'); 234 navCollapseCloseTimers[key] = null; 235 }, 220); 236 }); 237 238 $('#navigationCollapse').on('mouseleave', 'ul.responsive-dropdown-menu.collapse', function () { 239 if (isNavMobile()) return; 240 var $ul = $(this); 241 var $li = $ul.parent(); 242 var key = $ul.attr('id'); 243 if (key) clearCloseTimer(key); 244 navCollapseCloseTimers[key] = setTimeout(function () { 245 $ul.removeClass('show'); 246 $li.find('[data-nav-toggle="submenu"]').first().attr('aria-expanded', 'false'); 247 navCollapseCloseTimers[key] = null; 248 }, 220); 249 }); 250 }); 251 252 /* Disable SPA */ 253 Liferay.on("beforeNavigate", function (event) { 254 if ( 255 event.path.indexOf("control_panel") !== -1 || 256 (document.location.href.indexOf("control_panel") !== -1 && 257 event.path.indexOf("control_panel") === -1) 258 ) { 259 document.location.href = event.path; 260 } 261 Liferay.lastModifiedDate = null; 262 }); 263})(jQuery); 264 265 266/* POSICIONA MENUS DINAMICAMENTE */ 267Liferay.on('allPortletsReady', function() { 268 var menuToggleTimers = {}; 269 270 function positionDropdownMenus() { 271 document.querySelectorAll('.dropdown-menu-item > .dropdown-menu').forEach(function(submenu) { 272 if (submenu.offsetParent === null) return; 273 274 var item = submenu.parentElement; 275 var itemId = item.getAttribute('data-menu-id') || Math.random().toString(36).substring(2, 9); 276 item.setAttribute('data-menu-id', itemId); 277 278 if (menuToggleTimers[itemId]) clearTimeout(menuToggleTimers[itemId]); 279 280 menuToggleTimers[itemId] = setTimeout(function() { 281 var itemRect = item.getBoundingClientRect(); 282 var submenuWidth = submenu.offsetWidth; 283 var windowWidth = window.innerWidth; 284 285 if (itemRect.left + itemRect.width + submenuWidth + 20 > windowWidth) { 286 if (!submenu.classList.contains('dropdown-menu-right')) { 287 submenu.classList.add('dropdown-menu-right'); 288 } 289 } else { 290 if (submenu.classList.contains('dropdown-menu-right')) { 291 submenu.classList.remove('dropdown-menu-right'); 292 } 293 } 294 }, 50); 295 }); 296 } 297 298 function setupMenuEvents() { 299 document.querySelectorAll('.dropdown-menu-item').forEach(function(item) { 300 var hoverDelayTimer; 301 var leaveDelayTimer; 302 303 item.addEventListener('mouseenter', function() { 304 clearTimeout(leaveDelayTimer); 305 hoverDelayTimer = setTimeout(function() { 306 positionDropdownMenus(); 307 }, 100); 308 }); 309 310 item.addEventListener('mouseleave', function(e) { 311 clearTimeout(hoverDelayTimer); 312 313 var submenu = item.querySelector('.dropdown-menu'); 314 if (submenu && submenu.classList.contains('show')) { 315 leaveDelayTimer = setTimeout(function() { 316 if (!item.matches(':hover') && !submenu.matches(':hover')) { 317 submenu.classList.remove('show'); 318 } 319 }, 300); 320 } 321 }); 322 }); 323 324 document.querySelectorAll('.btn-dropchild').forEach(function(btn
324) { 325 btn.addEventListener('click', function() { 326 var item = btn.closest('.dropdown-menu-item'); 327 var submenu = item.querySelector('.dropdown-menu'); 328 329 if (submenu.classList.contains('show')) { 330 submenu.classList.remove('show'); 331 } else { 332 submenu.classList.add('show'); 333 setTimeout(positionDropdownMenus, 50); 334 } 335 }); 336 }); 337 } 338 339 setupMenuEvents(); 340 341 window.addEventListener('resize', positionDropdownMenus); 342 343 setTimeout(positionDropdownMenus, 500); 344 setInterval(positionDropdownMenus, 1000); 345}); 346 347/* REMOVE EMAIL PADRÃO DO PORTLET DE LOGIN */ 348document.addEventListener('DOMContentLoaded', function() { 349 var loginField = document.getElementById('_com_liferay_login_web_portlet_LoginPortlet_login'); 350 var defaultDomains = ['@liferay.com', '@df.gov.br']; 351 352 function shouldClearDefaultEmail(value) { 353 return defaultDomains.some(function(domain) { 354 return value.includes(domain); 355 }); 356 } 357 358 if (loginField) { 359 if (shouldClearDefaultEmail(loginField.value)) { 360 loginField.value = ''; 361 } 362 363 loginField.addEventListener('focus', function() { 364 if (shouldClearDefaultEmail(this.value)) { 365 this.value = ''; 366 } 367 }); 368 } 369});
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.