From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- comm/mail/base/content/migrationProgress.js | 64 +++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 comm/mail/base/content/migrationProgress.js (limited to 'comm/mail/base/content/migrationProgress.js') diff --git a/comm/mail/base/content/migrationProgress.js b/comm/mail/base/content/migrationProgress.js new file mode 100644 index 0000000000..d75536a137 --- /dev/null +++ b/comm/mail/base/content/migrationProgress.js @@ -0,0 +1,64 @@ +/* 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 { MigrationTasks } = ChromeUtils.import( + "resource:///modules/MailMigrator.jsm" +); + +window.addEventListener("load", async function () { + let list = document.getElementById("tasks"); + let itemTemplate = document.getElementById("taskItem"); + let progress = document.querySelector("progress"); + let l10nElements = []; + + for (let task of MigrationTasks.tasks) { + if (!task.fluentID) { + continue; + } + + let item = itemTemplate.content.firstElementChild.cloneNode(true); + item.classList.add(task.status); + + let name = item.querySelector(".task-name"); + document.l10n.setAttributes(name, task.fluentID); + l10nElements.push(name); + + if (task.status == "running") { + if (task.subTasks.length) { + progress.value = task.subTasks.filter( + t => t.status == "finished" + ).length; + progress.max = task.subTasks.length; + progress.style.visibility = null; + } else { + progress.style.visibility = "hidden"; + } + } + + list.appendChild(item); + + task.on("status-change", (event, status) => { + item.classList.remove("pending", "running", "finished"); + item.classList.add(status); + + if (status == "running") { + // Always hide the progress bar when starting a task. If there are + // sub-tasks, it will be shown by a progress event. + progress.style.visibility = "hidden"; + } + }); + task.on("progress", (event, value, max) => { + progress.value = value; + progress.max = max; + progress.style.visibility = null; + }); + } + + await document.l10n.translateElements(l10nElements); + window.sizeToContent(); + window.moveTo( + (screen.width - window.outerWidth) / 2, + (screen.height - window.outerHeight) / 2 + ); +}); -- cgit v1.2.3