diff --git a/src/browser/base/content/ZenViewSplitter.mjs b/src/browser/base/content/ZenViewSplitter.mjs
index 4d3e5d0a9..1ae101ca4 100644
--- a/src/browser/base/content/ZenViewSplitter.mjs
+++ b/src/browser/base/content/ZenViewSplitter.mjs
@@ -1,19 +1,78 @@
var gZenViewSplitter = {
init() {
+ this.initializeUI();
console.log(gZenSplitViewsBase)
},
- onLocationChange(browser) {
+ initializeUI() {
+ this.initializeUpdateContextMenuItems();
+ this.initializeTabContextMenu();
},
- contextCanSplitTabs() {
+ initializeTabContextMenu() {
+ const fragment = window.MozXULElement.parseXULToFragment(`
+
+
+ `);
+ document.getElementById("tabContextMenu").appendChild(fragment);
+ },
+
+ /**
+ * context menu item display update
+ */
+ initializeUpdateContextMenuItems() {
+ const contentAreaContextMenu = document.getElementById("tabContextMenu");
+ const tabCountInfo = JSON.stringify({
+ tabCount:
+ (window.gContextMenu?.contextTab.multiselected &&
+ window.gBrowser.multiSelectedTabsCount) ||
+ 1,
+ });
+
+ contentAreaContextMenu.addEventListener("popupshowing", () => {
+ document
+ .getElementById("context_zenSplitTabs")
+ .setAttribute("data-l10n-args", tabCountInfo);
+ document.getElementById("context_zenSplitTabs").disabled =
+ !this.contextCanSplitTabs();
+ });
+ },
+
+ onLocationChange(browser) {
+ gZenSplitViewsBase.onLocationChange(browser);
},
openSplitViewPanel(event) {
},
+ contextCanSplitTabs() {
+ let tabs = window.gBrowser.selectedTabs;
+ if (tabs.length < 2) {
+ return false;
+ }
+ // Check if there are 2 tabs in different groups
+ // Or if all the selected tabs are in the same group
+ let group = gZenSplitViewsBase.getTabView(tabs[0]);
+ for (let i = 1; i < tabs.length; i++) {
+ // Check if they are not in the same group, but we do allow
+ // if they are ungrouped
+ let tabGroup = gZenSplitViewsBase.getTabView(tabs[i]);
+ if (tabGroup === -1) {
+ continue;
+ }
+ if (group !== tabGroup) {
+ return false;
+ }
+ }
+ return true;
+ },
+
contextSplitTabs() {
+ let selectedTabs = gBrowser.selectedTabs;
+
},
};
diff --git a/src/browser/base/content/main-popupset-inc-xhtml.patch b/src/browser/base/content/main-popupset-inc-xhtml.patch
index 55cb94c83..d54c3b396 100644
--- a/src/browser/base/content/main-popupset-inc-xhtml.patch
+++ b/src/browser/base/content/main-popupset-inc-xhtml.patch
@@ -1,21 +1,8 @@
diff --git a/browser/base/content/main-popupset.inc.xhtml b/browser/base/content/main-popupset.inc.xhtml
-index ef8245938ea669227c255d85422a26b99cb2290b..48c061796072e976a45f7bd0ca1c8b3913728fc7 100644
+index a2725d45b2c40ee9c718142dd48e22985adfdbd6..888c91058b3266e5a17aea98f7efaee2d11ec9e5 100644
--- a/browser/base/content/main-popupset.inc.xhtml
+++ b/browser/base/content/main-popupset.inc.xhtml
-@@ -80,6 +80,12 @@
-
-+
-+
-+
-