From 2d8c478e8086abf80b206d0fd8abc488a035b5cd Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Fri, 2 Jan 2015 15:59:58 +0000 Subject: Modes; incorporate find mode. --- content_scripts/mode.coffee | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'content_scripts/mode.coffee') 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 -- cgit v1.2.3