Fix bug 442607 - Reminder details link does not work if calendar window is closed. r=decathlon
authorPhilipp Kewisch <mozilla@kewis.ch>
Fri, 05 Aug 2011 20:38:08 +0200
changeset 8238 9a65b6556462743e378fd45c001c17b7ff0d4703
parent 8237 b49da44d861f9fc94e14ff52d91d5166be83cadb
child 8239 bdd326df804a0bb88bde80e75a0bf0bd399a9642
push id6338
push usermozilla@kewis.ch
push dateFri, 05 Aug 2011 19:14:54 +0000
treeherdercomm-central@9cf88871ec09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdecathlon
bugs442607
Fix bug 442607 - Reminder details link does not work if calendar window is closed. r=decathlon
calendar/base/content/dialogs/calendar-alarm-dialog.js
calendar/base/content/dialogs/calendar-alarm-dialog.xul
--- a/calendar/base/content/dialogs/calendar-alarm-dialog.js
+++ b/calendar/base/content/dialogs/calendar-alarm-dialog.js
@@ -95,22 +95,24 @@ function onDismissAllAlarms() {
 
 /**
  * Event handler fired when the alarm widget's "Details..." label was clicked.
  * Open the event dialog in the most recent Sunbird or Thunderbird window
  *
  * @param event     The itemdetails event.
  */
 function onItemDetails(event) {
-    // We want this to happen in a calendar window.
-    let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
-                       .getService(Components.interfaces.nsIWindowMediator);
-    let calWindow = wm.getMostRecentWindow("calendarMainWindow") ||
-                    wm.getMostRecentWindow("mail:3pane");
-    calWindow.modifyEventWithDialog(event.target.item, null, true);
+    // We want this to happen in a calendar window if possible. Otherwise open
+    // it using our window.
+    let calWindow = cal.getCalendarWindow();
+    if (calWindow) {
+        calWindow.modifyEventWithDialog(event.target.item, null, true);
+    } else {
+        modifyEventWithDialog(event.target.item, null, true);
+    }
 }
 
 /**
  * Sets up the alarm dialog, initializing the default snooze length and setting
  * up the relative date update timer.
  */
 var gRelativeDateUpdateTimer;
 function setupWindow() {
@@ -323,8 +325,15 @@ function closeIfEmpty() {
  */
 function onSelectAlarm(event) {
     let richList = document.getElementById("alarm-richlist")
     if (richList == event.target) {
         richList.ensureElementIsVisible(richList.getSelectedItem(0));
         richList.userSelectedWidget = true;
     }
 }
+
+function ensureCalendarVisible(aCalendar) {
+    // This function is called on the alarm dialog from calendar-item-editing.js.
+    // Normally, it makes sure that the calendar being edited is made visible,
+    // but the alarm dialog is too far away from the calendar views that it
+    // makes sense to force visiblity for the calendar. Therefore, do nothing.
+}
--- a/calendar/base/content/dialogs/calendar-alarm-dialog.xul
+++ b/calendar/base/content/dialogs/calendar-alarm-dialog.xul
@@ -39,31 +39,34 @@
    - ***** END LICENSE BLOCK ***** -->
 
 <?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
 <?xml-stylesheet href="chrome://calendar/skin/calendar-alarm-dialog.css" type="text/css"?>
 
 <!-- used for button-text and button-menu-dropmarker classes -->
 <?xml-stylesheet href="chrome://global/skin/button.css" type="text/css"?>
 
+<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
+
 <!-- DTD File with all strings specific to the calendar -->
 <!DOCTYPE dialog SYSTEM "chrome://calendar/locale/calendar.dtd">
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         id="calendar-alarm-dialog"
         title="&calendar.alarm.title.label;"
         windowtype="Calendar:AlarmWindow"
         persist="screenX screenY width height"
         onload="setupWindow(); window.arguments[0].wrappedJSObject.window_onLoad();"
         onunload="finishWindow();"
         onfocus="onFocusWindow();"
         onkeypress="if (event.keyCode == event.DOM_VK_ESCAPE) { window.close(); }"
         width="600"
         height="300">
   <script type="application/javascript" src="chrome://calendar/content/calendar-alarm-dialog.js"/>
+  <script type="application/javascript" src="chrome://calendar/content/calendar-item-editing.js"/>
   <script type="application/javascript" src="chrome://calendar/content/calUtils.js"/>
 
   <richlistbox id="alarm-richlist" flex="1" onselect="onSelectAlarm(event)"/>
 
   <hbox pack="end" id="alarm-actionbar" align="center">
     <button id="alarm-snooze-all-button"
             type="menu"
             label="&calendar.alarm.snoozeallfor.label;">