Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 6c02cf8

Browse files
authored
✨ Allow the user to reposition the sidebar (#222)
1 parent b490a07 commit 6c02cf8

File tree

1 file changed

+45
-15
lines changed

1 file changed

+45
-15
lines changed

src/browser/base/content/browser-sidebar-js.patch

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/browser/base/content/browser-sidebar.js b/browser/base/content/browser-sidebar.js
2-
index c5ac301416d2d820ba95e21c0ce1fe305e63b554..fa3cd3184cce8759c834fa0fadc645afde674dd8 100644
2+
index c5ac301416d2d820ba95e21c0ce1fe305e63b554..a38040e1cba3de0e383cda4b5147b3cc6fdf86ad 100644
33
--- a/browser/base/content/browser-sidebar.js
44
+++ b/browser/base/content/browser-sidebar.js
55
@@ -11,6 +11,10 @@ var SidebarUI = {
@@ -92,7 +92,7 @@ index c5ac301416d2d820ba95e21c0ce1fe305e63b554..fa3cd3184cce8759c834fa0fadc645af
9292
_box: null,
9393
// The constructor of this label accesses the browser element due to the
9494
// control="sidebar" attribute, so avoid getting this label during startup.
95-
@@ -76,8 +116,13 @@ var SidebarUI = {
95+
@@ -76,8 +116,15 @@ var SidebarUI = {
9696
}
9797
return (this.__title = document.getElementById("sidebar-title"));
9898
},
@@ -101,17 +101,20 @@ index c5ac301416d2d820ba95e21c0ce1fe305e63b554..fa3cd3184cce8759c834fa0fadc645af
101101
_icon: null,
102102
+ _sidebarIcons: null,
103103
+ _sidebarIconsBottom: null,
104+
+ /** @type {HTMLDivElement?} */
105+
+ _sidebarTabs: null,
104106
+ /** @type {string[]} */
105107
+ loadedSidebars: null,
106108
_reversePositionButton: null,
107109
_switcherPanel: null,
108110
_switcherTarget: null,
109-
@@ -110,15 +155,59 @@ var SidebarUI = {
111+
@@ -110,15 +157,60 @@ var SidebarUI = {
110112
this._switcherTarget = document.getElementById("sidebar-switcher-target");
111113
this._switcherArrow = document.getElementById("sidebar-switcher-arrow");
112114

113115
+ this._sidebarIcons = document.getElementById("sidebar-icons");
114116
+ this._sidebarIconsBottom = document.getElementById("sidebar-icons-bottom");
117+
+ this._sidebarTabs = document.getElementById("sidebar-container")
115118
+
116119
this._switcherTarget.addEventListener("command", () => {
117120
this.toggleSwitcherPanel();
@@ -166,7 +169,7 @@ index c5ac301416d2d820ba95e21c0ce1fe305e63b554..fa3cd3184cce8759c834fa0fadc645af
166169
},
167170

168171
uninit() {
169-
@@ -127,7 +216,10 @@ var SidebarUI = {
172+
@@ -127,7 +219,10 @@ var SidebarUI = {
170173
let enumerator = Services.wm.getEnumerator("navigator:browser");
171174
if (!enumerator.hasMoreElements()) {
172175
let xulStore = Services.xulStore;
@@ -178,7 +181,7 @@ index c5ac301416d2d820ba95e21c0ce1fe305e63b554..fa3cd3184cce8759c834fa0fadc645af
178181

179182
if (this._box.hasAttribute("positionend")) {
180183
xulStore.persist(this._box, "positionend");
181-
@@ -148,6 +240,12 @@ var SidebarUI = {
184+
@@ -148,6 +243,12 @@ var SidebarUI = {
182185
xulStore.persist(this._title, "value");
183186
}
184187

@@ -191,7 +194,7 @@ index c5ac301416d2d820ba95e21c0ce1fe305e63b554..fa3cd3184cce8759c834fa0fadc645af
191194
Services.obs.removeObserver(this, "intl:app-locales-changed");
192195

193196
if (this._observer) {
194-
@@ -159,17 +257,62 @@ var SidebarUI = {
197+
@@ -159,17 +260,62 @@ var SidebarUI = {
195198
/**
196199
* The handler for Services.obs.addObserver.
197200
**/
@@ -258,7 +261,7 @@ index c5ac301416d2d820ba95e21c0ce1fe305e63b554..fa3cd3184cce8759c834fa0fadc645af
258261
}
259262
}
260263
},
261-
@@ -286,6 +413,9 @@ var SidebarUI = {
264+
@@ -286,17 +432,31 @@ var SidebarUI = {
262265
// First reset all ordinals to match DOM ordering.
263266
let browser = document.getElementById("browser");
264267
[...browser.children].forEach((node, i) => {
@@ -268,7 +271,34 @@ index c5ac301416d2d820ba95e21c0ce1fe305e63b554..fa3cd3184cce8759c834fa0fadc645af
268271
node.style.MozBoxOrdinalGroup = i + 1;
269272
});
270273

271-
@@ -485,6 +615,9 @@ var SidebarUI = {
274+
if (!this._positionStart) {
275+
- // DOM ordering is: | sidebar-box | splitter | appcontent |
276+
- // Want to display as: | appcontent | splitter | sidebar-box |
277+
- // So we just swap box and appcontent ordering
278+
+ // DOM ordering is: | sidebar-container | sidebar-box | splitter | appcontent |
279+
+ // Want to display as: | appcontent | splitter | sidebar-box | sidebar-container |
280+
+ // So we just swap
281+
+ // - sidebar-container and appcontent
282+
+ // - splitter and sidebar-box
283+
+
284+
+ // sidebar-container and appcontent
285+
let appcontent = document.getElementById("appcontent");
286+
- let boxOrdinal = this._box.style.MozBoxOrdinalGroup;
287+
- this._box.style.MozBoxOrdinalGroup = appcontent.style.MozBoxOrdinalGroup;
288+
+ let boxOrdinal = this._sidebarTabs.style.MozBoxOrdinalGroup;
289+
+ this._sidebarTabs.style.MozBoxOrdinalGroup = appcontent.style.MozBoxOrdinalGroup;
290+
appcontent.style.MozBoxOrdinalGroup = boxOrdinal;
291+
+
292+
+ // splitter and sidebar-box
293+
+ const splitterBoxOrdinal = this._splitter.style.MozBoxOrdinalGroup;
294+
+ this._splitter.style.MozBoxOrdinalGroup = this._box.style.MozBoxOrdinalGroup
295+
+ this._box.style.MozBoxOrdinalGroup = splitterBoxOrdinal
296+
+
297+
+
298+
// Indicate we've switched ordering to the box
299+
this._box.setAttribute("positionend", true);
300+
} else {
301+
@@ -485,6 +645,9 @@ var SidebarUI = {
272302
},
273303

274304
_loadSidebarExtension(commandID) {
@@ -278,15 +308,15 @@ index c5ac301416d2d820ba95e21c0ce1fe305e63b554..fa3cd3184cce8759c834fa0fadc645af
278308
let sidebar = this.sidebars.get(commandID);
279309
let { extensionId } = sidebar;
280310
if (extensionId) {
281-
@@ -523,6 +656,7 @@ var SidebarUI = {
311+
@@ -523,6 +686,7 @@ var SidebarUI = {
282312
}
283313

284314
this._fireFocusedEvent();
285315
+ this.loadedSidebars.push(commandID);
286316
return true;
287317
});
288318
},
289-
@@ -546,10 +680,28 @@ var SidebarUI = {
319+
@@ -546,10 +710,28 @@ var SidebarUI = {
290320
}
291321
return this._show(commandID).then(() => {
292322
this._loadSidebarExtension(commandID);
@@ -315,7 +345,7 @@ index c5ac301416d2d820ba95e21c0ce1fe305e63b554..fa3cd3184cce8759c834fa0fadc645af
315345
/**
316346
* Implementation for show. Also used internally for sidebars that are shown
317347
* when a window is opened and we don't want to ping telemetry.
318-
@@ -559,6 +711,29 @@ var SidebarUI = {
348+
@@ -559,6 +741,29 @@ var SidebarUI = {
319349
*/
320350
_show(commandID) {
321351
return new Promise(resolve => {
@@ -345,7 +375,7 @@ index c5ac301416d2d820ba95e21c0ce1fe305e63b554..fa3cd3184cce8759c834fa0fadc645af
345375
this.selectMenuItem(commandID);
346376

347377
this._box.hidden = this._splitter.hidden = false;
348-
@@ -570,13 +745,21 @@ var SidebarUI = {
378+
@@ -570,13 +775,21 @@ var SidebarUI = {
349379
this._box.setAttribute("sidebarcommand", commandID);
350380
this.lastOpenedId = commandID;
351381

@@ -369,7 +399,7 @@ index c5ac301416d2d820ba95e21c0ce1fe305e63b554..fa3cd3184cce8759c834fa0fadc645af
369399
this.browser.addEventListener(
370400
"load",
371401
event => {
372-
@@ -615,22 +798,46 @@ var SidebarUI = {
402+
@@ -615,22 +828,46 @@ var SidebarUI = {
373403

374404
this.selectMenuItem("");
375405

@@ -423,7 +453,7 @@ index c5ac301416d2d820ba95e21c0ce1fe305e63b554..fa3cd3184cce8759c834fa0fadc645af
423453
},
424454

425455
/**
426-
@@ -638,25 +845,121 @@ var SidebarUI = {
456+
@@ -638,25 +875,121 @@ var SidebarUI = {
427457
* none if the argument is an empty string.
428458
*/
429459
selectMenuItem(commandID) {
@@ -478,7 +508,7 @@ index c5ac301416d2d820ba95e21c0ce1fe305e63b554..fa3cd3184cce8759c834fa0fadc645af
478508
+ * @param {boolean} visible Sets the sidebar to be visible or not visible
479509
+ */
480510
+ setSidebarVisibility(visible) {
481-
+ const sidebarContainer = document.getElementById("sidebar-container");
511+
+ const sidebarContainer = this._sidebarTabs
482512
+
483513
+ if (visible) {
484514
+ sidebarContainer.style.display = "flex";

0 commit comments

Comments
 (0)