diff options
| author | mrmr1993 | 2017-10-28 16:42:51 +0100 |
|---|---|---|
| committer | Stephen Blott | 2017-10-29 05:50:14 +0000 |
| commit | b1f6da21a882f84965de73eea175475f5d8f7b37 (patch) | |
| tree | 0d6d4c3a6731c0774047b84c8cf13772aa2524c9 /pages | |
| parent | 720474858f2f52ad62934b43c346b49165c461ac (diff) | |
| download | vimium-b1f6da21a882f84965de73eea175475f5d8f7b37.tar.bz2 | |
FF: Show backup download link in the options page
Firefox doesn't seem to respect the |download| attribute for links, and
it garbage collects our blob URL when we navigate away from the options
page (to the object URL). We work around this by simply showing the
download link in Firefox.
Disappointingly, the user needs to right-click the link and choose to
download from the context menu.
Behaviour in Chrome is unchanged, except that the download link is now
visible.
Diffstat (limited to 'pages')
| -rw-r--r-- | pages/options.coffee | 15 | ||||
| -rw-r--r-- | pages/options.html | 1 |
2 files changed, 8 insertions, 8 deletions
diff --git a/pages/options.coffee b/pages/options.coffee index 0038c3f9..416b3ea7 100644 --- a/pages/options.coffee +++ b/pages/options.coffee @@ -333,15 +333,14 @@ DomUtils?.documentReady -> backup = {} for option in Option.all backup[option.field] = option.readValueFromElement() - blob = new Blob [ JSON.stringify backup ] - url = window.URL.createObjectURL blob - a = document.createElement "a" - document.body.appendChild a - a.style = "display: none" + # 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 ] + url = bgWin.URL.createObjectURL blob + a = $ "backupLink" a.href = url - a.download = "vimium-options-#{new Date().toISOString().split("T")[0]}.json" - a.click() - document.body.removeChild a + a.style.display = "" + a.click() unless Utils.isFirefox() $("chooseFile").addEventListener "change", (event) -> document.activeElement?.blur() diff --git a/pages/options.html b/pages/options.html index 943fc95c..79cb0999 100644 --- a/pages/options.html +++ b/pages/options.html @@ -327,6 +327,7 @@ b: http://b.com/?q=%s description </div> </div> <input id="backupButton" type="button" value="Create Backup" /> + <a id="backupLink" style="display: none" download="vimium-options.json">Download Backup</span> </td> </tr> <tr> |
