mirror of
https://github.com/zen-browser/desktop.git
synced 2025-09-05 19:08:18 +00:00
chore: Add context menu open link in new tab
This commit is contained in:
@@ -149,13 +149,20 @@ var gZenBrowserManagerSidebar = {
|
||||
toggle() {
|
||||
if (!this._currentPanel) {
|
||||
this._currentPanel = this._lastOpenedPanel;
|
||||
this.update();
|
||||
return;
|
||||
}
|
||||
// already open?
|
||||
if (document.getElementById("zen-sidebar-web-panel").hasAttribute("hidden")) {
|
||||
this.open();
|
||||
return;
|
||||
}
|
||||
this.close();
|
||||
},
|
||||
|
||||
open() {
|
||||
let sidebar = document.getElementById("zen-sidebar-web-panel");
|
||||
sidebar.removeAttribute("hidden");
|
||||
this.update();
|
||||
},
|
||||
|
||||
update() {
|
||||
this._updateWebPanels();
|
||||
this._updateSidebarButton();
|
||||
@@ -165,7 +172,7 @@ var gZenBrowserManagerSidebar = {
|
||||
|
||||
_updateSidebarButton() {
|
||||
let button = document.getElementById("zen-sidepanel-button");
|
||||
if (this._currentPanel) {
|
||||
if (!document.getElementById("zen-sidebar-web-panel").hasAttribute("hidden")) {
|
||||
button.setAttribute("open", "true");
|
||||
} else {
|
||||
button.removeAttribute("open");
|
||||
@@ -232,15 +239,6 @@ var gZenBrowserManagerSidebar = {
|
||||
document.getElementById("zen-sidebar-web-panel-pinned").removeAttribute("pinned");
|
||||
},
|
||||
|
||||
_openAndGetWebPanelWrapper() {
|
||||
let sidebar = document.getElementById("zen-sidebar-web-panel");
|
||||
sidebar.removeAttribute("hidden");
|
||||
if (Services.prefs.getBoolPref("zen.sidebar.floating")) {
|
||||
this._setPinnedToElements();
|
||||
}
|
||||
return sidebar;
|
||||
},
|
||||
|
||||
_closeSidebarPanel() {
|
||||
let sidebar = document.getElementById("zen-sidebar-web-panel");
|
||||
sidebar.setAttribute("hidden", "true");
|
||||
@@ -268,7 +266,7 @@ var gZenBrowserManagerSidebar = {
|
||||
};
|
||||
Services.prefs.setStringPref("zen.sidebar.data", JSON.stringify(data));
|
||||
this._currentPanel = newName;
|
||||
this.update();
|
||||
this.open();
|
||||
},
|
||||
|
||||
_updateButtons() {
|
||||
@@ -282,7 +280,7 @@ var gZenBrowserManagerSidebar = {
|
||||
},
|
||||
|
||||
_hideAllWebPanels() {
|
||||
let sidebar = this._openAndGetWebPanelWrapper();
|
||||
let sidebar = document.getElementById("zen-sidebar-web-panel");
|
||||
for (let browser of sidebar.querySelectorAll("browser[zen-sidebar-id]")) {
|
||||
browser.setAttribute("hidden", "true");
|
||||
browser.docShellIsActive = false;
|
||||
@@ -295,7 +293,7 @@ var gZenBrowserManagerSidebar = {
|
||||
|
||||
_updateWebPanel() {
|
||||
this._updateButtons();
|
||||
let sidebar = this._openAndGetWebPanelWrapper();
|
||||
let sidebar = document.getElementById("zen-sidebar-web-panel");
|
||||
this._hideAllWebPanels();
|
||||
if (!this._currentPanel) {
|
||||
this.introductionPanel.removeAttribute("hidden");
|
||||
@@ -514,6 +512,8 @@ var gZenBrowserManagerSidebar = {
|
||||
browser.remove();
|
||||
}
|
||||
this._closeSidebarPanel();
|
||||
this.close();
|
||||
this._lastOpenedPanel = null;
|
||||
Services.prefs.setStringPref("zen.sidebar.data", JSON.stringify(data));
|
||||
},
|
||||
|
||||
@@ -521,6 +521,8 @@ var gZenBrowserManagerSidebar = {
|
||||
let browser = this._getBrowserById(this.contextTab);
|
||||
browser.remove();
|
||||
this._closeSidebarPanel();
|
||||
this.close();
|
||||
this._lastOpenedPanel = null;
|
||||
},
|
||||
|
||||
insertIntoContextMenu() {
|
||||
|
@@ -18,6 +18,7 @@ var gZenViewSplitter = {
|
||||
init() {
|
||||
Services.prefs.setBoolPref("zen.splitView.working", false);
|
||||
window.addEventListener("TabClose", this);
|
||||
this.insertIntoContextMenu();
|
||||
console.log("ZenViewSplitter initialized");
|
||||
},
|
||||
|
||||
@@ -28,6 +29,18 @@ var gZenViewSplitter = {
|
||||
}
|
||||
},
|
||||
|
||||
insertIntoContextMenu() {
|
||||
const sibling = document.getElementById("context-stripOnShareLink");
|
||||
const menuitem = document.createXULElement("menuitem");
|
||||
menuitem.setAttribute("id", "context-zenSplitLink");
|
||||
menuitem.setAttribute("hidden", "true");
|
||||
menuitem.setAttribute("oncommand", "gZenViewSplitter.contextSplitLink();");
|
||||
menuitem.setAttribute("data-l10n-id", "zen-split-link");
|
||||
const separator = document.createXULElement("menuseparator");
|
||||
sibling.insertAdjacentElement("afterend", menuitem);
|
||||
sibling.insertAdjacentElement("afterend", separator);
|
||||
},
|
||||
|
||||
get tabBrowserPanel() {
|
||||
if (!this._tabBrowserPanel) {
|
||||
this._tabBrowserPanel = document.getElementById("tabbrowser-tabpanels");
|
||||
@@ -75,6 +88,13 @@ var gZenViewSplitter = {
|
||||
this._showSplitView(lastTab);
|
||||
},
|
||||
|
||||
contextSplitLink() {
|
||||
const url = gContextMenu.linkURL || gContextMenu.target.ownerDocument.location.href;
|
||||
const tab = gBrowser.selectedTab;
|
||||
const newTab = gZenUIManager.openAndChangeToTab(url);
|
||||
this.splitTabs([tab, newTab]);
|
||||
},
|
||||
|
||||
onLocationChange(browser) {
|
||||
let tab = gBrowser.getTabForBrowser(browser);
|
||||
this.updateSplitViewButton(!(tab && tab._zenSplitted));
|
||||
@@ -89,6 +109,17 @@ var gZenViewSplitter = {
|
||||
if (tabs.length < 2) {
|
||||
return;
|
||||
}
|
||||
// Check if any tab is already split
|
||||
for (const tab of tabs) {
|
||||
if (tab._zenSplitted) {
|
||||
let index = this._data.findIndex((group) => group.tabs.includes(tab));
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
this._showSplitView(tab);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this._data.push({
|
||||
tabs,
|
||||
gridType: "grid",
|
||||
|
@@ -1,8 +1,8 @@
|
||||
diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js
|
||||
index b5c8dd44daaab18397cf01d0ef9f5288f5113925..f59b494dc287edaa148f726902244224330d81c5 100644
|
||||
index b5c8dd44daaab18397cf01d0ef9f5288f5113925..8840b8171d5992da0a2f6216d8da9e1ec6dc1e93 100644
|
||||
--- a/browser/base/content/nsContextMenu.js
|
||||
+++ b/browser/base/content/nsContextMenu.js
|
||||
@@ -1047,6 +1047,11 @@ class nsContextMenu {
|
||||
@@ -1047,6 +1047,13 @@ class nsContextMenu {
|
||||
!this.isSecureAboutPage()
|
||||
);
|
||||
|
||||
@@ -10,6 +10,8 @@ index b5c8dd44daaab18397cf01d0ef9f5288f5113925..f59b494dc287edaa148f726902244224
|
||||
+ "context-zenAddToWebPanel",
|
||||
+ this.onLink && !this.onMailtoLink && !this.onTelLink
|
||||
+ );
|
||||
+
|
||||
+ this.showItem("context-zenSplitLink", this.onLink && !this.onMailtoLink && !this.onTelLink);
|
||||
+
|
||||
let copyLinkSeparator = document.getElementById("context-sep-copylink");
|
||||
// Show "Copy Link", "Copy" and "Copy Clean Link" with no divider, and "copy link" and "Send link to Device" with no divider between.
|
||||
|
@@ -1,2 +1,3 @@
|
||||
<link rel="localization" href="browser/zen-web-side-panels.ftl"/>
|
||||
<link rel="localization" href="browser/zen-workspaces.ftl"/>
|
||||
<link rel="localization" href="browser/zen-split-view.ftl"/>
|
||||
|
@@ -1,19 +0,0 @@
|
||||
diff --git a/browser/locales/en-US/browser/tabContextMenu.ftl b/browser/locales/en-US/browser/tabContextMenu.ftl
|
||||
index df58df794c5e7101aa1ea684edd009532d74240d..0b4237dfde4e8e30e279f0a7022c1a36e67a04e8 100644
|
||||
--- a/browser/locales/en-US/browser/tabContextMenu.ftl
|
||||
+++ b/browser/locales/en-US/browser/tabContextMenu.ftl
|
||||
@@ -101,6 +101,14 @@ tab-context-move-tabs =
|
||||
}
|
||||
.accesskey = v
|
||||
|
||||
+tab-zen-split-tabs =
|
||||
+ .label =
|
||||
+ { $tabCount ->
|
||||
+ [1] Split Tab (multiple selected tabs needed)
|
||||
+ *[other] Split { $tabCount } Tabs
|
||||
+ }
|
||||
+ .accesskey = S
|
||||
+
|
||||
tab-context-send-tabs-to-device =
|
||||
.label =
|
||||
{ $tabCount ->
|
12
src/browser/locales/en-US/browser/zen-split-view.ftl
Normal file
12
src/browser/locales/en-US/browser/zen-split-view.ftl
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
tab-zen-split-tabs =
|
||||
.label =
|
||||
{ $tabCount ->
|
||||
[1] Split Tab (multiple selected tabs needed)
|
||||
*[other] Split { $tabCount } Tabs
|
||||
}
|
||||
.accesskey = S
|
||||
|
||||
zen-split-link =
|
||||
.label = Split link to new tab
|
||||
.accesskey = S
|
@@ -40,6 +40,10 @@
|
||||
--menu-image: url("sidebars-right.svg") !important;
|
||||
}
|
||||
|
||||
#context-zenSplitLink {
|
||||
--menu-image: url("link.svg") !important;
|
||||
}
|
||||
|
||||
#sidebar-button:-moz-locale-dir(ltr):not([positionend]),
|
||||
#sidebar-button:-moz-locale-dir(rtl)[positionend],
|
||||
#zen-sidepanel-button {
|
||||
|
Reference in New Issue
Block a user