gorhill 2017-11-07 16:38:26 -05:00
parent 9d86ab0af9
commit e7294a46d4
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
3 changed files with 52 additions and 19 deletions

View File

@ -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"

View File

@ -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();
};

View File

@ -13,7 +13,7 @@
<span id="appinfo"><span id="appname">&nbsp;</span> <span id="version">&nbsp;</span></span>
<div id="panes">
<div class="tooltipContainer">
<p id="switch" data-i18n-tip="popupPowerSwitchInfo" data-tip-position="under"><span class="fa">&#xf011;</span></p>
<p id="switch" data-tip-position="under"><span class="fa">&#xf011;</span></p>
<p id="basicTools">
<span id="gotoZap" class="fa tool" data-i18n-tip="popupTipZapper" data-tip-position="under">&#xf0e7;</span>
<span id="gotoPick" class="fa tool" data-i18n-tip="popupTipPicker" data-tip-position="under">&#xf1fb;</span>