gecko-dev/calendar/prototypes/wcap/sun-calendar-event-dialog-r...

311 строки
14 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 Sun Microsystems code.
-
- The Initial Developer of the Original Code is Sun Microsystems.
- Portions created by the Initial Developer are Copyright (C) 2006
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Michael Buettner <michael.buettner@sun.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 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">
<!-- ########################################################################
## datepicker-box
######################################################################## -->
<binding id="datepicker-box" extends="xul:text">
<handlers>
<handler event="click" action="if (event.button == 0) this.calendar.dayClicked(this)"/>
</handlers>
</binding>
<!--
########################################################################
## datepicker-weekday
########################################################################
-->
<binding id="datepicker-weekday" extends="xul:box">
<resources>
<stylesheet src="chrome://calendar/content/sun-calendar-event-dialog-recurrence-datepicker.css"/>
</resources>
<content>
<xul:hbox anonid="mainbox" class="datepicker-weekday-mainbox" equalsize="always" flex="1">
<xul:text class="datepicker-box" flex="1"/>
<xul:text class="datepicker-box" flex="1"/>
<xul:text class="datepicker-box" flex="1"/>
<xul:text class="datepicker-box" flex="1"/>
<xul:text class="datepicker-box" flex="1"/>
<xul:text class="datepicker-box" flex="1"/>
<xul:text class="datepicker-box" flex="1"/>
</xul:hbox>
</content>
<implementation>
<!-- the weekday-picker manages an array of selected days of the week and
the 'days' property is the interface to this array. the expected argument is
an array containing integer elements, where each element represents a selected
day of the week, starting with SUNDAY=1. -->
<property name="days">
<setter>
<![CDATA[
var mainbox = document.getAnonymousElementByAttribute(this, "anonid", "mainbox");
var numChilds = mainbox.childNodes.length;
for (var i=0; i<numChilds; i++) {
var child = mainbox.childNodes[i];
child.removeAttribute("selected");
}
for (i=0; i<val.length; i++) {
var index = val[i]-1-this.weekStartOffset;
if(index < 0)
index += 7;
mainbox.childNodes[index].setAttribute("selected","true");
}
return val;
]]>
</setter>
<getter>
<![CDATA[
var mainbox = document.getAnonymousElementByAttribute(this, "anonid", "mainbox");
var numChilds = mainbox.childNodes.length;
var days = [];
for (var i=0; i<numChilds; i++) {
var child = mainbox.childNodes[i];
if (child.hasAttribute("selected")) {
var index = i+this.weekStartOffset;
if(index >= 7)
index -= 7;
days.push(index+1);
}
}
return days;
]]>
</getter>
</property>
<constructor>
<![CDATA[
var pb2 = Components.classes
["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch2);
this.weekStartOffset = 0;
try {
this.weekStartOffset = pb2.getIntPref("calendar.week.start");
} catch (ex) {}
var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
var props = sbs.createBundle("chrome://calendar/locale/dateFormat.properties");
var mainbox = document.getAnonymousElementByAttribute(this, "anonid", "mainbox");
var numChilds = mainbox.childNodes.length;
for (var i=0; i<numChilds; i++) {
var child = mainbox.childNodes[i];
var dow = i+this.weekStartOffset;
if(dow >= 7)
dow -= 7;
var day = props.GetStringFromName("day."+(dow+1)+".Mmm");
child.setAttribute("value",day);
child.calendar = this;
}
]]>
</constructor>
<method name="dayClicked">
<parameter name="aDay"/>
<body>
<![CDATA[
if (aDay.hasAttribute("selected")) {
aDay.removeAttribute("selected");
} else {
aDay.setAttribute("selected", "true");
}
var event = document.createEvent('Events');
event.initEvent('select', true, true);
this.dispatchEvent(event);
]]>
</body>
</method>
</implementation>
</binding>
<!--
########################################################################
## datepicker-monthday
########################################################################
-->
<binding id="datepicker-monthday" extends="xul:box">
<resources>
<stylesheet src="chrome://calendar/content/sun-calendar-event-dialog-recurrence-datepicker.css"/>
</resources>
<content>
<xul:vbox anonid="mainbox" class="datepicker-monthday-mainbox" equalsize="always" flex="1">
<xul:hbox class="datepicker-row" equalsize="always">
<xul:text class="datepicker-box" flex="1" value="1" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="2" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="3" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="4" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="5" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="6" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="7" xbl:inherits="disabled"/>
</xul:hbox>
<xul:hbox class="datepicker-row" equalsize="always">
<xul:text class="datepicker-box" flex="1" value="8" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="9" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="10" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="11" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="12" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="13" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="14" xbl:inherits="disabled"/>
</xul:hbox>
<xul:hbox class="datepicker-row" equalsize="always">
<xul:text class="datepicker-box" flex="1" value="15" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="16" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="17" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="18" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="19" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="20" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="21" xbl:inherits="disabled"/>
</xul:hbox>
<xul:hbox class="datepicker-row" equalsize="always">
<xul:text class="datepicker-box" flex="1" value="22" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="23" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="24" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="25" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="26" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="27" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="28" xbl:inherits="disabled"/>
</xul:hbox>
<xul:hbox class="datepicker-row" equalsize="always">
<xul:text class="datepicker-box" flex="1" value="29" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="30" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" value="31" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" othermonth="true" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" othermonth="true" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" othermonth="true" xbl:inherits="disabled"/>
<xul:text class="datepicker-box" flex="1" othermonth="true" xbl:inherits="disabled"/>
</xul:hbox>
</xul:vbox>
</content>
<implementation>
<property name="days">
<setter>
<![CDATA[
var mainbox = document.getAnonymousElementByAttribute(this, "anonid", "mainbox");
var numRows = mainbox.childNodes.length;
var days = [];
for (var i=0; i<numRows; i++) {
var row = mainbox.childNodes[i];
var numChilds = row.childNodes.length;
for (var j=0; j<numChilds; j++) {
var child = row.childNodes[j];
child.removeAttribute("selected");
days.push(child);
}
}
for (i=0; i<val.length; i++) {
days[val[i]-1].setAttribute("selected","true");
}
return val;
]]>
</setter>
<getter>
<![CDATA[
var mainbox = document.getAnonymousElementByAttribute(this, "anonid", "mainbox");
var numRows = mainbox.childNodes.length;
var days = [];
for (var i=0; i<numRows; i++) {
var row = mainbox.childNodes[i];
var numChilds = row.childNodes.length;
for (var j=0; j<numChilds; j++) {
var child = row.childNodes[j];
if (child.hasAttribute("selected")) {
days.push(Number(child.getAttribute("value")));
}
}
}
return days;
]]>
</getter>
</property>
<constructor>
<![CDATA[
var mainbox = document.getAnonymousElementByAttribute(this, "anonid", "mainbox");
var numRows = mainbox.childNodes.length;
for (var i=0; i<numRows; i++) {
var row = mainbox.childNodes[i];
var numChilds = row.childNodes.length;
for (var j=0; j<numChilds; j++) {
var child = row.childNodes[j];
child.calendar = this;
}
}
]]>
</constructor>
<method name="dayClicked">
<parameter name="aDay"/>
<body>
<![CDATA[
if (!aDay.hasAttribute("disabled") || !aDay.getAttribute("disabled")) {
if (aDay.hasAttribute("selected")) {
aDay.removeAttribute("selected");
} else {
aDay.setAttribute("selected", "true");
}
}
var event = document.createEvent('Events');
event.initEvent('select', true, true);
this.dispatchEvent(event);
]]>
</body>
</method>
</implementation>
</binding>
</bindings>