From f40a0e697c6d4f88bc4ccd410951339f86a609d6 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 29 Oct 2017 09:11:17 +0000 Subject: Fix backup link for FF and Chrome. This makes the UI for generating an options backup the same for FF and Chrome. We populate the *Backup* link on `mousedown`. --- pages/options.coffee | 11 +++-------- pages/options.css | 3 +++ pages/options.html | 3 +-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/pages/options.coffee b/pages/options.coffee index a6916d43..83c96339 100644 --- a/pages/options.coffee +++ b/pages/options.coffee @@ -333,8 +333,7 @@ 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() @@ -344,12 +343,8 @@ DomUtils?.documentReady -> 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").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
- - + Click to download backup -- cgit v1.2.3 From 75c229d5bda9529baee1993c74ac16c777f68000 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 29 Oct 2017 09:22:26 +0000 Subject: Tidy up backup code. This can be shorter now. --- pages/options.coffee | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pages/options.coffee b/pages/options.coffee index 83c96339..65838203 100644 --- a/pages/options.coffee +++ b/pages/options.coffee @@ -340,9 +340,7 @@ DomUtils?.documentReady -> # 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 + $("backupLink").href = bgWin.URL.createObjectURL blob $("backupLink").addEventListener "mousedown", populateBackupLinkUrl, true -- cgit v1.2.3 From a3c120bb7d2ca91a75f0d5125942f64dfad7890f Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 29 Oct 2017 10:18:33 +0000 Subject: Fix restore for exclusion rules. In the case of exclusion rules, we first have to remove existing rules; otherwise, the restored rules are *appended* to the existing rules. --- pages/options.coffee | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pages/options.coffee b/pages/options.coffee index 65838203..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) -> -- cgit v1.2.3