From 036a85c275fe7404e47b8c1657232fba971a803e Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Wed, 10 Jun 2015 15:52:07 +0100 Subject: Move getNextQueryFromFindModeMatches and getFindModeQuery into mode_find --- content_scripts/mode_find.coffee | 22 ++++++++++++++++++++++ content_scripts/vimium_frontend.coffee | 22 ---------------------- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'content_scripts') 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 -- cgit v1.2.3