diff options
| -rw-r--r-- | background_page.html | 9 | ||||
| -rw-r--r-- | helpDialog.html | 21 |
2 files changed, 24 insertions, 6 deletions
diff --git a/background_page.html b/background_page.html index 77150244..ee12a77d 100644 --- a/background_page.html +++ b/background_page.html @@ -79,7 +79,8 @@ upgradeNotificationClosed: upgradeNotificationClosed, updateScrollPosition: handleUpdateScrollPosition, copyToClipboard: copyToClipboard, - isEnabledForUrl: isEnabledForUrl + isEnabledForUrl: isEnabledForUrl, + saveHelpDialogSettings: saveHelpDialogSettings }; // Event handlers @@ -151,6 +152,10 @@ return { isEnabledForUrl: isEnabled }; } + function saveHelpDialogSettings(request) { + localStorage["helpDialog_showAdvancedCommands"] = request.showAdvancedCommands; + } + /* * Returns the previously saved zoom level for the current tab, or the default zoom level */ @@ -186,6 +191,8 @@ showUnboundCommands, showCommandNames)); dialogHtml = dialogHtml.replace("{{version}}", currentVersion); dialogHtml = dialogHtml.replace("{{title}}", customTitle || "Help"); + dialogHtml = dialogHtml.replace("{{showAdvancedCommands}}", + localStorage["helpDialog_showAdvancedCommands"] == "true"); return dialogHtml; } diff --git a/helpDialog.html b/helpDialog.html index c21c8b7b..ae78d149 100644 --- a/helpDialog.html +++ b/helpDialog.html @@ -132,10 +132,14 @@ <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.showAdvancedCommands(this.advancedCommandsVisible); }, /* @@ -143,13 +147,20 @@ */ toggleAdvancedCommands: function(event) { event.preventDefault(); - var advanced = VimiumHelpDialog.dialogElement.getElementsByClassName("advanced"); - var shouldShow = (advanced[0].style.display == "" || advanced[0].style.display == "none"); + 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 = - shouldShow ? "Hide advanced commands" : "Show advanced commands"; + 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 = (shouldShow ? "table-row" : "none"); - } + advanced[i].style.display = (visible ? "table-row" : "none"); + }, + }; VimiumHelpDialog.init(); |
