Skip to content

Commit

Permalink
autoHideNavbarSupport.uc.js:
Browse files Browse the repository at this point in the history
handle the possibility that multiple popups are open simultaneously.
this is usually only the case while using prevent autohide pref
(i.e. my toolbox button script).
  • Loading branch information
aminomancer committed Aug 20, 2022
1 parent a75323f commit 365741c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
17 changes: 11 additions & 6 deletions JS/autoHideNavbarSupport.uc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name Auto-hide Navbar Support
// @version 1.2.0
// @version 1.2.1
// @author aminomancer
// @homepage https://github.com/aminomancer
// @description In fullscreen, the navbar hides automatically when you're not
Expand All @@ -20,10 +20,13 @@
// ==/UserScript==

class AutoHideHandler {
prefs = {
autohide: "browser.fullscreen.autohide",
};
constructor() {
let autohidePref = "browser.fullscreen.autohide";
this.observe(Services.prefs, "nsPref:read", autohidePref);
Services.prefs.addObserver(autohidePref, this);
this.popups = new Set();
this.observe(Services.prefs, "nsPref:read", this.prefs.autohide);
Services.prefs.addObserver(this.prefs.autohide, this);
for (let ev of ["popupshowing", "popuphiding"]) {
this.mainPopupSet.addEventListener(ev, this, true);
gNavToolbox.addEventListener(ev, this, true);
Expand Down Expand Up @@ -73,7 +76,7 @@ class AutoHideHandler {
}
_onPrefChanged(sub, pref) {
switch (pref) {
case "browser.fullscreen.autohide":
case this.prefs.autohide:
let value = this.getPref(sub, pref, true);
if (value) document.documentElement.setAttribute("fullscreen-autohide", value);
else document.documentElement.removeAttribute("fullscreen-autohide");
Expand Down Expand Up @@ -111,13 +114,15 @@ class AutoHideHandler {
return;
switch (event.type) {
case "popupshowing":
this.popups.add(targ);
this.navBlock.setAttribute("popup-status", true);
break;
case "popuphiding":
if (popNode?.closest("panel") || popNode?.closest("menupopup")) return;
let panel = targ.closest("panel");
if (targ !== panel && panel?.getAttribute("panelopen")) return;
this.navBlock.removeAttribute("popup-status");
this.popups.delete(targ);
if (!this.popups.size) this.navBlock.removeAttribute("popup-status");
break;
}
}
Expand Down
3 changes: 2 additions & 1 deletion uc-app-menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,8 @@ panel .toolbaritem-combined-buttons {
}

#appMenu-zoom-controls #appMenu-zoomReset-button2[disabled] {
opacity: 0.6 !important;
background-color: transparent !important;
border-color: transparent !important;
}

#appMenu-zoom-controls #appMenu-zoomReset-button2 .toolbarbutton-text {
Expand Down

0 comments on commit 365741c

Please sign in to comment.