diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 3431b85d5..b9d525466 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -47,6 +47,14 @@ "message":"Click: disable\/enable uBlock₀ for this site.\n\nCtrl+click: disable uBlock₀ only on this page.", "description":"English: Click: disable\/enable uBlock₀ for this site.\n\nCtrl+click: disable uBlock₀ only on this page." }, + "popupPowerSwitchOffInfo":{ + "message":"Click to disable uBO for this site.\n\nCtrl+click to disable uBO only on this page.", + "description":"Message to be read by screen readers" + }, + "popupPowerSwitchOnInfo":{ + "message":"Click to enable uBO for this site.", + "description":"Message to be read by screen readers" + }, "popupBlockedRequestPrompt":{ "message":"requests blocked", "description":"English: requests blocked" diff --git a/src/js/popup.js b/src/js/popup.js index f5fb819ed..5f2b0db53 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -401,25 +401,26 @@ var renderPrivacyExposure = function() { // Assume everything has to be done incrementally. var renderPopup = function() { + var elem, text; + if ( popupData.tabTitle ) { document.title = popupData.appName + ' - ' + popupData.tabTitle; } - uDom('body') - .toggleClass('advancedUser', popupData.advancedUserEnabled) - .toggleClass( - 'off', - (popupData.pageURL === '') || - (!popupData.netFilteringSwitch) || - (popupData.pageHostname === 'behind-the-scene' && !popupData.advancedUserEnabled) - ); + elem = document.body; + elem.classList.toggle('advancedUser', popupData.advancedUserEnabled); + elem.classList.toggle( + 'off', + popupData.pageURL === '' || + !popupData.netFilteringSwitch || + popupData.pageHostname === 'behind-the-scene' && !popupData.advancedUserEnabled + ); // If you think the `=== true` is pointless, you are mistaken uDom.nodeFromId('gotoPick').classList.toggle('enabled', popupData.canElementPicker === true); uDom.nodeFromId('gotoZap').classList.toggle('enabled', popupData.canElementPicker === true); - var text, - blocked = popupData.pageBlockedRequestCount, + var blocked = popupData.pageBlockedRequestCount, total = popupData.pageAllowedRequestCount + blocked; if ( total === 0 ) { text = formatNumber(0); @@ -486,14 +487,37 @@ var renderPopup = function() { } uDom.nodeFromId('panes').classList.toggle('dfEnabled', dfPaneVisible); - uDom('#firewallContainer') - .toggleClass('minimized', popupData.firewallPaneMinimized) - .toggleClass('colorBlind', popupData.colorBlindFriendly); + + elem = uDom.nodeFromId('firewallContainer'); + elem.classList.toggle('minimized', popupData.firewallPaneMinimized); + elem.classList.toggle('colorBlind', popupData.colorBlindFriendly); // Build dynamic filtering pane only if in use if ( dfPaneVisible ) { buildAllFirewallRows(); } + + renderTooltips(); +}; + +/******************************************************************************/ + +// https://github.com/gorhill/uBlock/issues/2889 +// Use tooltip for ARIA purpose. + +var renderTooltips = function() { + var elem = uDom.nodeFromId('switch'), + off = document.body.classList.contains('off'), + text; + if ( off ) { + text = vAPI.i18n('popupPowerSwitchOnInfo'); + elem.setAttribute('aria-label', text); + elem.setAttribute('data-tip', text); + } else { + text = vAPI.i18n('popupPowerSwitchOffInfo'); + elem.setAttribute('aria-label', text); + elem.setAttribute('data-tip', text); + } }; /******************************************************************************/ @@ -580,10 +604,11 @@ messaging.addChannelListener('popup', onPopupMessage); /******************************************************************************/ var toggleNetFilteringSwitch = function(ev) { - if ( !popupData || !popupData.pageURL ) { - return; - } - if ( popupData.pageHostname === 'behind-the-scene' && !popupData.advancedUserEnabled ) { + if ( !popupData || !popupData.pageURL ) { return; } + if ( + popupData.pageHostname === 'behind-the-scene' && + !popupData.advancedUserEnabled + ) { return; } messaging.send( @@ -596,7 +621,7 @@ var toggleNetFilteringSwitch = function(ev) { tabId: popupData.tabId } ); - + renderTooltips(); hashFromPopupData(); }; diff --git a/src/popup.html b/src/popup.html index ea78d2cd6..04adfca3f 100644 --- a/src/popup.html +++ b/src/popup.html @@ -13,7 +13,7 @@    
-

+