From d765faafdf367a68ea51cec67106091e367b502b Mon Sep 17 00:00:00 2001 From: Matt Garriott Date: Fri, 24 Aug 2012 15:18:01 -0600 Subject: Fixed 'Show advanced commands' link on the options page. --- content_scripts/vimium_frontend.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 5b7a7402..f4fb17fe 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -830,7 +830,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") -- cgit v1.2.3 From 92da4d6de1825a03b9cd902c9c711c035a0e0b64 Mon Sep 17 00:00:00 2001 From: Matt Garriott Date: Sat, 25 Aug 2012 07:19:01 -0600 Subject: Fixed the formatting on the helpDialog overlay when viewed from the options menu. --- options/options.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/options/options.html b/options/options.html index 4a616328..089de394 100644 --- a/options/options.html +++ b/options/options.html @@ -79,7 +79,7 @@ /* Horizontal resizing is pretty screwy-looking. */ resize: vertical; } - table { + table#options{ width: 100%; font-size: 14px; position: relative; @@ -179,7 +179,7 @@
Vimium options
- +
Scroll step size -- cgit v1.2.3 From bebb767410db71e6cd493a7fe09a0aba4c4613a2 Mon Sep 17 00:00:00 2001 From: Matt Garriott Date: Sat, 25 Aug 2012 13:01:17 -0600 Subject: 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. --- content_scripts/vimium_frontend.coffee | 45 +++++++++++++++++++++++++++++++--- 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 -- cgit v1.2.3 From 4ec5cc6fcaaac22826b3e0535282733a2368d1e4 Mon Sep 17 00:00:00 2001 From: Matt Garriott Date: Sat, 25 Aug 2012 19:07:25 -0600 Subject: The help dialog will now properly read the user's preference for showing advanced commands. --- background_scripts/main.js | 7 +++++-- content_scripts/vimium_frontend.coffee | 12 ++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/background_scripts/main.js b/background_scripts/main.js index 6e6a3978..8e75314e 100644 --- a/background_scripts/main.js +++ b/background_scripts/main.js @@ -23,6 +23,7 @@ var portHandlers = { var sendRequestHandlers = { getCompletionKeys: getCompletionKeysRequest, getCurrentTabUrl: getCurrentTabUrl, + getShowAdvancedCommands: getShowAdvancedCommands, openUrlInNewTab: openUrlInNewTab, openUrlInCurrentTab: openUrlInCurrentTab, openOptionsPageInNewTab: openOptionsPageInNewTab, @@ -128,6 +129,10 @@ function addExcludedUrl(url) { }); } +function getShowAdvancedCommands(request){ + return Settings.get("helpDialog_showAdvancedCommands"); +} + function saveHelpDialogSettings(request) { Settings.set("helpDialog_showAdvancedCommands", request.showAdvancedCommands); } @@ -155,8 +160,6 @@ function helpDialogHtml(showUnboundCommands, showCommandNames, customTitle) { showUnboundCommands, showCommandNames)); dialogHtml = dialogHtml.replace("{{version}}", currentVersion); dialogHtml = dialogHtml.replace("{{title}}", customTitle || "Help"); - dialogHtml = dialogHtml.replace("{{showAdvancedCommands}}", - Settings.get("helpDialog_showAdvancedCommands")); return dialogHtml; } diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 548e9c6c..9accaa3b 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -854,25 +854,25 @@ window.showHelpDialog = (html, fid) -> # 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') + 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.showAdvancedCommands(this.advancedCommandsVisible) + this.getShowAdvancedCommands(this.showAdvancedCommands) # # 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) + VimiumHelpDialog.getShowAdvancedCommands((value) -> + VimiumHelpDialog.showAdvancedCommands(!value) + chrome.extension.sendRequest({ handler: "saveHelpDialogSettings", showAdvancedCommands: !value })) showAdvancedCommands: (visible) -> VimiumHelpDialog.dialogElement.getElementsByClassName("toggleAdvancedCommands")[0].innerHTML = -- cgit v1.2.3 From 354c0c5467ee589c3bb8e2009a3e7412f33ed1ab Mon Sep 17 00:00:00 2001 From: Matt Garriott Date: Fri, 31 Aug 2012 16:13:42 -0600 Subject: Removed unneeded comments. --- content_scripts/vimium_frontend.coffee | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 9accaa3b..eacf2eb1 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -842,19 +842,8 @@ 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. - #chrome.extension.getBackgroundPage().Settings.get('helpDialog_showAdvancedCommands') getShowAdvancedCommands: (callback) -> chrome.extension.sendRequest({ handler: "getShowAdvancedCommands"}, callback) -- cgit v1.2.3