Fixed browser panels, they are not tabs anymore

This commit is contained in:
Mauro Balades
2024-04-27 16:46:57 +02:00
parent d3a8fc192f
commit 8bdda39c35
12 changed files with 200 additions and 26 deletions

View File

@@ -0,0 +1,43 @@
var gZenNewWebPanel = {
init: function() {
document.addEventListener("dialogaccept", this.handleDialogAccept.bind(this));
},
handleURLChange: async function(aURL) {
try {
let url = new URL(aURL.value);
} catch (_) {
// TODO: Show error message
return;
}
},
handleDialogAccept: async function(aEvent) {
document.commandDispatcher.focusedElement?.blur();
let url = document.getElementById("zenNWP_url");
let ua = document.getElementById("zenNWP_userAgent");
if (!url || !ua) {
return;
}
try {
new URL(url.value);
} catch (_) {
return;
}
if (!url.value || !ua.value) {
return;
}
let newSite = {
url: url.value,
ua: ua.value,
};
let currentData = JSON.parse(Services.prefs.getStringPref("zen.sidebar.data"));
let newName = "p" + new Date().getTime();
currentData.index.push(newName);
currentData.data[newName] = newSite;
Services.prefs.setStringPref("zen.sidebar.data", JSON.stringify(currentData));
},
};
gZenNewWebPanel.init();

View File

@@ -0,0 +1,44 @@
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE window>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
id="zenNewWebPanel"
headerparent="zenNewWebPanelDialog"
style="min-width: 40em;">
<dialog id="zenNewWebPanelDialog"
buttons="accept, cancel">
<linkset>
<html:link rel="stylesheet" href="chrome://global/skin/global.css" />
<html:link
rel="stylesheet"
href="chrome://global/content/commonDialog.css"
/>
<html:link rel="stylesheet" href="chrome://global/skin/commonDialog.css" />
<html:link rel="localization" href="browser/zenNewWebPanel.ftl"/>
<script src="chrome://browser/content/zenThemeModifier.js"></script>
</linkset>
<script src="chrome://browser/content/places/zenNewWebPanel.js"/>
<label data-l10n-id="zen-new-web-panel-url"
control="zenNWP_url"/>
<html:input id="zenNWP_url"
type="url" onchange="gZenNewWebPanel.handleURLChange(this);"/>
<hbox flex="1" style="margin: 10px 5px;">
<html:input id="zenNWP_userAgent"
type="checkbox"/>
<label data-l10n-id="zen-new-web-panel-user-agent"
control="zenNWP_userAgent" for="zenNWP_userAgent"/>
</hbox>
</dialog>
</window>

View File

@@ -0,0 +1,10 @@
diff --git a/browser/components/places/jar.mn b/browser/components/places/jar.mn
index 7334914664484267ccf80eeeb2917c2001a1acaf..e0636a13798d6fbf41cbf69e51e460822b00ab1a 100644
--- a/browser/components/places/jar.mn
+++ b/browser/components/places/jar.mn
@@ -25,3 +25,5 @@ browser.jar:
content/browser/places/interactionsViewer.html (metadataViewer/interactionsViewer.html)
content/browser/places/interactionsViewer.js (metadataViewer/interactionsViewer.js)
#endif
+ content/browser/places/zenNewWebPanel.xhtml (content/zenNewWebPanel.xhtml)
+ content/browser/places/zenNewWebPanel.js (content/zenNewWebPanel.js)