Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

The help dialog now initializes the javascript from the within

vimium_frontend.coffee. All that is left now is to get the user's
settings for the showAdvancedCommands option.
  • Loading branch information...
commit bebb767410db71e6cd493a7fe09a0aba4c4613a2 1 parent 92da4d6
@mgarriott mgarriott authored
Showing with 42 additions and 39 deletions.
  1. +42 −3 content_scripts/vimium_frontend.coffee
  2. +0 −36 help_dialog.html
View
45 content_scripts/vimium_frontend.coffee
@@ -841,13 +841,52 @@ window.showHelpDialog = (html, fid) ->
container.innerHTML = html
container.getElementsByClassName("closeButton")[0].addEventListener("click", hideHelpDialog, false)
+
+ # Chrome's new security policy with manifest version 2 prevents the use
+ # of eval in this case. So instead of keeping the javascript in the help_dialog.html
+ # file we can just put it here as coffee script.
+ # See https://developer.chrome.com/trunk/extensions/sandboxingEval.html for more
+ # information on chrome's new security policies.
+ # @mgarriott - 8-25-2012
+ #
+ # OldMethod:
+ # scripts = Array.prototype.slice.call(container.getElementsByTagName("script"))
+ # scripts.forEach((script) -> eval(script.text))
+ VimiumHelpDialog =
+ # This setting is pulled out of local storage. It's false by default.
+ advancedCommandsVisible: false
+ #chrome.extension.getBackgroundPage().Settings.get('helpDialog_showAdvancedCommands')
+
+ init: () ->
+ this.dialogElement = document.getElementById("vimiumHelpDialog")
+ this.dialogElement.getElementsByClassName("toggleAdvancedCommands")[0].addEventListener("click",
+ VimiumHelpDialog.toggleAdvancedCommands, false)
+ this.dialogElement.style.maxHeight = window.innerHeight - 80
+ this.showAdvancedCommands(this.advancedCommandsVisible)
+
+ #
+ # Advanced commands are hidden by default so they don't overwhelm new and casual users.
+ #
+ toggleAdvancedCommands: (event) ->
+ event.preventDefault()
+ VimiumHelpDialog.advancedCommandsVisible = !VimiumHelpDialog.advancedCommandsVisible
+ chrome.extension.sendRequest(
+ { handler: "saveHelpDialogSettings", showAdvancedCommands: VimiumHelpDialog.advancedCommandsVisible })
+ VimiumHelpDialog.showAdvancedCommands(VimiumHelpDialog.advancedCommandsVisible)
+
+ 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
View
36 help_dialog.html
@@ -48,40 +48,4 @@
<span class="vimiumReset">Version {{version}}</span><br/>
</div>
</div>
-
- <script>
- VimiumHelpDialog = {
- // This setting is pulled out of local storage. It's false by default.
- advancedCommandsVisible: {{showAdvancedCommands}},
-
- init: function() {
- this.dialogElement = document.getElementById("vimiumHelpDialog");
- this.dialogElement.getElementsByClassName("toggleAdvancedCommands")[0].addEventListener("click",
- VimiumHelpDialog.toggleAdvancedCommands, false);
- this.dialogElement.style.maxHeight = window.innerHeight - 80;
- this.showAdvancedCommands(this.advancedCommandsVisible);
- },
-
- /*
- * Advanced commands are hidden by default so they don't overwhelm new and casual users.
- */
- toggleAdvancedCommands: function(event) {
- event.preventDefault();
- VimiumHelpDialog.advancedCommandsVisible = !VimiumHelpDialog.advancedCommandsVisible;
- chrome.extension.sendRequest({ handler: "saveHelpDialogSettings",
- showAdvancedCommands: VimiumHelpDialog.advancedCommandsVisible });
- VimiumHelpDialog.showAdvancedCommands(VimiumHelpDialog.advancedCommandsVisible);
- },
-
- showAdvancedCommands: function(visible) {
- VimiumHelpDialog.dialogElement.getElementsByClassName("toggleAdvancedCommands")[0].innerHTML =
- visible ? "Hide advanced commands" : "Show advanced commands";
- var advanced = VimiumHelpDialog.dialogElement.getElementsByClassName("advanced");
- for (var i = 0; i < advanced.length; i++)
- advanced[i].style.display = (visible ? "table-row" : "none");
- }
- };
-
- VimiumHelpDialog.init();
- </script>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.