mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 13:07:52 +00:00
Bug 329226: highlight current day. patch by thomas.benisch@sun.com, r=mvl
This commit is contained in:
parent
6498e1aa9e
commit
de11ff7f83
@ -37,6 +37,10 @@ calendar-month-day-box {
|
||||
background: #eeeeee;
|
||||
}
|
||||
|
||||
calendar-month-day-box[today="true"] {
|
||||
background: #dfeaf4 !important;
|
||||
}
|
||||
|
||||
calendar-month-day-box[selected="true"] {
|
||||
background: #ffe79c !important;
|
||||
}
|
||||
|
@ -914,6 +914,9 @@
|
||||
var dayCount = 7;
|
||||
var curRow = null;
|
||||
|
||||
// get today's date
|
||||
var today = this.today();
|
||||
|
||||
for each (var date in this.getDateList({})) {
|
||||
var box = createXULElement("calendar-month-day-box");
|
||||
box.setAttribute("context", this.getAttribute("context"));
|
||||
@ -956,6 +959,11 @@
|
||||
}
|
||||
box.monthView = this;
|
||||
|
||||
// highlight today
|
||||
if (date.compare(today) == 0) {
|
||||
box.setAttribute("today", "true");
|
||||
}
|
||||
|
||||
// add the box and its data to our stored array
|
||||
var boxdata = {
|
||||
date: date,
|
||||
@ -1001,6 +1009,9 @@
|
||||
mainMonth = mainMonth % 12;
|
||||
}
|
||||
|
||||
// get today's date
|
||||
var today = this.today();
|
||||
|
||||
for each (var date in this.getDateList({})) {
|
||||
var box;
|
||||
// Get the next box that we haven't updated from the previously
|
||||
@ -1041,6 +1052,11 @@
|
||||
box.showMonthLabel = true;
|
||||
}
|
||||
|
||||
// highlight today
|
||||
if (date.compare(today) == 0) {
|
||||
box.setAttribute("today", "true");
|
||||
}
|
||||
|
||||
// The box and its data is already in the array. We fixed the
|
||||
// date at the beginning, when we got it from the array.
|
||||
dateBoxCount++;
|
||||
@ -1160,6 +1176,17 @@
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="today">
|
||||
<body><![CDATA[
|
||||
var date = Components.classes["@mozilla.org/calendar/datetime;1"]
|
||||
.createInstance(Components.interfaces.calIDateTime);
|
||||
date.jsDate = new Date();
|
||||
date.isDate = true;
|
||||
date = date.getInTimezone(this.mTimezone);
|
||||
return date;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- our private observers and listeners -->
|
||||
|
||||
<field name="mOperationListener"><![CDATA[
|
||||
|
@ -12,10 +12,18 @@ calendar-event-column {
|
||||
border-top: 1px solid #999999;
|
||||
}
|
||||
|
||||
calendar-event-column[today="true"] {
|
||||
background: #dfeaf4 !important;
|
||||
}
|
||||
|
||||
calendar-event-column[selected="true"] {
|
||||
background: #ffe79c !important;
|
||||
}
|
||||
|
||||
calendar-header-container[today="true"] {
|
||||
background: #dfeaf4 !important;
|
||||
}
|
||||
|
||||
calendar-header-container[selected="true"] {
|
||||
background: #ffe79c !important;
|
||||
}
|
||||
|
@ -2250,6 +2250,9 @@
|
||||
var timebar = document.getAnonymousElementByAttribute(this, "anonid", "timebar");
|
||||
timebar.setStartEndMinutes(this.mStartMin, this.mEndMin);
|
||||
|
||||
// get today's date
|
||||
var today = this.today();
|
||||
|
||||
var counter = 0;
|
||||
for each (var d in computedDateList) {
|
||||
var dayEventsBox = createXULElement("calendar-event-column");
|
||||
@ -2272,6 +2275,12 @@
|
||||
dayHeaderBox.calendarView = this;
|
||||
dayHeaderBox.setAttribute("orient", orient);
|
||||
|
||||
// highlight today
|
||||
if (this.numVisibleDates > 1 && d.compare(today) == 0) {
|
||||
dayEventsBox.setAttribute("today", "true");
|
||||
dayHeaderBox.setAttribute("today", "true");
|
||||
}
|
||||
|
||||
var labelbox = createXULElement("box");
|
||||
labelbox.setAttribute("flex", "1");
|
||||
labelbox.setAttribute("orient", orient);
|
||||
@ -2590,6 +2599,18 @@
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="today">
|
||||
<body><![CDATA[
|
||||
var date = Components.classes["@mozilla.org/calendar/datetime;1"]
|
||||
.createInstance(Components.interfaces.calIDateTime);
|
||||
date.jsDate = new Date();
|
||||
date.isDate = true;
|
||||
date = date.getInTimezone(this.mTimezone);
|
||||
return date;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
|
@ -156,6 +156,7 @@
|
||||
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
this.mToday = false;
|
||||
this.mSelected = false;
|
||||
this.mValue = null;
|
||||
this.mEditorDate = null; // set only in showMonth
|
||||
@ -248,6 +249,17 @@
|
||||
<parameter name="aDate"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
|
||||
function sameDay(d1, d2) {
|
||||
if (d1 && d2 &&
|
||||
(d1.getFullYear() == d2.getFullYear()) &&
|
||||
(d1.getMonth() == d2.getMonth()) &&
|
||||
(d1.getDate() == d2.getDate())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!aDate) {
|
||||
aDate = new Date();
|
||||
} else {
|
||||
@ -261,6 +273,11 @@
|
||||
var monthChanged = (this.mEditorDate != aDate);
|
||||
this.mEditorDate = aDate; // only place mEditorDate is set.
|
||||
|
||||
if (this.mToday) {
|
||||
this.mToday.removeAttribute("today");
|
||||
this.mToday = null;
|
||||
}
|
||||
|
||||
if (this.mSelected) {
|
||||
this.mSelected.removeAttribute("selected");
|
||||
this.mSelected = null;
|
||||
@ -300,6 +317,9 @@
|
||||
var date = new Date(aDate);
|
||||
date.setDate(date.getDate()-firstWeekday);
|
||||
|
||||
// get today's date
|
||||
var today = new Date();
|
||||
|
||||
for (var k = 1; k < calbox.childNodes.length; k++) {
|
||||
var row = calbox.childNodes[k];
|
||||
for (i = 0; i < 7; i++) {
|
||||
@ -310,16 +330,19 @@
|
||||
day.removeAttribute("othermonth");
|
||||
}
|
||||
|
||||
// highlight today
|
||||
if (sameDay(today, date)) {
|
||||
this.mToday = day;
|
||||
day.setAttribute("today", "true");
|
||||
}
|
||||
|
||||
// highlight the current date
|
||||
var val = this.value;
|
||||
if (val) {
|
||||
if ((val.getFullYear() == date.getFullYear()) &&
|
||||
(val.getMonth() == date.getMonth()) &&
|
||||
(val.getDate() == date.getDate())) {
|
||||
this.mSelected = day;
|
||||
day.setAttribute("selected", "true");
|
||||
}
|
||||
if (sameDay(val, date)) {
|
||||
this.mSelected = day;
|
||||
day.setAttribute("selected", "true");
|
||||
}
|
||||
|
||||
day.date = new Date(date);
|
||||
day.calendar = this;
|
||||
day.setAttribute("value", date.getDate());
|
||||
|
@ -134,6 +134,10 @@
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.minimonth-day[today="true"] {
|
||||
background-color: #dfeaf4;
|
||||
}
|
||||
|
||||
.minimonth-day[selected="true"] {
|
||||
background-color: Highlight;
|
||||
color: HighlightText;
|
||||
|
@ -125,6 +125,10 @@
|
||||
font-weight : bold;
|
||||
}
|
||||
|
||||
.minimonth-day[today="true"] {
|
||||
background-color: #dfeaf4;
|
||||
}
|
||||
|
||||
.minimonth-day[selected="true"] {
|
||||
background-color: #778899;
|
||||
color: #ffffff;
|
||||
|
@ -121,6 +121,10 @@
|
||||
font-weight : bold;
|
||||
}
|
||||
|
||||
.minimonth-day[today="true"] {
|
||||
background-color: #dfeaf4;
|
||||
}
|
||||
|
||||
.minimonth-day[selected="true"] {
|
||||
background-color: #778899;
|
||||
color: #ffffff;
|
||||
|
@ -125,6 +125,10 @@
|
||||
font-weight : bold;
|
||||
}
|
||||
|
||||
.minimonth-day[today="true"] {
|
||||
background-color: #dfeaf4;
|
||||
}
|
||||
|
||||
.minimonth-day[selected="true"] {
|
||||
background-color: #778899;
|
||||
color: #ffffff;
|
||||
|
Loading…
x
Reference in New Issue
Block a user