[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 385/483: Updated to KeySelector changes

David Prévot taffit at moszumanska.debian.org
Thu Jan 22 21:41:59 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus-element-hiding-helper.

commit 4f05f9f20082534eca76a79e0ef2290e25c265ec
Author: Wladimir Palant <trev at adblockplus.org>
Date:   Mon Jan 23 11:15:55 2012 +0100

    Updated to KeySelector changes
---
 main.js | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/main.js b/main.js
index d21d67f..93941e3 100644
--- a/main.js
+++ b/main.js
@@ -13,6 +13,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 let {Aardvark} = require("aardvark");
 let {Prefs} = require("prefs");
+let {KeySelector} = require("keySelector");
 
 let Main = exports.Main =
 {
@@ -337,8 +338,7 @@ WindowWrapper.prototype =
 
     if (typeof this.key == "undefined")
       this.configureKey(event.currentTarget);
-    if (this.key && this.key.text)
-      item.setAttribute("acceltext", this.key.text);
+    item.setAttribute("acceltext", KeySelector.getTextForKey(this.key));
 
     item.addEventListener("command", this.toggleSelection, false);
 
@@ -365,26 +365,16 @@ WindowWrapper.prototype =
     if (typeof this.key == "undefined")
       this.configureKey(event.currentTarget);
 
-    if (event.defaultPrevented || !this.key)
-      return;
-    if (this.key.shift != event.shiftKey || this.key.alt != event.altKey)
-      return;
-    if (this.key.meta != event.metaKey || this.key.control != event.ctrlKey)
-      return;
-
-    if (this.key.char && (!event.charCode || String.fromCharCode(event.charCode).toUpperCase() != this.key.char))
-      return;
-    else if (this.key.code && (!event.keyCode || event.keyCode != this.key.code))
-      return;
-
-    event.preventDefault();
-    this.toggleSelection();
+    if (KeySelector.matchesKey(event, this.key))
+    {
+      event.preventDefault();
+      this.toggleSelection();
+    }
   },
 
   configureKey: function(window)
   {
-    this.key = require("keySelector").selectKey(window, Prefs.selectelement_key);
-    unrequire("keySelector");   // This module is used only once, release its scope
+    this.key = new KeySelector(window).selectKey(Prefs.selectelement_key);
   },
 
   hideTooltips: function()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus-element-hiding-helper.git



More information about the Pkg-mozext-commits mailing list