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

Commit bbcb24c

Browse files
authored
🔀 Initial vertical tabs prototype (#167)
Initial vertical tabs prototype
2 parents 92dade3 + 093c733 commit bbcb24c

File tree

15 files changed

+562
-23
lines changed

15 files changed

+562
-23
lines changed

‎package.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
"license": "MPL-2.0",
88
"private": true,
99
"dependencies": {
10-
"gluon-build": "^1.0.0-rc.2"
10+
"gluon-build": "^1.0.0-rc.4"
1111
},
1212
"scripts": {
1313
"build": "gluon build",
1414
"build:ui": "gluon build --ui",
1515
"bs": "yarn build && yarn start",
1616
"bus": "yarn build:ui && yarn start",
17-
"start": "gluon run",
17+
"start": "yarn clearStartupCache && gluon run",
1818
"export": "gluon export-file",
1919
"imp": "gluon import",
2020
"clearProfile": "rm -rf engine/obj-x86_64-pc-linux-gnu/tmp/profile-default",
21+
"clearStartupCache": "rm -rf engine/obj-x86_64-pc-linux-gnu/tmp/profile-default/startupCache",
2122
"download": "gluon download",
2223
"package": "gluon package",
2324
"ff-version": "gluon ff-version",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
2+
index a9d4fc4abe1d3b5d5213d3afd90fd0128ee0d032..f2eb4888521deefa7da2b7666ec6012af2a27a4e 100644
3+
--- a/browser/base/content/browser.js
4+
+++ b/browser/base/content/browser.js
5+
@@ -1841,6 +1841,7 @@ var gBrowserInit = {
6+
gPrivateBrowsingUI.init();
7+
BrowserSearch.init();
8+
BrowserPageActions.init();
9+
+ VerticalTabs.init();
10+
if (gToolbarKeyNavEnabled) {
11+
ToolbarKeyboardNavigator.init();
12+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
// @ts-check
5+
6+
const VERTICAL_TABS_POSITION = 'pulse.tabs.vertical'
7+
8+
var VerticalTabs = {
9+
/**
10+
* @return {Boolean} true if the vertical tabs feature is enabled.
11+
*/
12+
get verticalTabsEnabled() {
13+
return Services.prefs.getBoolPref(VERTICAL_TABS_POSITION, false)
14+
},
15+
16+
/**
17+
* @return {HTMLElement?}
18+
*/
19+
get tabsToolbar() {
20+
return document.getElementById('TabsToolbar')
21+
},
22+
23+
/**
24+
* @return {HTMLElement?}
25+
*/
26+
get titlebarContainer() {
27+
return document.getElementById('titlebar')
28+
},
29+
30+
/**
31+
* @return {HTMLElement?}
32+
*/
33+
get browserContainer() {
34+
return document.getElementById('browser')
35+
},
36+
37+
/** @type {HTMLElement?} */
38+
arrowScrollbox: null,
39+
/** @type {HTMLElement?} */
40+
tabBrowserTabs: null,
41+
42+
_initialized: false,
43+
44+
init() {
45+
if (this._initialized) {
46+
return
47+
}
48+
49+
this.arrowScrollbox = document.getElementById('tabbrowser-arrowscrollbox')
50+
this.tabBrowserTabs = document.getElementById('tabbrowser-tabs')
51+
52+
Services.prefs.addObserver(VERTICAL_TABS_POSITION, this)
53+
54+
if (this.verticalTabsEnabled) {
55+
this.enableVerticalTabs()
56+
}
57+
58+
this._initialized = true
59+
},
60+
61+
enableVerticalTabs() {
62+
this.browserContainer?.prepend(this.tabsToolbar || '')
63+
64+
this.arrowScrollbox?.setAttribute('orient', 'vertical')
65+
this.tabBrowserTabs?.setAttribute('orient', 'vertical')
66+
67+
document
68+
.getElementById('navigator-toolbox-background')
69+
?.setAttribute('verticaltabs', 'true')
70+
document
71+
.querySelector('#TabsToolbar .toolbar-items')
72+
?.setAttribute('align', 'start')
73+
},
74+
75+
disableVerticalTabs() {
76+
this.titlebarContainer?.prepend(this.tabsToolbar || '')
77+
78+
this.arrowScrollbox?.setAttribute('orient', 'horizontal')
79+
this.tabBrowserTabs?.setAttribute('orient', 'horizontal')
80+
81+
document
82+
.getElementById('navigator-toolbox-background')
83+
?.removeAttribute('verticaltabs')
84+
document
85+
.querySelector('#TabsToolbar .toolbar-items')
86+
?.setAttribute('align', 'end')
87+
},
88+
89+
/**
90+
* The handler for `Services.prefs.addObserver`.
91+
*/
92+
observe(_subject, topic, data) {
93+
switch (topic) {
94+
case 'nsPref:changed':
95+
if (data === VERTICAL_TABS_POSITION) {
96+
if (this.verticalTabsEnabled) {
97+
this.enableVerticalTabs()
98+
} else {
99+
this.disableVerticalTabs()
100+
}
101+
}
102+
break
103+
}
104+
},
105+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
diff --git a/browser/base/content/browser.xhtml b/browser/base/content/browser.xhtml
2+
index 8dfb7b3c787661b5541d77c0eddf408ee90c513f..2a8c13598f5d047bb2fbcbae0b1ee6032a50e9da 100644
3+
--- a/browser/base/content/browser.xhtml
4+
+++ b/browser/base/content/browser.xhtml
5+
@@ -105,6 +105,7 @@
6+
Services.scriptloader.loadSubScript("chrome://browser/content/browser-pageActions.js", this);
7+
Services.scriptloader.loadSubScript("chrome://browser/content/browser-sidebar.js", this);
8+
Services.scriptloader.loadSubScript("chrome://browser/content/browser-tabsintitlebar.js", this);
9+
+ Services.scriptloader.loadSubScript("chrome://browser/content/browser-verticaltabs.js", this);
10+
Services.scriptloader.loadSubScript("chrome://browser/content/tabbrowser.js", this);
11+
Services.scriptloader.loadSubScript("chrome://browser/content/tabbrowser-tab.js", this);
12+
Services.scriptloader.loadSubScript("chrome://browser/content/tabbrowser-tabs.js", this);
13+
@@ -112,6 +113,7 @@
14+
Services.scriptloader.loadSubScript("chrome://browser/content/search/autocomplete-popup.js", this);
15+
Services.scriptloader.loadSubScript("chrome://browser/content/search/searchbar.js", this);
16+
17+
+
18+
window.onload = gBrowserInit.onLoad.bind(gBrowserInit);
19+
window.onunload = gBrowserInit.onUnload.bind(gBrowserInit);
20+
window.onclose = WindowIsClosing;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/browser/base/content/navigator-toolbox.inc.xhtml b/browser/base/content/navigator-toolbox.inc.xhtml
2+
index 8071a5fa5e1f3ba3dfd0345fa1e3284082eb2e39..c6d6d3b08f033ff207daa44074f8422e51b52640 100644
3+
--- a/browser/base/content/navigator-toolbox.inc.xhtml
4+
+++ b/browser/base/content/navigator-toolbox.inc.xhtml
5+
@@ -475,6 +475,10 @@
6+
consumeanchor="PanelUI-button"
7+
data-l10n-id="appmenu-menu-button-closed2"/>
8+
</toolbaritem>
9+
+
10+
+# Intended for the vertical tabs view, should be hidden by default
11+
+#include titlebar-items.inc.xhtml
12+
+
13+
</toolbar>
14+
15+
<toolbar id="PersonalToolbar"

0 commit comments

Comments
 (0)