Fix bug 422069 - Attendees in Event Dialog with only common name should have email address as tooltip. r=philipp
authorBZ <vampireb@gmail.com>
Tue, 07 Jun 2011 14:43:53 +0200
changeset 7895 1683deedbd847444cf07cdd330f108a4e7f2c8c9
parent 7894 05d369d9ecaf62c38e22776a77def82b89bd20e3
child 7896 e76c429aac9c07b1105188654b5c80127bb9d64e
push id6065
push usermozilla@kewis.ch
push dateTue, 07 Jun 2011 12:45:26 +0000
treeherdercomm-central@e76c429aac9c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp
bugs422069
Fix bug 422069 - Attendees in Event Dialog with only common name should have email address as tooltip. r=philipp
calendar/base/content/dialogs/calendar-event-dialog.js
calendar/base/content/dialogs/calendar-event-dialog.xul
--- a/calendar/base/content/dialogs/calendar-event-dialog.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog.js
@@ -2812,51 +2812,60 @@ function toggleLink() {
 
     updateLink();
 }
 
 /**
  * This function updates dialog controls related to attendees.
  */
 function updateAttendees() {
-    var attendeeRow = document.getElementById("event-grid-attendee-row");
-    var attendeeRow2 = document.getElementById("event-grid-attendee-row-2");
+    let attendeeRow = document.getElementById("event-grid-attendee-row");
+    let attendeeRow2 = document.getElementById("event-grid-attendee-row-2");
     if (window.attendees && window.attendees.length > 0) {
         attendeeRow.removeAttribute('collapsed');
         if (isEvent(window.calendarItem)) { // sending email invitations currently only supported for events
             attendeeRow2.removeAttribute('collapsed');
         } else {
             attendeeRow2.setAttribute('collapsed', 'true');
         }
 
-        var attendeeNames = "";
-        var numAttendees = window.attendees.length;
-        var regexp = new RegExp("^mailto:(.*)", "i");
-        for (var i = 0; i < numAttendees; i++) {
-            var attendee = window.attendees[i];
-            if (attendee.commonName && attendee.commonName.length) {
-                attendeeNames += (attendee.commonName.search(/[,;]/) != -1) ? '"' + attendee.commonName + '"'
-                                                                            : attendee.commonName;
+        let attendeeNames = [];
+        let attendeeEmails = [];
+        let numAttendees = window.attendees.length;
+        let emailRE = new RegExp("^mailto:(.*)", "i");
+        for (let i = 0; i < numAttendees; i++) {
+            let attendee = window.attendees[i];
+            let name = attendee.commonName;
+            if (name && name.length) {
+                attendeeNames.push(name);
+                let email = attendee.id;
+                if (email && email.length) {
+                    if (emailRE.test(email)) {
+                        name += ' <' + RegExp.$1 + '>';
+                    } else {
+                        name += ' <' + email + '>';
+                    }
+                    attendeeEmails.push(name);
+                }
             } else if (attendee.id && attendee.id.length) {
-                var email = attendee.id;
-                if (regexp.test(email)) {
-                    attendeeNames += RegExp.$1;
+                let email = attendee.id;
+                if (emailRE.test(email)) {
+                    attendeeNames.push(RegExp.$1);
                 } else {
-                    attendeeNames += email;
+                    attendeeNames.push(email);
                 }
             } else {
                 continue;
             }
-            if (i + 1 < numAttendees) {
-                attendeeNames += ', ';
-            }
         }
-        var attendeeList = document.getElementById("attendee-list");
-        var callback = function func() {
-            attendeeList.setAttribute('value', attendeeNames);
+
+        let attendeeList = document.getElementById("attendee-list");
+        let callback = function func() {
+            attendeeList.setAttribute('value', attendeeNames.join(', '));
+            attendeeList.setAttribute('tooltiptext', attendeeEmails.join(', '));
         }
         setTimeout(callback, 1);
     } else {
         attendeeRow.setAttribute('collapsed', 'true');
         attendeeRow2.setAttribute('collapsed', 'true');
     }
 }
 
--- a/calendar/base/content/dialogs/calendar-event-dialog.xul
+++ b/calendar/base/content/dialogs/calendar-event-dialog.xul
@@ -705,16 +705,17 @@
             <row id="event-grid-attendee-row" align="center">
               <label value="&event.attendees.label;"
                      accesskey="&event.attendees.accesskey;"
                      control="attendee-list"
                      disable-on-readonly="true"/>
               <label id="attendee-list"
                      class="text-link"
                      crop="right"
+                     tooltiptext=""
                      onclick="showAttendeePopup(event)"/>
             </row>
             <row id="event-grid-attendee-row-2" align="center">
               <spacer/>
               <checkbox id="notify-attendees-checkbox"
                         class="lightning-only"
                         label="&newevent.attendees.notify.label;"
                         pack="start"/>