diff options
| author | mrmr1993 | 2015-06-10 15:56:30 +0100 |
|---|---|---|
| committer | mrmr1993 | 2015-06-10 20:59:17 +0100 |
| commit | 1c076fbcf9d37533cc24e30476e23c050f1eda0f (patch) | |
| tree | 3467ec9bb23949490887e9288f357e25f4aa4ee0 | |
| parent | 036a85c275fe7404e47b8c1657232fba971a803e (diff) | |
| download | vimium-1c076fbcf9d37533cc24e30476e23c050f1eda0f.tar.bz2 | |
Integrate functions exposed on window into FindMode
| -rw-r--r-- | content_scripts/mode_find.coffee | 36 | ||||
| -rw-r--r-- | content_scripts/mode_visual_edit.coffee | 2 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 2 |
3 files changed, 20 insertions, 20 deletions
diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee index e65450f2..4d7f3972 100644 --- a/content_scripts/mode_find.coffee +++ b/content_scripts/mode_find.coffee @@ -83,7 +83,7 @@ class FindMode extends Mode # 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() - query = if findModeQuery.isRegex then getNextQueryFromRegexMatches(0) else findModeQuery.parsedQuery + query = if findModeQuery.isRegex then FindMode.getNextQueryFromRegexMatches(0) else findModeQuery.parsedQuery window.findModeQuery.hasResults = executeFind(query, { caseSensitive: !findModeQuery.ignoreCase }) # should be called whenever rawQuery is modified. @@ -132,27 +132,27 @@ 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 + @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 + totalMatches = findModeQuery.regexMatches.length + findModeQuery.activeRegexIndex += stepSize + totalMatches + findModeQuery.activeRegexIndex %= totalMatches - findModeQuery.regexMatches[findModeQuery.activeRegexIndex] + 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() + @getQuery: (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 + if findModeQuery.isRegex + @getNextQueryFromRegexMatches(if backwards then -1 else 1) + else + findModeQuery.parsedQuery getCurrentRange = -> selection = getSelection() diff --git a/content_scripts/mode_visual_edit.coffee b/content_scripts/mode_visual_edit.coffee index 2abccaac..e01df819 100644 --- a/content_scripts/mode_visual_edit.coffee +++ b/content_scripts/mode_visual_edit.coffee @@ -352,7 +352,7 @@ class Movement extends CountPrefix unless @options.parentMode or options.oneMovementOnly do => executeFind = (count, findBackwards) => - if query = getFindModeQuery findBackwards + if query = FindMode.getQuery findBackwards initialRange = @selection.getRangeAt(0).cloneRange() for [0...count] unless window.find query, Utils.hasUpperCase(query), findBackwards, true, false, true, false diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 80da43bb..a71a094e 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -679,7 +679,7 @@ selectFoundInputElement = -> findAndFocus = (backwards) -> Marks.setPreviousPosition() - query = getFindModeQuery backwards + query = FindMode.getQuery backwards window.findModeQuery.hasResults = executeFind(query, { backwards: backwards, caseSensitive: !findModeQuery.ignoreCase }) |
