Ir para o conteúdo

MediaWiki:Common.js: mudanças entre as edições

De Normas Regulamentadoras
Sem resumo de edição
Sem resumo de edição
Linha 14: Linha 14:
/* Tabela NR 04 Anexo 1 */
/* Tabela NR 04 Anexo 1 */
$(function() {
$(function() {
     // 1. Clique no Nível 1 abre Nível 2
     // Função genérica para alternar visibilidade e limpar descendentes
     $('.linha-nivel-1').on('click', function() {
     $('.linha-nivel-1, .linha-nivel-2, .linha-nivel-3').on('click', function(e) {
        $(this).nextUntil('.linha-nivel-1').filter('.linha-nivel-2').toggleClass('show');
    });
 
    // 2. Clique no Nível 2 abre Nível 3
    $('.linha-nivel-2').on('click', function(e) {
         e.stopPropagation();
         e.stopPropagation();
         $(this).nextUntil('.linha-nivel-2').filter('.linha-nivel-3').toggleClass('show');
          
    });
        var nivelAtual = parseInt($(this).attr('class').match(/linha-nivel-(\d)/)[1]);
 
        var proximoNivel = nivelAtual + 1;
    // 3. Clique no Nível 3 abre Nível 4
       
    $('.linha-nivel-3').on('click', function(e) {
        // Se a linha já estiver aberta, estamos fechando (recolhendo)
        e.stopPropagation();
        if ($(this).hasClass('aberto')) {
        $(this).nextUntil('.linha-nivel-3').filter('.linha-nivel-4').toggleClass('show');
            // Remove a classe 'aberto' desta linha
            $(this).removeClass('aberto');
           
            // Fecha todos os descendentes (recursivo)
            $(this).nextUntil('.linha-nivel-' + nivelAtual).removeClass('show aberto');
        } else {
            // Se estamos abrindo:
            $(this).addClass('aberto');
           
            // Mostra apenas os filhos imediatos (do próximo nível)
            $(this).nextUntil('.linha-nivel-' + nivelAtual).filter('.linha-nivel-' + proximoNivel).addClass('show');
        }
     });
     });
});
});

Edição das 21h57min de 14 de julho de 2026

/* Página Normas - Texto Principal  Lógica para Ativação de Notas Explicativas no texto de Norma/Anexo */
$(document).ready(function() {
    // Varre todas as notas sobrescritas que possuem conteúdo vindo do banco
    $('.item-nr .nota-sup').each(function() {
        var textoNota = $(this).text().trim();
        
        // Se a nota contiver texto (ex: [1]), transforma esse texto no Tooltip oficial
        if (textoNota && textoNota !== "[]") {
            $(this).attr('title', 'Nota Explicativa ' + textoNota);
        }
    });
});

/* Tabela NR 04 Anexo 1 */
$(function() {
    // Função genérica para alternar visibilidade e limpar descendentes
    $('.linha-nivel-1, .linha-nivel-2, .linha-nivel-3').on('click', function(e) {
        e.stopPropagation();
        
        var nivelAtual = parseInt($(this).attr('class').match(/linha-nivel-(\d)/)[1]);
        var proximoNivel = nivelAtual + 1;
        
        // Se a linha já estiver aberta, estamos fechando (recolhendo)
        if ($(this).hasClass('aberto')) {
            // Remove a classe 'aberto' desta linha
            $(this).removeClass('aberto');
            
            // Fecha todos os descendentes (recursivo)
            $(this).nextUntil('.linha-nivel-' + nivelAtual).removeClass('show aberto');
        } else {
            // Se estamos abrindo:
            $(this).addClass('aberto');
            
            // Mostra apenas os filhos imediatos (do próximo nível)
            $(this).nextUntil('.linha-nivel-' + nivelAtual).filter('.linha-nivel-' + proximoNivel).addClass('show');
        }
    });
});