1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
|
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" [
<!ENTITY % calAttrs SYSTEM "jquery-calendar.ent">
%calAttrs;
]>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>jQuery Calendar</title>
<!-- Include jQuery -->
<script type="text/javascript" src="../core/jquery.js"></script>
<!-- Include Core Files -->
<script type="text/javascript" src="../core/ui.datepicker.js"></script>
<link rel="stylesheet" type="text/css" href="../core/ui.datepicker.css" title="default"/>
<!-- Include Demo Files -->
<script type="text/javascript" src="../demo/jquery.localisation.js"></script>
<link rel="stylesheet" type="text/css" href="../demo/ui.datepicker.alt.css" title="alt" id="alt"/>
<!-- Include Core Files (Compatibility Mode) -->
<script type="text/javascript" src="jquery-calendar-compatibility.js"></script>
<script type="text/javascript" src="jquery-calendar-demo.js"></script>
<link rel="stylesheet" type="text/css" href="jquery-calendar-demo.css" />
</head>
<body>
<div id="wrap">
<h2>jQuery Calendar Compatibility Mode</h2>
<ul id="tab_menu1" class="tabs">
<li><a href="#default">Defaults</a></li>
<li><a href="#invoke">Invocation</a></li>
<li><a href="#keys">Keystrokes</a></li>
<li><a href="#restrict">Restricting</a></li>
<li><a href="#custom">Customise</a></li>
<li><a href="#l10n">Localisation</a></li>
<li><a href="#range">Date range</a></li>
<li><a href="#misc">Miscellaneous</a></li>
<li><a href="#reconfig">Reconfigure</a></li>
<li><a href="#inline">Inline</a></li>
<li><a href="#styles">Stylesheets</a></li>
</ul>
<div id="default" class="tab_group1 container">
<h3>Defaults</h3>
<p>The calendar can easily be added to an input field with appropriate default settings.</p>
<pre><code>$('#defaultFocus').calendar();</code></pre>
<p><span class="calLabel">Default calendar (click to show):</span>
<input type="text" size="10" id="defaultFocus"/></p>
<p><span class="calLabel">IE select issue:</span>
<select><option>Show how the calendar covers a select in IE</option></select></p>
<p>The defaults are:</p>
<ul>
<li>Calendar appears on focus</li>
<li>Text is in English</li>
<li>Date format is dd/mm/yyyy</li>
<li><em>Clear</em>/<em>Close</em> controls show at the top</li>
<li>Month and year are selectable directly</li>
<li>10 years before and after the selected year are shown</li>
<li>Show a single month</li>
<li>Select a single date</li>
<li>Calendar initially starts on Sunday</li>
<li>Day names are clickable to change the first day of the week</li>
<li>Days in other months are not displayed</li>
<li>No date restrictions</li>
<li>Clicking elsewhere closes the calendar</li>
</ul>
<p>Processed fields are marked with a class of <code>hasCalendar</code>
and are not re-processed if targetted a second time.</p>
</div>
<div id="invoke" class="tab_group1 container">
<h3>Invocation</h3>
<p>The calendar can be invoked in a variety of ways, as shown below.
Also shown is the use of an image only trigger,
and how the controls and buttons appear when disabled.</p>
<p><span class="calLabel">Calendar appears on focus:</span>
<input type="text" size="10" id="invokeFocus"/>
<input type="button" id="enableFocus" value="Disable"/></p>
<p><span class="calLabel">Calendar appears via button:</span>
<input type="text" size="10" id="invokeButton"/>
<input type="button" id="enableButton" value="Disable"/></p>
<p style="clear:both"><span class="calLabel">Calendar appears both ways:</span>
<input type="text" size="10" class="invokeBoth"/>
<input type="button" id="enableBoth" value="Disable"/></p>
<p>This is achieved by overriding settings when attaching the calendar
to the appropriate input controls. Note that you can also override
the default settings that apply to all calendar instances.</p>
<pre><code>popUpCal.setDefaults({autoPopUp: 'both', buttonImageOnly: true,
buttonImage: 'calendar.gif', buttonText: 'Calendar'});
$('#invokeFocus').calendar({autoPopUp: 'focus', yearRange: '-5:+5'});
$('#invokeButton').calendar({autoPopUp: 'button', buttonImageOnly: false,
buttonImage: '', buttonText: '...', yearRange: '-7:+7'});
$('.invokeBoth').calendar();</code></pre>
<p>The calendar can also be triggered externally for a particular input.</p>
<p><span class="calLabel">External trigger:</span>
<button id="button1">Open calendar</button></p>
<pre><code>popUpCal.showFor($('#invokeFocus')[0]);</code></pre>
<p>Or even opened as a "dialog". If the <em>blockUI</em> plugin is available,
it is used to create a modal dialog.</p>
<p><span class="calLabel">Calendar dialog:</span>
<input type="text" size="10" id="invokeDialog" readonly="readonly"/>
<button id="button2">Open dialog</button></p>
<pre><code>popUpCal.dialogCalendar($('#invokeDialog').val(), setDateFromDialog,
{prompt: 'Choose a date', speed: ''});</code></pre>
</div>
<div id="keys" class="tab_group1 container">
<h3>Keystrokes</h3>
<p>The calendar also responds to keystrokes entered in the input field.</p>
<p><span class="calLabel">Keyboard driven:</span>
<input type="text" size="10" class="invokeBoth"/></p>
<p>The relevant keystrokes are:</p>
<ul>
<li><span class="calLabel">page down/up</span>previous/next month</li>
<li><span class="calLabel">ctrl+page down/up</span>previous/next year</li>
<li><span class="calLabel">ctrl+home</span>current month or open when closed</li>
<li><span class="calLabel">ctrl+left/right</span>previous/next day</li>
<li><span class="calLabel">ctrl+down/up</span>previous/next week</li>
<li><span class="calLabel">enter</span>accept the selected date</li>
<li><span class="calLabel">ctrl+end</span>close and erase the date</li>
<li><span class="calLabel">escape</span>close the calendar without selection</li>
</ul>
</div>
<div id="restrict" class="tab_group1 container">
<h3>Restricting</h3>
<p>You can restrict the functionality of the calendar in various ways.
The first example sets the first day of the week to Monday and prevents it from being
changed, as well as preventing the month and year from being selected directly.</p>
<p><span class="calLabel">Restricted functionality:</span>
<input type="text" size="10" id="restrictControls"/></p>
<pre><code>$('#restrictControls').calendar({firstDay: 1, changeFirstDay: false,
changeMonth: false, changeYear: false});</code></pre>
<p>You can also limit the range of dates selectable within the calendar.
Here it's between 26-Jan-05 and 26-Jan-07.</p>
<p><span class="calLabel">Limited dates:</span>
<input type="text" size="10" id="restrictDates"/></p>
<p>Note that the range of selectable months and years changes appropriately. Also,
note that the <em>Today</em> link is no longer available as today is not in the range.
By default, the <em>Prev</em> and <em>Next</em> links are disabled if they are not
applicable. You can override this to remove them instead, with the
<code>hideIfNoPrevNext</code> setting.</p>
<pre><code>$('#restrictDates').calendar({minDate: new Date(2005, 1 - 1, 26),
maxDate: new Date(2007, 1 - 1, 26)});</code></pre>
</div>
<div id="custom" class="tab_group1 container">
<h3>Customise</h3>
<p>You can customise the selectability and/or appearance of individual days
by setting a callback function that accepts a date and returns an array
with the first entry being true/false for selectability and the second
entry being a CSS class to apply (or '' for none). One appropriate
function is built-in that prevents the selection of days on weekends.</p>
<p><span class="calLabel">No weekends:</span>
<input type="text" size="10" id="noWeekends"/></p>
<pre><code>$('#noWeekends').calendar({customDate: popUpCal.noWeekends});</code></pre>
<p>Or you can provide your own function. The one below highlights and
prevents selection of a set of national days.</p>
<p><span class="calLabel">National days:</span>
<input type="text" size="10" id="nationalDays"/></p>
<pre><code>$('#nationalDays').calendar({customDate: nationalDays});
var natDays = [[1, 26, 'au'], [2, 6, 'nz'], [3, 17, 'ie'], [4, 27, 'za'],
[5, 25, 'ar'], [6, 6, 'se'], [7, 4, 'us'], [8, 17, 'id'], [9, 7, 'br'],
[10, 1, 'cn'], [11, 22, 'lb'], [12, 12, 'ke']];
function nationalDays(date) {
for (i = 0; i < natDays.length; i++) {
if (date.getMonth() == natDays[i][0] - 1 && date.getDate() == natDays[i][1]) {
return [false, natDays[i][2] + '_day'];
}
}
return [true, ''];
}</code></pre>
<p>With CSS like the following:</p>
<pre><code>.au_day { color: blue !important; background: #eee url(au.gif) no-repeat center !important; }</code></pre>
</div>
<div id="l10n" class="tab_group1 container">
<h3>Localisation</h3>
<p>You can localise the calendar for other languages and regional differences.
The calendar defaults to English with a date format of DD/MM/YYYY.
This is easily changed via the <code>dateFormat</code> setting. The first three
characters are 'Y', 'M', and 'D' in the order in which they should appear,
and the last character is the field separator to use (may be omitted).</p>
<p><span class="calLabel">ISO date format:</span>
<input type="text" size="10" id="isoFormat"/></p>
<pre><code>$('#isoFormat').calendar({dateFormat: 'YMD-'});</code></pre>
<p>Or translate the text into another language.</p>
<p><span class="calLabel">
<select id="language">
<option value="zh-CN">Chinese Simplified</option>
<option value="cs">Čeština</option>
<option value="de">Deutsch</option>
<option value="es">Español</option>
<option value="fr" selected="selected">Français</option>
<option value="it">Italiano</option>
<option value="pl">Polski</option>
<option value="ro">Română</option>
<option value="hu">Magyar</option>
<option value="pt-BR">Português</option>
<option value="ru">Русский</option>
<option value="sk">Slovenčina</option>
<option value="sv">Svenska</option>
</select>:</span>
<input type="text" size="10" id="l10nCalendar"/></p>
<p>You need to load the appropriate language package, which
adds a language set (popUpCal.regional[langCode]) and
automatically sets this language as the default for all calendars.</p>
<pre><code><script type="text/javascript" src="jquery-calendar-fr.js"></script></code></pre>
<p>Thereafter, if desired, you can restore the original language settings.</p>
<pre><code>popUpCal.setDefaults(popUpCal.regional['']);</code></pre>
<p>And then configure the language per calendar instance.</p>
<pre><code>$('#l10nCalendar').calendar(popUpCal.regional['fr']);</code></pre>
<p><strong>Localisation packages:</strong></p>
<p>Localisation packages can be found below under <a href="#documentation">Settings and Documentation</a>.</p>
</div>
<div id="range" class="tab_group1 container">
<h3>Date Range</h3>
<p>Use a custom field settings function to create a date range control:
two date fields, each restricting the other. The function takes an
input field as an argument and returns a settings object (anonymous).</p>
<p><span class="calLabel">Date range:</span>
<input type="text" size="10" class="calendarRange" id="dFrom"/> to
<input type="text" size="10" class="calendarRange" id="dTo"/></p>
<pre><code>$('.calendarRange').calendar({fieldSettings: customRange});
function customRange(input) {
return {minDate: (input.id == 'dTo' ? getDate($('#dFrom').val()) : null),
maxDate: (input.id == 'dFrom' ? getDate($('#dTo').val()) : null)};
}</code></pre>
<p>Select a date range on one calendar, first click is the start date and second click is the end date.
In the last example, <i>Previous</i> and <i>Next</i> move three months at a time.</p>
<p><span class="calLabel">Date range:</span>
<input type="text" size="25" id="rangeSelect"/></p>
<pre><code>$('#rangeSelect').calendar({rangeSelect: true});</code></pre>
<p><span class="calLabel">Show two months with date range select:</span>
<input type="text" size="25" id="rangeSelect2Months"/></p>
<pre><code>$("#rangeSelect2Months").calendar({rangeSelect: true, numberOfMonths: 2);</code></pre>
<p><span class="calLabel">Show six months with date range select:</span>
<input type="text" size="25" id="rangeSelect6Months"/></p>
<pre><code>$("#rangeSelect6Months").calendar({rangeSelect: true, numberOfMonths: [2, 3],
stepMonths: 3, prevText: '<< Previous Months', nextText: 'Next Months >>'});</code></pre>
</div>
<div id="misc" class="tab_group1 container">
<h3>Miscellaneous</h3>
<p>Set the date shown when first opening the calendar. The default is today.</p>
<p><span class="calLabel">Open at 01-Jan-2007:</span>
<input type="text" size="10" id="openDateJan01"/></p>
<p><span class="calLabel">Open at 7 days from today:</span>
<input type="text" size="10" id="openDatePlus7"/></p>
<pre><code>$('#openDateJan01').calendar({defaultDate: new Date(2007, 1 - 1, 1)});
$('#openDatePlus7').calendar({defaultDate: +7});</code></pre>
<p>Additional settings let you move the <em>Clear</em>/<em>Close</em> controls
to the bottom and display the days in other months (non-selectable).
A callback function is also added to operate when a date is selected.
If no callback is specified, the <code>onchange</code> event of the
input field is triggered.</p>
<p><span class="calLabel">Additional settings:</span>
<input type="text" size="10" id="addSettings"/></p>
<pre><code>$('#addSettings').calendar({closeAtTop: false,
showOtherMonths: true, onSelect: alertDate});</code></pre>
<p>Connect the calendar to linked drop-downs. You still need an input field,
but it is hidden following the drop-downs.</p>
<p><span class="calLabel">Linked drop-downs:</span>
<select id="selectDay"><option value="01">1</option><option value="02">2</option>
<option value="03">3</option><option value="04">4</option>
<option value="05">5</option><option value="06">6</option>
<option value="07">7</option><option value="08">8</option>
<option value="09">9</option><option value="10">10</option>
<option value="11">11</option><option value="12">12</option>
<option value="13">13</option><option value="14">14</option>
<option value="15">15</option><option value="16">16</option>
<option value="17">17</option><option value="18">18</option>
<option value="19">19</option><option value="20">20</option>
<option value="21">21</option><option value="22">22</option>
<option value="23">23</option><option value="24">24</option>
<option value="25">25</option><option value="26">26</option>
<option value="27">27</option><option value="28">28</option>
<option value="29">29</option><option value="30">30</option>
<option value="31">31</option></select>
<select id="selectMonth"><option value="01">Jan</option><option value="02">Feb</option>
<option value="03">Mar</option><option value="04">Apr</option>
<option value="05">May</option><option value="06">Jun</option>
<option value="07">Jul</option><option value="08">Aug</option>
<option value="09">Sep</option><option value="10">Oct</option>
<option value="11">Nov</option><option value="12">Dec</option></select>
<select id="selectYear"><option value="2001">2001</option><option value="2002">2002</option>
<option value="2003">2003</option><option value="2004">2004</option>
<option value="2005">2005</option><option value="2006">2006</option>
<option value="2007">2007</option><option value="2008">2008</option>
<option value="2009">2009</option><option value="2010">2010</option></select>
<input type="hidden" size="10" id="linkedCalendar" disabled="disabled"/></p>
<pre><code>$('#linkedCalendar').calendar({minDate: new Date(2001, 1 - 1, 1),
maxDate: new Date(2010, 12 - 1, 31), fieldSettings: readLinked,
onSelect: updateLinked});
function readLinked() {
$('#linkedCalendar').val($('#selectDay').val() + '/' +
$('#selectMonth').val() + '/' + $('#selectYear').val());
return {defaultDate: new Date($('#selectYear').val(),
$('#selectMonth').val() - 1, $('#selectDay').val())};
}
function updateLinked(date) {
$('#selectDay').val(date.substring(0, 2));
$('#selectMonth').val(date.substring(3, 5));
$('#selectYear').val(date.substring(6, 10));
}</code></pre>
</div>
<div id="reconfig" class="tab_group1 container">
<h3>Reconfiguration</h3>
<p>If necessary, the calendar for an input (or set of inputs) can be reconfigured
on the fly. As an example, here we change the speed at which the calendar appears.</p>
<p><span class="calLabel">Display speed:</span>
<select onchange="setSpeed(this);"><option value="">immediate</option>
<option value="slow">slow</option><option value="medium" selected="selected">medium</option>
<option value="fast">fast</option></select></p>
<p><span class="calLabel">Reconfigured calendar:</span>
<input type="text" size="10" id="reconfigureCal"/></p>
<p>When the option in the select changes, the following function is called:</p>
<pre><code>function setSpeed(select) {
popUpCal.reconfigureFor('#reconfigureCal',
{speed: select.options[select.selectedIndex].value});
}</code></pre>
<p>Calendars can also be configured inline.
Add attributes to the input control with the namespace "cal:"
corresponding to the calendar properties.
The attribute values are evaluated as JavaScript.</p>
<p><span class="calLabel">Inline configuration 1:</span>
<input type="text" size="10" class="inlineConfig" onchange="showDay(this);"
cal:closeAtTop="false" cal:firstDay="1" cal:appendText="which is a"/>
<span id="inlineDay">blank</span></p>
<p><span class="calLabel">Inline configuration 2:</span>
<input type="text" size="10" class="inlineConfig"
cal:minDate="new Date(2007, 1 - 1, 1)" cal:maxDate="new Date(2007, 12 - 1, 31)"/></p>
<pre><code><input type="text" size="10" class="inlineConfig" onchange="showDay(this);"
cal:closeAtTop="false" cal:firstDay="1" cal:appendText="which is a"/>
<input type="text" size="10" class="inlineConfig"
cal:minDate="new Date(2007, 1 - 1, 1)" cal:maxDate="new Date(2007, 12 - 1, 31)"/>
$('.inlineConfig').calendar();</code></pre>
</div>
<div id="inline" class="tab_group1 container">
<h3>Inline</h3>
<p>The calendar can be used inline rather than as a popup.</p>
<p><span class="calLabel">Inline date range:</span>
<span class="calendarInline" id="inlineFrom"></span>
<span style="float: left; padding: 0px 10px;">to</span>
<span class="calendarInline" id="inlineTo"></span></p>
<p style="clear: both; padding-top: 0.5em;"><span class="calLabel">Selected range is:</span>
<input type="text" size="25" id="inlineRange" readonly="readonly"/></p>
<p>Connect the calendar to a div or span rather than an input field.
Include a callback function for notification of a date selection.</p>
<pre><code>$('.calendarInline').calendar({onSelect: updateInlineRange});
function updateInlineRange() {
var inlineFrom = $('#inlineFrom')[0];
var inlineTo = $('#inlineTo')[0];
var dateFrom = popUpCal.getDateFor(inlineFrom);
var dateTo = popUpCal.getDateFor(inlineTo);
$('#inlineRange').val(formatDate(dateFrom) + ' to ' + formatDate(dateTo));
popUpCal.reconfigureFor(inlineFrom, {maxDate: dateTo});
popUpCal.reconfigureFor(inlineTo, {minDate: dateFrom});
}</code></pre>
<p>Or show a number of months at once and set the range directly.</p>
<p><span class="calLabel">Inline date range with two months:</span>
<span id="rangeInline"></span></p>
<p style="clear: both; padding-top: 0.5em;"><span class="calLabel">Selected range is:</span>
<input type="text" size="25" id="inlineRange2" readonly="readonly"/></p>
<pre><code>$('#rangeInline').calendar({rangeSelect: true, rangeSeparator: ' to ',
numberOfMonths: 2, onSelect: updateInlineRange2});
function updateInlineRange2(dateStr) {
$('#inlineRange2').val(dateStr ? dateStr :
formatDate(popUpCal.getDateFor('#rangeInline')));
}</code></pre>
</div>
<div id="styles" class="tab_group1 container">
<h3>Stylesheets</h3>
<p>The calendar can be formatted through the use of a stylesheet.
The default stylesheet is used in the rest of this demo
with an alternate one used here.</p>
<p><span class="calLabel">Alternate style:</span>
<input type="text" size="10" id="altStyle"/></p>
<p><span class="calLabel">In a dialog:</span>
<input type="text" size="10" id="altDialog" readonly="readonly"/>
<button id="button3">Open dialog</button></p>
<p>The basic HTML structure of the calendar is shown below:</p>
<pre><code><div id="calendar_div">
<div class="calendar_control">
<div class="calendar_clear"><a>Clear</a></div>
<div class="calendar_close"><a>Close</a></div>
</div>
<div class="calendar_links">
<div class="calendar_prev"><a>&lt;Prev</a></div>
<div class="calendar_current"><a>Today</a></div>
<div class="calendar_next"><a>Next&gt;</a></div>
</div>
<div class="calendar_oneMonth calendar_newRow">
<div class="calendar_header">
<select class="calendar_newMonth"></select>
<select class="calendar_newYear"></select>
</div>
<table class="calendar" cellpadding="0" cellspacing="0">
<thead>
<tr class="calendar_titleRow">
<td><a>Su</a></td><td><a>Mo</a></td>...
</tr>
</thead>
<tbody>
<tr class="calendar_daysRow">
<td class="calendar_daysCell calendar_weekEndCell
calendar_otherMonth calendar_unselectable">31</td>
<td class="calendar_daysCell"><a>1</a></td>
<td class="calendar_daysCell calendar_daysCellOver"><a>2</a></td>
<td class="calendar_daysCell calendar_daysCellOver calendar_currentDay"><a>3</a></td>
<td class="calendar_daysCell calendar_today"><a>4</a></td>
...
</tr>
...
</tbody>
</table>
</div>
<div class="calendar_oneMonth">
...
</div>
<div style="clear: both;"></div>
</div></code></pre>
</div>
</body>
</html>
|