5 <title>Calendar Picker test
</title>
8 background-color: #eeffff;
10 font-family: Helvetica, sans-serif;
14 display: inline-block;
27 <p>This is a testbed for a calendar picker.
</p>
31 <input type=
"text" id=
"date" style=
"margin: 0;"><br>
36 <ol id=
"console" style=
"font-family:monospace;"></ol>
39 <form action=
"" method=
"GET">
41 <legend>Locale
</legend>
43 <label for=
"locale">Locale
</label>
44 <select name=
"locale" id=
"config_locale">
45 <!-- Populated from locale_data. -->
48 <label for=
"locale_rtl">Locale RTL
</label>
49 <input type=
"checkbox" name=
"locale_rtl" id=
"config_locale_rtl" value=
"true">
51 <label for=
"week_start_day">Week start day
</label>
52 <select name=
"week_start_day" id=
"config_week_start_day">
53 <option value=
"0">Sunday
</option>
54 <option value=
"1">Monday
</option>
55 <option value=
"2">Tuesday
</option>
56 <option value=
"3">Wednesday
</option>
57 <option value=
"4">Thursday
</option>
58 <option value=
"5">Friday
</option>
59 <option value=
"6">Saturday
</option>
64 <legend>Attributes
</legend>
66 <label for=
"type">[type]
</label>
67 <select name=
"type" id=
"config_type">
70 <option>month
</option>
73 <label for=
"value">[value]
</label>
74 <input type=
"text" name=
"value" id=
"config_value">
76 <label for=
"min">[min]
</label>
77 <input type=
"text" name=
"min" id=
"config_min">
79 <label for=
"max">[max]
</label>
80 <input type=
"text" name=
"max" id=
"config_max">
82 <label for=
"step">[step]
</label>
83 <input type=
"number" name=
"step" id=
"config_step">
85 <input type=
"submit" value=
"Submit">
89 function getParam(key
) {
90 key
= key
.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
91 var pattern
= "[\\?&]" + key
+ "=([^&#]*)";
92 var regex
= new RegExp(pattern
);
93 var results
= regex
.exec(window
.location
.search
);
96 return decodeURIComponent(results
[1].replace(/\+/g, " "));
99 function setParam(key
, value
) {
101 value
= escape(value
);
103 var kvp
= document
.location
.search
.substr(1).split('&');
105 for (var i
= kvp
.length
- 1; i
>= 0; --i
){
107 var x
= kvp
[i
].split('=');
110 kvp
[i
] = x
.join('=');
116 kvp
[kvp
.length
] = key
+ "=" + value
;
118 document
.location
.search
= kvp
.join('&');
122 return document
.getElementById(id
);
126 function initializeConfig() {
127 for (locale
in locale_data
) {
128 var option
= document
.createElement("option");
129 option
.setAttribute("label", locale_data
[locale
].displayName
);
130 option
.setAttribute("value", locale
);
131 $("config_locale").appendChild(option
);
134 config
.locale
= getParam("locale") || "en_US";
135 config
.isLocaleRTL
= getParam("locale_rtl") === "true";
136 config
.weekStartDay
= parseInt(getParam("weekStartDay") || "0", 10);
137 config
.type
= getParam("type") || "date";
138 config
.value
= getParam("value") || "";
139 config
.min
= getParam("min") || "";
140 config
.max
= getParam("max") || "";
141 config
.step
= getParam("step") || "1";
143 $("config_locale").value
= config
.locale
;
144 $("config_locale_rtl").checked
= config
.isLocaleRTL
;
145 $("config_week_start_day").value
= config
.weekStartDay
;
146 $("config_type").value
= config
.type
;
147 $("config_value").value
= config
.value
;
148 $("config_min").value
= config
.min
;
149 $("config_max").value
= config
.max
;
150 $("config_step").value
= config
.step
;
155 "displayName": "English (United States)",
156 "shortMonthLabels": [
181 "displayName": "Japanese",
182 "shortMonthLabels": [
207 "displayName": "Arabic",
208 "shortMonthLabels": [
233 "displayName": "Vietnamese",
234 "shortMonthLabels": [
260 function createParam() {
263 locale
: config
.locale
,
264 weekStartDay
: config
.weekStartDay
,
265 isLocaleRTL
: config
.isLocaleRTL
,
266 dayLabels
: locale_data
[config
.locale
].dayLabels
,
267 shortMonthLabels
: locale_data
[config
.locale
].shortMonthLabels
,
270 step
: config
.step
* (config
.type
=== "month" ? 1 : 86400000),
272 currentValue
: config
.value
,
273 axShowMonthSelector
: "Show month selection panel",
274 axShowNextMonth
: "Show next month",
275 axShowPreviousMonth
: "Show previous month",
280 function openCalendar() {
281 var frame
= document
.getElementsByTagName('iframe')[0];
282 var doc
= frame
.contentDocument
;
283 doc
.documentElement
.innerHTML
= '<head></head><body><div id=main>Loading...</div></body>';
284 var commonCssLink
= doc
.createElement('link');
285 commonCssLink
.rel
= 'stylesheet';
286 commonCssLink
.href
= '../../Source/web/resources/pickerCommon.css?' + (new Date()).getTime();
287 doc
.head
.appendChild(commonCssLink
);
288 var buttonCssLink
= doc
.createElement('link');
289 buttonCssLink
.rel
= 'stylesheet';
290 buttonCssLink
.href
= '../../Source/web/resources/pickerButton.css?' + (new Date()).getTime();
291 doc
.head
.appendChild(buttonCssLink
);
292 var suggestionPickerCssLink
= doc
.createElement('link');
293 suggestionPickerCssLink
.rel
= 'stylesheet';
294 suggestionPickerCssLink
.href
= '../../Source/web/resources/suggestionPicker.css?' + (new Date()).getTime();
295 doc
.head
.appendChild(suggestionPickerCssLink
);
296 var link
= doc
.createElement('link');
297 link
.rel
= 'stylesheet';
298 link
.href
= '../../Source/web/resources/calendarPicker.css?' + (new Date()).getTime();
299 doc
.head
.appendChild(link
);
300 var commonJsScript
= doc
.createElement('script');
301 commonJsScript
.src
= '../../Source/web/resources/pickerCommon.js?' + (new Date()).getTime();
302 doc
.body
.appendChild(commonJsScript
);
303 var suggestionPickerJsScript
= doc
.createElement('script');
304 suggestionPickerJsScript
.src
= '../../Source/web/resources/suggestionPicker.js?' + (new Date()).getTime();
305 doc
.body
.appendChild(suggestionPickerJsScript
);
306 var script
= doc
.createElement('script');
307 script
.src
= '../../Source/web/resources/calendarPicker.js?' + (new Date()).getTime();
308 doc
.body
.appendChild(script
);
310 var pagePopupController
= {
311 setValueAndClosePopup: function(numValue
, stringValue
) {
312 window
.log('number=' + numValue
+ ', string="' + stringValue
+ '"');
314 window
.document
.getElementById('date').value
= stringValue
;
316 setValue: function(stringValue
) {
317 window
.log('string="' + stringValue
+ '"');
318 window
.document
.getElementById('date').value
= stringValue
;
320 closePopup: function() {
321 window
.log('closePopup');
323 localizeNumberString: function(numString
) {
324 if (typeof numString
== "number")
325 return numString
.toLocaleString();
326 return numString
.toString();
328 histogramEnumeration: function() {},
329 formatMonth: function(year
, zeroBaseMonth
) {
330 var monthLabels
= ['<January>', '<February>', '<March>', '<April>', '<May>', '<June>',
331 '<July>', '<August>', '<September>', '<October>', '<November>', '<December>'];
332 return monthLabels
[zeroBaseMonth
] + " " + year
;
334 formatShortMonth: function(year
, zeroBaseMonth
) {
335 var monthLabels
= ['<Jan>', '<Feb>', '<Mar>', '<Apr>', '<May>', '<Jun>',
336 '<Jul>', '<Aug>', '<Sept>', '<Oct>', '<Nov>', '<Dec>'];
337 return monthLabels
[zeroBaseMonth
] + " " + year
;
339 formatWeek: function(year
, week
, startDate
) {
340 return '' + year
+ '-W' + week
+ ' starting on ' + startDate
;
344 setTimeout(function() {
345 frame
.contentWindow
.postMessage(JSON
.stringify(createParam()), "*");
346 frame
.contentWindow
.pagePopupController
= pagePopupController
;
351 var entry
= document
.createElement('li');
352 entry
.innerText
= str
;
353 document
.getElementById('console').appendChild(entry
);
356 window
.onload = function() {