The title is a little vague, but I can't explain it in the character limit.
I'm creating a little splash screen with dialogues that appear as you hover over certain triggering links. Two of these contain forms (log-in prompt and a registration form). At present, if you hover over either the link or the dialogues themselves they remain at 100% opacity, and on mouseout they fade away. I've been trying to prevent the mouseout fade if a form input is focused, but keep it if no input is focused.
Since there is no possibility of doing something like
var input = $(input);
if (input.is(':focused'){ //do something };
the code I'm currently using doesn't really work the way I'd like:
// Fade the login box.
$(document).ready(function() {
var hide = false;
var formfocus = false;
// If the link or the dialogue is hovered
$(".log1, .login").hover(function(){
//Clear the hide timeout
if (hide) clearTimeout(hide);
// Fade out the other dialogues
$(".register, .about").fadeOut(40);
// Fade in the login dialogue
$(".login").fadeIn();
}, function() {
// If an input gains focus, set the variable to true
$('input').focus(function(){
if (hide) clearTimeout(hide);
var formfocus = true;
});
// If an input loses focus, set the variable to false
$('input').blur(function(){
var formfocus = false;
});
// Self explainatory
if (formfocus==false){
hide = setTimeout(function() {$(".login").fadeOut();}, 400);
}
});
});
Despite the above making logical sense (to me at least), it does not work as I expected it to. If anyone has any idea how I could implement this, I'd love to hear it.
Thanks, Brendan.