summaryrefslogtreecommitdiffstats
path: root/browser/components/migration/content/migration-dialog-window.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /browser/components/migration/content/migration-dialog-window.js
parentInitial commit. (diff)
downloadthunderbird-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 'browser/components/migration/content/migration-dialog-window.js')
-rw-r--r--browser/components/migration/content/migration-dialog-window.js82
1 files changed, 82 insertions, 0 deletions
diff --git a/browser/components/migration/content/migration-dialog-window.js b/browser/components/migration/content/migration-dialog-window.js
new file mode 100644
index 0000000000..feaa70f565
--- /dev/null
+++ b/browser/components/migration/content/migration-dialog-window.js
@@ -0,0 +1,82 @@
+/* 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/. */
+
+"use strict";
+
+/**
+ * This file manages a MigrationWizard embedded in a dialog that runs
+ * in a top-level dialog window. It's main responsibility is to listen
+ * for dialog-specific events from the embedded MigrationWizard and to
+ * respond appropriately to them.
+ *
+ * A single object argument is expected to be passed when opening
+ * this dialog.
+ *
+ * @param {object} window.arguments.0
+ * @param {Function} window.arguments.0.onResize
+ * A callback to resize the container of this document when the
+ * MigrationWizard resizes.
+ * @param {object} window.arguments.0.options
+ * A series of options for configuring the dialog. See
+ * MigrationUtils.showMigrationWizard for a description of this
+ * object.
+ */
+
+const MigrationDialog = {
+ _wiz: null,
+
+ init() {
+ addEventListener("load", this);
+ },
+
+ onLoad() {
+ this._wiz = document.getElementById("wizard");
+ this._wiz.addEventListener("MigrationWizard:Close", this);
+ document.addEventListener("keypress", this);
+
+ let args = window.arguments[0];
+ // When opened via nsIWindowWatcher.openWindow, the arguments are
+ // passed through C++, and they arrive to us wrapped as an XPCOM
+ // object. We use wrappedJSObject to get at the underlying JS
+ // object.
+ if (args instanceof Ci.nsISupports) {
+ args = args.wrappedJSObject;
+ }
+
+ // We have to inform the container of this document that the
+ // MigrationWizard has changed size in order for it to update
+ // its dimensions too.
+ let observer = new ResizeObserver(() => {
+ args.onResize();
+ });
+ observer.observe(this._wiz);
+
+ let panelList = this._wiz.querySelector("panel-list");
+ let panel = document.createXULElement("panel");
+ panel.appendChild(panelList);
+ this._wiz.appendChild(panel);
+ this._wiz.requestState();
+ },
+
+ handleEvent(event) {
+ switch (event.type) {
+ case "load": {
+ this.onLoad();
+ break;
+ }
+ case "keypress": {
+ if (event.keyCode == KeyEvent.DOM_VK_ESCAPE) {
+ window.close();
+ }
+ break;
+ }
+ case "MigrationWizard:Close": {
+ window.close();
+ break;
+ }
+ }
+ },
+};
+
+MigrationDialog.init();