[XForms] Pick out calendar widget. Bug 329204, r=doronr+me, patch by surkov@dc.baikal.ru
git-svn-id: svn://10.0.0.236/trunk@192627 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -7,6 +7,8 @@ xforms.jar:
|
||||
* content/xforms/xforms-prefs.xul (resources/content/xforms-prefs.xul)
|
||||
* content/xforms/xforms-prefs-ui.xul (resources/content/xforms-prefs-ui.xul)
|
||||
* content/xforms/xforms-prefs.js (resources/content/xforms-prefs.js)
|
||||
content/xforms/widgets.xml (resources/content/widgets.xml)
|
||||
content/xforms/widgets-xhtml.xml (resources/content/widgets-xhtml.xml)
|
||||
content/xforms/xforms.xml (resources/content/xforms.xml)
|
||||
content/xforms/xforms-xhtml.xml (resources/content/xforms-xhtml.xml)
|
||||
content/xforms/xforms-xul.xml (resources/content/xforms-xul.xml)
|
||||
|
||||
@@ -54,7 +54,8 @@
|
||||
<bindings id="xformsInputBindingsForXHTML"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl">
|
||||
xmlns:xbl="http://www.mozilla.org/xbl"
|
||||
xmlns:mozType="http://www.mozilla.org/projects/xforms/2005/type">
|
||||
|
||||
|
||||
<!-- INPUT: <DEFAULT> -->
|
||||
@@ -183,7 +184,37 @@
|
||||
</binding>
|
||||
|
||||
|
||||
<!-- INPUT: Month -->
|
||||
<!-- INPUT: <DATE, APPEARANCE='FULL' -->
|
||||
<binding id="xformswidget-input-date-full"
|
||||
extends="chrome://xforms/content/input.xml#xformswidget-input-base">
|
||||
<content>
|
||||
<children includes="label"/>
|
||||
<html:span mozType:calendar="true" anonid="control"/>
|
||||
<children/>
|
||||
</content>
|
||||
|
||||
<implementation>
|
||||
<method name="getControlElement">
|
||||
<body>
|
||||
return this.ownerDocument.
|
||||
getAnonymousElementByAttribute(this, "anonid", "control");
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<constructor>
|
||||
var changeHandler = {
|
||||
inputControl: this,
|
||||
handleEvent: function() {
|
||||
this.inputControl.updateInstanceData(false);
|
||||
}
|
||||
};
|
||||
this.addEventListener("change", changeHandler, false);
|
||||
</constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
|
||||
<!-- INPUT: Month -->
|
||||
<binding id="xformswidget-input-month"
|
||||
extends="chrome://xforms/content/input.xml#xformswidget-input-month-base">
|
||||
<content>
|
||||
|
||||
362
mozilla/extensions/xforms/resources/content/widgets-xhtml.xml
Normal file
362
mozilla/extensions/xforms/resources/content/widgets-xhtml.xml
Normal file
@@ -0,0 +1,362 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Mozilla XForms support.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- IBM Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2006
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Doron Rosenberg <doronr@us.ibm.com>
|
||||
- Alexander Surkov <surkov@dc.baikal.ru>
|
||||
-
|
||||
- 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
|
||||
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
- in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
- of those above. If you wish to allow use of your version of this file only
|
||||
- under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
- use your version of this file under the terms of the MPL, indicate your
|
||||
- decision by deleting the provisions above and replace them with the notice
|
||||
- and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
- the provisions above, a recipient may use your version of this file under
|
||||
- the terms of any one of the MPL, the GPL or the LGPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!DOCTYPE bindings [
|
||||
<!ENTITY % xformsDTD SYSTEM "chrome://xforms/locale/xforms.dtd">
|
||||
%xformsDTD;
|
||||
]>
|
||||
|
||||
|
||||
<bindings id="widgetsBindingsForXHTML"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl">
|
||||
|
||||
|
||||
<!-- CALENDAR WIDGETS -->
|
||||
|
||||
<!-- COMPACT CALENDAR -->
|
||||
<binding id="calendar-compact"
|
||||
extends="chrome://xforms/content/widgets.xml#calendar-base">
|
||||
|
||||
<content>
|
||||
<html:table>
|
||||
<html:tbody anonid="dayContainer"/>
|
||||
</html:table>
|
||||
</content>
|
||||
|
||||
<implementation>
|
||||
|
||||
<!-- successors interface -->
|
||||
<method name="refresh">
|
||||
<parameter name="aFocusedDay"/>
|
||||
<body>
|
||||
this.refreshCompactCalendar(aFocusedDay);
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="refreshCurrentDate">
|
||||
<parameter name="aCurrentDay"/>
|
||||
<parameter name="aFocusedDay"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var currentIndex = this.dayOffset + aCurrentDay - 1;
|
||||
var focusedIndex = null;
|
||||
if (aFocusedDay)
|
||||
focusedIndex = this.dayOffset + parseInt(aFocusedDay) - 1;
|
||||
|
||||
this.setCurrentDayByIndex(currentIndex, focusedIndex);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<!-- private -->
|
||||
<method name="setCurrentDayByIndex">
|
||||
<parameter name="aCurrentIndex"/>
|
||||
<parameter name="aFocusedIndex"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (!aFocusedIndex)
|
||||
aFocusedIndex = aCurrentIndex;
|
||||
|
||||
var dayElm = null;
|
||||
|
||||
if (this._currentDayIndex != -1) {
|
||||
dayElm = this._dayElements[this._currentDayIndex];
|
||||
dayElm.removeAttribute("current");
|
||||
}
|
||||
|
||||
if (this.isCurrentDate()) {
|
||||
dayElm = this._dayElements[aCurrentIndex];
|
||||
dayElm.setAttribute("current", "true");
|
||||
this._currentDayIndex = aCurrentIndex;
|
||||
} else {
|
||||
this._currentDayIndex = -1;
|
||||
}
|
||||
|
||||
if (aFocusedIndex != this._focusedDayIndex)
|
||||
this.setFocusedDayByIndex(aFocusedIndex);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="setFocusedDayByIndex">
|
||||
<parameter name="aIndex"/>
|
||||
<body>
|
||||
var dayElm = null;
|
||||
if (this._focusedDayIndex != -1) {
|
||||
dayElm = this._dayElements[this._focusedDayIndex];
|
||||
dayElm.setAttribute("tabindex", "-1");
|
||||
}
|
||||
|
||||
dayElm = this._dayElements[aIndex];
|
||||
dayElm.setAttribute("tabindex", "0");
|
||||
dayElm.focus();
|
||||
|
||||
this._focusedDayIndex = aIndex;
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<property name="focusedDayIndex"
|
||||
onget="return this._focusedDayIndex;"
|
||||
onset="this.setFocusedDayByIndex(val);"/>
|
||||
|
||||
<method name="refreshCompactCalendar">
|
||||
<parameter name="aFocusedDay"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (!this._isUIBuilt) {
|
||||
this.buildUI();
|
||||
this._isUIBuilt = true;
|
||||
}
|
||||
|
||||
// set days for previous month
|
||||
var dayOffset = this.dayOffset;
|
||||
var prevDayCount = this.prevDaysCount;
|
||||
for (var i = 0; i < dayOffset; i++) {
|
||||
this._dayElements[i].textContent = prevDayCount + i - dayOffset + 1;
|
||||
this._dayElements[i].setAttribute("class", "prevMonth");
|
||||
}
|
||||
|
||||
// set days for current month
|
||||
var count = this.daysCount + dayOffset;
|
||||
for (; i < count; i++) {
|
||||
this._dayElements[i].textContent = i - dayOffset + 1;
|
||||
this._dayElements[i].setAttribute("class", "currentMonth");
|
||||
}
|
||||
|
||||
// set days for next month
|
||||
for (var day = 1; i < this._dayElements.length; i++, day++) {
|
||||
this._dayElements[i].textContent = day;
|
||||
this._dayElements[i].setAttribute("class", "nextMonth");
|
||||
}
|
||||
|
||||
this.refreshCurrentDate(this.currentDate.getDate(), aFocusedDay);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="buildUI">
|
||||
<body>
|
||||
<![CDATA[
|
||||
var dayOfWeekNames = this.getDaysOfWeekNames();
|
||||
var row = this.ownerDocument.createElementNS(this.XHTML_NS, "tr");
|
||||
|
||||
// create days of a week names
|
||||
var header;
|
||||
for (var i = 0; i < 7; i++) {
|
||||
header = this.ownerDocument.createElementNS(this.XHTML_NS, "th");
|
||||
header.textContent = dayOfWeekNames[i];
|
||||
row.appendChild(header);
|
||||
}
|
||||
this.dayContainer.appendChild(row);
|
||||
|
||||
// create days
|
||||
var cell;
|
||||
for (var i = 0; i < 6; i++) {
|
||||
row = document.createElementNS(this.XHTML_NS, "tr");
|
||||
|
||||
for (var y = 0; y < 7; y++) {
|
||||
cell = this.ownerDocument.createElementNS(this.XHTML_NS, "td");
|
||||
cell.setAttribute("tabindex", "-1");
|
||||
this._dayElements.push(cell);
|
||||
row.appendChild(cell);
|
||||
}
|
||||
this.dayContainer.appendChild(row);
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="processAction">
|
||||
<parameter name="aActionType"/>
|
||||
<parameter name="aDay"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (!aDay)
|
||||
aDay = this.focusedDayIndex - this.dayOffset + 1;
|
||||
|
||||
aDay = parseInt(aDay);
|
||||
switch (aActionType) {
|
||||
case "prevMonth":
|
||||
this.setDate(this.year, this.month - 1, aDay);
|
||||
break;
|
||||
|
||||
case "nextMonth":
|
||||
this.setDate(this.year, this.month + 1, aDay);
|
||||
break;
|
||||
|
||||
case "currentMonth":
|
||||
if (!this.readonly) {
|
||||
this.currentDate = new Date(this.year, this.month - 1, aDay);
|
||||
this.fireChangeEvent();
|
||||
} else {
|
||||
this.focusedDayIndex = this.dayOffset + aDay - 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<property name="XHTML_NS" readonly="true"
|
||||
onget="return 'http://www.w3.org/1999/xhtml';"/>
|
||||
|
||||
<field name="_currentDayIndex">-1</field>
|
||||
<field name="_focusedDayIndex">-1</field>
|
||||
<field name="_dayElements">new Array()</field>
|
||||
<field name="_isUIBuilt">false</field>
|
||||
|
||||
<property name="dayContainer" readonly="true">
|
||||
<getter>
|
||||
if (!this._dayContainer)
|
||||
this._dayContainer = this.ownerDocument.
|
||||
getAnonymousElementByAttribute(this, "anonid", "dayContainer");
|
||||
return this._dayContainer;
|
||||
</getter>
|
||||
</property>
|
||||
<field name="_dayContainer">null</field>
|
||||
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
<handler event="keypress" keycode="VK_LEFT">
|
||||
<![CDATA[
|
||||
if (this.focusedDayIndex - 1 >= 0) {
|
||||
this.focusedDayIndex--;
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="keypress" keycode="VK_RIGHT">
|
||||
<![CDATA[
|
||||
if (this.focusedDayIndex + 1 < this._dayElements.length) {
|
||||
this.focusedDayIndex++;
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="keypress" keycode="VK_UP">
|
||||
<![CDATA[
|
||||
if (this.focusedDayIndex - 7 >= 0) {
|
||||
this.focusedDayIndex -= 7;
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="keypress" keycode="VK_DOWN">
|
||||
<![CDATA[
|
||||
if (this.focusedDayIndex + 7 < this._dayElements.length) {
|
||||
this.focusedDayIndex += 7;
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
|
||||
<handler event="keydown" keycode="VK_SPACE">
|
||||
var target = event.originalTarget;
|
||||
if (target.localName != "td" || target.namespaceURI != this.XHTML_NS)
|
||||
return;
|
||||
|
||||
this.processAction(target.getAttribute("class"), target.textContent);
|
||||
</handler>
|
||||
<handler event="mousedown" button="0">
|
||||
var target = event.originalTarget;
|
||||
if (target.localName != "td" || target.namespaceURI != this.XHTML_NS)
|
||||
return;
|
||||
|
||||
this.processAction(target.getAttribute("class"), target.textContent);
|
||||
</handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
|
||||
<!-- FULL CALENDAR -->
|
||||
<binding id="calendar-full" extends="#calendar-compact">
|
||||
<content>
|
||||
<html:table>
|
||||
<html:tbody anonid="dayContainer">
|
||||
<html:tr>
|
||||
<html:td colspan="1">
|
||||
<html:input type="button" anonid="back-button"
|
||||
class="-moz-date-back-button" title="&xforms.datepicker.prevMonth.title;"/>
|
||||
</html:td>
|
||||
<html:td colspan="5" align="center">
|
||||
<html:span anonid="date-label"/>
|
||||
</html:td>
|
||||
<html:td colspan="1">
|
||||
<html:input type="button" anonid="fwd-button"
|
||||
class="-moz-date-fwd-button" title="&xforms.datepicker.nextMonth.title;"/>
|
||||
</html:td>
|
||||
</html:tr>
|
||||
</html:tbody>
|
||||
</html:table>
|
||||
</content>
|
||||
|
||||
<implementation>
|
||||
<method name="refresh">
|
||||
<parameter name="aFocusedDay"/>
|
||||
<body>
|
||||
this.refreshCompactCalendar(aFocusedDay);
|
||||
var dateLabel = new Date(this.year, this.month - 1).toLocaleFormat("%B %Y");
|
||||
this.dateLabel.textContent = dateLabel;
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<property name="dateLabel" readonly="true">
|
||||
<getter>
|
||||
if (!this._dateLabel) {
|
||||
this._dateLabel = this.ownerDocument.
|
||||
getAnonymousElementByAttribute(this, "anonid", "date-label");
|
||||
}
|
||||
return this._dateLabel;
|
||||
</getter>
|
||||
</property>
|
||||
<field name="_dateLabel">null</field>
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
<handler event="click">
|
||||
switch (event.originalTarget.getAttribute("anonid")) {
|
||||
case "back-button":
|
||||
this.processAction("prevMonth", null);
|
||||
break;
|
||||
case "fwd-button":
|
||||
this.processAction("nextMonth", null);
|
||||
break;
|
||||
}
|
||||
</handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
</bindings>
|
||||
222
mozilla/extensions/xforms/resources/content/widgets.xml
Normal file
222
mozilla/extensions/xforms/resources/content/widgets.xml
Normal file
@@ -0,0 +1,222 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Mozilla XForms support.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- IBM Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2006
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Doron Rosenberg <doronr@us.ibm.com>
|
||||
- Alexander Surkov <surkov@dc.baikal.ru>
|
||||
-
|
||||
- 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
|
||||
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
- in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
- of those above. If you wish to allow use of your version of this file only
|
||||
- under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
- use your version of this file under the terms of the MPL, indicate your
|
||||
- decision by deleting the provisions above and replace them with the notice
|
||||
- and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
- the provisions above, a recipient may use your version of this file under
|
||||
- the terms of any one of the MPL, the GPL or the LGPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
|
||||
<bindings id="widgetsBindings"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl">
|
||||
|
||||
|
||||
<!-- CALENDAR WIDGETS -->
|
||||
|
||||
<!-- CALENDAR BASE
|
||||
The widget assumes successor widgets have following interface:
|
||||
refresh(aFocusedDay) - update days, it is called when year or month are changed
|
||||
refreshCurrentDate(aCurrentDate, aFocusedDay) - select current date
|
||||
-->
|
||||
<binding id="calendar-base">
|
||||
<implementation>
|
||||
|
||||
<!-- interface -->
|
||||
<property name="readonly">
|
||||
<getter>
|
||||
return this.hasAttribute("readonly");
|
||||
</getter>
|
||||
<setter>
|
||||
if (val)
|
||||
this.setAttribute("readonly", "readonly");
|
||||
else
|
||||
this.removeAttribute("readonly");
|
||||
</setter>
|
||||
</property>
|
||||
|
||||
<property name="value"
|
||||
onget="return this.currentDate ? this.currentDate.toLocaleFormat('%Y-%m-%d') : null;"
|
||||
onset="this.currentDate = new Date(val.replace(/-/g, '/'));"/>
|
||||
|
||||
<property name="year"
|
||||
onget="return parseInt(this.getAttribute('year'));"
|
||||
onset="this.setAttribute('year', val); this.refresh();"/>
|
||||
|
||||
<property name="month"
|
||||
onget="return parseInt(this.getAttribute('month'));"
|
||||
onset="this.setDate(this.year, val);"/>
|
||||
|
||||
<method name="setDate">
|
||||
<parameter name="aYear"/>
|
||||
<parameter name="aMonth"/>
|
||||
<parameter name="aFocusedDay"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
month = parseInt(aMonth) - 1;
|
||||
var deltayear = parseInt(month / 12);
|
||||
if (!deltayear && month < 0)
|
||||
deltayear = -1;
|
||||
|
||||
month %= 12;
|
||||
if (month < 0)
|
||||
month = (month + 12) % 12;
|
||||
|
||||
this.setAttribute("year", aYear + deltayear);
|
||||
this.setAttribute("month", month + 1);
|
||||
this.refresh(aFocusedDay);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<property name="currentDay" readonly="true"
|
||||
onget="return this._currentDate ? this._currentDate.getDate() : null;"/>
|
||||
|
||||
<property name="currentMonth" readonly="true"
|
||||
onget="return this._currentDate ? this._currentDate.getMonth() + 1 : null;"/>
|
||||
|
||||
<property name="currentYear" readonly="true"
|
||||
onget="return this._currentDate ? this._currentDate.getFullYear() : null;"/>
|
||||
|
||||
<property name="currentDate"
|
||||
onget="return this._currentDate;"
|
||||
onset="this.setCurrentDate(val);"/>
|
||||
|
||||
<method name="setCurrentDate">
|
||||
<parameter name="aCurrentDate"/>
|
||||
<parameter name="aFocusedDay"/>
|
||||
<body>
|
||||
if (!aCurrentDate)
|
||||
aCurrentDate = new Date();
|
||||
|
||||
this._currentDate = aCurrentDate;
|
||||
if (!this.isCurrentDate())
|
||||
this.setDate(this.currentYear, this.currentMonth, aFocusedDay);
|
||||
else
|
||||
this.refreshCurrentDate(this._currentDate.getDate(), aFocusedDay);
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="isCurrentDate">
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (this.currentYear == this.year && this.currentMonth == this.month)
|
||||
return true;
|
||||
return false;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<!-- interface for successor widgets -->
|
||||
|
||||
<!-- Return day of the week of the first day of the month -->
|
||||
<property name="dayOffset" readonly="true">
|
||||
<getter>
|
||||
return new Date(this.year, this.month - 1, 1).getDay();
|
||||
</getter>
|
||||
</property>
|
||||
|
||||
<!-- Return days count in current month -->
|
||||
<property name="daysCount" readonly="true"
|
||||
onget="return this.getDaysCount(this.month, this.year);"/>
|
||||
|
||||
<!-- Return days count in previous month -->
|
||||
<property name="prevDaysCount" readonly="true">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
var month = this.month - 1;
|
||||
var year = this.year;
|
||||
if (month <= 0) {
|
||||
month = 12;
|
||||
year--;
|
||||
}
|
||||
return this.getDaysCount(month, year);
|
||||
]]>
|
||||
</getter>
|
||||
</property>
|
||||
|
||||
<!-- Return short names of days of the week -->
|
||||
<method name="getDaysOfWeekNames">
|
||||
<body>
|
||||
<![CDATA[
|
||||
// shortname defaults
|
||||
var dayShort = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
||||
|
||||
// try to get localized short names.
|
||||
// May 2005's first day is a Sunday - also, month is 0-indexed in JS
|
||||
var day;
|
||||
for (var i = 0; i < 7; i++) {
|
||||
day = new Date(2005, 4, i+1).toLocaleFormat("%a");
|
||||
if (day)
|
||||
dayShort[i] = day;
|
||||
}
|
||||
return dayShort;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="fireChangeEvent">
|
||||
<body>
|
||||
var event = this.ownerDocument.createEvent("Events");
|
||||
event.initEvent("change", true, false);
|
||||
this.dispatchEvent(event);
|
||||
</body>
|
||||
</method>
|
||||
<!-- private -->
|
||||
|
||||
<method name="getDaysCount">
|
||||
<parameter name="aMonth"/>
|
||||
<parameter name="aYear"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
switch (aMonth) {
|
||||
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
|
||||
return 31;
|
||||
|
||||
case 2:
|
||||
if (aYear % 4 == 0 && aYear % 100 != 0 || aYear % 400 == 0)
|
||||
return 29; // leap-year
|
||||
return 28;
|
||||
|
||||
case 4: case 6: case 9: case 11:
|
||||
return 30;
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<field name="_currentDate">null</field>
|
||||
</implementation>
|
||||
</binding>
|
||||
</bindings>
|
||||
@@ -53,7 +53,8 @@
|
||||
<bindings id="xformsBindingsForXHTML"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl">
|
||||
xmlns:xbl="http://www.mozilla.org/xbl"
|
||||
xmlns:mozType="http://www.mozilla.org/projects/xforms/2005/type">
|
||||
|
||||
|
||||
<!-- OUTPUT: <DEFAULT> -->
|
||||
@@ -91,6 +92,25 @@
|
||||
</binding>
|
||||
|
||||
|
||||
<!-- OUTPUT: <DATE, APPEARANCE='FULL'> -->
|
||||
<binding id="xformswidget-output-date-full"
|
||||
extends="chrome://xforms/content/xforms.xml#xformswidget-output-base">
|
||||
<content>
|
||||
<children includes="label"/>
|
||||
<html:span mozType:calendar="true" anonid="control" readonly="true"/>
|
||||
<children/>
|
||||
</content>
|
||||
<implementation>
|
||||
<method name="getControlElement">
|
||||
<body>
|
||||
return this.ownerDocument.
|
||||
getAnonymousElementByAttribute(this, "anonid", "control");
|
||||
</body>
|
||||
</method>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
|
||||
<!-- LABEL: <DEFAULT> -->
|
||||
<binding id="xformswidget-label"
|
||||
extends="chrome://xforms/content/xforms.xml#xformswidget-label-base">
|
||||
|
||||
@@ -106,18 +106,29 @@ alert {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* output widgets */
|
||||
html|*:root output {
|
||||
-moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-output');
|
||||
}
|
||||
|
||||
html|*:root output[mozType|type="http://www.w3.org/2001/XMLSchema#date"][appearance="full"] {
|
||||
-moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-output-date-full');
|
||||
}
|
||||
html|*:root output[mozType|type="http://www.w3.org/2001/XMLSchema#date"][appearance="full"]
|
||||
html|span[mozType|calendar] {
|
||||
-moz-binding: url('chrome://xforms/content/widgets-xhtml.xml#calendar-full');
|
||||
}
|
||||
|
||||
xul|*:root output {
|
||||
-moz-binding: url('chrome://xforms/content/xforms-xul.xml#xformswidget-output');
|
||||
}
|
||||
|
||||
/* range widgets */
|
||||
range {
|
||||
-moz-binding: url('chrome://xforms/content/range.xml#xformswidget-range');
|
||||
}
|
||||
|
||||
/* input widgets */
|
||||
html|*:root input {
|
||||
-moz-binding: url('chrome://xforms/content/input-xhtml.xml#xformswidget-input');
|
||||
}
|
||||
@@ -138,6 +149,14 @@ input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] {
|
||||
-moz-binding: url('chrome://xforms/content/input.xml#xformswidget-input-date');
|
||||
}
|
||||
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"][appearance="full"] {
|
||||
-moz-binding: url('chrome://xforms/content/input-xhtml.xml#xformswidget-input-date-full');
|
||||
}
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"][appearance="full"]
|
||||
html|span[mozType|calendar] {
|
||||
-moz-binding: url('chrome://xforms/content/widgets-xhtml.xml#calendar-full');
|
||||
}
|
||||
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|input[anonid="dropmarker"] {
|
||||
min-width:27px;
|
||||
min-height: 1.3em;
|
||||
@@ -146,40 +165,49 @@ input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|input[anonid="d
|
||||
background-repeat: no-repeat !important;
|
||||
}
|
||||
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|div[anonid="picker"] {
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|div[anonid="picker"],
|
||||
html|span[mozType|calendar] html|table {
|
||||
border: 1px outset black !important;
|
||||
background-color: -moz-Field;
|
||||
font: -moz-list;
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|td {
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|td,
|
||||
html|span[mozType|calendar] html|td {
|
||||
border: 1px solid transparent;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|td.prevMonth,
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|td.nextMonth {
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|td.nextMonth,
|
||||
html|span[mozType|calendar] html|td.prevMonth,
|
||||
html|span[mozType|calendar] html|td.nextMonth {
|
||||
color: GrayText;
|
||||
}
|
||||
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|td.prevMonth:hover,
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|td.nextMonth:hover {
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|td.nextMonth:hover,
|
||||
html|span[mozType|calendar] html|td.prevMonth:hover,
|
||||
html|span[mozType|calendar] html|td.nextMonth:hover {
|
||||
background-color: grey;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|td.currentMonth {
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|td.currentMonth,
|
||||
html|span[mozType|calendar] html|td.currentMonth {
|
||||
color: black;
|
||||
}
|
||||
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|td.currentMonth:hover {
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|td.currentMonth:hover,
|
||||
html|span[mozType|calendar] html|td.currentMonth:hover{
|
||||
color: HighlightText;
|
||||
background-color: Highlight;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|td[tabindex="0"] {
|
||||
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] html|div[anonid="picker"] html|td[tabindex="0"],
|
||||
html|span[mozType|calendar] html|td[current] {
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
@@ -209,6 +237,7 @@ html|*:root input[mozType|type="http://www.w3.org/2001/XMLSchema#gYear"] {
|
||||
-moz-binding: url('chrome://xforms/content/input-xhtml.xml#xformswidget-input-year');
|
||||
}
|
||||
|
||||
/* secret widgets */
|
||||
html|*:root secret {
|
||||
-moz-binding: url('chrome://xforms/content/input-xhtml.xml#xformswidget-secret');
|
||||
}
|
||||
@@ -217,6 +246,7 @@ xul|*:root secret {
|
||||
-moz-binding: url('chrome://xforms/content/input-xul.xml#xformswidget-secret');
|
||||
}
|
||||
|
||||
/* textarea widgets */
|
||||
html|*:root textarea {
|
||||
-moz-binding: url('chrome://xforms/content/input-xhtml.xml#xformswidget-textarea');
|
||||
}
|
||||
@@ -225,6 +255,7 @@ xul|*:root textarea {
|
||||
-moz-binding: url('chrome://xforms/content/input-xul.xml#xformswidget-textarea');
|
||||
}
|
||||
|
||||
/* trigger and submit widgets */
|
||||
html|*:root trigger, html|*:root submit {
|
||||
-moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-trigger');
|
||||
}
|
||||
@@ -280,6 +311,7 @@ xul|*:root trigger[appearance="minimal"][disabled]:hover:active {
|
||||
color: GrayText !important;
|
||||
}
|
||||
|
||||
/* label widgets */
|
||||
html|*:root input[accesskey] > label,
|
||||
html|*:root secret[accesskey] > label,
|
||||
html|*:root textarea[accesskey] > label,
|
||||
@@ -302,6 +334,7 @@ xul|*:root input label, xul|*:root secret label, xul|*:root textarea label {
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
/* select widgets */
|
||||
select1 {
|
||||
-moz-binding: url('chrome://xforms/content/select1.xml#xformswidget-select1');
|
||||
}
|
||||
@@ -448,6 +481,7 @@ select html|div.select-choice-content {
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
/* upload widgets */
|
||||
upload {
|
||||
-moz-binding: url('chrome://xforms/content/xforms.xml#xformswidget-upload-disabled');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user