MediaWiki:Common.js: mudanças entre as edições
Ir para navegação
Ir para pesquisar
Sem resumo de edição |
Sem resumo de edição |
||
| Linha 5: | Linha 5: | ||
var tooltip = $('<div id="tooltip" class="tooltip"></div>').appendTo("body"); | var tooltip = $('<div id="tooltip" class="tooltip"></div>').appendTo("body"); | ||
$("body").on("mouseenter", "map area, .imagemap a", function ( | // Hover desktop | ||
$("body").on("mouseenter", "map area, .imagemap a", function () { | |||
var $el = $(this); | var $el = $(this); | ||
var text = $el.attr("title") || $el.data("tooltip"); | var text = $el.attr("title") || $el.data("tooltip"); | ||
if (text) { | if (text) { | ||
if (!$el.data("tooltip")) { | if (!$el.data("tooltip")) { | ||
$el.data("tooltip", text); | $el.data("tooltip", text); | ||
$el.removeAttr("title"); | $el.removeAttr("title"); | ||
} | } | ||
tooltip.text(text).show(); | tooltip.text(text).show(); | ||
} | } | ||
| Linha 32: | Linha 29: | ||
tooltip.hide(); | tooltip.hide(); | ||
}); | }); | ||
// | // Touch / clique | ||
$( | $("body").on("click", "map area, .imagemap a", function (e) { | ||
var $el = $(this); | |||
var text = $( | var text = $el.data("tooltip"); | ||
var href = $el.attr("href"); | |||
if (text) { | if (text) { | ||
// Mostra tooltip no mobile | |||
tooltip.text(text).show(); | |||
// Se NÃO tem link (href vazio ou "#"), evita highlight azul | |||
if (!href || href === "#") { | |||
e.preventDefault(); | |||
e.stopPropagation(); | |||
return false; | |||
} | |||
// Se tiver link -> segue fluxo normal (redireciona) | |||
// Não fazemos preventDefault | |||
} | } | ||
}); | }); | ||
}); | |||
// Carregar o script externo do chatbot | // Carregar o script externo do chatbot | ||
Edição atual tal como às 11h55min de 27 de setembro de 2025
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */
// Tooltip customizado para áreas do <imagemap>
mw.loader.using(["jquery"], function () {
var tooltip = $('<div id="tooltip" class="tooltip"></div>').appendTo("body");
// Hover desktop
$("body").on("mouseenter", "map area, .imagemap a", function () {
var $el = $(this);
var text = $el.attr("title") || $el.data("tooltip");
if (text) {
if (!$el.data("tooltip")) {
$el.data("tooltip", text);
$el.removeAttr("title");
}
tooltip.text(text).show();
}
});
$("body").on("mousemove", "map area, .imagemap a", function (e) {
tooltip.css({
left: e.pageX + 15 + "px",
top: e.pageY + 15 + "px",
});
});
$("body").on("mouseleave", "map area, .imagemap a", function () {
tooltip.hide();
});
// Touch / clique
$("body").on("click", "map area, .imagemap a", function (e) {
var $el = $(this);
var text = $el.data("tooltip");
var href = $el.attr("href");
if (text) {
// Mostra tooltip no mobile
tooltip.text(text).show();
// Se NÃO tem link (href vazio ou "#"), evita highlight azul
if (!href || href === "#") {
e.preventDefault();
e.stopPropagation();
return false;
}
// Se tiver link -> segue fluxo normal (redireciona)
// Não fazemos preventDefault
}
});
});
// Carregar o script externo do chatbot
function decodeChatBot() {
return atob("Q2hhdEJvdA==");
}
// Chamar a função corretamente para obter a string antes de concatenar
mw.loader.load(
"/v?title=MediaWiki:" +
decodeChatBot() +
".js&action=raw&ctype=text/javascript"
);