diff options
| author | Stephen Blott | 2015-06-13 13:03:10 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-06-13 13:03:10 +0100 |
| commit | 4f426affde34c895cf342dac256895ffe98ee4f3 (patch) | |
| tree | 00e86e7d58c20602a018ae4ff93e6c1b30052287 | |
| parent | f34f842417bdac363fac5a3e47366b3ee94c2454 (diff) | |
| download | vimium-4f426affde34c895cf342dac256895ffe98ee4f3.tar.bz2 | |
Refactor duplicate code.
| -rw-r--r-- | content_scripts/hud.coffee | 2 | ||||
| -rw-r--r-- | content_scripts/mode_find.coffee | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/content_scripts/hud.coffee b/content_scripts/hud.coffee index 2f4e008c..bfad71b7 100644 --- a/content_scripts/hud.coffee +++ b/content_scripts/hud.coffee @@ -57,7 +57,7 @@ HUD = @tween.fade 0, 150, => @hide true, updateIndicator hideFindMode: (data) -> - window.scrollTo @findMode.scrollX, @findMode.scrollY if @findMode.options.returnToViewport + @findMode.checkReturnToViewPort() # An element element won't receive a focus event if the search landed on it while we were in the HUD # iframe. To end up with the correct modes active, we create a focus/blur event manually after refocusing diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee index 297c4158..bba457b6 100644 --- a/content_scripts/mode_find.coffee +++ b/content_scripts/mode_find.coffee @@ -87,7 +87,7 @@ class FindMode extends Mode findInPlace: (query) -> # If requested, restore the scroll position (so that failed searches leave the scroll position unchanged). - window.scrollTo @scrollX, @scrollY if @options.returnToViewport + @checkReturnToViewPort() FindMode.updateQuery query # Restore the selection. That way, we're always searching forward from the same place, so we find the right # match as the user adds matching characters, or removes previously-matched characters. See #1434. @@ -196,6 +196,9 @@ class FindMode extends Mode @restoreDefaultSelectionHighlight: -> document.body.classList.remove("vimiumFindMode") + checkReturnToViewPort: -> + window.scrollTo @scrollX, @scrollY if @options.returnToViewport + getCurrentRange = -> selection = getSelection() if selection.type == "None" |
