@@ -58,9 +58,6 @@ httpsEverywhere.toolbarButton = {
5858
5959 var tb = httpsEverywhere . toolbarButton ;
6060
61- // make sure icon is proper color during init
62- tb . changeIcon ( ) ;
63-
6461 // make sure the checkbox for showing counter is properly set
6562 var showCounter = tb . shouldShowCounter ( ) ;
6663 var counterItem = document . getElementById ( 'https-everywhere-counter-item' ) ;
@@ -73,8 +70,9 @@ httpsEverywhere.toolbarButton = {
7370 httpNowhereItem . setAttribute ( 'checked' , showHttpNowhere ? 'true' : 'false' ) ;
7471 toolbarbutton . setAttribute ( 'http_nowhere' ,
7572 showHttpNowhere ? 'true' : 'false' ) ;
76- var enabled = HTTPSEverywhere . prefs . getBoolPref ( "globalEnabled" ) ;
77- httpNowhereItem . setAttribute ( 'disabled' , enabled ? 'false' : 'true' ) ;
73+
74+ // make sure UI is set depending on whether HTTPS-E is enabled
75+ toggleEnabledUI ( ) ;
7876
7977 // show ruleset counter when a tab is changed
8078 tb . updateRulesetsApplied ( ) ;
@@ -134,20 +132,6 @@ httpsEverywhere.toolbarButton = {
134132 gBrowser . removeEventListener ( "DOMContentLoaded" , tb . handleShowHint , true ) ;
135133 } ,
136134
137- /**
138- * Changes HTTPS Everywhere toolbar icon based on whether HTTPS Everywhere
139- * is enabled or disabled.
140- */
141- changeIcon : function ( ) {
142- var enabled = HTTPSEverywhere . prefs . getBoolPref ( "globalEnabled" ) ;
143-
144- var toolbarbutton = document . getElementById ( 'https-everywhere-button' ) ;
145- if ( enabled ) {
146- toolbarbutton . setAttribute ( 'status' , 'enabled' ) ;
147- } else {
148- toolbarbutton . setAttribute ( 'status' , 'disabled' ) ;
149- }
150- } ,
151135
152136 /**
153137 * Update the rulesets applied counter for the current tab.
@@ -355,15 +339,21 @@ function reload_window() {
355339
356340function toggleEnabledState ( ) {
357341 HTTPSEverywhere . toggleEnabledState ( ) ;
358- reload_window ( ) ;
342+ reload_window ( ) ;
343+ toggleEnabledUI ( ) ;
344+ }
359345
360- // Disable/enable toggling HTTP Nowhere mode
361- var httpNowhereItem = document . getElementById ( 'http-nowhere-item' ) ;
346+ function toggleEnabledUI ( ) {
347+ // Add/remove menu items depending on whether HTTPS-E is enabled
348+ var items = document . querySelectorAll ( ".hide-on-disable" ) ;
362349 var enabled = HTTPSEverywhere . prefs . getBoolPref ( "globalEnabled" ) ;
363- httpNowhereItem . setAttribute ( 'disabled' , enabled ? 'false' : 'true' ) ;
350+ for ( let i = 0 ; i < items . length ; i ++ ) {
351+ items [ i ] . hidden = ! enabled ;
352+ }
364353
365354 // Change icon depending on enabled state
366- httpsEverywhere . toolbarButton . changeIcon ( ) ;
355+ var toolbarbutton = document . getElementById ( 'https-everywhere-button' ) ;
356+ toolbarbutton . setAttribute ( 'status' , enabled ? 'enabled' : 'disabled' ) ;
367357}
368358
369359function open_in_tab ( url ) {
0 commit comments