aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranekos2008-12-01 03:03:49 +0000
committeranekos2008-12-01 03:03:49 +0000
commit8f348054e218bdb778bb8d3cffbc6dbf342c7e8e (patch)
treeff1540cdbb3a3ce38a0198eb9577d7d75c85a3ee
parent0e8d65f2ca815d3000f4f4b7e9ac55cff2df10aa (diff)
downloadvimperator-plugins-8f348054e218bdb778bb8d3cffbc6dbf342c7e8e.tar.bz2
Fix event listeners
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@25510 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r--gvimail.js17
1 files changed, 7 insertions, 10 deletions
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';