aboutsummaryrefslogtreecommitdiffstats
path: root/pages/help_dialog.coffee
diff options
context:
space:
mode:
authorStephen Blott2016-04-15 16:51:18 +0100
committerStephen Blott2016-04-16 14:15:33 +0100
commit5bfe6dc5d1e0aeb1ab3e372821997d83ba5c9164 (patch)
tree174c58b552cc0b869764d2dd28f14bb3f010ef2c /pages/help_dialog.coffee
parent014f53fb091ac8672d3efbeca13a494c15d8afcb (diff)
downloadvimium-5bfe6dc5d1e0aeb1ab3e372821997d83ba5c9164.tar.bz2
Rework UI component focus handling.
The code to handle the focus for UI components has been tweaked and adapted over time, and has become quite complicated (and brittle). This reworks it from scratch, and co-locates similar code which does related things. Fixes #2099.
Diffstat (limited to 'pages/help_dialog.coffee')
-rw-r--r--pages/help_dialog.coffee26
1 files changed, 6 insertions, 20 deletions
diff --git a/pages/help_dialog.coffee b/pages/help_dialog.coffee
index 0e4a8973..0300ec00 100644
--- a/pages/help_dialog.coffee
+++ b/pages/help_dialog.coffee
@@ -6,7 +6,7 @@
# top-level frame), and then we don't need to be concerned about nested help dialog frames.
HelpDialog =
dialogElement: null
- showing: true
+ isShowing: -> true
# This setting is pulled out of local storage. It's false by default.
getShowAdvancedCommands: -> Settings.get("helpDialog_showAdvancedCommands")
@@ -30,9 +30,7 @@ HelpDialog =
@hide() unless @dialogElement.contains event.target
, false
- isReady: -> true
-
- show: (html) ->
+ show: ({html}) ->
for own placeholder, htmlString of html
@dialogElement.querySelector("#help-dialog-#{placeholder}").innerHTML = htmlString
@@ -48,15 +46,8 @@ HelpDialog =
chrome.runtime.sendMessage handler: "copyToClipboard", data: commandName
HUD.showForDuration("Yanked #{commandName}.", 2000)
- @exitOnEscape = new Mode name: "help-page-escape", exitOnEscape: true
- @exitOnEscape.onExit (event) => @hide() if event?.type == "keydown"
-
- hide: ->
- @exitOnEscape?.exit()
- UIComponentServer.postMessage "hide"
-
- toggle: (html) ->
- if @showing then @hide() else @show html
+ hide: -> UIComponentServer.hide()
+ toggle: (html) -> @hide()
#
# Advanced commands are hidden by default so they don't overwhelm new and casual users.
@@ -77,13 +68,8 @@ HelpDialog =
UIComponentServer.registerHandler (event) ->
switch event.data.name ? event.data
- when "frameFocused"
- # We normally close when we lose the focus. However, we do not close on the options page. This allows
- # users to view the help dialog while typing in the key-mappings input.
- HelpDialog.hide() unless event.data.focusFrameId == frameId or try window.top.isVimiumOptionsPage
- when "hide"
- HelpDialog.hide()
- else
+ when "hide" then HelpDialog.hide()
+ when "activate"
HelpDialog.init()
HelpDialog.show event.data