gecko-dev/calendar/resources/content/datepicker/datepicker.xml
mostafah%oeone.com 47c8810e16 Added License.
Fixed indenting.
2004-04-14 19:11:55 +00:00

147 lines
5.6 KiB
XML

<?xml version="1.0"?>
<!--
/* ***** 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 OEone Calendar Code, released October 31st, 2001.
*
* The Initial Developer of the Original Code is
* OEone Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Garth Smedley <garths@oeone.com>
* Mike Potter <mikep@oeone.com>
*
* 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="xulDatePicker"
xmlns="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="datepicker" extends="xul:box" inherits="value,ondatepick">
<!-- ::::::::::::::::: CONTENT ::::::::::::::::::::::::: -->
<content id="content">
<xul:hbox flex="1" id="hbox">
<xul:textbox id="textbox"
onkeypress="if (event.keyCode == 13) this.parentNode.parentNode.parseTextDate();"
onblur="this.parentNode.parentNode.parentNode.parentNode.parseTextDate(true);"/>
<xul:menu class="datepicker-button">
<xul:menupopup popupanchor="bottomright" popupalign="topright"
onpopupshowing="this.parentNode.parentNode.parentNode.openPopup()">
<xul:calendar onchange="this.parentNode.hidePopup(); this.parentNode.parentNode.parentNode.parentNode.update(new Date(this.value),true); "/>
</xul:menupopup>
</xul:menu>
</xul:hbox>
</content>
<!-- ::::::::::::::::: INTERFACE ::::::::::::::::::::::::: -->
<implementation>
<property name="value"
onset="this.update(val,false)"
onget="return this.mValue"/>
<property name="ondatepick"
onset="this.callback = val;"/>
<constructor>
<![CDATA[
this.mTextBox = document.getAnonymousNodes(this)[0].childNodes[0];
this.mPopup = document.getAnonymousNodes(this)[0].childNodes[1].childNodes[0];
this.calendar = document.getAnonymousNodes(this)[0].childNodes[1].childNodes[0].childNodes[0];
this.formatter= new DateFormater();
var val = this.getAttribute("value");
if (val) {
this.value = val;
} else {
this.value = new Date();
}
val = this.getAttribute("ondatepick");
if (val) this.callback = new Function( val );
]]>
</constructor>
<method name="update">
<parameter name="aValue"/>
<parameter name="refresh"/>
<body><![CDATA[
if (aValue == null) { // invalid date, revert to previous date
// set textBox.value property, not attribute
this.mTextBox.value = this.getPrettyDate(this.mValue);
} else {
this.mValue = aValue;
this.mTextBox.value = this.getPrettyDate(this.mValue);
if( this.callback && refresh != false )
this.callback();
}
]]></body>
</method>
<method name="refreshDisplay">
<body><![CDATA[
this.calendar.refreshDisplay( );
alert( "in refresh display" );
]]></body>
</method>
<method name="getPrettyDate">
<parameter name="aValue"/>
<body><![CDATA[
return this.formatter.getShortFormatedDate(aValue);
]]></body>
</method>
<method name="parseTextDate">
<parameter name="aRefresh"/>
<body><![CDATA[
this.update(this.formatter.parseShortDate(this.mTextBox.value),
aRefresh);
]]></body>
</method>
<method name="openPopup">
<body><![CDATA[
this.calendar.update( this.mValue );
]]></body>
</method>
</implementation>
<!-- ::::::::::::::::: HANDLERS ::::::::::::::::::::::::: -->
<handlers>
<handler event="bindingattached" action="this.initialize();"/>
</handlers>
</binding>
</bindings>