MediaWiki:Common.js: mudanças entre as edições
Ir para navegação
Ir para pesquisar
m (Desfeita a edição 9013 de Fabio.frozza (Discussão)) Etiqueta: Desfazer |
m (Desfeita a edição 9012 de Fabio.frozza (Discussão)) Etiqueta: Desfazer |
||
| Linha 2: | Linha 2: | ||
function abrirOculto(elemento) { | function abrirOculto(elemento) { | ||
elemento.parents('.oculto-conteudo').removeClass('mw-collapsed'); | |||
elemento.parents('.oculto-conteudo').css('display', 'block'); | |||
}; | }; | ||
| Linha 24: | Linha 21: | ||
}); | }); | ||
if (abas_id === '') { | |||
'.tabs-tabbox:has(input[name=tabs-' + abas_num + ']) .tabs-label | var aba = $('.tabs-tabbox:has(input[name=tabs-' + abas_num + ']) .tabs-label:contains(' + aba_nome + ')') | ||
'.tabs-tabbox[id=' + abas_id + '] .tabs-label | } else { | ||
var aba = $('.tabs-tabbox[id=' + abas_id + '] .tabs-label:contains(' + aba_nome + ')') | |||
}; | |||
aba.each(function () { | aba.each(function () { | ||
abrirOculto($(this)); | abrirOculto($(this)); | ||
this.click(); | this.click(); | ||
window.scrollTo(0, $(this).offset().top | window.scrollTo(0, $(this).offset().top); | ||
}); | }); | ||
| Linha 38: | Linha 36: | ||
if ($(this).parents('.oculto-conteudo')) { | if ($(this).parents('.oculto-conteudo')) { | ||
abrirOculto($(this)); | abrirOculto($(this)); | ||
window.scrollTo( | window.scrollTo(0, $(this).offset().top); | ||
} | }; | ||
$(this).parents('.tabs-container').siblings('[data-tabpos=' + | if ($(this).parents('.tabs-content')) { | ||
window.scrollTo( | var aba = $(this).parents('.tabs-content').attr('class').split('-')[3]; | ||
$(this).parents('.tabs-container').siblings('[data-tabpos=' + aba + ']').click(); | |||
window.scrollTo(0, $(this).offset().top); | |||
}; | }; | ||
}); | }); | ||
| Linha 52: | Linha 52: | ||
// 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', abrirAba); | $(window).on('hashchange', abrirAba); | ||
}); | }); | ||
$(document).ready(function() { | $(document).ready(function() { | ||
| Linha 118: | Linha 120: | ||
/* Confere se o ìndice e o box Relacionados estão ocultos e muda a margem direita*/ | /* Confere se o ìndice e o box Relacionados estão ocultos e muda a margem direita*/ | ||
function checarTOCeRelacionados() { | function checarTOCeRelacionados() { | ||
if ($('#toc').is(':hidden') || $('.toc').length == 0) { | |||
var toc_oculto = true; | |||
} else { | |||
if ( | var toc_oculto = false; | ||
$('.mw-body | }; | ||
if ($('.relacionados').is(':hidden') || $('.relacionados').length == 0) { | |||
var relacionados_oculto = true; | |||
} else { | |||
var relacionados_oculto = false; | |||
}; | |||
if (toc_oculto && relacionados_oculto) { | |||
$('.mw-body').css({'margin-right': '1em'}); | |||
$('#p-personal').css({'margin-right': '1em'}); | |||
$('#right-navigation').css({'margin-right': '1em'}); | |||
}; | }; | ||
}; | }; | ||
| Linha 128: | Linha 139: | ||
/* Exibe texto do logo DCOM e altera posição índice ao rolar tela*/ | /* Exibe texto do logo DCOM e altera posição índice ao rolar tela*/ | ||
$.fn.isInViewport = function() { | $.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; | return elementBottom > viewportTop && elementTop < viewportBottom; | ||
}; | }; | ||
| Linha 138: | Linha 148: | ||
$(window).on('ready resize load scroll', function() { | $(window).on('ready resize load scroll', function() { | ||
if ($('#mw-head').isInViewport()) { | if ($('#mw-head').isInViewport()) { | ||
$('.toc').css({'top': '55px'}); | |||
$('.mw-wiki-logo').css({'opacity': '0'}); | |||
} else { | } else { | ||
$('.toc').css({'top': '10px'}); | |||
$('.mw-wiki-logo').css({'opacity': '1'}); | |||
}; | }; | ||
}); | }); | ||
checarTOCeRelacionados(); | checarTOCeRelacionados(); | ||
}); | }); | ||
Edição das 00h41min de 8 de fevereiro de 2025
jQuery(function ($) {
function abrirOculto(elemento) {
elemento.parents('.oculto-conteudo').removeClass('mw-collapsed');
elemento.parents('.oculto-conteudo').css('display', 'block');
};
function abrirAba() {
var aba_escolhida = location.hash.slice(1).trim().split('/');
abas_id = '';
abas_num = '';
aba_nome = '';
$.each(aba_escolhida, function () {
if (this.indexOf('abas_id=') === 0) {
abas_id = this.split('=')[1];
} else if (this.indexOf('abas_num=') === 0) {
abas_num = this.split('=')[1];
} else if (this.indexOf('aba_nome=') === 0) {
aba_nome = decodeURIComponent(this.split('=')[1]).replace(/_/g, ' ');
}
});
if (abas_id === '') {
var aba = $('.tabs-tabbox:has(input[name=tabs-' + abas_num + ']) .tabs-label:contains(' + aba_nome + ')')
} else {
var aba = $('.tabs-tabbox[id=' + abas_id + '] .tabs-label:contains(' + aba_nome + ')')
};
aba.each(function () {
abrirOculto($(this));
this.click();
window.scrollTo(0, $(this).offset().top);
});
$(':target').each(function () {
if ($(this).parents('.oculto-conteudo')) {
abrirOculto($(this));
window.scrollTo(0, $(this).offset().top);
};
if ($(this).parents('.tabs-content')) {
var aba = $(this).parents('.tabs-content').attr('class').split('-')[3];
$(this).parents('.tabs-container').siblings('[data-tabpos=' + aba + ']').click();
window.scrollTo(0, $(this).offset().top);
};
});
};
// Chama a função abrirAba quando o documento estiver pronto
$(document).ready(abrirAba);
// Chama a função abrirAba quando o hash da URL mudar
$(window).on('hashchange', abrirAba);
});
$(document).ready(function() {
$('.tabs-tabbox .tabs-label').on('click', function () {
var abas_id = $(this).closest("div").prop("id");
var abas_num = $(this).attr("for").split('-')[2];
var aba_nome = $(this).text();
if (abas_id === '') {
var hash = 'abas_num=' + abas_num + '/aba_nome=' + aba_nome;
} else {
var hash = 'abas_id=' + abas_id + '/abas_num=' + abas_num + '/aba_nome=' + aba_nome;
}
history.replaceState(null, null, document.location.pathname + '#' + hash)
});
/* Fecha o box "Relacionados" */
$('#botao-fechar').on('click', function() {
$('.relacionados').hide();
checarTOCeRelacionados();
});
/* Oculta o Índice totalmente */
$('input#toctogglecheckbox.toctogglecheckbox').on('click', function() {
if ($('.toc ul').is(":hidden")) {
$('.toc').hide();
};
checarTOCeRelacionados();
} );
/* 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();
});
/* Confere se o ìndice e o box Relacionados estão ocultos e muda a margem direita*/
function checarTOCeRelacionados() {
if ($('#toc').is(':hidden') || $('.toc').length == 0) {
var toc_oculto = true;
} else {
var toc_oculto = false;
};
if ($('.relacionados').is(':hidden') || $('.relacionados').length == 0) {
var relacionados_oculto = true;
} else {
var relacionados_oculto = false;
};
if (toc_oculto && relacionados_oculto) {
$('.mw-body').css({'margin-right': '1em'});
$('#p-personal').css({'margin-right': '1em'});
$('#right-navigation').css({'margin-right': '1em'});
};
};
/* 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'});
};
});
checarTOCeRelacionados();
});