Bug 1544932 - Stop applying dialog cancel handler to the main window; r=Fallen DONTBUILD
authorGeoff Lankow <geoff@darktrojan.net>
Wed, 17 Apr 2019 21:40:41 +1200
changeset 26371 4a2e39cfc820
parent 26370 b6e519322394
child 26372 1552305b49b0
push id15806
push usergeoff@darktrojan.net
push dateWed, 17 Apr 2019 09:41:12 +0000
treeherdercomm-central@4a2e39cfc820 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFallen
bugs1544932
Bug 1544932 - Stop applying dialog cancel handler to the main window; r=Fallen DONTBUILD
calendar/lightning/content/lightning-item-panel.js
calendar/lightning/content/lightning-item-panel.xul
--- a/calendar/lightning/content/lightning-item-panel.js
+++ b/calendar/lightning/content/lightning-item-panel.js
@@ -248,16 +248,26 @@ function onLoadLightningItemPanel(aIfram
 
         // hide the ok and cancel dialog buttons
         let accept = document.documentElement.getButton("accept");
         let cancel = document.documentElement.getButton("cancel");
         accept.setAttribute("collapsed", "true");
         cancel.setAttribute("collapsed", "true");
         cancel.parentNode.setAttribute("collapsed", "true");
 
+        document.addEventListener("dialogaccept", (event) => {
+            sendMessage({ command: "onAccept" });
+            event.preventDefault();
+        });
+
+        document.addEventListener("dialogcancel", (event) => {
+            sendMessage({ command: "onCancel" });
+            event.preventDefault();
+        });
+
         // set toolbar icon color for light or dark themes
         if (typeof window.ToolbarIconColor !== "undefined") {
             window.ToolbarIconColor.init();
         }
 
         // Enlarge the dialog window so the iframe content fits, and prevent it
         // getting smaller. We don't know the minimum size of the content unless
         // it's overflowing, so don't attempt to enforce what we don't know.
@@ -367,34 +377,16 @@ function updateItemTabState(aArg) {
  */
 function initializeItemMenu(aLabel, aAccessKey) {
     let menuItem = document.getElementById("item-menu");
     menuItem.setAttribute("label", aLabel);
     menuItem.setAttribute("accesskey", aAccessKey);
 }
 
 /**
- * Handler for when dialog is accepted.
- */
-document.addEventListener("dialogaccept", () => {
-    sendMessage({ command: "onAccept" });
-    return false;
-});
-
-/**
- * Handler for when dialog is cancelled. (calendar.item.editInTab = false)
- */
-document.addEventListener("dialogcancel", (event) => {
-    sendMessage({ command: "onCancel" });
-    // We prevent closing of a window until we
-    // can ask the user about saving any unsaved changes.
-    event.preventDefault();
-});
-
-/**
  * Handler for when tab is cancelled. (calendar.item.editInTab = true)
  *
  * @param {string} aIframeId  The id of the iframe
  */
 function onCancel(aIframeId) {
     sendMessage({ command: "onCancel", iframeId: aIframeId }, aIframeId);
     // We return false to prevent closing of a window until we
     // can ask the user about saving any unsaved changes.
--- a/calendar/lightning/content/lightning-item-panel.xul
+++ b/calendar/lightning/content/lightning-item-panel.xul
@@ -86,17 +86,17 @@
 
           <!-- attendees -->
           <command id="cmd_attendees"
                    oncommand="editAttendees();"/>
 
           <!-- accept, attachments, timezone -->
           <command id="cmd_accept"
                    disable-on-readonly="true"
-                   oncommand="onAccept();"/>
+                   oncommand="sendMessage({ command: 'onAccept' });"/>
           <command id="cmd_attach_url"
                    disable-on-readonly="true"
                    oncommand="attachURL()"/>
           <command id="cmd_attach_cloud"
                    disable-on-readonly="true"/>
           <command id="cmd_timezone"
                    persist="checked"
                    checked="false"