From f19f21f7114c6cdc2c62b69e0f6dafac68fd84a0 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 6 Jan 2015 12:04:19 +0000 Subject: Mode; simplify InsertModeBlocker logic. --- content_scripts/mode.coffee | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'content_scripts/mode.coffee') diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee index b81a4ede..df833c51 100644 --- a/content_scripts/mode.coffee +++ b/content_scripts/mode.coffee @@ -153,16 +153,15 @@ class ExitOnEscapeMode extends SingletonMode event: event @suppressEvent -# This mode exits when @constrainingElement (if defined) loses the focus. +# This mode exits when element (if defined) loses the focus. class ConstrainedMode extends ExitOnEscapeMode - constructor: (@constrainingElement, singleton, options) -> + constructor: (element, singleton=null, options={}) -> super singleton, options - if @constrainingElement - @constrainingElement.focus() + if element?.focus? + element.focus() @push - "blur": (event) => @alwaysContinueBubbling => - @exit() if event.srcElement == @constrainingElement + "blur": (event) => @alwaysContinueBubbling => @exit() if event.srcElement == element # The state mode tracks the enabled state in @enabled and @passKeys. It calls @registerStateChange() whenever # the state changes. The state is distributed by bubbling a "registerStateChange" event down the handler -- cgit v1.2.3