aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/mode.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'content_scripts/mode.coffee')
-rw-r--r--content_scripts/mode.coffee16
1 files changed, 11 insertions, 5 deletions
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee
index 7ca818b4..a2a8b8b0 100644
--- a/content_scripts/mode.coffee
+++ b/content_scripts/mode.coffee
@@ -9,11 +9,11 @@ class Mode
@propagate = true
# Default values.
- name: "" # The name of this mode.
- badge: "" # A badge to display on the popup when this mode is active.
- keydown: "suppress" # A function, or "suppress" or "pass"; the latter are replaced with suitable functions.
- keypress: "suppress" # A function, or "suppress" or "pass"; the latter are replaced with suitable functions.
- keyup: "suppress" # A function, or "suppress" or "pass"; the latter are replaced with suitable functions.
+ name: "" # The name of this mode.
+ badge: "" # A badge to display on the popup when this mode is active.
+ keydown: "pass" # A function, or "suppress" or "pass"; the latter are replaced with suitable handlers.
+ keypress: "pass" # A function, or "suppress" or "pass"; the latter are replaced with suitable handlers.
+ keyup: "pass" # A function, or "suppress" or "pass"; the latter are replaced with suitable handlers.
constructor: (options) ->
extend @, options
@@ -73,5 +73,11 @@ class Mode
@sendBadge: (badge) ->
chrome.runtime.sendMessage({ handler: "setBadge", badge: badge })
+ # Install a mode, call a function, and exit the mode again.
+ @runIn: (mode, func) ->
+ mode = new mode()
+ func()
+ mode.exit()
+
root = exports ? window
root.Mode = Mode