diff options
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 45 | ||||
| -rw-r--r-- | help_dialog.html | 36 |
2 files changed, 42 insertions, 39 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index f4fb17fe..548e9c6c 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/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 diff --git a/help_dialog.html b/help_dialog.html index 5e188406..2a69ea03 100644 --- a/help_dialog.html +++ b/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> |
