From 21c283fb773bb17c631504b2d2ad2f2bbbb1c723 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Wed, 3 Feb 2016 02:50:29 +0000 Subject: Move help dialog setup to VimiumHelpDialog.init --- content_scripts/vimium_frontend.coffee | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index d85d738a..6f084204 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -772,6 +772,21 @@ VimiumHelpDialog = # This setting is pulled out of local storage. It's false by default. getShowAdvancedCommands: -> Settings.get("helpDialog_showAdvancedCommands") + init: (html) -> + container = DomUtils.createElement "div" + container.id = "vimiumHelpDialogContainer" + container.className = "vimiumReset" + + document.body.appendChild(container) + + container.innerHTML = html + container.getElementsByClassName("closeButton")[0].addEventListener("click", hideHelpDialog, false) + container.getElementsByClassName("optionsPage")[0].addEventListener("click", (clickEvent) -> + clickEvent.preventDefault() + chrome.runtime.sendMessage({handler: "openOptionsPageInNewTab"}) + false) + + show: -> @dialogElement = document.getElementById("vimiumHelpDialog") @dialogElement.getElementsByClassName("toggleAdvancedCommands")[0].addEventListener("click", @@ -797,22 +812,10 @@ VimiumHelpDialog = window.showHelpDialog = (html, fid) -> return if (isShowingHelpDialog || !document.body || fid != frameId) isShowingHelpDialog = true - container = DomUtils.createElement "div" - container.id = "vimiumHelpDialogContainer" - container.className = "vimiumReset" - - document.body.appendChild(container) - - container.innerHTML = html - container.getElementsByClassName("closeButton")[0].addEventListener("click", hideHelpDialog, false) + VimiumHelpDialog.init html VimiumHelpDialog.show() - container.getElementsByClassName("optionsPage")[0].addEventListener("click", (clickEvent) -> - clickEvent.preventDefault() - chrome.runtime.sendMessage({handler: "openOptionsPageInNewTab"}) - false) - # Simulating a click on the help dialog makes it the active element for scrolling. DomUtils.simulateClick document.getElementById "vimiumHelpDialog" -- cgit v1.2.3