Ativa o menu
Alternar menu de preferências
Alternar menu pessoal
Não autenticado(a)
Your IP address will be publicly visible if you make any edits.

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

Página de Interface do MediaWiki
Sem resumo de edição
Sem resumo de edição
 
(4 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 2: Linha 2:
   1. GOOGLE ANALYTICS 4 (GA4) - PRIORIDADE MÁXIMA
   1. GOOGLE ANALYTICS 4 (GA4) - PRIORIDADE MÁXIMA
   ======================================================= */
   ======================================================= */
(function () {
(function() {
  var gaId = 'G-EMV99DJ8V4';
    var gaId = 'G-EMV99DJ8V4';  


  // Carrega a biblioteca externa do Google
    // Carrega a biblioteca externa do Google
  var script = document.createElement('script');
    var script = document.createElement('script');
  script.async = true;
    script.async = true;
  script.src = 'https://www.googletagmanager.com/gtag/js?id=' + gaId;
    script.src = 'https://www.googletagmanager.com/gtag/js?id=' + gaId;
  document.head.appendChild(script);
    document.head.appendChild(script);


  // Inicializa o Gtag
    // Inicializa o Gtag
  window.dataLayer = window.dataLayer || [];
    window.dataLayer = window.dataLayer || [];
  function gtag() { dataLayer.push(arguments); }
    function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
    gtag('js', new Date());
  gtag('config', gaId);
    gtag('config', gaId);
})();
})();


Linha 35: Linha 35:
       button.type = 'button';
       button.type = 'button';
       button.ariaLabel = 'Copiar código';
       button.ariaLabel = 'Copiar código';
 
     
       button.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>';
       button.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>';


Linha 44: Linha 44:
           const originalHTML = button.innerHTML;
           const originalHTML = button.innerHTML;
           button.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>';
           button.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>';
 
         
           setTimeout(function () {
           setTimeout(function () {
             button.classList.remove('copied');
             button.classList.remove('copied');
Linha 72: Linha 72:
     });
     });
   });
   });
 
 
   observer.observe(document.body, { childList: true, subtree: true });
   observer.observe(document.body, { childList: true, subtree: true });
})();
})();
Linha 78: Linha 78:


/* =======================================================
/* =======================================================
   3. MENUS DO SIMULADOR ERP COM MEMÓRIA (CORRIGIDO)
   3. MENUS DO SIMULADOR ERP COM MEMÓRIA
   ======================================================= */
   ======================================================= */
$(function () {
$(function() {
  var STORAGE_KEY = 'erp_active_submenu';
    var STORAGE_KEY = 'erp_active_submenu';
  var STORAGE_PAGE = 'erp_current_page';
   
 
    // Salva o submenu ativo
  // Salva o submenu ativo E a página atual
    function saveActiveSubmenu(submenuId) {
  function saveActiveSubmenu(submenuId) {
        try {
    try {
            localStorage.setItem(STORAGE_KEY, submenuId);
      localStorage.setItem(STORAGE_KEY, submenuId);
        } catch(e) {
      localStorage.setItem(STORAGE_PAGE, window.location.pathname);
            // Silencioso
      console.log('✅ Salvou:', submenuId, 'na página:', window.location.pathname);
        }
    } catch (e) {
      console.log('❌ LocalStorage não disponível');
     }
     }
  }
   
 
    // Recupera o submenu salvo
  // Recupera o submenu apenas se estiver na mesma página
    function getActiveSubmenu() {
  function getActiveSubmenu() {
        try {
    try {
            return localStorage.getItem(STORAGE_KEY);
      var savedPage = localStorage.getItem(STORAGE_PAGE);
         } catch(e) {
      var currentPage = window.location.pathname;
            return null;
 
        }
      // Verifica se está na página de tutoriais (ou página que contém o menu)
      if (currentPage.indexOf('/Tutoriais') !== -1 ||
        currentPage.indexOf('/tutoriais') !== -1 ||
        savedPage === currentPage) {
        var submenu = localStorage.getItem(STORAGE_KEY);
         console.log('✅ Recuperou submenu:', submenu, 'Página atual:', currentPage);
        return submenu;
      }
 
      console.log('ℹ️ Não recuperou - páginas diferentes. Salva:', savedPage, 'Atual:', currentPage);
      return null;
    } catch (e) {
      return null;
     }
     }
  }
   
 
    // Limpa a memória
  // Limpa a memória
    function clearActiveSubmenu(reason) {
  function clearActiveSubmenu() {
        try {
    try {
            localStorage.removeItem(STORAGE_KEY);
      localStorage.removeItem(STORAGE_KEY);
        } catch(e) {
      localStorage.removeItem(STORAGE_PAGE);
            // Silencioso
      console.log('🗑️ Limpou memória do submenu');
        }
    } catch (e) {
      console.log('❌ Erro ao limpar localStorage');
     }
     }
  }
   
 
    // Abre um submenu específico
  // Abre um submenu específico
    function openSubmenu(submenuId) {
  function openSubmenu(submenuId) {
        $('.erp-submenu-overlay').hide();
    $('.erp-submenu-overlay').hide();
        $('.erp-menu-item').removeClass('active');
    $('.erp-menu-item').removeClass('active');
       
 
        var $submenu = $(submenuId);
    var $submenu = $(submenuId);
        var menuName = submenuId.replace('#submenu-', '');
    var menuName = submenuId.replace('#submenu-', '');
        var $menuItem = $('.erp-click-' + menuName);
    var $menuItem = $('.erp-click-' + menuName);
       
 
        if ($submenu.length && $menuItem.length) {
    if ($submenu.length && $menuItem.length) {
            $submenu.show();
      $submenu.show();
            $menuItem.addClass('active');
      $menuItem.addClass('active');
        }
 
      // FORÇA a cor azul via JavaScript
      forceBlueColor($menuItem);
 
      console.log('✅ Abriu submenu:', submenuId);
    } else {
      console.log('❌ Não encontrou submenu:', submenuId);
     }
     }
  }
   
 
    // Restaura o submenu ao carregar a página
  // Restaura o submenu ao carregar
    function restoreSubmenu() {
  function restoreSubmenu() {
        var currentPath = window.location.pathname;
    var savedSubmenu = getActiveSubmenu();
       
 
        // Se NÃO está em página de tutoriais, limpa a memória
    if (savedSubmenu) {
        if (currentPath.indexOf('/Tutoriais') === -1 && currentPath.indexOf('/tutoriais') === -1) {
      setTimeout(function () {
            clearActiveSubmenu('saiu da área de tutoriais');
        openSubmenu(savedSubmenu);
            return;
      }, 150);
        }
       
        var savedSubmenu = getActiveSubmenu();
       
        if (savedSubmenu) {
            setTimeout(function() {
                openSubmenu(savedSubmenu);
            }, 150);
        }
     }
     }
  }
   
    // Lógica de abertura dos submenus
    $('body').on('click', '[class*="erp-click-"]', function(e) {
        e.preventDefault();
        e.stopPropagation();


  // Lógica de abertura dos submenus
        var botao = $(this);
  $('body').on('click', '[class*="erp-click-"]', function (e) {
        var targetId = '';
    e.preventDefault();
    e.stopPropagation();


    var botao = $(this);
        if (botao.hasClass('erp-click-principal')) targetId = '#submenu-principal';
    var targetId = '';
        else if (botao.hasClass('erp-click-estoque')) targetId = '#submenu-estoque';
        else if (botao.hasClass('erp-click-financeiro')) targetId = '#submenu-financeiro';
        else if (botao.hasClass('erp-click-vendas')) targetId = '#submenu-vendas';
        else if (botao.hasClass('erp-click-compras')) targetId = '#submenu-compras';
        else if (botao.hasClass('erp-click-gerencial')) targetId = '#submenu-gerencial';
        else if (botao.hasClass('erp-click-pessoal')) targetId = '#submenu-pessoal';
        else if (botao.hasClass('erp-click-supermercado')) targetId = '#submenu-supermercado';
        else if (botao.hasClass('erp-click-ferramentas')) targetId = '#submenu-ferramentas';


    if (botao.hasClass('erp-click-principal')) targetId = '#submenu-principal';
        if (!targetId) return;
    else if (botao.hasClass('erp-click-estoque')) targetId = '#submenu-estoque';
    else if (botao.hasClass('erp-click-financeiro')) targetId = '#submenu-financeiro';
    else if (botao.hasClass('erp-click-vendas')) targetId = '#submenu-vendas';
    else if (botao.hasClass('erp-click-compras')) targetId = '#submenu-compras';
    else if (botao.hasClass('erp-click-gerencial')) targetId = '#submenu-gerencial';
    else if (botao.hasClass('erp-click-pessoal')) targetId = '#submenu-pessoal';
    else if (botao.hasClass('erp-click-supermercado')) targetId = '#submenu-supermercado';
    else if (botao.hasClass('erp-click-ferramentas')) targetId = '#submenu-ferramentas';


    if (!targetId) return;
        var submenu = $(targetId);


    var submenu = $(targetId);
        if (submenu.is(':visible')) {
            submenu.hide();
            botao.removeClass('active');
        } else {
            $('.erp-submenu-overlay').hide();
            $('.erp-menu-item').removeClass('active');
            submenu.show();
            botao.addClass('active');
            saveActiveSubmenu(targetId);
        }
    });


     if (submenu.is(':visible')) {
     // Fechar ao clicar fora (mas NÃO limpar memória se clicar em link)
      submenu.hide();
    $('body').on('click', '.erp-content-stage, .erp-bg-logo', function(e) {
      botao.removeClass('active');
        // Se clicou em um link, NÃO limpa a memória
      clearActiveSubmenu();
        if ($(e.target).is('a') || $(e.target).closest('a').length) {
    } else {
            return;
      $('.erp-submenu-overlay').hide();
        }
      $('.erp-menu-item').removeClass('active');
       
      submenu.show();
        // Se clicou na área vazia, fecha e limpa
      botao.addClass('active');
        $('.erp-submenu-overlay').hide();
 
        $('.erp-menu-item').removeClass('active');
      // Salva na memória
        clearActiveSubmenu('clicou fora do menu');
      saveActiveSubmenu(targetId);
    });
   
    // Restaura o submenu ao carregar
    restoreSubmenu();
   
    // Limpa após 30 minutos de inatividade
    var inactivityTimer;
    function resetInactivityTimer() {
        clearTimeout(inactivityTimer);
        inactivityTimer = setTimeout(function() {
            clearActiveSubmenu('30 minutos de inatividade');
        }, 30 * 60 * 1000);
     }
     }
  });
   
    $(document).on('mousemove keypress click', resetInactivityTimer);
    resetInactivityTimer();
});


  // Fechar ao clicar fora
  $('body').on('click', '.erp-content-stage, .erp-bg-logo', function () {
    $('.erp-submenu-overlay').hide();
    $('.erp-menu-item').removeClass('active');
    clearActiveSubmenu();
  });
  // NÃO limpa quando clica em links internos
  // Removido: $('body').on('click', '.sys-col-item a', function() { ... });
  // Restaura o submenu
  restoreSubmenu();
  // Limpa após 30 minutos de inatividade
  var inactivityTimer;
  function resetInactivityTimer() {
    clearTimeout(inactivityTimer);
    inactivityTimer = setTimeout(function () {
      clearActiveSubmenu();
    }, 30 * 60 * 1000);
  }
  $(document).on('mousemove keypress click', resetInactivityTimer);
  resetInactivityTimer();
});


/* =======================================================
/* =======================================================
   4. FIX: CLICK EM QUALQUER ÁREA DO CARD REDIRECIONA
   4. FIX: CLICK EM QUALQUER ÁREA DO CARD REDIRECIONA
   ======================================================= */
   ======================================================= */
$(function () {
$(function() {
  $('body').on('click', '.sys-col-item', function (e) {
    $('body').on('click', '.sys-col-item', function(e) {
    if ($(e.target).is('a') || $(e.target).closest('a').length) {
        if ($(e.target).is('a') || $(e.target).closest('a').length) {
      return true;
            return true;
    }
        }
 
       
    var link = $(this).find('a').first();
        var link = $(this).find('a').first();
    if (link.length) {
        if (link.length) {
      e.preventDefault();
            e.preventDefault();
      e.stopPropagation();
            e.stopPropagation();
      window.location.href = link.attr('href');
            window.location.href = link.attr('href');
    }
        }
  });
    });
});
});

Edição atual tal como às 20h39min de 13 de dezembro de 2025

/* =======================================================
   1. GOOGLE ANALYTICS 4 (GA4) - PRIORIDADE MÁXIMA
   ======================================================= */
(function() {
    var gaId = 'G-EMV99DJ8V4'; 

    // Carrega a biblioteca externa do Google
    var script = document.createElement('script');
    script.async = true;
    script.src = 'https://www.googletagmanager.com/gtag/js?id=' + gaId;
    document.head.appendChild(script);

    // Inicializa o Gtag
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', gaId);
})();


/* =======================================================
   2. BOTÃO "COPIAR" PARA BLOCOS DE CÓDIGO
   ======================================================= */
(function () {
  'use strict';

  function addCopyButtons() {
    const codeBlocks = document.querySelectorAll('pre, .mw-highlight, .mw-code');

    codeBlocks.forEach(function (block) {
      if (block.querySelector('.mw-copy-btn')) return;

      const button = document.createElement('button');
      button.className = 'mw-copy-btn';
      button.type = 'button';
      button.ariaLabel = 'Copiar código';
      
      button.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>';

      button.addEventListener('click', function () {
        const code = block.innerText || block.textContent;
        navigator.clipboard.writeText(code).then(function () {
          button.classList.add('copied');
          const originalHTML = button.innerHTML;
          button.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>';
          
          setTimeout(function () {
            button.classList.remove('copied');
            button.innerHTML = originalHTML;
          }, 2000);
        });
      });

      if (getComputedStyle(block).position === 'static') {
        block.style.position = 'relative';
      }
      block.appendChild(button);
    });
  }

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', addCopyButtons);
  } else {
    addCopyButtons();
  }

  const observer = new MutationObserver(function (mutations) {
    mutations.forEach(function (mutation) {
      if (mutation.addedNodes.length) {
        addCopyButtons();
      }
    });
  });
  
  observer.observe(document.body, { childList: true, subtree: true });
})();


/* =======================================================
   3. MENUS DO SIMULADOR ERP COM MEMÓRIA
   ======================================================= */
$(function() {
    var STORAGE_KEY = 'erp_active_submenu';
    
    // Salva o submenu ativo
    function saveActiveSubmenu(submenuId) {
        try {
            localStorage.setItem(STORAGE_KEY, submenuId);
        } catch(e) {
            // Silencioso
        }
    }
    
    // Recupera o submenu salvo
    function getActiveSubmenu() {
        try {
            return localStorage.getItem(STORAGE_KEY);
        } catch(e) {
            return null;
        }
    }
    
    // Limpa a memória
    function clearActiveSubmenu(reason) {
        try {
            localStorage.removeItem(STORAGE_KEY);
        } catch(e) {
            // Silencioso
        }
    }
    
    // Abre um submenu específico
    function openSubmenu(submenuId) {
        $('.erp-submenu-overlay').hide();
        $('.erp-menu-item').removeClass('active');
        
        var $submenu = $(submenuId);
        var menuName = submenuId.replace('#submenu-', '');
        var $menuItem = $('.erp-click-' + menuName);
        
        if ($submenu.length && $menuItem.length) {
            $submenu.show();
            $menuItem.addClass('active');
        }
    }
    
    // Restaura o submenu ao carregar a página
    function restoreSubmenu() {
        var currentPath = window.location.pathname;
        
        // Se NÃO está em página de tutoriais, limpa a memória
        if (currentPath.indexOf('/Tutoriais') === -1 && currentPath.indexOf('/tutoriais') === -1) {
            clearActiveSubmenu('saiu da área de tutoriais');
            return;
        }
        
        var savedSubmenu = getActiveSubmenu();
        
        if (savedSubmenu) {
            setTimeout(function() {
                openSubmenu(savedSubmenu);
            }, 150);
        }
    }
    
    // Lógica de abertura dos submenus
    $('body').on('click', '[class*="erp-click-"]', function(e) {
        e.preventDefault();
        e.stopPropagation();

        var botao = $(this);
        var targetId = '';

        if (botao.hasClass('erp-click-principal')) targetId = '#submenu-principal';
        else if (botao.hasClass('erp-click-estoque')) targetId = '#submenu-estoque';
        else if (botao.hasClass('erp-click-financeiro')) targetId = '#submenu-financeiro';
        else if (botao.hasClass('erp-click-vendas')) targetId = '#submenu-vendas';
        else if (botao.hasClass('erp-click-compras')) targetId = '#submenu-compras';
        else if (botao.hasClass('erp-click-gerencial')) targetId = '#submenu-gerencial';
        else if (botao.hasClass('erp-click-pessoal')) targetId = '#submenu-pessoal';
        else if (botao.hasClass('erp-click-supermercado')) targetId = '#submenu-supermercado';
        else if (botao.hasClass('erp-click-ferramentas')) targetId = '#submenu-ferramentas';

        if (!targetId) return;

        var submenu = $(targetId);

        if (submenu.is(':visible')) {
            submenu.hide();
            botao.removeClass('active');
        } else {
            $('.erp-submenu-overlay').hide();
            $('.erp-menu-item').removeClass('active');
            submenu.show();
            botao.addClass('active');
            saveActiveSubmenu(targetId);
        }
    });

    // Fechar ao clicar fora (mas NÃO limpar memória se clicar em link)
    $('body').on('click', '.erp-content-stage, .erp-bg-logo', function(e) {
        // Se clicou em um link, NÃO limpa a memória
        if ($(e.target).is('a') || $(e.target).closest('a').length) {
            return;
        }
        
        // Se clicou na área vazia, fecha e limpa
        $('.erp-submenu-overlay').hide();
        $('.erp-menu-item').removeClass('active');
        clearActiveSubmenu('clicou fora do menu');
    });
    
    // Restaura o submenu ao carregar
    restoreSubmenu();
    
    // Limpa após 30 minutos de inatividade
    var inactivityTimer;
    function resetInactivityTimer() {
        clearTimeout(inactivityTimer);
        inactivityTimer = setTimeout(function() {
            clearActiveSubmenu('30 minutos de inatividade');
        }, 30 * 60 * 1000);
    }
    
    $(document).on('mousemove keypress click', resetInactivityTimer);
    resetInactivityTimer();
});


/* =======================================================
   4. FIX: CLICK EM QUALQUER ÁREA DO CARD REDIRECIONA
   ======================================================= */
$(function() {
    $('body').on('click', '.sys-col-item', function(e) {
        if ($(e.target).is('a') || $(e.target).closest('a').length) {
            return true;
        }
        
        var link = $(this).find('a').first();
        if (link.length) {
            e.preventDefault();
            e.stopPropagation();
            window.location.href = link.attr('href');
        }
    });
});