aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts
diff options
context:
space:
mode:
authorPhil Crosby2012-09-01 12:18:27 -0700
committerPhil Crosby2012-09-01 12:18:27 -0700
commit7876a0618c93e950bea4faba4c26076cef394b96 (patch)
treee081961b71da3e475a99d6bf9aafc255f943b050 /content_scripts
parent666a2f3c091f0d9268a0883f17a46e565331fc12 (diff)
parent354c0c5467ee589c3bb8e2009a3e7412f33ed1ab (diff)
downloadvimium-7876a0618c93e950bea4faba4c26076cef394b96.tar.bz2
Merge pull request #628 from mgarriott/help_bug_fixes
Help Dialog bug fixes
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/vimium_frontend.coffee36
1 files changed, 32 insertions, 4 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index 75092f79..9c86e808 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -832,7 +832,7 @@ exitFindMode = ->
findMode = false
HUD.hide()
-showHelpDialog = (html, fid) ->
+window.showHelpDialog = (html, fid) ->
return if (isShowingHelpDialog || !document.body || fid != frameId)
isShowingHelpDialog = true
container = document.createElement("div")
@@ -843,13 +843,41 @@ showHelpDialog = (html, fid) ->
container.innerHTML = html
container.getElementsByClassName("closeButton")[0].addEventListener("click", hideHelpDialog, false)
+
+ VimiumHelpDialog =
+ # This setting is pulled out of local storage. It's false by default.
+ getShowAdvancedCommands: (callback) ->
+ chrome.extension.sendRequest({ handler: "getShowAdvancedCommands"}, callback)
+
+ init: () ->
+ this.dialogElement = document.getElementById("vimiumHelpDialog")
+ this.dialogElement.getElementsByClassName("toggleAdvancedCommands")[0].addEventListener("click",
+ VimiumHelpDialog.toggleAdvancedCommands, false)
+ this.dialogElement.style.maxHeight = window.innerHeight - 80
+ this.getShowAdvancedCommands(this.showAdvancedCommands)
+
+ #
+ # Advanced commands are hidden by default so they don't overwhelm new and casual users.
+ #
+ toggleAdvancedCommands: (event) ->
+ event.preventDefault()
+ VimiumHelpDialog.getShowAdvancedCommands((value) ->
+ VimiumHelpDialog.showAdvancedCommands(!value)
+ chrome.extension.sendRequest({ handler: "saveHelpDialogSettings", showAdvancedCommands: !value }))
+
+ showAdvancedCommands: (visible) ->
+ VimiumHelpDialog.dialogElement.getElementsByClassName("toggleAdvancedCommands")[0].innerHTML =
+ if visible then "Hide advanced commands" else "Show advanced commands"
+ advancedEls = VimiumHelpDialog.dialogElement.getElementsByClassName("advanced")
+ for el in advancedEls
+ el.style.display = if visible then "table-row" else "none"
+
+ VimiumHelpDialog.init()
+
container.getElementsByClassName("optionsPage")[0].addEventListener("click",
-> chrome.extension.sendRequest({ handler: "openOptionsPageInNewTab" })
false)
- # This is necessary because innerHTML does not evaluate javascript embedded in <script> tags.
- scripts = Array.prototype.slice.call(container.getElementsByTagName("script"))
- scripts.forEach((script) -> eval(script.text))
hideHelpDialog = (clickEvent) ->
isShowingHelpDialog = false