diff options
| author | Stephen Blott | 2015-01-18 17:26:17 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-18 17:26:17 +0000 |
| commit | 520060d69cff5f7a14e9d3fc2b4480a827110dff (patch) | |
| tree | 5bf17aff8a94f00d04fe5cb593aab725208c8424 /content_scripts/mode_insert.coffee | |
| parent | 3b334ee221a2b226ca147eec887007eae1c17f91 (diff) | |
| download | vimium-520060d69cff5f7a14e9d3fc2b4480a827110dff.tar.bz2 | |
Modes; refactor permanent instance.
I had intended the whole Insert.permanentInstance lark to be gone before
merging #1413. Somehow, this got missed.
It's retained, here, but is only needed for the tests. It gives the
tests a hook into the single insert-mode permanent instance, so they can
test its state.
Diffstat (limited to 'content_scripts/mode_insert.coffee')
| -rw-r--r-- | content_scripts/mode_insert.coffee | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/content_scripts/mode_insert.coffee b/content_scripts/mode_insert.coffee index 91103a55..eac4a3d0 100644 --- a/content_scripts/mode_insert.coffee +++ b/content_scripts/mode_insert.coffee @@ -1,12 +1,9 @@ class InsertMode extends Mode - # There is one permanently-installed instance of InsertMode. It tracks focus changes and - # activates/deactivates itself (by setting @insertModeLock) accordingly. - @permanentInstance: null - constructor: (options = {}) -> - InsertMode.permanentInstance ||= @ - @permanent = (@ == InsertMode.permanentInstance) + # There is one permanently-installed instance of InsertMode. It tracks focus changes and + # activates/deactivates itself (by setting @insertModeLock) accordingly. + @permanent = options.permanent # If truthy, then we were activated by the user (with "i"). @global = options.global @@ -51,6 +48,9 @@ class InsertMode extends Mode if @insertModeLock != event.target and DomUtils.isFocusable event.target @activateOnElement event.target + # Only for tests. This gives us a hook to test the status of the permanent instance. + InsertMode.permanentInstance = @ if @permanent + isActive: (event) -> return false if event == InsertMode.suppressedEvent return true if @insertModeLock or @global |
