[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 251/483: Implemented "lock/unlock selection" command
David Prévot
taffit at moszumanska.debian.org
Thu Jan 22 21:41:46 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 f520b1df186f6e44c4a3b5ec4decdf239d2dbc66
Author: Wladimir Palant <trev at adblockplus.org>
Date: Tue Oct 26 08:37:08 2010 +0200
Implemented "lock/unlock selection" command
---
chrome/locale/en-US/global.properties | 2 ++
modules/Aardvark.jsm | 63 ++++++++++++++++++++++++++---------
2 files changed, 50 insertions(+), 15 deletions(-)
diff --git a/chrome/locale/en-US/global.properties b/chrome/locale/en-US/global.properties
index fbd667f..6c5341c 100644
--- a/chrome/locale/en-US/global.properties
+++ b/chrome/locale/en-US/global.properties
@@ -4,6 +4,8 @@ command.wider.key=w
command.wider.label=wider
command.narrower.key=n
command.narrower.label=narrower
+command.lock.key=l
+command.lock.label=lock/unlock selection
command.quit.key=q
command.quit.label=quit selection
command.blinkElement.key=b
diff --git a/modules/Aardvark.jsm b/modules/Aardvark.jsm
index 24013f3..bdc8eac 100644
--- a/modules/Aardvark.jsm
+++ b/modules/Aardvark.jsm
@@ -46,6 +46,7 @@ var Aardvark = {
anchorElem: null,
selectedElem: null,
isUserSelected: false,
+ lockedAnchor: null,
commentElem: null,
mouseX: -1,
mouseY: -1,
@@ -250,24 +251,36 @@ Aardvark.onMouseMove = function(event) {
if (elem)
{
- this.anchorElem = elem;
-
- if (this.isUserSelected)
+ if (!this.lockedAnchor)
+ this.setAnchorElement(elem);
+ else
{
- // User chose an element via wider/narrower commands, keep the selection if
- // out new anchor is still a child of that element
- let e = elem;
- while (e && e != this.selectedElem)
- e = this.getParentElement(e);
-
- if (e)
- elem = this.selectedElem;
- else
- this.isUserSelected = false;
+ this.lockedAnchor = elem;
+ this.showBoxAndLabel(this.selectedElem);
}
+ }
+}
+
+Aardvark.setAnchorElement = function(anchor)
+{
+ this.anchorElem = anchor;
+
+ let newSelection = anchor;
+ if (this.isUserSelected)
+ {
+ // User chose an element via wider/narrower commands, keep the selection if
+ // out new anchor is still a child of that element
+ let e = newSelection;
+ while (e && e != this.selectedElem)
+ e = this.getParentElement(e);
- this.showBoxAndLabel(elem);
+ if (e)
+ newSelection = this.selectedElem;
+ else
+ this.isUserSelected = false;
}
+
+ this.showBoxAndLabel(newSelection);
}
// Makes sure event handlers like Aardvark.keyPress redirect
@@ -345,7 +358,6 @@ Aardvark.showBoxAndLabel = function(elem, string)
}
Aardvark.clearBox = function() {
- this.anchorElem = null;
if (this.boxElem.parentNode)
this.boxElem.parentNode.removeChild(this.boxElem);
}
@@ -446,6 +458,7 @@ Aardvark.commands = [
"select",
"wider",
"narrower",
+ "lock",
"quit",
"blinkElement",
"viewSource",
@@ -491,6 +504,24 @@ Aardvark.narrower = function (elem)
}
return false;
}
+
+//------------------------------------------------------------
+
+Aardvark.lock = function (elem)
+{
+ if (!elem)
+ return false;
+
+ if (this.lockedAnchor)
+ {
+ this.setAnchorElement(this.lockedAnchor);
+ this.lockedAnchor = null;
+ }
+ else
+ this.lockedAnchor = this.anchorElem;
+
+ return true;
+}
//------------------------------------------------------------
Aardvark.quit = function ()
@@ -516,10 +547,12 @@ Aardvark.quit = function ()
this.browser.removeEventListener("mousemove", this.mouseMove, true);
this.browser.contentWindow.removeEventListener("pagehide", this.pageHide, true);
+ this.anchorElem = null;
this.selectedElem = null;
this.window = null;
this.browser = null;
this.commentElem = null;
+ this.lockedAnchor = null;
E = function(id) null;
return false;
}
--
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