19,678
edits
(adding support for hovertable class) |
(implementing new hovergif class) |
||
| Line 142: | Line 142: | ||
addOnloadHook(initHoverTables); | addOnloadHook(initHoverTables); | ||
/** Hover GIFs ********************************************************* | |||
* | |||
* Description: Allows GIFs to only animate upon mouse-over. | |||
* | |||
* Maintainers: [[User:Iritscen]] | |||
*/ | |||
function swapImage(gifID, show_gif) | |||
{ | |||
var gif = document.getElementsByID(gifID); | |||
if (!gifID) | |||
return false; | |||
if (show_gif) | |||
gif.src = gif.src.replace('.jpg', '.gif'); | |||
else | |||
gif.src = gif.src.replace('.gif', '.jpg'); | |||
} | |||
function initHoverGIFs() | |||
{ | |||
var gifs = document.getElementsByClassName("hovergif"); | |||
if (!gifs) | |||
return false; | |||
for (var i = 0; i < gifs.length; i++) | |||
{ | |||
addHandler(gifs[i], "mouseover", new Function("evt", "swapImage(this.id, true);")); | |||
addHandler(gifs[i], "mouseout", new Function("evt", "swapImage(this.id, false);")); | |||
} | |||
} | |||
addOnloadHook(initHoverGIFs); | |||