MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
Gorgonzola (talk | contribs) mNo edit summary |
Gorgonzola (talk | contribs) Javascript for Template:Icon tooltips (shows the image caption in a tooltip). |
||
| Line 10: | Line 10: | ||
$(this).children('.spoilers-show').show(); | $(this).children('.spoilers-show').show(); | ||
$(this).children('.spoilers-hide').hide(); | $(this).children('.spoilers-hide').hide(); | ||
}); | |||
// Gorgonzola: [[Template:Icon]] tooltips | |||
var elItemTT; | |||
function ggItemTT(bDisp, sTitle) { | |||
if (bDisp && !elItemTT) { | |||
elItemTT = $('<div class="gg-icon-tt"></p>').appendTo('body'); | |||
} | |||
if (bDisp) { | |||
elItemTT.text(sTitle).show(); | |||
} else { | |||
elItemTT.hide(); | |||
} | |||
} | |||
$("body").on("mouseover mouseout mousemove", ".js-icon-tt", function(ev) { | |||
ev.preventDefault(); | |||
if (ev.type !== "mousemove") { | |||
var sTitle = $(this).parent("a").attr("title"); | |||
ggItemTT(ev.type == "mouseover", sTitle); | |||
} | |||
elItemTT.css({ top: ev.pageY -24 , left: ev.pageX +5 }); | |||
}); | }); | ||
Latest revision as of 21:19, 29 October 2014
/* Any JavaScript here will be loaded for all users on every page load. */
// Gorgonzola: Used by [[Template:Spoilers]] (reusing classes from <spoiler> extension)
$('.spoilers-button').toggle(function() {
$(this).parents('.spoilers').find('.spoilers-body').show();
$(this).children('.spoilers-show').hide();
$(this).children('.spoilers-hide').show();
}, function() {
$(this).parents('.spoilers').find('.spoilers-body').hide();
$(this).children('.spoilers-show').show();
$(this).children('.spoilers-hide').hide();
});
// Gorgonzola: [[Template:Icon]] tooltips
var elItemTT;
function ggItemTT(bDisp, sTitle) {
if (bDisp && !elItemTT) {
elItemTT = $('<div class="gg-icon-tt"></p>').appendTo('body');
}
if (bDisp) {
elItemTT.text(sTitle).show();
} else {
elItemTT.hide();
}
}
$("body").on("mouseover mouseout mousemove", ".js-icon-tt", function(ev) {
ev.preventDefault();
if (ev.type !== "mousemove") {
var sTitle = $(this).parent("a").attr("title");
ggItemTT(ev.type == "mouseover", sTitle);
}
elItemTT.css({ top: ev.pageY -24 , left: ev.pageX +5 });
});