aboutsummaryrefslogtreecommitdiffstats
path: root/vimiumFrontend.js
diff options
context:
space:
mode:
authorJez Ng2012-01-26 02:46:49 -0500
committerJez Ng2012-01-26 13:18:35 -0500
commit1e04eb8c3b57701206ddd65bf3b3292f0678e3e1 (patch)
tree1d41e3ca581f3cb1030b9df7d12529473c59787b /vimiumFrontend.js
parentbaace1c5d2760116b95c2ee2305d05ae348eab97 (diff)
downloadvimium-1e04eb8c3b57701206ddd65bf3b3292f0678e3e1.tar.bz2
Color find matches orange.
The brighter color makes them more visible. The orange is chosen to match Chrome's default color.
Diffstat (limited to 'vimiumFrontend.js')
-rw-r--r--vimiumFrontend.js28
1 files changed, 27 insertions, 1 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index 335f33f8..65ac240c 100644
--- a/vimiumFrontend.js
+++ b/vimiumFrontend.js
@@ -689,6 +689,15 @@ function handleKeyCharForFindMode(keyChar) {
function handleEscapeForFindMode() {
exitFindMode();
+ document.body.classList.remove("vimiumFindMode");
+ // removing the class does not re-color existing selections. we recreate the current selection so it reverts
+ // back to the default color.
+ var selection = window.getSelection();
+ if (!selection.isCollapsed) {
+ var range = window.getSelection().getRangeAt(0);
+ window.getSelection().removeAllRanges();
+ window.getSelection().addRange(range);
+ }
focusFoundLink() || selectFoundInputElement();
}
@@ -711,6 +720,7 @@ function handleDeleteForFindMode() {
function handleEnterForFindMode() {
exitFindMode();
focusFoundLink();
+ document.body.classList.add("vimiumFindMode");
settings.set("findModeRawQuery", findModeQuery.rawQuery);
}
@@ -742,12 +752,22 @@ function performFindInPlace() {
// :options is an optional dict. valid parameters are 'caseSensitive' and 'backwards'.
function executeFind(query, options) {
+ options = options || {};
+
// rather hacky, but this is our way of signalling to the insertMode listener not to react to the focus
// changes that find() induces.
var oldFindMode = findMode;
findMode = true;
- options = options || {};
+
+ document.body.classList.add("vimiumFindMode");
+
+ // ignore the selectionchange event generated by find()
+ document.removeEventListener("selectionchange",restoreDefaultSelectionHighlight, true);
var rv = window.find(query, options.caseSensitive, options.backwards, true, false, true, false);
+ setTimeout(function() {
+ document.addEventListener("selectionchange", restoreDefaultSelectionHighlight, true);
+ }, 0);
+
findMode = oldFindMode;
// we need to save the anchor node here because <esc> seems to nullify it, regardless of whether we do
// preventDefault()
@@ -755,6 +775,10 @@ function executeFind(query, options) {
return rv;
}
+function restoreDefaultSelectionHighlight() {
+ document.body.classList.remove("vimiumFindMode");
+}
+
function focusFoundLink() {
if (findModeQueryHasResults) {
var link = getLinkFromSelection();
@@ -994,7 +1018,9 @@ function hideHelpDialog(clickEvent) {
clickEvent.preventDefault();
}
+// do our best to return the document to its 'default' state.
function handleEscapeForNormalMode() {
+ window.getSelection().collapse();
if (document.activeElement !== document.body)
document.activeElement.blur();
else if (window.top !== window.self)