diff options
| author | Matthew Ryan | 2015-06-13 14:16:07 +0100 |
|---|---|---|
| committer | Matthew Ryan | 2015-06-13 14:16:07 +0100 |
| commit | 107c8abd7ea1f2dc6d6a7e36b7cdeb93e1ca9335 (patch) | |
| tree | ebc3ba8787099d253325d3ba049f2fc110d9f111 /content_scripts/mode_find.coffee | |
| parent | 26a0653318be7bae4254e2e643dcb5ae5e2498e9 (diff) | |
| parent | 8151d592b3ec2b37d4c41123cf94ed23d119d3c9 (diff) | |
| download | vimium-107c8abd7ea1f2dc6d6a7e36b7cdeb93e1ca9335.tar.bz2 | |
Merge pull request #1 from smblott-github/hud-iframe-input
Hud iframe input
Diffstat (limited to 'content_scripts/mode_find.coffee')
| -rw-r--r-- | content_scripts/mode_find.coffee | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee index ff9506e7..bba457b6 100644 --- a/content_scripts/mode_find.coffee +++ b/content_scripts/mode_find.coffee @@ -60,14 +60,15 @@ class FindMode extends Mode matchCount: 0 hasResults: false - constructor: (@options = {}) -> + constructor: (options = {}) -> + console.log "constructor", @options # Save the selection, so findInPlace can restore it. @initialRange = getCurrentRange() FindMode.query = rawQuery: "" - if @options.returnToViewport + if options.returnToViewport @scrollX = window.scrollX @scrollY = window.scrollY - super + super extend options, name: "find" indicator: false exitOnClick: true @@ -84,7 +85,10 @@ class FindMode extends Mode selection.removeAllRanges() selection.addRange range - findInPlace: -> + findInPlace: (query) -> + # If requested, restore the scroll position (so that failed searches leave the scroll position unchanged). + @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. @restoreSelection() @@ -192,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" |
