forked from jquery/jquery-ui
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
284 lines (275 loc) · 11.5 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../jquery-1.7.1.js"></script>
<script src="../ui/jquery.ui.core.js"></script>
<script src="../ui/jquery.ui.widget.js"></script>
<script src="../ui/jquery.ui.button.js"></script>
<script src="../ui/jquery.ui.position.js"></script>
<script src="../ui/jquery.ui.popup.js"></script>
<script src="jquery.tmpl.js"></script>
<script src="../external/globalize.js"></script>
<script src="../external/globalize.culture.de-DE.js"></script>
<script src="../external/globalize.culture.ja-JP.js"></script>
<script src="localization.js"></script>
<script src="date.js"></script>
<script src="picker.js"></script>
<link rel="stylesheet" href="../themes/base/jquery.ui.all.css">
<title>jQuery UI Datepicker Rewrite</title>
<style>
body { font:62.5% Verdana,Arial,sans-serif; }
.ui-datepicker-multi-3 { width: 51em !important; }
.ui-datepicker-calendar a.ui-state-focus {
text-decoration: underline;
}
/* TODO: This needs to go into a popup specific stylesheet */
.ui-popup { position: absolute; z-index: 5000; }
</style>
</head>
<body>
<select id="culture">
<option value="en">en</option>
<option value="de-DE">de-DE</option>
<option value="ja-JP">ja-JP</option>
</select>
<input id="inline-output" />
<h2>Accessibility Enabled Template:</h2>
<p>Inline Date Picker:</p>
<div id="datepicker-inline-default"></div>
<p>Popup Datepicker:</p>
<label for="datepickerPopup1">Date of Birth</label> <input id="datepickerPopup1" type="text" aria-describedby="datepickerPopupInstruction" />
<p id="datepickerPopupInstruction">Press up or down to move focus to date picker grid. Cusor up/down/left/right to navigate days. Page up/down to switch months, hold alt key to switch years. Enter to select.</p>
<h2>Older Templates:</h2>
<div id="datepicker-inline-multi"></div>
<div id="datepicker-inline"></div>
<input id="datepicker" type="text" />
<input id="datepicker2" type="text" />
<input id="datepicker3" type="text" />
<script>
$( function() {
$( "#culture" ).change( function() {
Globalize.culture( $( this ).val() );
$( ":ui-datepicker" ).datepicker( "refresh" );
});
$( "#datepicker-inline-default" ).datepicker( {
select: function( event, ui ) {
$( "#inline-output" ).val( ui.date );
}
});
$( "#datepicker-inline-multi" ).datepicker( {
tmpl: "#ui-datepicker-multi-tmpl",
select: function( event, ui ) {
$( "#inline-output" ).val( ui.date );
}
});
$( "#datepicker-inline" ).datepicker( {
tmpl: "#ui-datepicker-weeks-tmpl",
select: function( event, ui ) {
$( "#inline-output" ).val( ui.date );
},
eachDay: function( day ) {
if ( day.lead && day.date > 20 ) {
day.selectable = false;
day.render = true;
day.title = "These are the days of last month";
day.extraClasses = "ui-state-disabled";
}
if ( day.lead && day.date < 3 ) {
day.selectable = true;
day.render = true;
day.extraClasses = "ui-state-disabled";
}
if ( day.date == 1 ) {
day.extraClasses = "ui-state-error";
day.title = "Something bad explaining the error highlight";
}
if ( day.today ) {
day.title = "A good day!";
}
}
});
$( "#datepicker, #datepicker2, #datepickerPopup1" ).datepicker();
var input = $("#datepicker3");
var button = $("<button>").insertAfter(input);
var picker = $("<div>").css( {
position: "absolute"
}).datepicker({
select: function(event, ui) {
input.val(ui.date);
picker.datepicker("close");
},
position: {
of: input
}
}).insertAfter(input).hide();
button.click(function() {
picker.datepicker("open");
});
});
</script>
<!--
Reason for separating templates: Refreshing the entire datepicker during interaction confuses screen readers, specfically because
the grid heading is marked up as a live region and will often not update if it's destroyed and recreated instead of just having its
text change. Additionally, interacting with the prev and next links would cause loss of focus issues because the links being interacted
with will disappear while focused. With this approach there are 3 templates: the outer template (#ui-datepicker-tmpl), The grid template
(#ui-datepicker-grid-tmpl) and the title template (#ui-datepicker-title-tmpl). This gets rid of the accessibility problems mentioned, and
also allows developers to modify parts of the datepicker without having to duplicate the entire template.
-->
<script id="ui-datepicker-grid-tmpl" type="text/x-jquery-tmpl">
<table class="ui-datepicker-calendar" role="grid" aria-readonly="true" aria-labelledby="${instance.id}-month-lbl" tabindex="0" aria-activedescendant="${instance.id}-${instance.focusedDay}">
<thead role="presentation">
<tr role="row">
{{each(index, day) date.weekdays()}}
<th class="" role="columnheader" abbr="${day.fullname}" aria-label="${day.fullname}"><span title="${day.fullname}">${day.shortname}</span></th>
{{/each}}
</tr>
</thead>
<tbody role="presentation">
{{each(weekIndex, week) date.days()}}
<tr role="row">
{{each(dayIndex, day) week.days}}
<td {{if day.render}}id="${instance.id}-${day.date}"{{/if}} role="gridcell" aria-selected="{{if day.current}}true{{else}}false{{/if}}" {{if !day.selectable}}aria-disabled="true"{{/if}}>
{{if day.render}}
{{if day.selectable}}
<a class="{{if day.date == instance.focusedDay}}ui-state-focus {{/if}}ui-state-default{{if day.current}} ui-state-active{{/if}}{{if day.today}} ui-state-highlight{{/if}} ${day.extraClasses}" href="#" tabindex="-1" data-timestamp=${day.timestamp}>
${day.date}
{{if day.today}} <span class="ui-helper-hidden-accessible">, ${labels.currentText}</span>{{/if}}
</a>
{{/if}}
{{if !day.selectable}}
<span class="{{if day.current}} ui-state-active{{/if}}{{if day.today}} ui-state-highlight{{/if}} ${day.extraClasses}">
${day.date}
</span>
{{/if}}
{{/if}}
</td>
{{/each}}
</tr>
{{/each}}
</tbody>
</table>
</script>
<script id="ui-datepicker-title-tmpl" type="text/x-jquery-tmpl">
<span class="ui-datepicker-month">${date.monthname()}</span> <span class="ui-datepicker-year">${date.year()}</span>
</script>
<script id="ui-datepicker-tmpl" type="text/x-jquery-tmpl">
<div class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" role="region" aria-labelledby="${instance.id}-title">
<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all">
<a href="#" class="ui-datepicker-prev ui-corner-all" title="${labels.prevText}"><span class="ui-icon ui-icon-circle-triangle-w">${labels.prevText}</span></a>
<a href="#" class="ui-datepicker-next ui-corner-all" title="${labels.nextText}"><span class="ui-icon ui-icon-circle-triangle-e">${labels.nextText}</span></a>
<div role="header" id="${instance.id}-title">
<div id="${instance.id}-month-lbl" class="ui-datepicker-title">
{{tmpl({date : date}) "#ui-datepicker-title-tmpl"}}
</div>
<span class="ui-helper-hidden-accessible">, ${labels.datePickerRole}</span>
</div>
</div>
{{tmpl({date : date, labels : labels, instance : instance}) "#ui-datepicker-grid-tmpl"}}
<div class="ui-datepicker-buttonpane ui-widget-content">
<button class="ui-datepicker-current">${labels.currentText}</button>
<button class="ui-datepicker-close">${labels.closeText}</button>
</div>
</div>
</script>
<script id="ui-datepicker-weeks-tmpl" type="text/x-jquery-tmpl">
<div class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all">
<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all">
<a class="ui-datepicker-prev ui-corner-all" title="${labels.prevText}"><span class="ui-icon ui-icon-circle-triangle-w">${labels.prevText}</span></a>
<a class="ui-datepicker-next ui-corner-all" title="${labels.nextText}"><span class="ui-icon ui-icon-circle-triangle-e">${labels.nextText}</span></a>
<div class="ui-datepicker-title">
<span class="ui-datepicker-month">${date.monthname()}</span> <span class="ui-datepicker-year">${date.year()}</span>
</div>
</div>
<table class="ui-datepicker-calendar">
<thead>
<tr>
<th>${labels.weekHeader}</th>
{{each(index, day) date.weekdays()}}
<th class=""><span title="${day.fullname}">${day.shortname}</span></th>
{{/each}}
</tr>
</thead>
<tbody>
{{each(index, week) date.days()}}
<tr>
<td>${week.number}</td>
{{each(index, day) week.days}}
<td>
{{if day.render}}
{{if day.selectable}}
<a title="${day.title}" class="ui-state-default{{if day.current}} ui-state-active{{/if}}{{if day.today}} ui-state-highlight{{/if}} ${day.extraClasses}" href="#">
${day.date}
</a>
{{/if}}
{{if !day.selectable}}
<span title="${day.title}" class="{{if day.current}} ui-state-active{{/if}}{{if day.today}} ui-state-highlight{{/if}} ${day.extraClasses}">
${day.date}
</span>
{{/if}}
{{/if}}
</td>
{{/each}}
</tr>
{{/each}}
</tbody>
</table>
</div>
</script>
<script id="ui-datepicker-multi-tmpl" type="text/x-jquery-tmpl">
<div class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-datepicker-multi-3 ui-datepicker-multi">
{{each(index, monthObj) date.months(2)}}
<div class="ui-datepicker-group">
<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix {{if monthObj.first}}ui-corner-left{{/if}}{{if monthObj.last}}ui-corner-right{{/if}}">
{{if monthObj.first}}
<a class="ui-datepicker-prev ui-corner-all" title="${labels.prevText}"><span class="ui-icon ui-icon-circle-triangle-w">${labels.prevText}</span></a>
{{/if}}
{{if monthObj.last}}
<a class="ui-datepicker-next ui-corner-all" title="${labels.nextText}"><span class="ui-icon ui-icon-circle-triangle-e">${labels.nextText}</span></a>
{{/if}}
<div class="ui-datepicker-title">
<span class="ui-datepicker-month">${monthObj.monthname()}</span> <span class="ui-datepicker-year">${monthObj.year()}</span>
</div>
</div>
<table class="ui-datepicker-calendar">
<thead>
<tr>
{{each(index, day) monthObj.weekdays()}}
<th class=""><span title="${day.fullname}">${day.shortname}</span></th>
{{/each}}
</tr>
</thead>
<tbody>
{{each(index, week) monthObj.days()}}
<tr>
{{each(index, day) week.days}}
<td>
{{if day.render}}
{{if day.selectable}}
<a title="${day.title}" class="ui-state-default{{if day.current}} ui-state-active{{/if}}{{if day.today}} ui-state-highlight{{/if}} ${day.extraClasses}" href="#">
${day.date}
</a>
{{/if}}
{{if !day.selectable}}
<span title="${day.title}" class="{{if day.current}} ui-state-active{{/if}}{{if day.today}} ui-state-highlight{{/if}} ${day.extraClasses}">
${day.date}
</span>
{{/if}}
{{/if}}
</td>
{{/each}}
</tr>
{{/each}}
</tbody>
</table>
</div>
{{/each}}
<div class="ui-datepicker-row-break"></div>
<div class="ui-datepicker-buttonpane ui-widget-content">
<button class="ui-datepicker-current">${labels.currentText}</button>
<button class="ui-datepicker-close">${labels.closeText}</button>
</div>
</div>
</script>
</body>
</html>