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

De Wiki@DCOM
Ir para navegação Ir para pesquisar
mSem resumo de edição
mSem resumo de edição
Linha 9: Linha 9:
       window.scrollTo( 0, $( this ).offset().top );
       window.scrollTo( 0, $( this ).offset().top );
       return false;  
       return false;  
    } );
  }
  function abrirAbaNome() {
    var hash = decodeURIComponent(location.hash.slice( 1 )).replace( /_/g, ' ' ).trim();
    $( '.tabs-tabbox .tabs-label:contains(' + hash + ')' ).each( function () {
      if ( this.innerHTML.trim() !== hash ) {
      return true;
    }
    this.click();
    window.scrollTo( 0, $( this ).offset().top );
    return false;
     } );
     } );
   }  
   }  


   // Chama a função abrirAba quando o documento estiver pronto
   // Chama a função abrirAba quando o documento estiver pronto
  $(document).ready(abrirAbaNome);
   $(document).ready(abrirAba);
   $(document).ready(abrirAba);


   // Chama a função abrirAba quando o hash da URL mudar
   // Chama a função abrirAba quando o hash da URL mudar
  $(window).on('hashchange', abrirAbaNome);
   $(window).on('hashchange', abrirAba);
   $(window).on('hashchange', abrirAba);



Edição das 00h59min de 4 de fevereiro de 2025

jQuery( function ( $ ) {

  function abrirAba() {
    var aba_escolhida = location.hash.slice(1).trim().split('/');
    var aba = aba_escolhida[0];
    var posicao = aba_escolhida[1];
      $( '.tabs-tabbox[id=' + aba + '] .tabs-label[data-tabpos=' + posicao + ']' ).each( function () {
      this.click(); 
      window.scrollTo( 0, $( this ).offset().top );
      return false; 
    } );
  } 

  function abrirAbaNome() {
    var hash = decodeURIComponent(location.hash.slice( 1 )).replace( /_/g, ' ' ).trim();
    $( '.tabs-tabbox .tabs-label:contains(' + hash + ')' ).each( function () {
      if ( this.innerHTML.trim() !== hash ) {
      return true; 
    }
    this.click(); 
    window.scrollTo( 0, $( this ).offset().top );
    return false; 
    } );
  } 

  // Chama a função abrirAba quando o documento estiver pronto
  $(document).ready(abrirAbaNome);
  $(document).ready(abrirAba);

  // Chama a função abrirAba quando o hash da URL mudar
  $(window).on('hashchange', abrirAbaNome);
  $(window).on('hashchange', abrirAba);

} );

$(document).ready(function() {

  $( '.tabs-tabbox .tabs-label' ).on('click', function () {
    var aba = $(this).closest("div").prop("id");
    var posicao = $(this).attr("data-tabpos");
    var hash = aba + '/' + posicao;
    history.replaceState(null, null, document.location.pathname + '#' + hash)
  });

  /* Fecha o box "Relacionados" */
  $('#botao-fechar').on('click', function() {
    $('.relacionados').hide();
  });
  
  /* Obtém os dados da referência no fim da página e exibe como pop-up ao passar o mouse sobre o seu número*/
  $('.reference').on('mouseover', function(e) {
    var referencia_id = $(this).children().eq(0).attr('href').substring(1);
    var referencia_nome = $('#' + referencia_id);
    var referencia_conteudo = referencia_nome.find('.reference-text').html();
  
    var topo     = ($(this).offset().top  - 140) + "px";
    var esquerda = ($(this).offset().left - 115) + "px"; 
   
    $('#referencia_tip').html(referencia_conteudo);
    $('#referencia_tip').css({
      top: topo,
      left: esquerda  
    });
    $('#referencia_tip').hide().dequeue();
    $('#referencia_tip').show();
  });

  /* Oculta o pop-up da referência ao tirar o mouse do número*/
  $('.reference').on('mouseout', function(e) {
    $('#referencia_tip').delay(1000).hide(1);
  });

  /* Mantém o pop-up aberto enquanto estiver com o mouse*/
  $('#referencia_tip').on('mouseover', function(e) {
    $('#referencia_tip').hide().dequeue();
    $('#referencia_tip').show();
  });

  /* Oculta o pop-up da referência ao tirar o mouse do pop-up*/
  $('#referencia_tip').on('mouseout', function(e) {
    $('#referencia_tip').hide();
  });

  /* Exibe texto do logo DCOM e altera posição índice ao rolar tela*/
  $.fn.isInViewport = function() {
    var elementTop = $(this).offset().top;
    var elementBottom = elementTop + $(this).outerHeight();
    var viewportTop = $(window).scrollTop();
    var viewportBottom = viewportTop + $(window).height();
    return elementBottom > viewportTop && elementTop < viewportBottom;
  };

  $(window).on('ready resize load scroll', function() {
    if ($('#mw-head').isInViewport()) {
      $('.toc').css({'top': '55px'});
      $('.mw-wiki-logo').css({'opacity': '0'});
    } else {
      $('.toc').css({'top': '10px'});
      $('.mw-wiki-logo').css({'opacity': '1'});
    }
  }); 

});