summaryrefslogtreecommitdiffstats
path: root/src/js/popup-fenix.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/popup-fenix.js')
-rw-r--r--src/js/popup-fenix.js69
1 files changed, 41 insertions, 28 deletions
diff --git a/src/js/popup-fenix.js b/src/js/popup-fenix.js
index b44b923..9f2af08 100644
--- a/src/js/popup-fenix.js
+++ b/src/js/popup-fenix.js
@@ -70,6 +70,9 @@ let cachedPopupHash = '';
const reCyrillicNonAmbiguous = /[\u0400-\u042b\u042d-\u042f\u0431\u0432\u0434\u0436-\u043d\u0442\u0444\u0446-\u0449\u044b-\u0454\u0457\u0459-\u0460\u0462-\u0474\u0476-\u04ba\u04bc\u04be-\u04ce\u04d0-\u0500\u0502-\u051a\u051c\u051e-\u052f]/;
const reCyrillicAmbiguous = /[\u042c\u0430\u0433\u0435\u043e\u043f\u0440\u0441\u0443\u0445\u044a\u0455\u0456\u0458\u0461\u0475\u04bb\u04bd\u04cf\u0501\u051b\u051d]/;
+const hasOwnProperty = (o, p) =>
+ Object.prototype.hasOwnProperty.call(o, p);
+
/******************************************************************************/
const cachePopupData = function(data) {
@@ -88,7 +91,7 @@ const cachePopupData = function(data) {
return popupData;
}
for ( const hostname in hostnameDict ) {
- if ( hostnameDict.hasOwnProperty(hostname) === false ) { continue; }
+ if ( hasOwnProperty(hostnameDict, hostname) === false ) { continue; }
let domain = hostnameDict[hostname].domain;
let prefix = hostname.slice(0, 0 - domain.length - 1);
// Prefix with space char for 1st-party hostnames: this ensure these
@@ -160,7 +163,7 @@ const formatNumber = function(count) {
});
if (
intl.resolvedOptions instanceof Function &&
- intl.resolvedOptions().hasOwnProperty('notation')
+ hasOwnProperty(intl.resolvedOptions(), 'notation')
) {
intlNumberFormat = intl;
}
@@ -545,7 +548,7 @@ const renderPrivacyExposure = function() {
if ( des === '*' || desHostnameDone.has(des) ) { continue; }
const hnDetails = hostnameDict[des];
const { domain, counts } = hnDetails;
- if ( allDomains.hasOwnProperty(domain) === false ) {
+ if ( hasOwnProperty(allDomains, domain) === false ) {
allDomains[domain] = false;
allDomainCount += 1;
}
@@ -614,11 +617,11 @@ const renderPopup = function() {
}
}
- dom.cl.toggle(
- '#basicTools',
- 'canPick',
- popupData.canElementPicker === true && isFiltering
- );
+ const canPick = popupData.canElementPicker && isFiltering;
+
+ dom.cl.toggle('#gotoZap', 'canPick', canPick);
+ dom.cl.toggle('#gotoPick', 'canPick', canPick && popupData.userFiltersAreEnabled);
+ dom.cl.toggle('#gotoReport', 'canPick', canPick);
let blocked, total;
if ( popupData.pageCounts !== undefined ) {
@@ -675,7 +678,7 @@ const renderPopup = function() {
total ? Math.min(total, 99).toLocaleString() : ''
);
- // Unprocesseed request(s) warning
+ // Unprocessed request(s) warning
dom.cl.toggle(dom.root, 'warn', popupData.hasUnprocessedRequest === true);
dom.cl.toggle(dom.html, 'colorBlind', popupData.colorBlindFriendly === true);
@@ -802,7 +805,7 @@ let renderOnce = function() {
dom.attr('#firewall [title][data-src]', 'title', null);
}
- // This must be done the firewall is populated
+ // This must be done when the firewall is populated
if ( popupData.popupPanelHeightMode === 1 ) {
dom.cl.add(dom.body, 'vMin');
}
@@ -1462,6 +1465,33 @@ const getPopupData = async function(tabId, first = false) {
}
};
+ const setOrientation = async ( ) => {
+ if ( dom.cl.has(dom.root, 'mobile') ) {
+ dom.cl.remove(dom.root, 'desktop');
+ dom.cl.add(dom.root, 'portrait');
+ return;
+ }
+ if ( selfURL.searchParams.get('portrait') !== null ) {
+ dom.cl.remove(dom.root, 'desktop');
+ dom.cl.add(dom.root, 'portrait');
+ return;
+ }
+ if ( popupData.popupPanelOrientation === 'landscape' ) { return; }
+ if ( popupData.popupPanelOrientation === 'portrait' ) {
+ dom.cl.remove(dom.root, 'desktop');
+ dom.cl.add(dom.root, 'portrait');
+ return;
+ }
+ if ( dom.cl.has(dom.root, 'desktop') === false ) { return; }
+ await nextFrames(8);
+ const main = qs$('#main');
+ const firewall = qs$('#firewall');
+ const minWidth = (main.offsetWidth + firewall.offsetWidth) / 1.1;
+ if ( window.innerWidth < minWidth ) {
+ dom.cl.add(dom.root, 'portrait');
+ }
+ };
+
// The purpose of the following code is to reset to a vertical layout
// should the viewport not be enough wide to accommodate the horizontal
// layout.
@@ -1474,24 +1504,7 @@ const getPopupData = async function(tabId, first = false) {
// Use a tolerance proportional to the sum of the width of the panes
// when testing against viewport width.
const checkViewport = async function() {
- if (
- dom.cl.has(dom.root, 'mobile') ||
- selfURL.searchParams.get('portrait')
- ) {
- dom.cl.add(dom.root, 'portrait');
- dom.cl.remove(dom.root, 'desktop');
- } else if ( dom.cl.has(dom.root, 'desktop') ) {
- await nextFrames(8);
- const main = qs$('#main');
- const firewall = qs$('#firewall');
- const minWidth = (main.offsetWidth + firewall.offsetWidth) / 1.1;
- if (
- selfURL.searchParams.get('portrait') ||
- window.innerWidth < minWidth
- ) {
- dom.cl.add(dom.root, 'portrait');
- }
- }
+ await setOrientation();
if ( dom.cl.has(dom.root, 'portrait') ) {
const panes = qs$('#panes');
const sticky = qs$('#sticky');