diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/mailnews/news/content | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/mailnews/news/content')
-rw-r--r-- | comm/mailnews/news/content/downloadheaders.js | 92 | ||||
-rw-r--r-- | comm/mailnews/news/content/downloadheaders.xhtml | 82 |
2 files changed, 174 insertions, 0 deletions
diff --git a/comm/mailnews/news/content/downloadheaders.js b/comm/mailnews/news/content/downloadheaders.js new file mode 100644 index 0000000000..80d31935b8 --- /dev/null +++ b/comm/mailnews/news/content/downloadheaders.js @@ -0,0 +1,92 @@ +/* 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/. */ + +var { MailServices } = ChromeUtils.import( + "resource:///modules/MailServices.jsm" +); + +var markreadElement = null; +var numberElement = null; + +var nntpServer = null; +var args = null; + +document.addEventListener("dialogaccept", OkButtonCallback); +document.addEventListener("dialogcancel", CancelButtonCallback); + +function OnLoad() { + let newsBundle = document.getElementById("bundle_news"); + + if ("arguments" in window && window.arguments[0]) { + args = window.arguments[0].QueryInterface(Ci.nsINewsDownloadDialogArgs); + /* by default, act like the user hit cancel */ + args.hitOK = false; + /* by default, act like the user did not select download all */ + args.downloadAll = false; + + nntpServer = MailServices.accounts + .getIncomingServer(args.serverKey) + .QueryInterface(Ci.nsINntpIncomingServer); + + document.title = newsBundle.getString("downloadHeadersTitlePrefix"); + + let infotext = newsBundle.getFormattedString("downloadHeadersInfoText", [ + args.articleCount, + ]); + setText("info", infotext); + let okButtonText = newsBundle.getString("okButtonText"); + let okbutton = document.querySelector("dialog").getButton("accept"); + okbutton.setAttribute("label", okButtonText); + okbutton.focus(); + setText("newsgroupLabel", args.groupName); + } + + numberElement = document.getElementById("number"); + numberElement.value = nntpServer.maxArticles; + + markreadElement = document.getElementById("markread"); + markreadElement.checked = nntpServer.markOldRead; + + setupDownloadUI(true); + + return true; +} + +function setText(id, value) { + let element = document.getElementById(id); + if (!element) { + return; + } + + while (element.lastChild) { + element.lastChild.remove(); + } + let textNode = document.createTextNode(value); + element.appendChild(textNode); +} + +function OkButtonCallback() { + nntpServer.maxArticles = numberElement.value; + nntpServer.markOldRead = markreadElement.checked; + + let radio = document.getElementById("all"); + if (radio) { + args.downloadAll = radio.selected; + } + + args.hitOK = true; +} + +function CancelButtonCallback() { + args.hitOK = false; +} + +function setupDownloadUI(enable) { + let checkbox = document.getElementById("markread"); + let numberFld = document.getElementById("number"); + + checkbox.disabled = !enable; + numberFld.disabled = !enable; + numberFld.select(); +} diff --git a/comm/mailnews/news/content/downloadheaders.xhtml b/comm/mailnews/news/content/downloadheaders.xhtml new file mode 100644 index 0000000000..b212d5d288 --- /dev/null +++ b/comm/mailnews/news/content/downloadheaders.xhtml @@ -0,0 +1,82 @@ +<?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/. --> + +<?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?> +<?xml-stylesheet href="chrome://messenger/skin/colors.css" type="text/css"?> +<?xml-stylesheet href="chrome://messenger/skin/themeableDialog.css" type="text/css"?> + +<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/downloadheaders.dtd"> + +<dialog + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + xmlns:html="http://www.w3.org/1999/xhtml" + style="max-width: 27em; padding: 10px" + buttonpack="center" + lightweightthemes="true" + onload="OnLoad();" +> + <stringbundle + id="bundle_news" + src="chrome://messenger/locale/news.properties" + /> + <script src="chrome://messenger/content/downloadheaders.js" /> + <script src="chrome://messenger/content/dialogShadowDom.js" /> + + <label + id="newsgroupLabel" + control="downloadGroup" + class="header" + style="width: 25em; max-width: 25em; margin-inline-start: 6px" + /> + <description + style="width: 25em; max-width: 25em" + id="info" + control="downloadGroup" + /> + <separator class="thin" /> + <vbox class="indent"> + <radiogroup id="downloadGroup"> + <radio + id="all" + label="&all.label;" + accesskey="&all.accesskey;" + oncommand="setupDownloadUI(false);" + value="all" + /> + <separator class="thin" /> + <hbox align="center"> + <radio + id="some" + selected="true" + label="&download.label;" + accesskey="&download.accesskey;" + oncommand="setupDownloadUI(true);" + aria-labelledby="some number headers" + value="some" + /> + <html:input + id="number" + type="number" + min="1" + aria-labelledby="some number headers" + /> + <label + id="headers" + control="number" + value="&headers.label;" + accesskey="&headers.accesskey;" + /> + </hbox> + </radiogroup> + + <hbox class="indent" align="start"> + <checkbox + id="markread" + label="&mark.label;" + accesskey="&mark.accesskey;" + /> + </hbox> + </vbox> +</dialog> |