Changing DOS <CR>s to linux linefeeds
git-svn-id: svn://10.0.0.236/trunk@155293 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1,425 +1,425 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
/* MiniMonth Calendar: day-of-month grid XBL component.
|
||||
Displays month name above days of month in grid, by week rows.
|
||||
Arrows beside month move forward or back a month.
|
||||
Clicking on a day cell calls onchange attribute.
|
||||
Clicking on month arrows calls onmonthchange attribute.
|
||||
|
||||
Used in datepicker.xbl and as mini-month in calendar.xul of Calendar.
|
||||
|
||||
At site, can provide id, and code to run when value changed by picker.
|
||||
<calendar id="my-date-picker" onchange="myDatePick( this );"/>
|
||||
|
||||
May get/set value in javascript with
|
||||
document.getElementById("my-date-picker").value = new Date();
|
||||
*/
|
||||
-->
|
||||
<bindings id="xulMiniMonth"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl"
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<binding id="minimonth" extends="xul:box" xbl:inherits="onchange,onmonthchange">
|
||||
|
||||
<!-- ::::::::::::::::: CONTENT ::::::::::::::::::::::::: -->
|
||||
<content>
|
||||
|
||||
<xul:vbox class="minimonth-mainbox" flex="1">
|
||||
<xul:hbox class="minimonth-month-box">
|
||||
<xul:image class="minimonth-navbtn" dir="-1"/>
|
||||
<xul:spacer flex="1"/>
|
||||
<xul:text id="month-name" class="minimonth-month-name" value="Month"/>
|
||||
<xul:spacer flex="1"/>
|
||||
<xul:image class="minimonth-navbtn" dir="1"/>
|
||||
</xul:hbox>
|
||||
<xul:vbox class="minimonth-cal-box" flex="1">
|
||||
<xul:hbox class="minimonth-row-head" equalsize="always">
|
||||
<xul:text class="minimonth-header" flex="1"/>
|
||||
<xul:text class="minimonth-header" flex="1"/>
|
||||
<xul:text class="minimonth-header" flex="1"/>
|
||||
<xul:text class="minimonth-header" flex="1"/>
|
||||
<xul:text class="minimonth-header" flex="1"/>
|
||||
<xul:text class="minimonth-header" flex="1"/>
|
||||
<xul:text class="minimonth-header" flex="1"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox class="minimonth-row-body" equalsize="always" flex="1">
|
||||
<xul:text class="minimonth-day" flex="1" />
|
||||
<xul:text class="minimonth-day" flex="1" />
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox class="minimonth-row-body" equalsize="always" flex="1">
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox class="minimonth-row-body" equalsize="always" flex="1">
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox class="minimonth-row-body" equalsize="always" flex="1">
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox class="minimonth-row-body" equalsize="always" flex="1">
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox class="minimonth-row-body" equalsize="always" flex="1">
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
</xul:hbox>
|
||||
</xul:vbox>
|
||||
</xul:vbox>
|
||||
</content>
|
||||
|
||||
<!-- ::::::::::::::::: INTERFACE ::::::::::::::::::::::::: -->
|
||||
<implementation>
|
||||
|
||||
<property name="value"
|
||||
onget="return this.mValue"
|
||||
onset="this.update(val)"/>
|
||||
|
||||
<property name="onchange"/>
|
||||
|
||||
<property name="onmonthchange"/>
|
||||
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
this.refreshDisplay( );
|
||||
]]>
|
||||
</constructor>
|
||||
|
||||
<method name="refreshDisplay">
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (!this.mInitialized) {
|
||||
this.mInitialized = true;
|
||||
|
||||
// Find out which should be the first day of the week
|
||||
var pref = Components.classes[
|
||||
"@mozilla.org/preferences-service;1"
|
||||
].getService(Components.interfaces.nsIPrefBranch);
|
||||
|
||||
this.weekStart;
|
||||
try {
|
||||
this.weekStart = pref.getIntPref("calendar.week.start");
|
||||
}
|
||||
catch (e) {
|
||||
this.weekStart = 0;
|
||||
}
|
||||
|
||||
// save references for convenience
|
||||
var monthbox = document.getAnonymousNodes(this)[0].childNodes[0];
|
||||
this.mLeftBtn = monthbox.childNodes[0];
|
||||
this.mLeftBtn.mCalendar = this;
|
||||
this.mRightBtn = monthbox.childNodes[4];
|
||||
this.mRightBtn.mCalendar = this;
|
||||
this.mMonthCell = monthbox.childNodes[2];
|
||||
|
||||
var val = this.parentNode.parentNode.parentNode.parentNode.value;
|
||||
if (val) this.mValue = new Date(val);
|
||||
else this.mValue = new Date();
|
||||
|
||||
var change = this.getAttribute("onchange");
|
||||
if (change) this.onchange = new Function(change);
|
||||
|
||||
var monthchange = this.getAttribute("onmonthchange");
|
||||
if (monthchange) this.onmonthchange = new Function(monthchange);
|
||||
|
||||
this.setHeader();
|
||||
this.showMonth(this.mValue);
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="setHeader">
|
||||
<body><![CDATA[
|
||||
// need to create string bundle manually instead of
|
||||
// using <xul:stringbundle/> see bug 63370 for details
|
||||
|
||||
var localeService = Components.classes[
|
||||
"@mozilla.org/intl/nslocaleservice;1"
|
||||
].getService(Components.interfaces.nsILocaleService);
|
||||
|
||||
var stringBundleService = Components.classes[
|
||||
"@mozilla.org/intl/stringbundle;1"
|
||||
].getService(Components.interfaces.nsIStringBundleService);
|
||||
|
||||
var bundleURL = "chrome://calendar/locale/dateFormat.properties";
|
||||
var dateBundle = stringBundleService.createBundle(
|
||||
bundleURL, localeService.getApplicationLocale()
|
||||
);
|
||||
|
||||
// Reset the headers
|
||||
var header = document.getAnonymousNodes(this)[0].
|
||||
childNodes[1].childNodes[0]
|
||||
;
|
||||
|
||||
for (var column = 0; column < header.childNodes.length; column++) {
|
||||
|
||||
header.childNodes[column].setAttribute( "value",
|
||||
dateBundle.GetStringFromName(
|
||||
"day."+
|
||||
((this.weekStart + column) % 7 + 1) +
|
||||
".short"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
||||
<method name="showMonth">
|
||||
<parameter name="aDate"/>
|
||||
<body><![CDATA[
|
||||
if (!aDate) {
|
||||
aDate = new Date();
|
||||
} else {
|
||||
aDate = new Date(aDate.toString());
|
||||
aDate.setDate(1);
|
||||
}
|
||||
this.mEditorDate = aDate;
|
||||
|
||||
if (this.mSelected) {
|
||||
this.mSelected.setAttribute("selected", "");
|
||||
this.mSelected = null;
|
||||
}
|
||||
|
||||
//-------- Update the month title
|
||||
var mon = this.getMonthName(aDate) + " " + aDate.getFullYear();
|
||||
|
||||
this.mMonthCell.setAttribute("value", mon);
|
||||
|
||||
//-------- Update the calendar
|
||||
var calbox = document.getAnonymousNodes(this)[0].childNodes[1];
|
||||
|
||||
var firstWeekday = (7 + aDate.getDay() - this.weekStart) % 7;
|
||||
var date = new Date(aDate.getTime());
|
||||
date.setDate(date.getDate()-firstWeekday);
|
||||
|
||||
for (var k = 1; k < calbox.childNodes.length; k++) {
|
||||
var row = calbox.childNodes[k];
|
||||
|
||||
|
||||
for (var i = 0; i < 7; i++) {
|
||||
var day = row.childNodes[i];
|
||||
|
||||
if (aDate.getMonth() != date.getMonth()) {
|
||||
day.setAttribute("othermonth", "true");
|
||||
} else {
|
||||
day.setAttribute("othermonth", "");
|
||||
}
|
||||
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
day.date = date;
|
||||
day.calendar = this;
|
||||
day.setAttribute("value", date.getDate());
|
||||
date = new Date(date.getTime());
|
||||
date.setDate(date.getDate() + 1);
|
||||
}
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="setBusyDates">
|
||||
<parameter name="arrayOfDates"/>
|
||||
<body><![CDATA[
|
||||
/* CODE FROM monthView.js for finding the events for the month. */
|
||||
/*
|
||||
document.getElementById( "lefthandcalendar" ).value = date;
|
||||
|
||||
//get a list of events for this month.
|
||||
var monthEvents =
|
||||
this.eventSource.getEventsForMonth( this.getSelectedDate() );
|
||||
|
||||
var arrayOfDates = new Array();
|
||||
|
||||
for( var eventIndex = 0; eventIndex < monthEvents.length; ++eventIndex )
|
||||
{
|
||||
var calendarEventDisplay = monthEvents[ eventIndex ];
|
||||
var eventDate = new Date( calendarEventDisplay.displayDate );
|
||||
|
||||
//add them to an array
|
||||
arrayOfDates[ eventDate.getDate() ] = true;
|
||||
|
||||
}
|
||||
document.getElementById( "lefthandcalendar" ).setBusyDates( arrayOfDates );
|
||||
*/
|
||||
var aDate = new Date();
|
||||
aDate.setDate( 1 );
|
||||
//-------- Update the calendar
|
||||
var calbox = document.getAnonymousNodes(this)[0].childNodes[1];
|
||||
|
||||
// weekStart day is set by preference
|
||||
var firstWeekday = (7 + aDate.getDay() - this.weekStart) % 7;
|
||||
var date = new Date(aDate.getTime());
|
||||
date.setDate(date.getDate() - firstWeekday);
|
||||
|
||||
for (var k = 1; k < calbox.childNodes.length; k++) {
|
||||
var row = calbox.childNodes[k];
|
||||
for (var i = 0; i < 7; i++) {
|
||||
var day = row.childNodes[i];
|
||||
|
||||
if (aDate.getMonth() == date.getMonth() &&
|
||||
arrayOfDates[ date.getDate() ] == true ) {
|
||||
day.setAttribute("busy", "true");
|
||||
} else {
|
||||
day.removeAttribute("busy");
|
||||
}
|
||||
|
||||
// next date of month, may increment month
|
||||
date.setDate(date.getDate() + 1);
|
||||
}
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="advanceMonth">
|
||||
<parameter name="aDir"/>
|
||||
<body><![CDATA[
|
||||
|
||||
var ad = this.mEditorDate.getMonth() + aDir;
|
||||
this.mEditorDate.setMonth(ad);
|
||||
|
||||
this.showMonth(this.mEditorDate);
|
||||
|
||||
if (this.mSelected) {
|
||||
this.mSelected.removeAttribute("selected");
|
||||
}
|
||||
|
||||
this.value = this.mEditorDate;
|
||||
|
||||
if (this.onmonthchange) this.onmonthchange();
|
||||
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="dayClicked">
|
||||
<parameter name="aDay"/>
|
||||
<body><![CDATA[
|
||||
|
||||
if (this.mSelected) {
|
||||
this.mSelected.setAttribute("selected", "");
|
||||
}
|
||||
|
||||
this.mSelected = aDay;
|
||||
aDay.setAttribute("selected", "true");
|
||||
|
||||
this.value = aDay.date;
|
||||
|
||||
if (this.onchange) this.onchange();
|
||||
|
||||
if (this.parentNode.parentNode.parentNode.parentNode.callback)
|
||||
this.parentNode.parentNode.parentNode.parentNode.callback();
|
||||
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="update">
|
||||
<parameter name="aValue"/>
|
||||
<body><![CDATA[
|
||||
|
||||
this.mValue = aValue;
|
||||
this.showMonth(aValue);
|
||||
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="getMonthName">
|
||||
<parameter name="aDate"/>
|
||||
<body><![CDATA[
|
||||
|
||||
var dateStringBundle =
|
||||
srGetStrBundle("chrome://calendar/locale/dateFormat.properties");
|
||||
|
||||
var monthNames = new Array(12);
|
||||
monthNames[0] = dateStringBundle.GetStringFromName("month.1.name");
|
||||
monthNames[1] = dateStringBundle.GetStringFromName("month.2.name");
|
||||
monthNames[2] = dateStringBundle.GetStringFromName("month.3.name");
|
||||
monthNames[3] = dateStringBundle.GetStringFromName("month.4.name");
|
||||
monthNames[4] = dateStringBundle.GetStringFromName("month.5.name");
|
||||
monthNames[5] = dateStringBundle.GetStringFromName("month.6.name");
|
||||
monthNames[6] = dateStringBundle.GetStringFromName("month.7.name");
|
||||
monthNames[7] = dateStringBundle.GetStringFromName("month.8.name");
|
||||
monthNames[8] = dateStringBundle.GetStringFromName("month.9.name");
|
||||
monthNames[9] = dateStringBundle.GetStringFromName("month.10.name");
|
||||
monthNames[10]= dateStringBundle.GetStringFromName("month.11.name");
|
||||
monthNames[11]= dateStringBundle.GetStringFromName("month.12.name");
|
||||
|
||||
var midx = aDate.getMonth();
|
||||
|
||||
return monthNames[midx];
|
||||
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
</implementation>
|
||||
|
||||
<!-- ::::::::::::::::: HANDLERS ::::::::::::::::::::::::: -->
|
||||
<handlers>
|
||||
<handler event="bindingattached" action="this.initialize();"/>
|
||||
</handlers>
|
||||
|
||||
</binding>
|
||||
|
||||
<binding id="minimonth-navbtn" inherits="dir">
|
||||
<!-- ::::::::::::::::: HANDLERS ::::::::::::::::::::::::: -->
|
||||
<handlers>
|
||||
<handler event="click">
|
||||
<![CDATA[
|
||||
this.mCalendar.advanceMonth(parseInt(this.getAttribute('dir')));
|
||||
]]>
|
||||
</handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
<binding id="minimonth-day" extends="xul:text">
|
||||
<!-- ::::::::::::::::: HANDLERS ::::::::::::::::::::::::: -->
|
||||
<handlers>
|
||||
<handler event="click" action="this.calendar.dayClicked(this)"/>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
</bindings>
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
/* MiniMonth Calendar: day-of-month grid XBL component.
|
||||
Displays month name above days of month in grid, by week rows.
|
||||
Arrows beside month move forward or back a month.
|
||||
Clicking on a day cell calls onchange attribute.
|
||||
Clicking on month arrows calls onmonthchange attribute.
|
||||
|
||||
Used in datepicker.xbl and as mini-month in calendar.xul of Calendar.
|
||||
|
||||
At site, can provide id, and code to run when value changed by picker.
|
||||
<calendar id="my-date-picker" onchange="myDatePick( this );"/>
|
||||
|
||||
May get/set value in javascript with
|
||||
document.getElementById("my-date-picker").value = new Date();
|
||||
*/
|
||||
-->
|
||||
<bindings id="xulMiniMonth"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl"
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<binding id="minimonth" extends="xul:box" xbl:inherits="onchange,onmonthchange">
|
||||
|
||||
<!-- ::::::::::::::::: CONTENT ::::::::::::::::::::::::: -->
|
||||
<content>
|
||||
|
||||
<xul:vbox class="minimonth-mainbox" flex="1">
|
||||
<xul:hbox class="minimonth-month-box">
|
||||
<xul:image class="minimonth-navbtn" dir="-1"/>
|
||||
<xul:spacer flex="1"/>
|
||||
<xul:text id="month-name" class="minimonth-month-name" value="Month"/>
|
||||
<xul:spacer flex="1"/>
|
||||
<xul:image class="minimonth-navbtn" dir="1"/>
|
||||
</xul:hbox>
|
||||
<xul:vbox class="minimonth-cal-box" flex="1">
|
||||
<xul:hbox class="minimonth-row-head" equalsize="always">
|
||||
<xul:text class="minimonth-header" flex="1"/>
|
||||
<xul:text class="minimonth-header" flex="1"/>
|
||||
<xul:text class="minimonth-header" flex="1"/>
|
||||
<xul:text class="minimonth-header" flex="1"/>
|
||||
<xul:text class="minimonth-header" flex="1"/>
|
||||
<xul:text class="minimonth-header" flex="1"/>
|
||||
<xul:text class="minimonth-header" flex="1"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox class="minimonth-row-body" equalsize="always" flex="1">
|
||||
<xul:text class="minimonth-day" flex="1" />
|
||||
<xul:text class="minimonth-day" flex="1" />
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox class="minimonth-row-body" equalsize="always" flex="1">
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox class="minimonth-row-body" equalsize="always" flex="1">
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox class="minimonth-row-body" equalsize="always" flex="1">
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox class="minimonth-row-body" equalsize="always" flex="1">
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox class="minimonth-row-body" equalsize="always" flex="1">
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
<xul:text class="minimonth-day" flex="1"/>
|
||||
</xul:hbox>
|
||||
</xul:vbox>
|
||||
</xul:vbox>
|
||||
</content>
|
||||
|
||||
<!-- ::::::::::::::::: INTERFACE ::::::::::::::::::::::::: -->
|
||||
<implementation>
|
||||
|
||||
<property name="value"
|
||||
onget="return this.mValue"
|
||||
onset="this.update(val)"/>
|
||||
|
||||
<property name="onchange"/>
|
||||
|
||||
<property name="onmonthchange"/>
|
||||
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
this.refreshDisplay( );
|
||||
]]>
|
||||
</constructor>
|
||||
|
||||
<method name="refreshDisplay">
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (!this.mInitialized) {
|
||||
this.mInitialized = true;
|
||||
|
||||
// Find out which should be the first day of the week
|
||||
var pref = Components.classes[
|
||||
"@mozilla.org/preferences-service;1"
|
||||
].getService(Components.interfaces.nsIPrefBranch);
|
||||
|
||||
this.weekStart;
|
||||
try {
|
||||
this.weekStart = pref.getIntPref("calendar.week.start");
|
||||
}
|
||||
catch (e) {
|
||||
this.weekStart = 0;
|
||||
}
|
||||
|
||||
// save references for convenience
|
||||
var monthbox = document.getAnonymousNodes(this)[0].childNodes[0];
|
||||
this.mLeftBtn = monthbox.childNodes[0];
|
||||
this.mLeftBtn.mCalendar = this;
|
||||
this.mRightBtn = monthbox.childNodes[4];
|
||||
this.mRightBtn.mCalendar = this;
|
||||
this.mMonthCell = monthbox.childNodes[2];
|
||||
|
||||
var val = this.parentNode.parentNode.parentNode.parentNode.value;
|
||||
if (val) this.mValue = new Date(val);
|
||||
else this.mValue = new Date();
|
||||
|
||||
var change = this.getAttribute("onchange");
|
||||
if (change) this.onchange = new Function(change);
|
||||
|
||||
var monthchange = this.getAttribute("onmonthchange");
|
||||
if (monthchange) this.onmonthchange = new Function(monthchange);
|
||||
|
||||
this.setHeader();
|
||||
this.showMonth(this.mValue);
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="setHeader">
|
||||
<body><![CDATA[
|
||||
// need to create string bundle manually instead of
|
||||
// using <xul:stringbundle/> see bug 63370 for details
|
||||
|
||||
var localeService = Components.classes[
|
||||
"@mozilla.org/intl/nslocaleservice;1"
|
||||
].getService(Components.interfaces.nsILocaleService);
|
||||
|
||||
var stringBundleService = Components.classes[
|
||||
"@mozilla.org/intl/stringbundle;1"
|
||||
].getService(Components.interfaces.nsIStringBundleService);
|
||||
|
||||
var bundleURL = "chrome://calendar/locale/dateFormat.properties";
|
||||
var dateBundle = stringBundleService.createBundle(
|
||||
bundleURL, localeService.getApplicationLocale()
|
||||
);
|
||||
|
||||
// Reset the headers
|
||||
var header = document.getAnonymousNodes(this)[0].
|
||||
childNodes[1].childNodes[0]
|
||||
;
|
||||
|
||||
for (var column = 0; column < header.childNodes.length; column++) {
|
||||
|
||||
header.childNodes[column].setAttribute( "value",
|
||||
dateBundle.GetStringFromName(
|
||||
"day."+
|
||||
((this.weekStart + column) % 7 + 1) +
|
||||
".short"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
||||
<method name="showMonth">
|
||||
<parameter name="aDate"/>
|
||||
<body><![CDATA[
|
||||
if (!aDate) {
|
||||
aDate = new Date();
|
||||
} else {
|
||||
aDate = new Date(aDate.toString());
|
||||
aDate.setDate(1);
|
||||
}
|
||||
this.mEditorDate = aDate;
|
||||
|
||||
if (this.mSelected) {
|
||||
this.mSelected.setAttribute("selected", "");
|
||||
this.mSelected = null;
|
||||
}
|
||||
|
||||
//-------- Update the month title
|
||||
var mon = this.getMonthName(aDate) + " " + aDate.getFullYear();
|
||||
|
||||
this.mMonthCell.setAttribute("value", mon);
|
||||
|
||||
//-------- Update the calendar
|
||||
var calbox = document.getAnonymousNodes(this)[0].childNodes[1];
|
||||
|
||||
var firstWeekday = (7 + aDate.getDay() - this.weekStart) % 7;
|
||||
var date = new Date(aDate.getTime());
|
||||
date.setDate(date.getDate()-firstWeekday);
|
||||
|
||||
for (var k = 1; k < calbox.childNodes.length; k++) {
|
||||
var row = calbox.childNodes[k];
|
||||
|
||||
|
||||
for (var i = 0; i < 7; i++) {
|
||||
var day = row.childNodes[i];
|
||||
|
||||
if (aDate.getMonth() != date.getMonth()) {
|
||||
day.setAttribute("othermonth", "true");
|
||||
} else {
|
||||
day.setAttribute("othermonth", "");
|
||||
}
|
||||
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
day.date = date;
|
||||
day.calendar = this;
|
||||
day.setAttribute("value", date.getDate());
|
||||
date = new Date(date.getTime());
|
||||
date.setDate(date.getDate() + 1);
|
||||
}
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="setBusyDates">
|
||||
<parameter name="arrayOfDates"/>
|
||||
<body><![CDATA[
|
||||
/* CODE FROM monthView.js for finding the events for the month. */
|
||||
/*
|
||||
document.getElementById( "lefthandcalendar" ).value = date;
|
||||
|
||||
//get a list of events for this month.
|
||||
var monthEvents =
|
||||
this.eventSource.getEventsForMonth( this.getSelectedDate() );
|
||||
|
||||
var arrayOfDates = new Array();
|
||||
|
||||
for( var eventIndex = 0; eventIndex < monthEvents.length; ++eventIndex )
|
||||
{
|
||||
var calendarEventDisplay = monthEvents[ eventIndex ];
|
||||
var eventDate = new Date( calendarEventDisplay.displayDate );
|
||||
|
||||
//add them to an array
|
||||
arrayOfDates[ eventDate.getDate() ] = true;
|
||||
|
||||
}
|
||||
document.getElementById( "lefthandcalendar" ).setBusyDates( arrayOfDates );
|
||||
*/
|
||||
var aDate = new Date();
|
||||
aDate.setDate( 1 );
|
||||
//-------- Update the calendar
|
||||
var calbox = document.getAnonymousNodes(this)[0].childNodes[1];
|
||||
|
||||
// weekStart day is set by preference
|
||||
var firstWeekday = (7 + aDate.getDay() - this.weekStart) % 7;
|
||||
var date = new Date(aDate.getTime());
|
||||
date.setDate(date.getDate() - firstWeekday);
|
||||
|
||||
for (var k = 1; k < calbox.childNodes.length; k++) {
|
||||
var row = calbox.childNodes[k];
|
||||
for (var i = 0; i < 7; i++) {
|
||||
var day = row.childNodes[i];
|
||||
|
||||
if (aDate.getMonth() == date.getMonth() &&
|
||||
arrayOfDates[ date.getDate() ] == true ) {
|
||||
day.setAttribute("busy", "true");
|
||||
} else {
|
||||
day.removeAttribute("busy");
|
||||
}
|
||||
|
||||
// next date of month, may increment month
|
||||
date.setDate(date.getDate() + 1);
|
||||
}
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="advanceMonth">
|
||||
<parameter name="aDir"/>
|
||||
<body><![CDATA[
|
||||
|
||||
var ad = this.mEditorDate.getMonth() + aDir;
|
||||
this.mEditorDate.setMonth(ad);
|
||||
|
||||
this.showMonth(this.mEditorDate);
|
||||
|
||||
if (this.mSelected) {
|
||||
this.mSelected.removeAttribute("selected");
|
||||
}
|
||||
|
||||
this.value = this.mEditorDate;
|
||||
|
||||
if (this.onmonthchange) this.onmonthchange();
|
||||
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="dayClicked">
|
||||
<parameter name="aDay"/>
|
||||
<body><![CDATA[
|
||||
|
||||
if (this.mSelected) {
|
||||
this.mSelected.setAttribute("selected", "");
|
||||
}
|
||||
|
||||
this.mSelected = aDay;
|
||||
aDay.setAttribute("selected", "true");
|
||||
|
||||
this.value = aDay.date;
|
||||
|
||||
if (this.onchange) this.onchange();
|
||||
|
||||
if (this.parentNode.parentNode.parentNode.parentNode.callback)
|
||||
this.parentNode.parentNode.parentNode.parentNode.callback();
|
||||
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="update">
|
||||
<parameter name="aValue"/>
|
||||
<body><![CDATA[
|
||||
|
||||
this.mValue = aValue;
|
||||
this.showMonth(aValue);
|
||||
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="getMonthName">
|
||||
<parameter name="aDate"/>
|
||||
<body><![CDATA[
|
||||
|
||||
var dateStringBundle =
|
||||
srGetStrBundle("chrome://calendar/locale/dateFormat.properties");
|
||||
|
||||
var monthNames = new Array(12);
|
||||
monthNames[0] = dateStringBundle.GetStringFromName("month.1.name");
|
||||
monthNames[1] = dateStringBundle.GetStringFromName("month.2.name");
|
||||
monthNames[2] = dateStringBundle.GetStringFromName("month.3.name");
|
||||
monthNames[3] = dateStringBundle.GetStringFromName("month.4.name");
|
||||
monthNames[4] = dateStringBundle.GetStringFromName("month.5.name");
|
||||
monthNames[5] = dateStringBundle.GetStringFromName("month.6.name");
|
||||
monthNames[6] = dateStringBundle.GetStringFromName("month.7.name");
|
||||
monthNames[7] = dateStringBundle.GetStringFromName("month.8.name");
|
||||
monthNames[8] = dateStringBundle.GetStringFromName("month.9.name");
|
||||
monthNames[9] = dateStringBundle.GetStringFromName("month.10.name");
|
||||
monthNames[10]= dateStringBundle.GetStringFromName("month.11.name");
|
||||
monthNames[11]= dateStringBundle.GetStringFromName("month.12.name");
|
||||
|
||||
var midx = aDate.getMonth();
|
||||
|
||||
return monthNames[midx];
|
||||
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
</implementation>
|
||||
|
||||
<!-- ::::::::::::::::: HANDLERS ::::::::::::::::::::::::: -->
|
||||
<handlers>
|
||||
<handler event="bindingattached" action="this.initialize();"/>
|
||||
</handlers>
|
||||
|
||||
</binding>
|
||||
|
||||
<binding id="minimonth-navbtn" inherits="dir">
|
||||
<!-- ::::::::::::::::: HANDLERS ::::::::::::::::::::::::: -->
|
||||
<handlers>
|
||||
<handler event="click">
|
||||
<![CDATA[
|
||||
this.mCalendar.advanceMonth(parseInt(this.getAttribute('dir')));
|
||||
]]>
|
||||
</handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
<binding id="minimonth-day" extends="xul:text">
|
||||
<!-- ::::::::::::::::: HANDLERS ::::::::::::::::::::::::: -->
|
||||
<handlers>
|
||||
<handler event="click" action="this.calendar.dayClicked(this)"/>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
</bindings>
|
||||
|
||||
Reference in New Issue
Block a user