Fix bug 433352 (and bug 416604, bug 432957) - Day/week view: category color is used for the entire event box (regression). r=berend

git-svn-id: svn://10.0.0.236/trunk@251652 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mozilla%kewis.ch 2008-05-15 15:27:05 +00:00
parent fa87f46f54
commit 36f100ea2e
5 changed files with 69 additions and 93 deletions

View File

@ -43,11 +43,30 @@
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="agenda-checkbox-richlist-item"
<binding id="agenda-base-richlist-item"
extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
<resources>
<stylesheet src="chrome://calendar/skin/widgets/calendar-widgets.css"/>
</resources>
<implementation>
<field name="mItem">null</field>;
<method name="getItem">
<body><![CDATA[
return this.mItem;
]]></body>
</method>
</implementation>
<handlers>
<handler event="dblclick" phase="capturing"><![CDATA[
document.getElementById('agenda_edit_event_command').doCommand();
event.stopPropagation();
event.preventDefault();
]]></handler>
</handlers>
</binding>
<binding id="agenda-checkbox-richlist-item"
extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
<content>
<xul:treenode-checkbox class="agenda-checkbox" anonid="agenda-checkbox-widget"
flex="1"
@ -55,10 +74,14 @@
</content>
<implementation>
<field name="kCheckbox">null</field>;
<field name="mItem">null</field>;
<constructor><![CDATA[
this.kCheckbox = document.getAnonymousElementByAttribute(this, "anonid", "agenda-checkbox-widget");
]]></constructor>
<method name="getItem">
<body><![CDATA[
return this.mItem;
]]></body>
</method>
<method name="setItem">
<parameter name="synthetic"/>
<parameter name="showsToday"/>
@ -81,11 +104,6 @@
}
]]></body>
</method>
<method name="getItem">
<body><![CDATA[
return this.mItem;
]]></body>
</method>
<method name="getCheckbox">
<body><![CDATA[
return this.kCheckbox;
@ -95,14 +113,12 @@
</binding>
<binding id="agenda-allday-richlist-item"
extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
<resources>
<stylesheet src="chrome://calendar/content/calendar-view-bindings.css"/>
</resources>
extends="chrome://calendar/content/agenda-listbox.xml#agenda-base-richlist-item">
<content>
<xul:hbox anonid="agenda-container-box" class="agenda-allday-container-box" xbl:inherits="selected,disabled"
flex="1"
ondblclick="document.getElementById('agenda_edit_event_command').doCommand();">
<xul:hbox anonid="agenda-container-box"
class="agenda-allday-container-box"
xbl:inherits="selected,disabled"
flex="1">
<xul:vbox pack="center" flex="1">
<xul:hbox flex="1">
<xul:calendar-month-day-box-item anonid="allday-item" flex="1"/>
@ -111,54 +127,35 @@
</xul:hbox>
</content>
<implementation>
<field name="mItem">null</field>;
<field name="mAllDayItem">null</field>;
<constructor><![CDATA[
this.mAllDayItem = document.getAnonymousElementByAttribute(this, "anonid", "allday-item");
this.mAllDayItem.removeShadows();
this.mAllDayItem.removeAttribute("tooltip");
this.mAllDayItem.addEventListener("dblclick", this.ondblclick, true);
]]></constructor>
<destructor><![CDATA[
this.mAllDayItem.removeEventListener("dblclick", this.ondblclick, true);
]]></destructor>
<method name="ondblclick">
<parameter name="aEvent"/>
<body><![CDATA[
document.getElementById('agenda_edit_event_command').doCommand();
aEvent.stopPropagation();
aEvent.preventDefault();
]]></body>
</method>
<method name="setItem">
<parameter name="item"/>
<parameter name="period"/>
<body><![CDATA[
this.mItem= item;
this.mItem = item;
this.mAllDayItem.occurrence = item;
var container = document.getAnonymousElementByAttribute(this.mAllDayItem, "anonid", "event-container");
container.setAttribute("class", "calendar-item");
]]></body>
</method>
<method name="getItem">
<body><![CDATA[
return this.mItem;
]]></body>
</method>
</implementation>
</binding>
<binding id="agenda-richlist-item"
extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
extends="chrome://calendar/content/agenda-listbox.xml#agenda-base-richlist-item">
<content>
<xul:hbox anonid="agenda-container-box" class="agenda-container-box" xbl:inherits="selected,disabled,current" flex="1"
ondblclick="document.getElementById('agenda_edit_event_command').doCommand();">
<xul:hbox>
<xul:vbox>
<xul:image anonid="agenda-calendar-image" class="agenda-calendar-image"/>
<xul:spacer flex="1"/>
</xul:vbox>
</xul:hbox>
<xul:hbox anonid="agenda-container-box" class="agenda-container-box" xbl:inherits="selected,disabled,current" flex="1">
<xul:hbox>
<xul:vbox>
<xul:image anonid="agenda-calendar-image" class="agenda-calendar-image"/>
<xul:spacer flex="1"/>
</xul:vbox>
</xul:hbox>
<xul:vbox anonid="agenda-description">
<xul:label anonid="agenda-event-start" class="agenda-event-start" crop="end" xbl:inherits="selected"/>
<xul:label anonid="agenda-event-title" class="agenda-event-title" crop="end" xbl:inherits="selected"/>
@ -166,12 +163,11 @@
</xul:hbox>
</content>
<implementation>
<field name="mItem">null</field>;
<method name="setItem">
<parameter name="item"/>
<parameter name="longFormat"/>
<body><![CDATA[
this.mItem= item;
this.mItem = item;
var titlebox = document.getAnonymousElementByAttribute(this, "anonid", "agenda-event-title");
titlebox.value = item.title;
@ -198,11 +194,6 @@
imagebox.setAttribute("style","background-color: " + calcolor + ";");
]]></body>
</method>
<method name="getItem">
<body><![CDATA[
return this.mItem;
]]></body>
</method>
</implementation>
</binding>
</bindings>

View File

@ -52,11 +52,14 @@
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="calendar-month-day-box-item" extends="chrome://calendar/content/calendar-view-core.xml#calendar-editable-item">
<content>
<content tooltip="itemTooltip">
<xul:vbox flex="1">
<xul:hbox>
<xul:image anonid="shadow-left-image" class="calendar-event-box-shadow-left"/>
<xul:box anonid="event-container" flex="1">
<xul:box anonid="event-container"
class="calendar-color-box"
xbl:inherits="item-calendar"
flex="1">
<xul:box class="calendar-event-selection" orient="horizontal" flex="1">
<xul:stack anonid="eventbox"
class="calendar-event-box-container"
@ -108,19 +111,6 @@
</xul:vbox>
</content>
<implementation>
<constructor><![CDATA[
var container = document.getAnonymousElementByAttribute(this,
"anonid",
"event-container");
container.setAttribute("class", "calendar-item");
container.setAttribute("class", this.getAttribute("class"));
container.setAttribute("item-calendar", this.getAttribute("item-calendar"));
this.removeAttribute("class");
this.removeAttribute("item-calendar");
]]>
</constructor>
<property name="occurrence">
<getter><![CDATA[
return this.mOccurrence;
@ -135,7 +125,7 @@
var label = document.getAnonymousElementByAttribute(this,"anonid","item-label");
var df = Components.classes["@mozilla.org/calendar/datetime-formatter;1"].
getService(Components.interfaces.calIDateTimeFormatter);
var timezone = this.calendarView? this.calendarView.mTimezone:
var timezone = this.calendarView ? this.calendarView.mTimezone :
calendarDefaultTimezone();
label.value = df.formatTime(
val.startDate.getInTimezone(timezone));
@ -525,9 +515,7 @@
var box = createXULElement("calendar-month-day-box-item");
box.setAttribute("context", this.getAttribute("item-context") || this.getAttribute("context"));
box.setAttribute("class", "calendar-item");
box.setAttribute("item-calendar", itd.item.calendar.uri.spec);
box.setAttribute("tooltip", "itemTooltip");
this.dayitems.insertBefore(box, before);

View File

@ -1955,7 +1955,7 @@
-->
<binding id="calendar-event-box" extends="chrome://calendar/content/calendar-view-core.xml#calendar-editable-item">
<content>
<content tooltip="itemTooltip">
<xul:box anonid="shadowbox"
xbl:inherits="width,height">
<xul:box anonid="shadow-left-box"
@ -1971,6 +1971,7 @@
class="calendar-event-box-shadow-left"
hidden="true"/>
<xul:box anonid="event-container"
class="calendar-color-box"
xbl:inherits="orient,readonly,flashing,alarm,allday,priority,progress,status,calendar,categories"
flex="1">
<xul:box class="calendar-event-selection" orient="horizontal" flex="1">
@ -2078,7 +2079,6 @@
var eventbox = document.getAnonymousElementByAttribute(this, "anonid", "eventbox");
eventbox.setAttribute("orient", val);
eventbox.setAttribute("class", "calendar-item calendar-event-box-" + val);
var gb1 = document.getAnonymousElementByAttribute(this, "anonid", "gripbar1");
gb1.parentorient = val;
var gb2 = document.getAnonymousElementByAttribute(this, "anonid", "gripbar2");

View File

@ -48,11 +48,13 @@
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="calendar-editable-item">
<content>
<content tooltip="itemTooltip">
<xul:vbox flex="1">
<xul:hbox>
<xul:image class="calendar-event-box-shadow-left"/>
<xul:box anonid="event-container" flex="1">
<xul:box anonid="event-container"
class="calendar-color-box"
flex="1">
<xul:box class="calendar-event-selection" orient="horizontal" flex="1">
<xul:stack anonid="eventbox"
class="calendar-event-box-container"
@ -83,7 +85,7 @@
</xul:hbox>
<xul:image anonid="gradient"
class="calendar-event-box-gradient"
hidden="true" height="1px"/>
height="1px"/>
</xul:stack>
</xul:box>
<xul:calendar-category-box anonid="category-box" xbl:inherits="categories"/>
@ -100,19 +102,6 @@
<implementation>
<constructor><![CDATA[
var gradient = document.getAnonymousElementByAttribute(this,
"anonid",
"gradient");
var container = document.getAnonymousElementByAttribute(this,
"anonid",
"event-container");
if (gradient) {
gradient.removeAttribute("hidden");
}
this.setAttribute("tooltip", "itemTooltip");
container.setAttribute("class", "calendar-item");
var self = this;
this.eventNameInput.onblur = function onBlur() { self.stopEditing(true); };
this.eventNameInput.onkeypress = function onKeyPress(event) {
@ -200,7 +189,7 @@
<method name="setCSSClasses">
<body><![CDATA[
var item = this.mOccurrence
var item = this.mOccurrence;
var container = document.getAnonymousElementByAttribute(this,
"anonid",
"event-container");
@ -244,7 +233,8 @@
this.setAttribute("readonly", "true");
}
if (item.hashId in this.calendarView.mFlashingEvents) {
if (this.calendarView &&
item.hashId in this.calendarView.mFlashingEvents) {
this.setAttribute("flashing", "true");
}
@ -280,8 +270,9 @@
this.eventNameTextbox.value = this.mOriginalTextLabel;
this.eventNameTextbox.removeAttribute("hidden");
if (this.calendarView)
if (this.calendarView) {
this.calendarView.activeInPlaceEdit = true;
}
this.eventNameInput.focus();
this.eventNameInput.select();
]]></body>
@ -289,6 +280,9 @@
<method name="select">
<parameter name="event"/>
<body><![CDATA[
if (!this.calendarView) {
return;
}
var items;
if (event.ctrlKey || event.metaKey) {
items = this.calendarView.mSelectedItems;
@ -307,8 +301,9 @@
this.mEditing = false;
if (this.calendarView)
if (this.calendarView) {
this.calendarView.activeInPlaceEdit = false;
}
if (saveChanges && (this.eventNameTextbox.value != this.mOriginalTextLabel)) {
this.calendarView.controller.modifyOccurrence(this.mOccurrence,
@ -363,7 +358,7 @@
this.editingTimer = null;
}
if (this.calendarView.controller) {
if (this.calendarView && this.calendarView.controller) {
var item = (event.ctrlKey) ? this.mOccurrence.parentItem : this.mOccurrence;
this.calendarView.controller.modifyOccurrence(item);
}
@ -443,7 +438,7 @@
is not specified -->
<content>
<xul:vbox anonid="category-box"
class="calendar-item calendar-event-selection"
class="category-color-box calendar-event-selection"
xbl:inherits="categories">
<xul:hbox flex="1">
<xul:image class="calendar-category-box-gradient" height="1"/>

View File

@ -447,10 +447,11 @@ function getStyleSheet(aStyleSheetPath) {
* equivalent to formatStringForCSSRule(categoryNameInUnicode)].
*/
function updateStyleSheetForObject(aObject, aSheet) {
var selectorPrefix, name, ruleUpdaterFunc;
var selectorPrefix, name, ruleUpdaterFunc, classPrefix;
if (aObject.uri) {
// For a calendar, set background and contrasting text colors
name = aObject.uri.spec;
classPrefix = ".calendar-color-box";
selectorPrefix = "item-calendar=";
ruleUpdaterFunc = function calendarRuleFunc(aRule, aIndex) {
var color = aObject.getProperty('color');
@ -465,6 +466,7 @@ function updateStyleSheetForObject(aObject, aSheet) {
// it uses the ~= selector, since there could be multiple categories.
name = aObject;
selectorPrefix = "categories~=";
classPrefix = ".category-color-box"
ruleUpdaterFunc = function categoryRuleFunc(aRule, aIndex) {
var color = getPrefSafe("calendar.category.color."+name, null);
if (color) {
@ -475,7 +477,7 @@ function updateStyleSheetForObject(aObject, aSheet) {
};
}
var selector = '.calendar-item[' + selectorPrefix + '"' + name + '"]';
var selector = classPrefix + '[' + selectorPrefix + '"' + name + '"]';
// Now go find our rule
var rule, ruleIndex;