diff options
| author | Stephen Blott | 2017-10-29 10:20:37 +0000 |
|---|---|---|
| committer | GitHub | 2017-10-29 10:20:37 +0000 |
| commit | 933fb4d7fc0a89c1b7908e3f8c7e7a7162fbe151 (patch) | |
| tree | 3929c4c8342470958e45be2a4b0fe48164fb504f /pages | |
| parent | 93e37ee633e86a3af3e7a583ccbcab0c4e5cfce3 (diff) | |
| parent | a3c120bb7d2ca91a75f0d5125942f64dfad7890f (diff) | |
| download | vimium-933fb4d7fc0a89c1b7908e3f8c7e7a7162fbe151.tar.bz2 | |
Merge pull request #2751 from smblott-github/backup-settings
Fix backup link for FF and Chrome.
Diffstat (limited to 'pages')
| -rw-r--r-- | pages/options.coffee | 21 | ||||
| -rw-r--r-- | pages/options.css | 3 | ||||
| -rw-r--r-- | pages/options.html | 3 |
3 files changed, 12 insertions, 15 deletions
diff --git a/pages/options.coffee b/pages/options.coffee index a6916d43..9df1c175 100644 --- a/pages/options.coffee +++ b/pages/options.coffee @@ -100,8 +100,10 @@ class ExclusionRulesOption extends Option element populateElement: (rules) -> - for rule in rules - @appendRule rule + # For the case of restoring a backup, we first have to remove existing rules. + exclusionRules = $ "exclusionRules" + exclusionRules.deleteRow 1 while exclusionRules.rows[1] + @appendRule rule for rule in rules # Append a row for a new rule. Return the newly-added element. appendRule: (rule) -> @@ -333,23 +335,16 @@ document.addEventListener "DOMContentLoaded", -> # # Backup and restore. "?" is for the tests." DomUtils?.documentReady -> - $("backupButton").addEventListener "click", -> - document.activeElement?.blur() + populateBackupLinkUrl = -> backup = settingsVersion: bgSettings.get "settingsVersion" for option in Option.all backup[option.field] = option.readValueFromElement() # Create the blob in the background page so it isn't garbage collected when the page closes in FF. bgWin = chrome.extension.getBackgroundPage() blob = new bgWin.Blob [ JSON.stringify backup, null, 2 ] - url = bgWin.URL.createObjectURL blob - a = $ "backupLink" - a.href = url - if Utils.isFirefox() - # On Firefox, the user has to click the link manually. - a.style.display = "" - a.textContent = "Click to download backup" - else - a.click() + $("backupLink").href = bgWin.URL.createObjectURL blob + + $("backupLink").addEventListener "mousedown", populateBackupLinkUrl, true $("chooseFile").addEventListener "change", (event) -> document.activeElement?.blur() diff --git a/pages/options.css b/pages/options.css index 5e2a3dfc..dab342a3 100644 --- a/pages/options.css +++ b/pages/options.css @@ -231,3 +231,6 @@ input.pattern, input.passKeys, .exclusionHeaderText { white-space: nowrap; width: 110px; } +#backupLink { + cursor: pointer; +} diff --git a/pages/options.html b/pages/options.html index 2e170cb3..f14ac3df 100644 --- a/pages/options.html +++ b/pages/options.html @@ -326,8 +326,7 @@ b: http://b.com/?q=%s description <div class="example"> </div> </div> - <input id="backupButton" type="button" value="Create Backup" /> - <a id="backupLink" style="display: none" download="vimium-options.json"></a> + <a id="backupLink" download="vimium-options.json">Click to download backup</a> </td> </tr> <tr> |
