From d65e723f24cd409b5324e9f8e121bc01aef06017 Mon Sep 17 00:00:00 2001 From: matthew Date: Thu, 8 Feb 2007 22:08:19 +0000 Subject: Close email alert box if move mouse away. --- web/js.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'web/js.js') diff --git a/web/js.js b/web/js.js index 3c6848397..0cffd6ed4 100644 --- a/web/js.js +++ b/web/js.js @@ -39,18 +39,37 @@ YAHOO.util.Event.onContentReady('mapForm', function() { } }); +var timer; +function email_alert_close() { + YAHOO.util.Dom.setStyle('email_alert_box', 'display', 'none'); +} YAHOO.util.Event.onContentReady('email_alert', function() { YAHOO.util.Event.addListener(this, 'click', function(e) { YAHOO.util.Event.preventDefault(e); if (YAHOO.util.Dom.getStyle('email_alert_box', 'display') == 'block') { - YAHOO.util.Dom.setStyle('email_alert_box', 'display', 'none'); + email_alert_close(); } else { var pos = YAHOO.util.Dom.getXY(this); pos[0] -= 20; pos[1] += 20; YAHOO.util.Dom.setStyle('email_alert_box', 'display', 'block'); YAHOO.util.Dom.setXY('email_alert_box', pos); + document.getElementById('alert_email').focus(); } }); + YAHOO.util.Event.addListener(this, 'mouseout', function(e) { + timer = window.setTimeout(email_alert_close, 2000); + }); + YAHOO.util.Event.addListener(this, 'mouseover', function(e) { + window.clearTimeout(timer); + }); +}); +YAHOO.util.Event.onContentReady('email_alert_box', function() { + YAHOO.util.Event.addListener(this, 'mouseout', function(e) { + timer = window.setTimeout(email_alert_close, 2000); + }); + YAHOO.util.Event.addListener(this, 'mouseover', function(e) { + window.clearTimeout(timer); + }); }); // I love the global -- cgit v1.2.3