diff options
| author | mrmr1993 | 2015-06-10 15:52:07 +0100 |
|---|---|---|
| committer | mrmr1993 | 2015-06-10 20:59:17 +0100 |
| commit | 036a85c275fe7404e47b8c1657232fba971a803e (patch) | |
| tree | 568df537e3d3d1c9d782422c38ba3cfbe28e06b9 | |
| parent | dbf7d4eb053cc99f2c29b56ea61a671ec46fac62 (diff) | |
| download | vimium-036a85c275fe7404e47b8c1657232fba971a803e.tar.bz2 | |
Move getNextQueryFromFindModeMatches and getFindModeQuery into mode_find
| -rw-r--r-- | content_scripts/mode_find.coffee | 22 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 22 |
2 files changed, 22 insertions, 22 deletions
diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee index 54c8438a..e65450f2 100644 --- a/content_scripts/mode_find.coffee +++ b/content_scripts/mode_find.coffee @@ -132,6 +132,28 @@ class FindMode extends Mode text = document.body.innerText findModeQuery.matchCount = text.match(pattern)?.length +window.getNextQueryFromRegexMatches = (stepSize) -> + # find()ing an empty query always returns false + return "" unless findModeQuery.regexMatches + + totalMatches = findModeQuery.regexMatches.length + findModeQuery.activeRegexIndex += stepSize + totalMatches + findModeQuery.activeRegexIndex %= totalMatches + + findModeQuery.regexMatches[findModeQuery.activeRegexIndex] + +window.getFindModeQuery = (backwards) -> + # check if the query has been changed by a script in another frame + mostRecentQuery = FindModeHistory.getQuery() + if (mostRecentQuery != findModeQuery.rawQuery) + findModeQuery.rawQuery = mostRecentQuery + FindMode.updateQuery() + + if findModeQuery.isRegex + getNextQueryFromRegexMatches(if backwards then -1 else 1) + else + findModeQuery.parsedQuery + getCurrentRange = -> selection = getSelection() if selection.type == "None" diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 13e07e7a..80da43bb 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -677,28 +677,6 @@ selectFoundInputElement = -> DomUtils.isDOMDescendant(findModeAnchorNode, document.activeElement)) DomUtils.simulateSelect(document.activeElement) -window.getNextQueryFromRegexMatches = (stepSize) -> - # find()ing an empty query always returns false - return "" unless findModeQuery.regexMatches - - totalMatches = findModeQuery.regexMatches.length - findModeQuery.activeRegexIndex += stepSize + totalMatches - findModeQuery.activeRegexIndex %= totalMatches - - findModeQuery.regexMatches[findModeQuery.activeRegexIndex] - -window.getFindModeQuery = (backwards) -> - # check if the query has been changed by a script in another frame - mostRecentQuery = FindModeHistory.getQuery() - if (mostRecentQuery != findModeQuery.rawQuery) - findModeQuery.rawQuery = mostRecentQuery - FindMode.updateQuery() - - if findModeQuery.isRegex - getNextQueryFromRegexMatches(if backwards then -1 else 1) - else - findModeQuery.parsedQuery - findAndFocus = (backwards) -> Marks.setPreviousPosition() query = getFindModeQuery backwards |
