Second set of bustage fixes for bug 475715 - Create a binding for the calendar list. r=ssitter
authorPhilipp Kewisch <mozilla@kewis.ch>
Wed, 04 Mar 2009 20:32:15 +0100
changeset 2130 78b9ab3d6c7e2179a953b92091ece7e7a6117221
parent 2129 0c9fa2b7a595c2cd90851ad29115d7583e0fef55
child 2131 8c263323b62ad1f7bd4ec72b8d023b42bda45327
push idunknown
push userunknown
push dateunknown
reviewersssitter
bugs475715
Second set of bustage fixes for bug 475715 - Create a binding for the calendar list. r=ssitter
calendar/base/content/calendar-task-tree.xml
calendar/base/content/widgets/calendar-list-tree.xml
--- a/calendar/base/content/calendar-task-tree.xml
+++ b/calendar/base/content/calendar-task-tree.xml
@@ -893,17 +893,17 @@
 
           onDefaultCalendarChanged: function tTO_onDefaultCalendarChanged(aNewDefaultCalendar) {}
       })
       ]]></field>
 
       <method name="observe">
         <parameter name="aSubject"/>
         <parameter name="aTopic"/>
-        <parameter name="aData"/>
+        <parameter name="aPrefName"/>
         <body><![CDATA[
           switch (aPrefName) {
               case "calendar.date.format":
               case "calendar.timezone.local":
                   this.refresh();
                   break;
           }
 
--- a/calendar/base/content/widgets/calendar-list-tree.xml
+++ b/calendar/base/content/widgets/calendar-list-tree.xml
@@ -46,16 +46,17 @@
       - This binding implements a full calendar list, that automatically adds
       - and removes calendars when a calendar is registered or unregistered.
       -->
     <implementation>
       <constructor><![CDATA[
         Components.utils.import("resource://calendar/modules/calUtils.jsm");
         let calMgr = cal.getCalendarManager();
         calMgr.addObserver(this.calMgrObserver);
+
       ]]></constructor>
       <destructor><![CDATA[
         let calMgr = cal.getCalendarManager();
         calMgr.removeObserver(this.calMgrObserver);
         this.calMgrObserver.listTree = null;
       ]]></destructor>
 
       <field name="mAddingFromComposite">false</field>
@@ -406,19 +407,16 @@
                 readonly="true"
                 onget="return this.compositeCalendar.getCalendars({});"/>
       <property name="allowDrag"
                 onget="return (this.getAttribute('allowdrag') == 'true');"
                 onset="return setBooleanAttribute(this, 'allowdrag', val);"/>
       <property name="writable"
                 onget="return (this.getAttribute('writable') == 'true');"
                 onset="return setBooleanAttribute(this, 'writable', val);"/>
-      <property name="seltype"
-                onget="return (this.getAttribute('seltype') || 'checkbox');"
-                onset="this.setAttribute('seltype', val); return val;"/>
       <property name="ignoreDisabledState"
                 onget="return (this.getAttribute('ignoredisabledstate') == 'true');"
                 onset="return setBooleanAttribute(this, 'ignoredisabledstate', val);"/>
 
       <method name="sortOrderChanged">
         <parameter name=""/>
         <body><![CDATA[
           if (this.mAddingFromComposite) {
@@ -568,31 +566,27 @@
       <method name="updateCalendarColor">
         <!--
           - Update a calendar's color rules.
           - 
           - @param aCalendar     The calendar to update.
           -->
         <parameter name="aCalendar"/>
         <body><![CDATA[
+          let color = aCalendar.getProperty("color") || "#a8c2e1";
+          let sheet = this.sheet;
           if (!(aCalendar.id in this.ruleCache)) {
-              let color = aCalendar.getProperty("color");
-              if (color) {
-                  let sheet = this.sheet;
-                  if (!(aCalendar.id in this.ruleCache)) {
-                      let ruleString = "calendar-list-tree > tree > treechildren" +
-                                       "::-moz-tree-cell(color-treecol, id-"  +
-                                       aCalendar.id + ") {}";
-                                     
-                      let ruleIndex = sheet.insertRule(ruleString, sheet.cssRules.length);
-                      this.ruleCache[aCalendar.id] = sheet.cssRules[ruleIndex];
-                  }
-                  this.ruleCache[aCalendar.id].style.backgroundColor = color;
-              }
+              let ruleString = "calendar-list-tree > tree > treechildren" +
+                               "::-moz-tree-cell(color-treecol, id-"  +
+                               aCalendar.id + ") {}";
+                             
+              let ruleIndex = sheet.insertRule(ruleString, sheet.cssRules.length);
+              this.ruleCache[aCalendar.id] = sheet.cssRules[ruleIndex];
           }
+          this.ruleCache[aCalendar.id].style.backgroundColor = color;
         ]]></body>
       </method>
 
       <method name="getCalendarFromEvent">
         <!--
           - Get the calendar from the given DOM event. This can be a Mouse event or a
           - keyboard event.
           -
@@ -1057,18 +1051,19 @@
         this.compositeCalendar.defaultCalendar = this.getCalendar(this.tree.currentIndex);
       ]]></handler>
       <handler event="keypress" keycode="VK_DELETE"><![CDATA[
         if (this.writable) {
             promptDeleteCalendar(this.compositeCalendar.defaultCalendar);
             event.preventDefault();
         }
       ]]></handler>
-      <handler event="keypress" keycode="VK_SPACE"><![CDATA[
-        if (this.tree.currentIndex > -1 && this.seltype == "checkbox") {
+      <!-- use key=" " since keycode="VK_SPACE" doesn't work -->
+      <handler event="keypress" key=" "><![CDATA[
+        if (this.tree.currentIndex > -1) {
             this.cycleCell(this.tree.currentIndex, this.getColumn("checkbox-treecol"));
             event.preventDefault();
         }
       ]]></handler>
       <handler event="keypress" keycode="VK_DOWN" modifiers="control"><![CDATA[
         if (!this.allowDrag) {
           return;
         }