From 35050a40d1336f162041c328f4f589fe1adebf0e Mon Sep 17 00:00:00 2001 From: papush Date: Sun, 29 Aug 2021 14:35:04 +0200 Subject: add a refreshUI method to RedirectorOverlay to update the UI state --- chrome/js/browserOverlay.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'chrome/js/browserOverlay.js') diff --git a/chrome/js/browserOverlay.js b/chrome/js/browserOverlay.js index 39066b8..2767d7b 100644 --- a/chrome/js/browserOverlay.js +++ b/chrome/js/browserOverlay.js @@ -38,15 +38,8 @@ var RedirectorOverlay = { changedPrefs : function(prefs) { var button = document.getElementById('redirector-button'); - - if (prefs.enabled) { - button.setAttribute('disabled', true); - } else { - button.removeAttribute('disabled'); - } - - // document.getElementById('redirector-status').hidden = !prefs.showStatusBarIcon; document.getElementById('redirector-context').hidden = !prefs.showContextMenu; + this.refreshUI(); }, showContextMenu : function(event) { @@ -70,8 +63,7 @@ var RedirectorOverlay = { this.openSettings(); }, - toggleEnabled: function(event) { - this.prefs.enabled = !this.prefs.enabled; + refreshUI: function() { let button = document.getElementById("redirector-button"); let item = document.getElementById("redirector-enabled-item"); if (this.prefs.enabled) { @@ -83,6 +75,11 @@ var RedirectorOverlay = { } }, + toggleEnabled: function(event) { + this.prefs.enabled = !this.prefs.enabled; + this.refreshUI(); + }, + openSettings : function() { gBrowser.selectedTab = gBrowser.addTab("chrome://redirector/content/redirector.html"); }, -- cgit v1.2.3-70-g09d2