Skip to content

Instantly share code, notes, and snippets.

@Bellfalasch
Created February 17, 2014 12:03
Show Gist options
  • Save Bellfalasch/9049389 to your computer and use it in GitHub Desktop.
Save Bellfalasch/9049389 to your computer and use it in GitHub Desktop.
A small preview snippet to hide/show some html on mouseover - with a timeout!
// Function that RutineBiblioteket uses to create small popups/previews for Rutine ingresser.
// Called when Ajax-request for menu filtered listing of Rutiner is done.
function ingresspopup() {
var timer;
var denna;
$("#rutine-list td > a.popup").hover( function() {
denna = $(this);
// We need a timer to show a card first after X milliseconds, to annoying if it pops up instantly.
if (timer) {
clearTimeout(timer);
timer = null;
}
timer = setTimeout( function() {
// Hide all visible cards first
$("#rutine-list").find(".ingress").hide();
$(denna).parent().find(".ingress").show();
}, 350);
}, function() {
// Reset the timer if we leave the link (leaving the link indicates you don't want the popup anyway)
if (timer) {
clearTimeout(timer);
timer = null;
}
});
$("body").click( function() {
$("#rutine-list .ingress").hide(); // fadeOut
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment