1 <?xml version="1.0"?>
2 <!-- ***** BEGIN LICENSE BLOCK *****
3 - Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 -
5 - The contents of this file are subject to the Mozilla Public License Version
6 - 1.1 (the "License"); you may not use this file except in compliance with
7 - the License. You may obtain a copy of the License at
8 - http://www.mozilla.org/MPL/
9 -
10 - Software distributed under the License is distributed on an "AS IS" basis,
11 - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 - for the specific language governing rights and limitations under the
13 - License.
14 -
15 - The Original Code is Sun Microsystems code.
16 -
17 - The Initial Developer of the Original Code is Sun Microsystems.
18 - Portions created by the Initial Developer are Copyright (C) 2006
19 - the Initial Developer. All Rights Reserved.
20 -
21 - Contributor(s):
22 - Michael Buettner <michael.buettner@sun.com>
23 - Berend Cornelius <berend.cornelius@sun.com>
24 -
25 - Alternatively, the contents of this file may be used under the terms of
26 - either the GNU General Public License Version 2 or later (the "GPL"), or
27 - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 - in which case the provisions of the GPL or the LGPL are applicable instead
29 - of those above. If you wish to allow use of your version of this file only
30 - under the terms of either the GPL or the LGPL, and not to allow others to
31 - use your version of this file under the terms of the MPL, indicate your
32 - decision by deleting the provisions above and replace them with the notice
33 - and other provisions required by the GPL or the LGPL. If you do not delete
34 - the provisions above, a recipient may use your version of this file under
35 - the terms of any one of the MPL, the GPL or the LGPL.
36 -
37 - ***** END LICENSE BLOCK ***** -->
38
39 <bindings xmlns="http://www.mozilla.org/xbl"
40 xmlns:xbl="http://www.mozilla.org/xbl"
41 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
42
43 <!--
44 ########################################################################
45 ## daypicker
46 ########################################################################
47 -->
48
49 <binding id="daypicker" display="xul:button"
50 extends="chrome://global/content/bindings/button.xml#button-base">
51 <resources>
52 <stylesheet src="chrome://calendar/content/calendar-daypicker.css"/>
53 </resources>
54 <content>
55 <xul:stack anonid="stackid" class="daystack" xbl:inherits="bottom,right">
56 <xul:image anonid="imageid" xbl:inherits="mode,height,width"/>
57 <xul:hbox align="center">
58 <xul:label anonid="daytext"
59 class="toolbarbutton-text"
60 flex="1"
61 xbl:inherits="value=label"/>
62 </xul:hbox>
63 </xul:stack>
64 </content>
65 <implementation>
66 <method name="onmodified">
67 <parameter name="aEvent"/>
68 <body>
69 <![CDATA[
70 if (aEvent.attrName =="checked") {
71 var event = document.createEvent('Events');
72 event.initEvent('select', true, true);
73 this.calendar.dispatchEvent(event);
74 }
75 ]]>
76 </body>
77 </method>
78 <constructor>
79 <![CDATA[
80 this.setAttribute("autoCheck", "true");
81 this.setAttribute("type", "checkbox");
82 this.addEventListener("DOMAttrModified", this.onmodified, false);
83 ]]>
84 </constructor>
85 </implementation>
86 </binding>
87
88 <!--
89 ########################################################################
90 ## daypicker-weekday
91 ########################################################################
92 -->
93
94 <binding id="daypicker-weekday" extends="xul:box">
95 <resources>
96 <stylesheet src="chrome://calendar/skin/calendar-daypicker.css"/>
97 </resources>
98
99 <content>
100 <xul:hbox anonid="mainbox" flex="1">
101 <xul:daypicker bottom="true" xbl:inherits="disabled,mode=id"/>
102 <xul:daypicker bottom="true" xbl:inherits="disabled,mode=id"/>
103 <xul:daypicker bottom="true" xbl:inherits="disabled,mode=id"/>
104 <xul:daypicker bottom="true" xbl:inherits="disabled,mode=id"/>
105 <xul:daypicker bottom="true" xbl:inherits="disabled,mode=id"/>
106 <xul:daypicker bottom="true" xbl:inherits="disabled,mode=id"/>
107 <xul:daypicker bottom="true" right="true" xbl:inherits="disabled,mode=id"/>
108 </xul:hbox>
109 </content>
110
111 <implementation>
112 <!--
113 The weekday-picker manages an array of selected days of the week and
114 the 'days' property is the interface to this array. the expected argument is
115 an array containing integer elements, where each element represents a selected
116 day of the week, starting with SUNDAY=1.
117 -->
118 <property name="days">
119 <setter><![CDATA[
120 var mainbox =
121 document.getAnonymousElementByAttribute(
122 this, "anonid", "mainbox");
123 var numChilds = mainbox.childNodes.length;
124 for (var i = 0; i < numChilds; i++) {
125 var child = mainbox.childNodes[i];
126 child.removeAttribute("checked");
127 }
128 for (i = 0; i < val.length; i++) {
129 var index = val[i] - 1 - this.weekStartOffset;
130 if (index < 0) {
131 index += 7;
132 }
133 mainbox.childNodes[index].setAttribute("checked", "true");
134 }
135 return val;
136 ]]></setter>
137 <getter><![CDATA[
138 var mainbox =
139 document.getAnonymousElementByAttribute(
140 this, "anonid", "mainbox");
141 var numChilds = mainbox.childNodes.length;
142 var days = [];
143 for (var i = 0; i < numChilds; i++) {
144 var child = mainbox.childNodes[i];
145 if (child.getAttribute("checked") == "true") {
146 var index = i + this.weekStartOffset;
147 if (index >= 7)
148 index -= 7;
149 days.push(index + 1);
150 }
151 }
152 return days;
153 ]]></getter>
154 </property>
155
156 <constructor><![CDATA[
157 var pb2 = Components.classes[
158 "@mozilla.org/preferences-service;1"]
159 .getService(
160 Components.interfaces.nsIPrefBranch2);
161 this.weekStartOffset = 0;
162 try {
163 this.weekStartOffset =
164 pb2.getIntPref("calendar.week.start");
165 } catch (ex) {
166 }
167 var sbs = Components.classes[
168 "@mozilla.org/intl/stringbundle;1"]
169 .getService(
170 Components.interfaces.nsIStringBundleService);
171 var props =
172 sbs.createBundle(
173 "chrome://calendar/locale/dateFormat.properties");
174 var mainbox =
175 document.getAnonymousElementByAttribute(
176 this, "anonid", "mainbox");
177 var numChilds = mainbox.childNodes.length;
178 for (var i = 0; i < numChilds; i++) {
179 var child = mainbox.childNodes[i];
180 var dow = i + this.weekStartOffset;
181 if (dow >= 7) {
182 dow -= 7;
183 }
184 var day = props.GetStringFromName("day." + (dow + 1) + ".Mmm");
185 child.label = day;
186 child.calendar = this;
187 }
188 ]]></constructor>
189
190 </implementation>
191 </binding>
192
193 <!--
194 ########################################################################
195 ## daypicker-monthday
196 ########################################################################
197 -->
198
199 <binding id="daypicker-monthday" extends="xul:box">
200 <resources>
201 <stylesheet src="chrome://calendar/skin/calendar-daypicker.css"/>
202 </resources>
203
204 <content>
205 <xul:vbox anonid="mainbox" class="daypicker-monthday-mainbox" flex="1" >
206 <xul:hbox class="daypicker-row" flex="1">
207 <daypicker label="1" xbl:inherits="disabled, mode=id"/>
208 <daypicker label="2" xbl:inherits="disabled, mode=id"/>
209 <daypicker label="3" xbl:inherits="disabled, mode=id"/>
210 <daypicker label="4" xbl:inherits="disabled, mode=id"/>
211 <daypicker label="5" xbl:inherits="disabled, mode=id"/>
212 <daypicker label="6" xbl:inherits="disabled, mode=id"/>
213 <daypicker label="7" right="true" xbl:inherits="disabled, mode=id"/>
214 </xul:hbox>
215 <xul:hbox class="daypicker-row" flex="1">
216 <daypicker label="8" xbl:inherits="disabled, mode=id"/>
217 <daypicker label="9" xbl:inherits="disabled, mode=id"/>
218 <daypicker label="10" xbl:inherits="disabled, mode=id"/>
219 <daypicker label="11" xbl:inherits="disabled, mode=id"/>
220 <daypicker label="12" xbl:inherits="disabled, mode=id"/>
221 <daypicker label="13" xbl:inherits="disabled, mode=id"/>
222 <daypicker label="14" right="true" xbl:inherits="disabled, mode=id"/>
223 </xul:hbox>
224 <xul:hbox class="daypicker-row" flex="1">
225 <daypicker label="15" xbl:inherits="disabled, mode=id"/>
226 <daypicker label="16" xbl:inherits="disabled, mode=id"/>
227 <daypicker label="17" xbl:inherits="disabled, mode=id"/>
228 <daypicker label="18" xbl:inherits="disabled, mode=id"/>
229 <daypicker label="19" xbl:inherits="disabled, mode=id"/>
230 <daypicker label="20" xbl:inherits="disabled, mode=id"/>
231 <daypicker label="21" right="true" xbl:inherits="disabled, mode=id"/>
232 </xul:hbox>
233 <xul:hbox class="daypicker-row" flex="1">
234 <daypicker label="22" xbl:inherits="disabled, mode=id"/>
235 <daypicker label="23" xbl:inherits="disabled, mode=id"/>
236 <daypicker label="24" xbl:inherits="disabled, mode=id"/>
237 <daypicker label="25" xbl:inherits="disabled, mode=id"/>
238 <daypicker label="26" xbl:inherits="disabled, mode=id"/>
239 <daypicker label="27" xbl:inherits="disabled, mode=id"/>
240 <daypicker label="28" right="true" xbl:inherits="disabled, mode=id"/>
241 </xul:hbox>
242 <xul:hbox class="daypicker-row" flex="1">
243 <daypicker bottom="true" label="29" xbl:inherits="disabled, mode=id"/>
244 <daypicker bottom="true" label="30" xbl:inherits="disabled, mode=id"/>
245 <daypicker bottom="true" label="31" xbl:inherits="disabled, mode=id"/>
246 <daypicker disabled="true" bottom="true" xbl:inherits="mode=id"/>
247 <daypicker disabled="true" bottom="true" xbl:inherits="mode=id"/>
248 <daypicker disabled="true" bottom="true" xbl:inherits="mode=id"/>
249 <daypicker disabled="true" bottom="true" right="true" xbl:inherits="mode=id"/>
250 </xul:hbox>
251 </xul:vbox>
252 </content>
253 <implementation>
254 <property name="days">
255 <setter><![CDATA[
256 var mainbox =
257 document.getAnonymousElementByAttribute(
258 this, "anonid", "mainbox");
259 var numRows = mainbox.childNodes.length;
260 var days = [];
261 for (var i = 0; i < numRows; i++) {
262 var row = mainbox.childNodes[i];
263 var numChilds = row.childNodes.length;
264 for (var j = 0; j < numChilds; j++) {
265 var child = row.childNodes[j];
266 child.removeAttribute("checked");
267 days.push(child);
268 }
269 }
270 for (i = 0; i < val.length; i++) {
271 days[val[i]-1].setAttribute("checked", "true");
272 }
273 return val;
274 ]]></setter>
275 <getter><![CDATA[
276 var mainbox =
277 document.getAnonymousElementByAttribute(
278 this, "anonid", "mainbox");
279 var numRows = mainbox.childNodes.length;
280 var days = [];
281 for (var i = 0; i < numRows; i++) {
282 var row = mainbox.childNodes[i];
283 var numChilds = row.childNodes.length;
284 for (var j = 0; j < numChilds; j++) {
285 var child = row.childNodes[j];
286 if (child.getAttribute("checked") == "true") {
287 days.push(Number(child.label));
288 }
289 }
290 }
291 return days;
292 ]]></getter>
293 </property>
294
295 <constructor><![CDATA[
296 var mainbox =
297 document.getAnonymousElementByAttribute(
298 this, "anonid", "mainbox");
299 var numRows = mainbox.childNodes.length;
300 for (var i = 0; i < numRows; i++) {
301 var row = mainbox.childNodes[i];
302 var numChilds = row.childNodes.length;
303 for (var j = 0; j < numChilds; j++) {
304 var child = row.childNodes[j];
305 child.calendar = this;
306 }
307 }
308 ]]></constructor>
309 </implementation>
310 </binding>
311 </bindings>