From 8f348054e218bdb778bb8d3cffbc6dbf342c7e8e Mon Sep 17 00:00:00 2001 From: anekos Date: Mon, 1 Dec 2008 03:03:49 +0000 Subject: Fix event listeners git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@25510 d0d07461-0603-4401-acd4-de1884942a52 --- gvimail.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'gvimail.js') diff --git a/gvimail.js b/gvimail.js index dceb166..49a8826 100644 --- a/gvimail.js +++ b/gvimail.js @@ -54,13 +54,7 @@ GViMail.getMainCanvas().contentWindow.focus(); }, /// On TabSelect (if Gmail Tab), we will give focus to the main canvas. - isGmail:function(uri, even) - { - if (/^https?:\/\/mail\.google\.com\//.test(uri)) - { - window.setTimeout(function(){GViMail.focusMainFrame();}, 100); - } - }, + get isGmail () (/^https?:\/\/mail\.google\.com\//.test(buffer.URL)), /// when you type some key to make an action, habitually, the main canvas looses focus. /// we will add an EventListener on keypress to avoid this. preventLooseFocus:function() @@ -155,10 +149,13 @@ mappings.addUserMap(GViMail.modes, ["zf"], "Focus main frame", function () { GViMail.focusMainFrame(); }); getBrowser().mTabBox.addEventListener('TabSelect', function(event){ - GViMail.isGmail(this.parentNode.currentURI.spec, event); + if (GViMail.isGmail) + window.setTimeout(function(){GViMail.focusMainFrame();}, 100); }, false); -window.addEventListener('keypress', GViMail.preventLooseFocus, true); - +window.addEventListener('keypress', function () { + if (GViMail.isGmail) + GViMail.preventLooseFocus(); +}, true); if (use_gvimail_css && (typeof liberator.globalVariables.styles == 'undefined' || liberator.globalVariables.styles == '')) { liberator.globalVariables.styles = 'style,gvimail'; -- cgit v1.2.3