Fix bug 369848 - Full weekday name in multiday views. r=mickey ui-r: christian

This commit is contained in:
mozilla%kewis.ch 2007-06-29 14:05:17 +00:00
Родитель 7fd7dc705e
Коммит 4a5b49327a
4 изменённых файлов: 138 добавлений и 18 удалений

Просмотреть файл

@ -1774,9 +1774,86 @@
</handlers>
</binding>
<binding id="calendar-day-label">
<content>
<xul:hbox anonid="mainbox" flex="1">
<xul:spacer flex="1"/>
<xul:vbox>
<xul:label anonid="dateName" class="calendar-day-label-date"/>
<xul:label anonid="longWeekdayName" class="calendar-day-label-name"/>
<xul:label anonid="shortWeekdayName" class="calendar-day-label-name" hidden="true"/>
</xul:vbox>
<xul:spacer flex="1"/>
</xul:hbox>
</content>
<implementation>
<field name="longWeekdayPixels">0</field>
<field name="mDate">null</field>
<property name="date">
<getter><![CDATA[
return this.mDate;
]]></getter>
<setter><![CDATA[
this.mDate = val;
var df = Cc["@mozilla.org/calendar/datetime-formatter;1"].
getService(Ci.calIDateTimeFormatter);
var short = document.getAnonymousElementByAttribute(this, "anonid", "shortWeekdayName");
var long = document.getAnonymousElementByAttribute(this, "anonid", "longWeekdayName");
var day = document.getAnonymousElementByAttribute(this, "anonid", "dateName");
long.setAttribute("value", calGetString("dateFormat","day." + (val.weekday + 1) + ".name"));
short.setAttribute("value", calGetString("dateFormat","day." + (val.weekday + 1) + ".Mmm"));
day.setAttribute("value", df.formatDateWithoutYear(val));
return val;
]]></setter>
</property>
<property name="shortWeekNames">
<getter><![CDATA[
return document.getAnonymousElementByAttribute(this, "anonid", "shortWeekdayName").hasAttribute("hidden");
]]></getter>
<setter><![CDATA[
var short = document.getAnonymousElementByAttribute(this, "anonid", "shortWeekdayName");
var long = document.getAnonymousElementByAttribute(this, "anonid", "longWeekdayName");
// cache before change, in case we are switching to short
this.cacheLongWeekdayPixels(long);
if (val) {
long.setAttribute("hidden","true");
short.removeAttribute("hidden");
} else {
long.removeAttribute("hidden");
short.setAttribute("hidden","true");
}
// cache after change, in case we are switching from short
this.cacheLongWeekdayPixels(long);
return val;
]]></setter>
</property>
<method name="cacheLongWeekdayPixels">
<parameter name="long"/>
<body><![CDATA[
// Only do this if the long weekdays are visible and we haven't already cached.
if (!this.longWeekdayPixels && !long.hasAttribute("hidden")) {
this.longWeekdayPixels = long.boxObject.width +
parseInt(document.defaultView.getComputedStyle(long, null).getPropertyValue("margin-left")) +
parseInt(document.defaultView.getComputedStyle(long, null).getPropertyValue("margin-right"));
}
]]></body>
</method>
</implementation>
</binding>
<binding id="calendar-multiday-view">
<content>
<xul:box anonid="mainbox" flex="1">
<xul:box anonid="mainbox" flex="1" onoverflow="adjustWeekdayLength();">
<!-- these boxes are tricky: width or height in CSS depend on orient -->
<xul:box anonid="labelbox">
<xul:box anonid="labeltimespacer">
@ -1832,6 +1909,13 @@
this.mCalendar.removeObserver(this.mObserver);
]]></destructor>
<property name="daysInView" readonly="true">
<getter><![CDATA[
var labeldaybox = document.getAnonymousElementByAttribute(this, "anonid", "labeldaybox");
return labeldaybox.childNodes && labeldaybox.childNodes.length;
]]></getter>
</property>
<method name="onResize">
<parameter name="aRealSelf"/>
<body><![CDATA[
@ -1853,6 +1937,9 @@
}
self.pixelsPerMinute = ppm;
setTimeout(function(){self.scrollToMinute(self.mFirstVisibleMinute)}, 1);
// Fit the weekday labels while scrolling.
self.adjustWeekdayLength();
]]></body>
</method>
@ -1882,6 +1969,7 @@
<field name="mBatchCount">0</field>
<field name="mPixPerMin">0.6</field>
<field name="mMinPixelsPerMinute">0.1</field>
<field name="mLongWeekdayTotalPixels">0</field>
<field name="mSelectedItems">[]</field>
<field name="mSelectedDayCol">null</field>
<field name="mSelectedDay">null</field>
@ -2601,6 +2689,7 @@
// get today's date
var today = this.today();
var counter = 0;
var maxDayWidth = 0;
var dayboxkids = daybox.childNodes;
var headerboxkids = headerdaybox.childNodes;
var labelboxkids = labeldaybox.childNodes;
@ -2655,26 +2744,17 @@
getService(Ci.calIDateTimeFormatter);
if (counter < labelboxkids.length) {
labelbox = labelboxkids[counter];
labelbox.firstChild.setAttribute("value", df.formatDateWithoutYear(d));
labelbox.childNodes[1].setAttribute("value", calGetString("dateFormat", "day."+ (d.weekday+1)+ ".Mmm"));
labelbox.date = d;
labelbox.shortWeekNames = false;
} else {
labelbox = createXULElement("vbox");
labelbox = createXULElement("calendar-day-label");
labelbox.setAttribute("flex", "1");
labelbox.setAttribute("class", "calendar-day-label-box");
var label = createXULElement("label");
label.setAttribute("value", df.formatDateWithoutYear(d));
label.setAttribute("class", "calendar-day-label-date");
labelbox.appendChild(label);
labeldaybox.appendChild(labelbox);
label = createXULElement("label");
label.setAttribute("value", calGetString("dateFormat", "day."+ (d.weekday+1)+ ".Mmm"));
label.setAttribute("class", "calendar-day-label-name");
labelbox.appendChild(label);
labeldaybox.appendChild(labelbox);
labelbox.date = d;
labelbox.shortWeekNames = false;
}
maxDayWidth = Math.max(maxDayWidth, labelbox.longWeekdayPixels);
// We don't want to actually mess with our original dates, plus
// they're likely to be immutable.
@ -2695,6 +2775,9 @@
removeExtraKids(headerdaybox);
removeExtraKids(labeldaybox);
// Cache weekday length, give a 10 px grace period.
this.mLongWeekdayTotalPixels = maxDayWidth * labeldaybox.childNodes.length + 10;
// fix pixels-per-minute
this.onResize();
for each (col in this.mDateColumns) {
@ -2863,6 +2946,36 @@
return date;
]]></body>
</method>
<method name="adjustWeekdayLength">
<body><![CDATA[
// This function is called from the resize handler and also from the
// overflow event of the mainbox. The latter guarantees that the
// labels are clipped in the instance that the overflow occurrs,
// avoiding horizontal scrollbars from showing up for a short period.
var labeldaybox = document.getAnonymousElementByAttribute(this, "anonid", "labeldaybox");
var labeldayboxkids = labeldaybox.childNodes;
if (!labeldayboxkids || !labeldayboxkids[0]) {
// This happens in rotated view. Don't do anything there.
return;
}
if (labeldayboxkids[0].boxObject.width * this.daysInView > this.mLongWeekdayTotalPixels) {
// We have an underflow. Since the boxes all have equal width, we
// can use the first boxes' width and multiply bu the number of
// days in the view.
for each (var kid in labeldayboxkids) {
kid.shortWeekNames = false;
}
} else {
// We have an overflow
for each (var kid in labeldayboxkids) {
kid.shortWeekNames = true;
}
}
]]></body>
</method>
<method name="adjustScrollBarSpacers">
<body><![CDATA[

Просмотреть файл

@ -22,6 +22,7 @@
* Vladimir Vukicevic <vladimir@pobox.com>
* Joey Minta <jminta@gmail.com>
* Michiel van Leeuwen <mvl@exedo.nl>
* Philipp Kewisch <mozilla@kewis.ch>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -60,6 +61,10 @@ calendar-multiday-view {
-moz-user-focus: normal;
}
calendar-day-label {
-moz-binding: url(chrome://calendar/content/calendar-multiday-view.xml#calendar-day-label);
}
calendar-header-container {
-moz-binding: url(chrome://calendar/content/calendar-multiday-view.xml#calendar-header-container);
}

Просмотреть файл

@ -22,6 +22,7 @@
* Vladimir Vukicevic <vladimir@pobox.com>
* Joey Minta <jminta@gmail.com>
* Michiel van Leeuwen <mvl@exedo.nl>
* Philipp Kewisch <mozilla@kewis.ch>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -267,7 +268,7 @@ calendar-multiday-view[hidden="true"] {
display: none;
}
.calendar-day-label-box {
calendar-day-label {
color: #3F7D91;
background: #E7EEEC;
border-top: 1px solid #3F7D91;

Просмотреть файл

@ -22,6 +22,7 @@
* Vladimir Vukicevic <vladimir@pobox.com>
* Joey Minta <jminta@gmail.com>
* Michiel van Leeuwen <mvl@exedo.nl>
* Philipp Kewisch <mozilla@kewis.ch>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -267,7 +268,7 @@ calendar-multiday-view[hidden="true"] {
display: none;
}
.calendar-day-label-box {
calendar-day-label {
color: #3F7D91;
background: #E7EEEC;
border-top: 1px solid #3F7D91;