From a2edd82790681f886d2a4f365d4b6b2f64cf1a07 Mon Sep 17 00:00:00 2001 From: "allan%beaufour.dk" Date: Mon, 20 Mar 2006 11:00:10 +0000 Subject: [PATCH] [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 --- mozilla/extensions/xforms/jar.mn | 2 + .../xforms/resources/content/input-xhtml.xml | 35 +- .../resources/content/widgets-xhtml.xml | 362 ++++++++++++++++++ .../xforms/resources/content/widgets.xml | 222 +++++++++++ .../xforms/resources/content/xforms-xhtml.xml | 22 +- .../xforms/resources/content/xforms.css | 48 ++- 6 files changed, 681 insertions(+), 10 deletions(-) create mode 100644 mozilla/extensions/xforms/resources/content/widgets-xhtml.xml create mode 100644 mozilla/extensions/xforms/resources/content/widgets.xml diff --git a/mozilla/extensions/xforms/jar.mn b/mozilla/extensions/xforms/jar.mn index 5ce85c9d112..4d1d4fa23bf 100755 --- a/mozilla/extensions/xforms/jar.mn +++ b/mozilla/extensions/xforms/jar.mn @@ -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) diff --git a/mozilla/extensions/xforms/resources/content/input-xhtml.xml b/mozilla/extensions/xforms/resources/content/input-xhtml.xml index e564ffb5beb..46851967385 100644 --- a/mozilla/extensions/xforms/resources/content/input-xhtml.xml +++ b/mozilla/extensions/xforms/resources/content/input-xhtml.xml @@ -54,7 +54,8 @@ + xmlns:xbl="http://www.mozilla.org/xbl" + xmlns:mozType="http://www.mozilla.org/projects/xforms/2005/type"> @@ -183,7 +184,37 @@ - + + + + + + + + + + + + return this.ownerDocument. + getAnonymousElementByAttribute(this, "anonid", "control"); + + + + + var changeHandler = { + inputControl: this, + handleEvent: function() { + this.inputControl.updateInstanceData(false); + } + }; + this.addEventListener("change", changeHandler, false); + + + + + + diff --git a/mozilla/extensions/xforms/resources/content/widgets-xhtml.xml b/mozilla/extensions/xforms/resources/content/widgets-xhtml.xml new file mode 100644 index 00000000000..0a4d7edbf58 --- /dev/null +++ b/mozilla/extensions/xforms/resources/content/widgets-xhtml.xml @@ -0,0 +1,362 @@ + + + + %xformsDTD; +]> + + + + + + + + + + + + + + + + + + + + + + + this.refreshCompactCalendar(aFocusedDay); + + + + + + + + + + + + + + + + + + + + + + + + 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; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -1 + -1 + new Array() + false + + + + if (!this._dayContainer) + this._dayContainer = this.ownerDocument. + getAnonymousElementByAttribute(this, "anonid", "dayContainer"); + return this._dayContainer; + + + null + + + + + + = 0) { + this.focusedDayIndex--; + } + ]]> + + + + + + = 0) { + this.focusedDayIndex -= 7; + } + ]]> + + + + + + + var target = event.originalTarget; + if (target.localName != "td" || target.namespaceURI != this.XHTML_NS) + return; + + this.processAction(target.getAttribute("class"), target.textContent); + + + var target = event.originalTarget; + if (target.localName != "td" || target.namespaceURI != this.XHTML_NS) + return; + + this.processAction(target.getAttribute("class"), target.textContent); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + this.refreshCompactCalendar(aFocusedDay); + var dateLabel = new Date(this.year, this.month - 1).toLocaleFormat("%B %Y"); + this.dateLabel.textContent = dateLabel; + + + + + + if (!this._dateLabel) { + this._dateLabel = this.ownerDocument. + getAnonymousElementByAttribute(this, "anonid", "date-label"); + } + return this._dateLabel; + + + null + + + + + switch (event.originalTarget.getAttribute("anonid")) { + case "back-button": + this.processAction("prevMonth", null); + break; + case "fwd-button": + this.processAction("nextMonth", null); + break; + } + + + + diff --git a/mozilla/extensions/xforms/resources/content/widgets.xml b/mozilla/extensions/xforms/resources/content/widgets.xml new file mode 100644 index 00000000000..d53b80afeeb --- /dev/null +++ b/mozilla/extensions/xforms/resources/content/widgets.xml @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + return this.hasAttribute("readonly"); + + + if (val) + this.setAttribute("readonly", "readonly"); + else + this.removeAttribute("readonly"); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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); + + + + + + + + + + + + + + + return new Date(this.year, this.month - 1, 1).getDay(); + + + + + + + + + + + + + + + + + + + + + + + var event = this.ownerDocument.createEvent("Events"); + event.initEvent("change", true, false); + this.dispatchEvent(event); + + + + + + + + + + + + + null + + + diff --git a/mozilla/extensions/xforms/resources/content/xforms-xhtml.xml b/mozilla/extensions/xforms/resources/content/xforms-xhtml.xml index fe3aa797b03..0cb4b23604c 100644 --- a/mozilla/extensions/xforms/resources/content/xforms-xhtml.xml +++ b/mozilla/extensions/xforms/resources/content/xforms-xhtml.xml @@ -53,7 +53,8 @@ + xmlns:xbl="http://www.mozilla.org/xbl" + xmlns:mozType="http://www.mozilla.org/projects/xforms/2005/type"> @@ -91,6 +92,25 @@ + + + + + + + + + + + return this.ownerDocument. + getAnonymousElementByAttribute(this, "anonid", "control"); + + + + + + diff --git a/mozilla/extensions/xforms/resources/content/xforms.css b/mozilla/extensions/xforms/resources/content/xforms.css index 3249f0ec04d..dd35e9300f4 100755 --- a/mozilla/extensions/xforms/resources/content/xforms.css +++ b/mozilla/extensions/xforms/resources/content/xforms.css @@ -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'); }