зеркало из https://github.com/mozilla/pjs.git
Fix bug 403808 - Missing license header (minimonth.css & minimonth.xml). r=mvl, p=thetux
This commit is contained in:
Родитель
cdc608036b
Коммит
6faffdef66
|
@ -1,14 +0,0 @@
|
|||
@import url("chrome://calendar/skin/datetimepickers/minimonth.css");
|
||||
|
||||
minimonth {
|
||||
-moz-binding: url("chrome://calendar/content/datetimepickers/minimonth.xml#minimonth");
|
||||
}
|
||||
|
||||
.minimonth-navbtn {
|
||||
-moz-binding: url("chrome://calendar/content/datetimepickers/minimonth.xml#minimonth-navbtn");
|
||||
}
|
||||
|
||||
.minimonth-day {
|
||||
-moz-binding: url("chrome://calendar/content/datetimepickers/minimonth.xml#minimonth-day");
|
||||
}
|
||||
|
|
@ -1,791 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
/* MiniMonth Calendar: day-of-month grid XBL component.
|
||||
Displays month name and year above grid of days of month by week rows.
|
||||
Arrows move forward or back a month.
|
||||
Selecting a month name from month menu moves to that month in same year.
|
||||
Selecting a year from year menu moves to same month in selected year.
|
||||
Clicking on a day cell calls onchange attribute.
|
||||
Changing month via arrows or menus 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();
|
||||
|
||||
Use attributes onpopuplisthidden and onmonthchange for working around
|
||||
bugs that occur when minimonth is displayed in a popup (as in datepicker):
|
||||
Currently (2005.3)
|
||||
whenever a child popup is hidden, the parent popup needs to be reshown.
|
||||
Use onpopuplisthidden to reshow parent popop (hidePopup, showPopup).
|
||||
When title month or year changes, parent popup may need to be reshown.
|
||||
Use onmonthchange to reshow parent popop (hidePopup, showPopup).
|
||||
*/
|
||||
-->
|
||||
<!DOCTYPE dialog SYSTEM "chrome://calendar/locale/global.dtd">
|
||||
|
||||
<bindings id="xulMiniMonth"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<binding id="minimonth" extends="xul:box" xbl:inherits="onchange,onmonthchange,onpopuplisthidden,readonly">
|
||||
<resources>
|
||||
<stylesheet src="chrome://calendar/skin/datetimepickers/minimonth.css"/>
|
||||
</resources>
|
||||
|
||||
<!-- ::::::::::::::::: 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:deck anonid="monthheader" class="minimonth-month-name" onclick="showPopupList(event, 'month')">
|
||||
<xul:text value="&month.1.name;"/>
|
||||
<xul:text value="&month.2.name;"/>
|
||||
<xul:text value="&month.3.name;"/>
|
||||
<xul:text value="&month.4.name;"/>
|
||||
<xul:text value="&month.5.name;"/>
|
||||
<xul:text value="&month.6.name;"/>
|
||||
<xul:text value="&month.7.name;"/>
|
||||
<xul:text value="&month.8.name;"/>
|
||||
<xul:text value="&month.9.name;"/>
|
||||
<xul:text value="&month.10.name;"/>
|
||||
<xul:text value="&month.11.name;"/>
|
||||
<xul:text value="&month.12.name;"/>
|
||||
</xul:deck>
|
||||
<xul:deck>
|
||||
<xul:text anonid="yearcell" class="minimonth-year-name" onclick="showPopupList(event, 'year')"/>
|
||||
<xul:text class="minimonth-year-name"/>
|
||||
</xul:deck>
|
||||
<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>
|
||||
<xul:popupset>
|
||||
<xul:popup anonid="months-popup" position="after_start"
|
||||
onpopupshowing="event.stopPropagation();"
|
||||
onpopuphidden="firePopupListHidden();">
|
||||
<xul:vbox>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
</xul:vbox>
|
||||
</xul:popup>
|
||||
<xul:popup anonid="years-popup" position="after_start"
|
||||
onpopupshowing="moveYears('reset'); event.stopPropagation();"
|
||||
onpopuphidden="firePopupListHidden();">
|
||||
<xul:vbox>
|
||||
<xul:autorepeatbutton class="autorepeatbutton-up"
|
||||
orient="vertical"
|
||||
oncommand="moveYears('up');"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:text class="minimonth-list"/>
|
||||
<xul:autorepeatbutton class="autorepeatbutton-down"
|
||||
orient="vertical"
|
||||
oncommand="moveYears('down');"/>
|
||||
</xul:vbox>
|
||||
</xul:popup>
|
||||
</xul:popupset>
|
||||
</content>
|
||||
|
||||
<!-- ::::::::::::::::: INTERFACE ::::::::::::::::::::::::: -->
|
||||
<implementation>
|
||||
<property name="value"
|
||||
onget="return this.mValue"
|
||||
onset="this.update(val)"/>
|
||||
|
||||
<property name="firstDate"
|
||||
readonly="true"
|
||||
onget="return this.kDaysOfMonthBox.childNodes[1].firstChild.date;"/>
|
||||
|
||||
<property name="lastDate"
|
||||
readonly="true"
|
||||
onget="return this.kDaysOfMonthBox.lastChild.lastChild.date;"/>
|
||||
|
||||
<field name="mDaymap">null</field>
|
||||
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
this.mToday = false;
|
||||
this.mSelected = false;
|
||||
this.mValue = null;
|
||||
this.mEditorDate = null; // set only in showMonth
|
||||
this.mPopup = null;
|
||||
// save references for convenience
|
||||
var anonContent = document.getAnonymousNodes(this);
|
||||
var mainBox = anonContent[0];
|
||||
var headBox = mainBox.childNodes[0];
|
||||
this.kLeftBtn = headBox.firstChild;
|
||||
this.kLeftBtn.kMinimonth = this;
|
||||
this.kRightBtn = headBox.lastChild;
|
||||
this.kRightBtn.kMinimonth = this;
|
||||
this.kMonthCell = headBox.childNodes[2];
|
||||
this.kYearCell = document.getAnonymousElementByAttribute(this, "anonid", "yearcell");
|
||||
this.kDaysOfMonthBox = mainBox.childNodes[1];
|
||||
var popupSet = anonContent[1];
|
||||
this.kMonthPopup = popupSet.childNodes[0];
|
||||
this.kMonthList = this.kMonthPopup.firstChild.childNodes;
|
||||
this.kYearPopup = popupSet.childNodes[1];
|
||||
this.kYearList = this.kYearPopup.firstChild.childNodes;
|
||||
if (this.getAttribute("readonly")) {
|
||||
this.kLeftBtn.collapsed = true;
|
||||
this.kRightBtn.collapsed = true;
|
||||
} else {
|
||||
this.kMonthCell.setAttribute("interactive", "true");
|
||||
this.kYearCell.setAttribute("interactive", "true");
|
||||
}
|
||||
this.refreshDisplay( );
|
||||
]]>
|
||||
</constructor>
|
||||
|
||||
<method name="moveYears">
|
||||
<parameter name="direction"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
// Update the year popup
|
||||
var years = this.kYearList;
|
||||
var current = this.mEditorDate.getFullYear();
|
||||
var offset;
|
||||
|
||||
switch (direction) {
|
||||
case "reset":
|
||||
var middleyear = years[Math.floor(years.length / 2)].getAttribute("value");
|
||||
if (current <= (years.length / 2)) {
|
||||
offset = - years[1].getAttribute("value") + 1;
|
||||
} else {
|
||||
offset = current - middleyear;
|
||||
}
|
||||
break;
|
||||
case "up":
|
||||
offset = -1;
|
||||
break;
|
||||
case "down":
|
||||
offset = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
// Disable the up arrow when we get to the year 1.
|
||||
years[0].disabled = (parseInt(years[1].getAttribute("value")) + offset < 2);
|
||||
|
||||
if (!offset) {
|
||||
// No need to loop through when the offset is zero.
|
||||
return;
|
||||
}
|
||||
|
||||
// Go through all visible years and set the new value. Be sure to
|
||||
// skip the autorepeatbuttons.
|
||||
for (var i = 1; i < years.length - 1; i++) {
|
||||
var value = parseInt(years[i].getAttribute("value")) + offset;
|
||||
years[i].setAttribute("value", value);
|
||||
years[i].setAttribute("current", "false");
|
||||
if (years[i].getAttribute("value") == current) {
|
||||
years[i].setAttribute("current", "true");
|
||||
}
|
||||
}
|
||||
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="refreshDisplay">
|
||||
<body>
|
||||
<![CDATA[
|
||||
// Find out which should be the first day of the week
|
||||
try {
|
||||
var pref = Components.classes[
|
||||
"@mozilla.org/preferences-service;1"
|
||||
].getService(Components.interfaces.nsIPrefBranch);
|
||||
// this.weekStart;
|
||||
this.weekStart = pref.getIntPref("calendar.week.start");
|
||||
} catch (e) {
|
||||
this.weekStart = 0;
|
||||
}
|
||||
if (!this.mValue) this.mValue = new Date();
|
||||
|
||||
this.setHeader();
|
||||
this.showMonth(this.mValue);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="setHeader">
|
||||
<body>
|
||||
<![CDATA[
|
||||
// Reset the headers
|
||||
var header = document.getAnonymousNodes(this)[0].
|
||||
childNodes[1].childNodes[0];
|
||||
var dayList = new Array(7);
|
||||
var tempDate = new Date();
|
||||
var i, j;
|
||||
var useOSFormat;
|
||||
tempDate.setDate(tempDate.getDate() - (tempDate.getDay() - this.weekStart));
|
||||
for (i = 0; i < header.childNodes.length; i++) {
|
||||
// if available, use UILocale days, else operating system format
|
||||
try {
|
||||
dayList[i] =
|
||||
calGetString("dateFormat",
|
||||
"day." + (tempDate.getDay() + 1) + ".short");
|
||||
} catch (e) {
|
||||
dayList[i] = tempDate.toLocaleFormat("%a");
|
||||
useOSFormat = true;
|
||||
}
|
||||
tempDate.setDate(tempDate.getDate() + 1);
|
||||
}
|
||||
|
||||
if (useOSFormat) {
|
||||
// To keep datepicker popup compact, shrink localized weekday
|
||||
// abbreviations down to 1 or 2 chars so each column of week can
|
||||
// be as narrow as 2 digits.
|
||||
//
|
||||
// 1. Compute the minLength of the day name abbreviations.
|
||||
var minLength = dayList[0].length;
|
||||
for (i = 1; i < dayList.length; i++) {
|
||||
minLength = Math.min(minLength, dayList[i].length);
|
||||
}
|
||||
// 2. If some day name abbrev. is longer than 2 chars (not Catalan),
|
||||
// and ALL localized day names share same prefix (as in Chinese),
|
||||
// then trim shared "day-" prefix.
|
||||
if (dayList.some(function(dayAbbr){ return dayAbbr.length > 2; })) {
|
||||
for (var endPrefix = 0; endPrefix < minLength; endPrefix++) {
|
||||
var c = dayList[0][endPrefix];
|
||||
if (dayList.some(function(dayAbbr) {
|
||||
return dayAbbr[endPrefix] != c; })) {
|
||||
if (endPrefix > 0) {
|
||||
for (i = 0; i < dayList.length; i++) // trim prefix chars.
|
||||
dayList[i] = dayList[i].substring(endPrefix);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 3. trim each day abbreviation to 1 char if unique, else 2 chars.
|
||||
for (i = 0; i < dayList.length; i++) {
|
||||
var foundMatch = 1;
|
||||
for (j = 0; j < dayList.length; j++) {
|
||||
if (i != j) {
|
||||
if (dayList[i].substring(0,1) == dayList[j].substring(0,1)) {
|
||||
foundMatch = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
dayList[i] = dayList[i].substring(0,foundMatch)
|
||||
}
|
||||
}
|
||||
|
||||
for (var column = 0; column < header.childNodes.length; column++) {
|
||||
header.childNodes[column].setAttribute( "value", dayList[column]);
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="showMonth">
|
||||
<parameter name="aDate"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (!aDate) {
|
||||
aDate = new Date();
|
||||
} else {
|
||||
aDate = new Date(aDate);
|
||||
}
|
||||
aDate.setDate(1);
|
||||
aDate.setHours(0);
|
||||
aDate.setMinutes(0);
|
||||
aDate.setSeconds(0);
|
||||
aDate.setMilliseconds(0);
|
||||
// Don't fire onmonthchange event upon initialization
|
||||
var monthChanged = this.mEditorDate && (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;
|
||||
}
|
||||
|
||||
// Update the month and year title
|
||||
this.kMonthCell.selectedIndex = aDate.getMonth();
|
||||
this.kYearCell.setAttribute("value", aDate.getFullYear());
|
||||
|
||||
// Update the month popup
|
||||
var i;
|
||||
var months = this.kMonthList;
|
||||
for (i = 0; i < months.length; i++) {
|
||||
months[i].setAttribute("value", this.kMonthCell.childNodes[i].getAttribute("value"));
|
||||
months[i].setAttribute("index", i);
|
||||
months[i].setAttribute("current", "false");
|
||||
if (i == aDate.getMonth())
|
||||
months[i].setAttribute("current", "true");
|
||||
}
|
||||
|
||||
// Update the year popup
|
||||
var years = this.kYearList;
|
||||
var year = new Date(aDate);
|
||||
year.setFullYear(Math.max(1, aDate.getFullYear() - parseInt(years.length / 2) + 1));
|
||||
for (var i = 1; i < years.length - 1; i++) {
|
||||
years[i].setAttribute("value", year.getFullYear());
|
||||
years[i].setAttribute("current", "false");
|
||||
if (year.getFullYear() == aDate.getFullYear())
|
||||
years[i].setAttribute("current", "true");
|
||||
year.setFullYear(year.getFullYear() + 1);
|
||||
}
|
||||
|
||||
// Update the calendar
|
||||
var calbox = this.kDaysOfMonthBox;
|
||||
var date = this._getStartDate(aDate);
|
||||
|
||||
// get today's date
|
||||
var today = new Date();
|
||||
|
||||
this.mDayMap = {};
|
||||
|
||||
var isReadOnly = this.getAttribute("readonly");
|
||||
|
||||
for (var k = 1; k < calbox.childNodes.length; k++) {
|
||||
var row = calbox.childNodes[k];
|
||||
for (i = 0; i < 7; i++) {
|
||||
var day = row.childNodes[i];
|
||||
var ymd = date.getFullYear() + "-" +
|
||||
date.getMonth() + "-" +
|
||||
date.getDate();
|
||||
this.mDayMap[ymd] = day;
|
||||
|
||||
if (!isReadOnly) {
|
||||
day.setAttribute("interactive", "true");
|
||||
}
|
||||
|
||||
if (aDate.getMonth() != date.getMonth()) {
|
||||
day.setAttribute("othermonth", "true");
|
||||
} else {
|
||||
day.removeAttribute("othermonth");
|
||||
}
|
||||
|
||||
// highlight today
|
||||
if (this._sameDay(today, date)) {
|
||||
this.mToday = day;
|
||||
day.setAttribute("today", "true");
|
||||
}
|
||||
|
||||
// highlight the current date
|
||||
var val = this.value;
|
||||
if (this._sameDay(val, date)) {
|
||||
this.mSelected = day;
|
||||
day.setAttribute("selected", "true");
|
||||
}
|
||||
|
||||
day.date = new Date(date);
|
||||
day.calendar = this;
|
||||
day.setAttribute("value", date.getDate());
|
||||
date.setDate(date.getDate() + 1);
|
||||
|
||||
if (monthChanged) {
|
||||
this.resetAttributesForDate(day.date);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (monthChanged) this.fireEvent('monthchange');
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="showPopupList">
|
||||
<parameter name="event"/>
|
||||
<parameter name="type"/> <!-- 'month' or 'year' -->
|
||||
<body>
|
||||
<![CDATA[
|
||||
// Don't do anything for right/middle-clicks
|
||||
if (event.button != 0)
|
||||
return;
|
||||
|
||||
var base = (type == 'month'? this.kMonthCell : this.kYearCell);
|
||||
if (base.hasAttribute("interactive")) {
|
||||
// Close open popups (if any), to prevent linux crashes
|
||||
if (this.mPopup)
|
||||
this.mPopup.hidePopup();
|
||||
this.mPopup = (type == 'month'? this.kMonthPopup : this.kYearPopup);
|
||||
this.mPopup.showPopup(base, -1, -1, "popup", "bottomleft", "topleft");
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="hidePopupList">
|
||||
<body>
|
||||
<![CDATA[
|
||||
// Close open popups (if any)
|
||||
var popup = this.mPopup;
|
||||
this.mPopup = null;
|
||||
if (popup)
|
||||
popup.hidePopup();
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="fireEvent">
|
||||
<parameter name="aEventName"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var event = document.createEvent('Events');
|
||||
event.initEvent(aEventName, true, true);
|
||||
this.dispatchEvent(event);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="firePopupListHidden">
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (this.mPopup) {
|
||||
this.mPopup = null;
|
||||
this.fireEvent("popuplisthidden");
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="getBoxForDate">
|
||||
<parameter name="aDate"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var ymd = aDate.getFullYear() + "-" +
|
||||
aDate.getMonth() + "-" +
|
||||
aDate.getDate();
|
||||
return this.mDayMap[ymd];
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="resetAttributesForDate">
|
||||
<parameter name="aDate"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
function removeForBox(aBox) {
|
||||
var allowedAttributes = 0;
|
||||
while (aBox.attributes.length > allowedAttributes) {
|
||||
switch (aBox.attributes[allowedAttributes].nodeName) {
|
||||
case "selected":
|
||||
case "othermonth":
|
||||
case "today":
|
||||
case "interactive":
|
||||
case "value":
|
||||
case "class":
|
||||
case "flex":
|
||||
allowedAttributes++;
|
||||
break;
|
||||
default:
|
||||
aBox.removeAttribute(aBox.attributes[allowedAttributes].nodeName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aDate) {
|
||||
var box = this.getBoxForDate(aDate);
|
||||
if (box) {
|
||||
removeForBox(box);
|
||||
}
|
||||
} else {
|
||||
for (var k = 1; k < this.kDaysOfMonthBox.childNodes.length; k++) {
|
||||
for (var i = 0; i < 7; i++) {
|
||||
removeForBox(this.kDaysOfMonthBox.childNodes[k].childNodes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="advanceMonth">
|
||||
<parameter name="aDir"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var advEditorDate = new Date(this.mEditorDate); // at 1st of month
|
||||
var advMonth = this.mEditorDate.getMonth() + aDir;
|
||||
advEditorDate.setMonth(advMonth);
|
||||
this.showMonth(advEditorDate);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="dayClicked">
|
||||
<parameter name="aDay"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (this.getAttribute("readonly")) {
|
||||
return;
|
||||
}
|
||||
if (this.mSelected) {
|
||||
this.mSelected.removeAttribute("selected");
|
||||
}
|
||||
this.mSelected = aDay;
|
||||
aDay.setAttribute("selected", "true");
|
||||
this.value = aDay.date;
|
||||
this.fireEvent('select');
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="update">
|
||||
<parameter name="aValue"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
this.mValue = aValue;
|
||||
this.fireEvent('change');
|
||||
this.showMonth(aValue);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="switchMonth">
|
||||
<parameter name="aMonth"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var newMonth = new Date(this.mEditorDate);
|
||||
newMonth.setMonth(aMonth);
|
||||
this.showMonth(newMonth);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="switchYear">
|
||||
<parameter name="aYear"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var newMonth = new Date(this.mEditorDate);
|
||||
newMonth.setFullYear(aYear);
|
||||
this.showMonth(newMonth);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="selectDate">
|
||||
<parameter name="aDate"/>
|
||||
<parameter name="aMainDate"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (!aMainDate || (aDate < this._getStartDate(aMainDate) || aDate > this._getEndDate(aMainDate))) {
|
||||
aMainDate = new Date(aDate);
|
||||
aMainDate.setDate(1);
|
||||
}
|
||||
// note, that aMainDate and this.mEditorDate refer to the first day
|
||||
// of the corresponding month
|
||||
var sameMonth = this._sameDay(aMainDate, this.mEditorDate);
|
||||
var sameDate = this._sameDay(aDate,this.mValue);
|
||||
if (!sameMonth && !sameDate) {
|
||||
// change month and select day
|
||||
this.mValue = aDate;
|
||||
this.showMonth(aMainDate);
|
||||
} else if (!sameMonth) {
|
||||
// change month only
|
||||
this.showMonth(aMainDate);
|
||||
} else if (!sameDate) {
|
||||
// select day only
|
||||
var day = this.getBoxForDate(aDate);
|
||||
if (this.mSelected) {
|
||||
this.mSelected.removeAttribute("selected");
|
||||
}
|
||||
this.mSelected = day;
|
||||
day.setAttribute("selected", "true");
|
||||
this.mValue = aDate;
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="_getStartDate">
|
||||
<parameter name="aMainDate"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var date = new Date(aMainDate);
|
||||
var firstWeekday = (7 + aMainDate.getDay() - this.weekStart) % 7;
|
||||
date.setDate(date.getDate()-firstWeekday);
|
||||
return date;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="_getEndDate">
|
||||
<parameter name="aMainDate"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var date = this._getStartDate(aMainDate);
|
||||
var days = (this.kDaysOfMonthBox.childNodes.length - 1) * 7;
|
||||
date.setDate(date.getDate() + days - 1);
|
||||
return date;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="_sameDay">
|
||||
<parameter name="aDate1"/>
|
||||
<parameter name="aDate2"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (aDate1 && aDate2 &&
|
||||
(aDate1.getDate() == aDate2.getDate()) &&
|
||||
(aDate1.getMonth() == aDate2.getMonth()) &&
|
||||
(aDate1.getFullYear() == aDate2.getFullYear())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
</implementation>
|
||||
|
||||
<!-- ::::::::::::::::: HANDLERS ::::::::::::::::::::::::: -->
|
||||
<handlers>
|
||||
<handler event="bindingattached" action="this.initialize();"/>
|
||||
|
||||
<!-- handle click from nested months popup and years popup -->
|
||||
<handler event="click">
|
||||
<![CDATA[
|
||||
var element = event.originalTarget;
|
||||
if (element.parentNode && element.parentNode.parentNode) {
|
||||
var grandparent = element.parentNode.parentNode;
|
||||
switch(grandparent) {
|
||||
case this.kMonthPopup:
|
||||
this.hidePopupList();
|
||||
this.switchMonth(element.getAttribute("index"));
|
||||
break;
|
||||
case this.kYearPopup:
|
||||
this.hidePopupList();
|
||||
var value = element.getAttribute("value");
|
||||
if (value) {
|
||||
this.switchYear(value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="DOMMouseScroll">
|
||||
<![CDATA[
|
||||
var rows = event.detail;
|
||||
if (rows == NSUIEvent.SCROLL_PAGE_UP) {
|
||||
rows = -1;
|
||||
} else if (rows == NSUIEvent.SCROLL_PAGE_DOWN) {
|
||||
rows = 1;
|
||||
} else {
|
||||
// In this case event.detail contains the default number of lines
|
||||
// to scroll. We always want to only scroll 1 month though
|
||||
rows = (rows > 0) ? 1 : -1;
|
||||
}
|
||||
|
||||
this.advanceMonth(rows);
|
||||
]]>
|
||||
</handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
<binding id="minimonth-navbtn" inherits="dir">
|
||||
<!-- ::::::::::::::::: HANDLERS ::::::::::::::::::::::::: -->
|
||||
<handlers>
|
||||
<handler event="click">
|
||||
<![CDATA[
|
||||
this.kMinimonth.advanceMonth(parseInt(this.getAttribute('dir')));
|
||||
]]>
|
||||
</handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
<binding id="minimonth-day" extends="xul:text">
|
||||
<!-- ::::::::::::::::: HANDLERS ::::::::::::::::::::::::: -->
|
||||
<handlers>
|
||||
<handler event="click" action="if (event.button == 0) this.calendar.dayClicked(this)"/>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
</bindings>
|
Загрузка…
Ссылка в новой задаче