Skip to content

Commit

Permalink
Merge pull request #3 from Floorp-Projects/verticaltab-reimplementing
Browse files Browse the repository at this point in the history
Re-implement verticaltab
  • Loading branch information
surapunoyousei authored Oct 17, 2023
2 parents 2bd415a + c9e8e5d commit 41221c0
Show file tree
Hide file tree
Showing 11 changed files with 430 additions and 496 deletions.
1 change: 1 addition & 0 deletions browser/app/profile/000-floorp.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ pref("floorp.browser.tabs.openNewTabPosition", -1);
//ネイティブ実装垂直タブ
pref("floorp.browser.native.verticaltabs.enabled", false);
pref("floorp.verticaltab.hover.enabled", false);
pref("floorp.browser.tabs.verticaltab.right", false);

// Chrome 形式のダウンローダー
pref("floorp.browser.native.downloadbar.enabled", false);
Expand Down
15 changes: 15 additions & 0 deletions browser/base/content/browser-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ function OpenChromeDirectory() {
new nsLocalFile(profileDir).reveal();
}

function changeXULElementTagName(oldElementId, newTagName) {
const oldElement = document.getElementById(oldElementId);
const newElement = document.createElement(newTagName);

const attrs = oldElement.attributes;
for (let i = 0; i < attrs.length; i++) {
newElement.setAttribute(attrs[i].name, attrs[i].value);
}

while (oldElement.firstChild) {
newElement.appendChild(oldElement.firstChild);
}
oldElement.parentNode.replaceChild(newElement, oldElement);
}

function restartbrowser() {
Services.obs.notifyObservers(null, "startupcache-invalidate");

Expand Down
170 changes: 126 additions & 44 deletions browser/base/content/browser-manager-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,61 +84,138 @@ const bmsController = {
let floorpSidebarPositionPref = Services.prefs.getBoolPref(
floorpSidebarPosition
);
let verticaltabPositionPref = Services.prefs.getBoolPref(
"floorp.browser.tabs.verticaltab.right"
);

let fxSidebar = document.getElementById("sidebar-box");
let fxSidebarSplitter = document.getElementById("sidebar-splitter");

let floorpSidebar = document.getElementById("sidebar2-box");
let floorpSidebarSplitter = document.getElementById("sidebar-splitter2");
let floorpSidebarSelectBox =
document.getElementById("sidebar-select-box");

let verticaltabbar = document.getElementById("TabsToolbar");
let verticaltabbarSplitter = document.getElementById(
"verticaltab-splitter"
);

let browserBox = document.getElementById("appcontent");

// Set flex order to all elements
// floorpSidebarSelectBox has to always be the window's last child
// Vetical tab bar has to always be the window's first child.
// Fx's sidebar has to always be between the vertical tab bar and the floorp's sidebar.
// Seeking opinions on whether we should nest.
if (
fxSidebarPositionPref === true &&
floorpSidebarPositionPref === true
) {
//Firefox's sidebar position: left, Floorp's sidebar position: right
fxSidebar.style.order = "0";
fxSidebarSplitter.style.order = "1";
browserBox.style.order = "2";
floorpSidebarSplitter.style.order = "3";
floorpSidebar.style.order = "4";
floorpSidebarSelectBox.style.order = "5";
} else if (
fxSidebarPositionPref === true &&
floorpSidebarPositionPref === false
) {
//Firefox's sidebar position: left, Floorp's sidebar position: left
floorpSidebarSelectBox.style.order = "0";
floorpSidebar.style.order = "1";
floorpSidebarSplitter.style.order = "2";
fxSidebar.style.order = "3";
fxSidebarSplitter.style.order = "4";
browserBox.style.order = "5";
} else if (
fxSidebarPositionPref === false &&
floorpSidebarPositionPref === true
) {
//Firefox's sidebar position: right, Floorp's sidebar position: right
browserBox.style.order = "0";
fxSidebarSplitter.style.order = "1";
fxSidebar.style.order = "2";
floorpSidebarSplitter.style.order = "3";
floorpSidebar.style.order = "4";
floorpSidebarSelectBox.style.order = "5";
} else if (
fxSidebarPositionPref === false &&
floorpSidebarPositionPref === false
) {
//Firefox's sidebar position: right, Floorp's sidebar position: left
floorpSidebarSelectBox.style.order = "0";
floorpSidebar.style.order = "1";
floorpSidebarSplitter.style.order = "2";
browserBox.style.order = "3";
fxSidebarSplitter.style.order = "4";
fxSidebar.style.order = "5";

if (verticaltabPositionPref) {
if (
fxSidebarPositionPref &&
floorpSidebarPositionPref
){
// Default
// Fx's sidebar -> browser -> Vertical tab bar -> Floorp's sidebar
fxSidebar.style.order = "0";
fxSidebarSplitter.style.order = "1";
browserBox.style.order = "2";
verticaltabbarSplitter.style.order = "3";
verticaltabbar.style.order = "4";
floorpSidebarSplitter.style.order = "5";
floorpSidebar.style.order = "6";
floorpSidebarSelectBox.style.order = "7";
} else if (
fxSidebarPositionPref &&
!floorpSidebarPositionPref
) {
// Floorp sidebar -> Fx's sidebar -> browser -> Vertical tab bar
floorpSidebarSelectBox.style.order = "0";
floorpSidebar.style.order = "1";
floorpSidebarSplitter.style.order = "2";
fxSidebar.style.order = "3";
fxSidebarSplitter.style.order = "4";
browserBox.style.order = "5";
verticaltabbarSplitter.style.order = "6";
verticaltabbar.style.order = "7";
} else if (
!fxSidebarPositionPref &&
floorpSidebarPositionPref
) {
// browser -> Vertical tab bar -> Fx's sidebar -> Floorp's sidebar
browserBox.style.order = "0";
verticaltabbarSplitter.style.order = "1";
verticaltabbar.style.order = "2";
fxSidebar.style.order = "3";
fxSidebarSplitter.style.order = "4";
floorpSidebarSplitter.style.order = "5";
floorpSidebar.style.order = "6";
floorpSidebarSelectBox.style.order = "7";
} else {
// !fxSidebarPositionPref && !floorpSidebarPositionPref
// Floorp's sidebar -> browser -> Vertical tab bar -> Fx's sidebar
floorpSidebarSelectBox.style.order = "0";
floorpSidebar.style.order = "1";
floorpSidebarSplitter.style.order = "2";
browserBox.style.order = "3";
verticaltabbarSplitter.style.order = "4";
verticaltabbar.style.order = "5";
fxSidebar.style.order = "6";
fxSidebarSplitter.style.order = "7";
}
} else if (!verticaltabPositionPref) {
if (
fxSidebarPositionPref &&
floorpSidebarPositionPref
){
// Fx's sidebar -> vertical tab bar -> browser -> Floorp's sidebar
fxSidebar.style.order = "0";
fxSidebarSplitter.style.order = "1";
verticaltabbar.style.order = "2";
verticaltabbarSplitter.style.order = "3";
browserBox.style.order = "4";
floorpSidebarSplitter.style.order = "5";
floorpSidebar.style.order = "6";
floorpSidebarSelectBox.style.order = "7";
} else if (
fxSidebarPositionPref &&
!floorpSidebarPositionPref
) {
// Floorp sidebar -> Fx's sidebar -> vertical tab bar -> browser
floorpSidebarSelectBox.style.order = "0";
floorpSidebar.style.order = "1";
floorpSidebarSplitter.style.order = "2";
fxSidebar.style.order = "3";
fxSidebarSplitter.style.order = "4";
verticaltabbar.style.order = "5";
verticaltabbarSplitter.style.order = "6";
browserBox.style.order = "7";
} else if (
!fxSidebarPositionPref &&
floorpSidebarPositionPref
) {
// vertical tab bar -> browser -> Fx's sidebar -> Floorp's sidebar
verticaltabbar.style.order = "0";
verticaltabbarSplitter.style.order = "1";
browserBox.style.order = "2";
fxSidebarSplitter.style.order = "3";
fxSidebar.style.order = "4";
floorpSidebarSplitter.style.order = "5";
floorpSidebar.style.order = "6";
floorpSidebarSelectBox.style.order = "7";
} else {
// !fxSidebarPositionPref && !floorpSidebarPositionPref
// Floorp's sidebar -> browser -> vertical tab bar -> Fx's sidebar
floorpSidebarSelectBox.style.order = "0";
floorpSidebar.style.order = "1";
floorpSidebarSplitter.style.order = "2";
browserBox.style.order = "3";
verticaltabbar.style.order = "4";
verticaltabbarSplitter.style.order = "5";
fxSidebar.style.order = "6";
fxSidebarSplitter.style.order = "7";
}
}

},
selectSidebarItem: event => {
let custom_url_id = event.target.id.replace("select-", "");
Expand Down Expand Up @@ -813,6 +890,7 @@ const bmsController = {
// Floorp pref: true = right, false = left
const fxSidebarPosition = "sidebar.position_start";
const floorpSidebarPosition = "floorp.browser.sidebar.right";
const verticaltabPosition = "floorp.browser.tabs.verticaltab.right";
Services.prefs.addObserver(
fxSidebarPosition,
bmsController.eventFunctions.setFlexOrder
Expand All @@ -821,6 +899,10 @@ const bmsController = {
floorpSidebarPosition,
bmsController.eventFunctions.setFlexOrder
);
Services.prefs.addObserver(
verticaltabPosition,
bmsController.eventFunctions.setFlexOrder
);
// Run function when browser start.
SessionStore.promiseInitialized.then(() => {
bmsController.eventFunctions.setFlexOrder();
Expand Down
26 changes: 0 additions & 26 deletions browser/base/content/browser-tabbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,32 +306,6 @@ document.addEventListener(
} else {
removeMultirowTabMaxHeight();
setBrowserDesign();

const tabToolbarItems = document.querySelector(
"#TabsToolbar > .toolbar-items"
);
const tabsToolbar = document.getElementById(
"TabsToolbar-customization-target"
);
const tabbrowserTabs = document.getElementById("tabbrowser-tabs");

tabToolbarItems.style.visibility = "hidden";

window.setTimeout(() => {
new Promise(() => {
tabsToolbar.setAttribute("flex", "");
tabbrowserTabs.setAttribute(
"style",
"-moz-box-flex: unset !important;"
);

setTimeout(() => {
tabsToolbar.setAttribute("flex", "1");
tabbrowserTabs.style.removeProperty("-moz-box-flex");
tabToolbarItems.style.visibility = "";
}, 0);
});
}, 1000);
}
};
Services.prefs.addObserver("floorp.tabbar.style", applyMultitab);
Expand Down
Loading

0 comments on commit 41221c0

Please sign in to comment.