summaryrefslogtreecommitdiffstats
path: root/comm/calendar/base/content/dialogs/calendar-providerUninstall-dialog.js
diff options
context:
space:
mode:
Diffstat (limited to 'comm/calendar/base/content/dialogs/calendar-providerUninstall-dialog.js')
-rw-r--r--comm/calendar/base/content/dialogs/calendar-providerUninstall-dialog.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/comm/calendar/base/content/dialogs/calendar-providerUninstall-dialog.js b/comm/calendar/base/content/dialogs/calendar-providerUninstall-dialog.js
new file mode 100644
index 0000000000..0f39cecbf1
--- /dev/null
+++ b/comm/calendar/base/content/dialogs/calendar-providerUninstall-dialog.js
@@ -0,0 +1,58 @@
+/* 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 { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
+
+window.addEventListener("DOMContentLoaded", onLoad);
+function onLoad() {
+ let extension = window.arguments[0].extension;
+ document.getElementById("provider-name-label").value = extension.name;
+
+ let calendarList = document.getElementById("calendar-list");
+
+ for (let calendar of cal.manager.getCalendars()) {
+ if (calendar.providerID != extension.id) {
+ continue;
+ }
+
+ let item = document.createXULElement("richlistitem");
+ item.setAttribute("calendar-id", calendar.id);
+
+ let checkbox = document.createXULElement("checkbox");
+ checkbox.classList.add("calendar-selected");
+ item.appendChild(checkbox);
+
+ let colorMarker = document.createElement("div");
+ colorMarker.classList.add("calendar-color");
+ item.appendChild(colorMarker);
+ colorMarker.style.backgroundColor = calendar.getProperty("color");
+
+ let label = document.createXULElement("label");
+ label.classList.add("calendar-name");
+ label.value = calendar.name;
+ item.appendChild(label);
+
+ calendarList.appendChild(item);
+ }
+}
+
+document.addEventListener("dialogaccept", () => {
+ // Tell our caller that the extension should be uninstalled.
+ let args = window.arguments[0];
+ args.shouldUninstall = true;
+
+ let calendarList = document.getElementById("calendar-list");
+
+ // Unsubscribe from all selected calendars
+ for (let item of calendarList.children) {
+ if (item.querySelector(".calendar-selected").checked) {
+ cal.manager.unregisterCalendar(cal.manager.getCalendarById(item.getAttribute("calendar-id")));
+ }
+ }
+});
+
+document.addEventListener("dialogcancel", () => {
+ let args = window.arguments[0];
+ args.shouldUninstall = false;
+});