| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 5 |
<title>13899 mvc Stateful Dates</title> |
| 6 |
|
| 7 |
<style> |
| 8 |
@import "../../../../dijit/themes/claro/document.css"; |
| 9 |
@import "../../../../util/doh/robot/robot.css"; |
| 10 |
@import "../../../../dijit/tests/css/dijitTests.css"; |
| 11 |
</style> |
| 12 |
|
| 13 |
|
| 14 |
<link id="themeStyles" rel="stylesheet" href="../../../../dijit/themes/claro/claro.css"/> |
| 15 |
|
| 16 |
|
| 17 |
<script type="text/javascript" src="../../../../dojo/dojo.js" |
| 18 |
data-dojo-config="isDebug: true, parseOnLoad: false"></script> |
| 19 |
|
| 20 |
|
| 21 |
<script type="text/javascript" src="../../../../dijit/tests/_testCommon.js"></script> |
| 22 |
|
| 23 |
<script type="text/javascript"> |
| 24 |
var model; |
| 25 |
|
| 26 |
require([ |
| 27 |
'dijit/form/DateTextBox', |
| 28 |
'dijit/CalendarLite', |
| 29 |
'dojox/mvc/StatefulModel', |
| 30 |
'dijit/form/Button', |
| 31 |
'dojox/mvc/Output', |
| 32 |
'dijit/form/TextBox', |
| 33 |
'dojo/date/stamp', |
| 34 |
'dojox/mvc', |
| 35 |
'dojo/on', |
| 36 |
'dojo/domReady!' |
| 37 |
], function (DateTextBox, Calendar, StatefulModel, Button, Output, TextBox, dateStamp) { |
| 38 |
|
| 39 |
// *** Test1 setup begin: *** |
| 40 |
var test1_init = dateStamp.fromISOString("1987-08-01"); // 8/1/1987 |
| 41 |
test1_model = new StatefulModel({ |
| 42 |
data: { |
| 43 |
date: test1_init |
| 44 |
} |
| 45 |
}); |
| 46 |
var test1_cal = new Calendar({ |
| 47 |
ref: test1_model.date // bind to model.date |
| 48 |
}, document.getElementById('test1_cal')); |
| 49 |
test1_cal.startup(); |
| 50 |
|
| 51 |
var test1_cal2 = new Calendar({ |
| 52 |
ref: test1_model.date // bind to model.date |
| 53 |
}, document.getElementById('test1_cal2')); |
| 54 |
test1_cal2.startup(); |
| 55 |
|
| 56 |
var test1_txt2 = new TextBox({ |
| 57 |
ref: test1_model.date |
| 58 |
}, document.getElementById('test1_txt2')); |
| 59 |
dojo.style(test1_txt2.domNode, "width", "368px"); |
| 60 |
test1_txt2.startup(); |
| 61 |
|
| 62 |
var test1_out2 = new Output({ |
| 63 |
ref: test1_model.date // bind to model.date |
| 64 |
}, document.getElementById('test1_output2')); |
| 65 |
test1_out2.startup(); |
| 66 |
|
| 67 |
var test1_setday2 = new Button({ |
| 68 |
label: 'Set Calendar to dateStamp.fromISOString("1991-09-07") (Sep 7 1991)', |
| 69 |
onClick: function() { |
| 70 |
//console.log("test1_setday2 called"); |
| 71 |
//var day2 = new Date(1991,9,7); // 9/7/1991 |
| 72 |
//var day2 = new Date("1991-09-07"); // 9/7/1991 |
| 73 |
var day2 = dateStamp.fromISOString("1991-09-07"); // 9/7/1991 |
| 74 |
test1_cal2.set("value", day2); |
| 75 |
} |
| 76 |
}, document.getElementById('test1_setdate1')); |
| 77 |
test1_setday2.startup(); |
| 78 |
|
| 79 |
var test1_settext2 = new Button({ |
| 80 |
label: 'Set TextBox to dateStamp.fromISOString("1991-05-05") (May 5, 1991)', |
| 81 |
onClick: function() { |
| 82 |
//test1_txt2.set("value", new Date("1993-05-05")); // ISO date format |
| 83 |
test1_txt2.set("value", dateStamp.fromISOString("1991-05-05")); // 5/5/1993 |
| 84 |
//test1_cal2.set("value", "1991-05-05"); |
| 85 |
//test1_txt2.set("value", "Sun May 05 1991 00:00:00 GMT-0400 (Eastern Daylight Time)"); |
| 86 |
} |
| 87 |
}, document.getElementById('test1_setdate2')); |
| 88 |
test1_settext2.startup(); |
| 89 |
|
| 90 |
var test1_settext3 = new Button({ |
| 91 |
label: 'Set TextBox to ISO String("2011-11-06") (Nov 6, 2011) fails on IE', |
| 92 |
onClick: function() { |
| 93 |
//test1_txt2.set("value", new Date("2011-11-07")); // ISO date format |
| 94 |
test1_txt2.set("value", "2011-11-07"); // 11/6/2011 |
| 95 |
//test1_cal2.set("value", "2011-11-07"); |
| 96 |
//test1_txt2.set("value", "Sun Nov 06 2011 01:00:00 GMT-0500 (Eastern Standard Time)"); |
| 97 |
} |
| 98 |
}, document.getElementById('test1_setdate3')); |
| 99 |
test1_settext3.startup(); |
| 100 |
|
| 101 |
var test1_reset2 = new Button({ |
| 102 |
label: "Reset Calendar back to (Aug 1 1987)", |
| 103 |
onClick: function() { |
| 104 |
test1_model.date.reset(); |
| 105 |
} |
| 106 |
}, document.getElementById('test1_reset2')); |
| 107 |
test1_reset2.startup(); |
| 108 |
// *** Test1 setup end: *** |
| 109 |
|
| 110 |
// *** Test2 setup begin: *** |
| 111 |
var test2_init = dateStamp.fromISOString("2011-11-06"); // Nov 6, 2011 |
| 112 |
test2_model = new StatefulModel({ |
| 113 |
data: { |
| 114 |
date: test2_init |
| 115 |
} |
| 116 |
}); |
| 117 |
var test2_cal = new DateTextBox({ |
| 118 |
ref: test2_model.date // bind to model.date |
| 119 |
}, document.getElementById('test2_cal')); |
| 120 |
test2_cal.startup(); |
| 121 |
|
| 122 |
var test2_cal2 = new DateTextBox({ |
| 123 |
ref: test2_model.date // bind to model.date |
| 124 |
}, document.getElementById('test2_cal2')); |
| 125 |
test2_cal2.startup(); |
| 126 |
|
| 127 |
var test2_txt2 = new TextBox({ |
| 128 |
ref: test2_model.date |
| 129 |
}, document.getElementById('test2_txt2')); |
| 130 |
dojo.style(test2_txt2.domNode, "width", "368px"); |
| 131 |
test2_txt2.startup(); |
| 132 |
|
| 133 |
var test2_out2 = new Output({ |
| 134 |
ref: test2_model.date // bind to model.date |
| 135 |
}, document.getElementById('test2_output2')); |
| 136 |
test2_out2.startup(); |
| 137 |
|
| 138 |
var test2_setday2 = new Button({ |
| 139 |
label: 'Set DateTextBox to new Date(1993,9,28) (Oct 28, 1993)', |
| 140 |
onClick: function() { |
| 141 |
var day2 = new Date(1993,9,28); // 10/28/1993 |
| 142 |
//var day2 = new Date("1993-10-28"); // 10/28/1993 |
| 143 |
//var day2 = dateStamp.fromISOString("1993-09-28"); // 10/28/1997 |
| 144 |
//test2_cal2.set("value", day2); |
| 145 |
test2_txt2.set("value", day2); |
| 146 |
} |
| 147 |
}, document.getElementById('test2_setdate1')); |
| 148 |
test2_setday2.startup(); |
| 149 |
|
| 150 |
var test2_settext2 = new Button({ |
| 151 |
label: 'Set DateTextBox to dateStamp.fromISOString("1997-10-14") (Oct 14 1997)', |
| 152 |
onClick: function() { |
| 153 |
//test2_txt2.set("value", new Date("1997-10-14")); // ISO date format |
| 154 |
test2_txt2.set("value", dateStamp.fromISOString("1997-10-14")); // Oct 14 1997 |
| 155 |
//test2_cal2.set("value", "1997-10-14"); |
| 156 |
//test2_txt2.set("value", "Tue Oct 14 1997 00:00:00 GMT-0400 (Eastern Daylight Time)"); |
| 157 |
} |
| 158 |
}, document.getElementById('test2_setdate2')); |
| 159 |
test2_settext2.startup(); |
| 160 |
|
| 161 |
var test2_reset2 = new Button({ |
| 162 |
label: "Reset DateTextBox back to (Nov 6 2011)", |
| 163 |
onClick: function() { |
| 164 |
test2_model.date.reset(); |
| 165 |
} |
| 166 |
}, document.getElementById('test2_reset2')); |
| 167 |
|
| 168 |
var test2_settext3 = new Button({ |
| 169 |
label: 'Set TextBox to ISO String("1991-05-05") (May 5, 1991)', |
| 170 |
onClick: function() { |
| 171 |
//test2_txt2.set("value", new Date("1991-05-05")); // ISO date format |
| 172 |
test2_txt2.set("value", "1991-05-05"); // 5/5/1993 |
| 173 |
//test2_cal2.set("value", "1991-05-05"); |
| 174 |
//test2_txt2.set("value", "Sun May 05 1991 00:00:00 GMT-0400 (Eastern Daylight Time)"); |
| 175 |
} |
| 176 |
}, document.getElementById('test2_setdate3')); |
| 177 |
test2_settext3.startup(); |
| 178 |
|
| 179 |
test2_reset2.startup(); |
| 180 |
// *** Test2 setup end: *** |
| 181 |
|
| 182 |
|
| 183 |
// *** Test3 setup begin: *** |
| 184 |
// *** Test3 setup begin: *** |
| 185 |
var test3_init = dateStamp.fromISOString("2011-08-27"); // 8/27/2011 |
| 186 |
test3_model = new StatefulModel({ |
| 187 |
data: { |
| 188 |
date: test3_init, |
| 189 |
date2: test3_init |
| 190 |
} |
| 191 |
}); |
| 192 |
var test3_cal = new Calendar({ |
| 193 |
ref: test3_model.date // bind to model.date |
| 194 |
}, document.getElementById('test3_cal')); |
| 195 |
test3_cal.startup(); |
| 196 |
|
| 197 |
var test3_cal2 = new DateTextBox({ |
| 198 |
ref: test3_model.date // bind to model.date |
| 199 |
}, document.getElementById('test3_cal2')); |
| 200 |
test3_cal2.startup(); |
| 201 |
|
| 202 |
var test3_txt2 = new TextBox({ |
| 203 |
ref: test3_model.date, |
| 204 |
disabled: true |
| 205 |
}, document.getElementById('test3_txt2')); |
| 206 |
dojo.style(test3_txt2.domNode, "width", "368px"); |
| 207 |
test3_txt2.startup(); |
| 208 |
|
| 209 |
var test3_out2 = new Output({ |
| 210 |
ref: test3_model.date // bind to model.date |
| 211 |
}, document.getElementById('test3_output2')); |
| 212 |
test3_out2.startup(); |
| 213 |
|
| 214 |
var test3_setday2 = new Button({ |
| 215 |
label: 'Set Calendar to dateStamp.fromISOString("1997-10-14") (Oct 14 1997)', |
| 216 |
onClick: function() { |
| 217 |
//console.log("test3_setday2 called"); |
| 218 |
//var day2 = new Date(1997,10,14); // 10/14/1997 |
| 219 |
//var day2 = new Date("1997-10-14"); // 10/14/1997 |
| 220 |
var day2 = dateStamp.fromISOString("1997-10-14"); // 10/14/1997 |
| 221 |
test3_cal2.set("value", day2); |
| 222 |
} |
| 223 |
}, document.getElementById('test3_setdate1')); |
| 224 |
test3_setday2.startup(); |
| 225 |
|
| 226 |
var test3_settext2 = new Button({ |
| 227 |
label: 'Set TextBox to dateStamp.fromISOString("2011-11-06") (Nov 6, 2011)', |
| 228 |
onClick: function() { |
| 229 |
//test3_txt2.set("value", new Date("2011-11-06")); // ISO date format |
| 230 |
test3_txt2.set("value", dateStamp.fromISOString("2011-11-06")); // 11/6/2011 |
| 231 |
//test3_cal2.set("value", "2011-11-06"); |
| 232 |
//test3_txt2.set("value", "2011-11-06"); // FAILS |
| 233 |
//test3_txt2.set("value", "1991-05-06"); // 5/5/1991 |
| 234 |
//test3_txt2.set("value", "Sun Nov 06 2011 00:00:00 GMT-0400 (Eastern Daylight Time)"); |
| 235 |
} |
| 236 |
}, document.getElementById('test3_setdate2')); |
| 237 |
test3_settext2.startup(); |
| 238 |
|
| 239 |
var test3_settext3 = new Button({ |
| 240 |
label: 'Set TextBox to ISO String("1991-05-06T01:00:00") via new Date (May 5, 1991)', |
| 241 |
onClick: function() { |
| 242 |
//test3_txt2.set("value", new Date("1991-05-05")); // ISO date format |
| 243 |
var d = new Date("1991-05-06T01:00:00"); |
| 244 |
test3_txt2.set("value", d); // 5/5/1991 YYYY-MM-DDThh:mm:ss via new Date |
| 245 |
//test3_txt2.set("value", "1991-05-06T01:00:00"); // 5/5/1991 YYYY-MM-DDThh:mm:ss FAILS |
| 246 |
//test3_cal2.set("value", "1991-05-05"); |
| 247 |
//test3_txt2.set("value", "Sun May 05 1991 00:00:00 GMT-0400 (Eastern Daylight Time)"); |
| 248 |
} |
| 249 |
}, document.getElementById('test3_setdate3')); |
| 250 |
test3_settext3.startup(); |
| 251 |
if(dojo.isIE){ // new Date("1991-05-06") will not work on IE |
| 252 |
test3_settext3.set('disabled',true); |
| 253 |
} |
| 254 |
|
| 255 |
var test3_reset2 = new Button({ |
| 256 |
label: "Reset Calendar back to (Aug 27 2011)", |
| 257 |
onClick: function() { |
| 258 |
//console.log("test3_callreset2 called"); |
| 259 |
test3_model.date.reset(); |
| 260 |
} |
| 261 |
}, document.getElementById('test3_reset2')); |
| 262 |
test3_reset2.startup(); |
| 263 |
// *** Test3 setup end: *** |
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
// *** Test4 setup begin: RegExp Test*** |
| 268 |
// *** Test4 setup begin: RegExp Test*** |
| 269 |
var regx = new RegExp("abc","i"); |
| 270 |
test4_model = new StatefulModel({ |
| 271 |
data: { |
| 272 |
//regex: /abc/i // should be regex: /abc/ |
| 273 |
regex: regx // should be regex: /abc/ |
| 274 |
} |
| 275 |
}); |
| 276 |
|
| 277 |
console.log('test4_model.regex', test4_model.regex.get('value')); |
| 278 |
var str = "ABCDEFGHIJKLMNOP abcdefghi"; |
| 279 |
var patt1 = test4_model.regex.get('value'); |
| 280 |
console.log("str.match(test4_model.regex.get('value')) is ",str.match(test4_model.regex.get('value'))); |
| 281 |
console.log('str.match(patt1)',str.match(patt1)); |
| 282 |
test4_model.regex.set('value',/def/); |
| 283 |
console.log("set to def str.match(test4_model.regex.get('value')) is ",str.match(test4_model.regex.get('value'))); |
| 284 |
test4_model.regex.reset(); |
| 285 |
console.log("after reset str.match(test4_model.regex.get('value')) is ",str.match(test4_model.regex.get('value'))); |
| 286 |
// *** Test4 setup end: *** |
| 287 |
|
| 288 |
}); |
| 289 |
</script> |
| 290 |
</head> |
| 291 |
|
| 292 |
<body class="claro"> |
| 293 |
<h2>Test 1: Two Calendars bound to each other, a TextBox and an mvc Output field.</h2> |
| 294 |
<div style="border-style: solid; border-width: 2px; width: 827px;"> |
| 295 |
<table> |
| 296 |
<tbody> |
| 297 |
<tr> |
| 298 |
<td><div id="test1_cal"></div></td> |
| 299 |
<td><div id="test1_cal2"></div></td> |
| 300 |
<td> |
| 301 |
<table><tbody> |
| 302 |
<tr><td><label for="test1_txt2">TextBox bound to date:</label></td></tr> |
| 303 |
<tr><td><div id="test1_txt2"></div></td></tr> |
| 304 |
<tr><td><label for="test1_txt2">MVC Output bound to date:</label></td></tr> |
| 305 |
<tr><td><div id="test1_output2"></div></td></tr> |
| 306 |
</tbody></table> |
| 307 |
<table><tbody><tr> |
| 308 |
<td><div id="test1_setdate1"></div></td> |
| 309 |
</tr></tbody></table> |
| 310 |
<table><tbody><tr> |
| 311 |
<td><div id="test1_setdate2"></div></td> |
| 312 |
</tr></tbody></table> |
| 313 |
<table><tbody><tr> |
| 314 |
<td><div id="test1_setdate3"></div></td> |
| 315 |
</tr></tbody></table> |
| 316 |
<table><tbody><tr> |
| 317 |
<td><div id="test1_reset2"></div></td> |
| 318 |
</tr></tbody></table> |
| 319 |
</td> |
| 320 |
</tr> |
| 321 |
</tbody> |
| 322 |
</table> |
| 323 |
</div> |
| 324 |
|
| 325 |
<h2>Test 2: Two DateTextBoxes bound to each other, a TextBox and an mvc Output field.</h2> |
| 326 |
<div style="border-style: solid; border-width: 2px; width: 827px;"> |
| 327 |
<table> |
| 328 |
<tbody> |
| 329 |
<tr> |
| 330 |
<td style="vertical-align: top;"><div id="test2_cal"></div></td> |
| 331 |
<td style="vertical-align: top;"><div id="test2_cal2"></div></td> |
| 332 |
<td> |
| 333 |
<table><tbody> |
| 334 |
<tr><td><label for="test2_txt2">TextBox bound to date:</label></td></tr> |
| 335 |
<tr><td><div id="test2_txt2"></div></td></tr> |
| 336 |
<tr><td><label for="test2_txt2">MVC Output bound to date:</label></td></tr> |
| 337 |
<tr><td><div id="test2_output2"></div></td></tr> |
| 338 |
</tbody></table> |
| 339 |
<table><tbody><tr> |
| 340 |
<td><div id="test2_setdate1"></div></td> |
| 341 |
</tr></tbody></table> |
| 342 |
<table><tbody><tr> |
| 343 |
<td><div id="test2_setdate2"></div></td> |
| 344 |
</tr></tbody></table> |
| 345 |
<table><tbody><tr> |
| 346 |
<td><div id="test2_setdate3"></div></td> |
| 347 |
</tr></tbody></table> |
| 348 |
<table><tbody><tr> |
| 349 |
<td><div id="test2_reset2"></div></td> |
| 350 |
</tr></tbody></table> |
| 351 |
</td> |
| 352 |
</tr> |
| 353 |
</tbody> |
| 354 |
</table> |
| 355 |
</div> |
| 356 |
|
| 357 |
|
| 358 |
<h2>Test 3: One Calendar bound to a DateTextbox, a TextBox and an mvc Output field.</h2> |
| 359 |
<div style="border-style: solid; border-width: 2px; width: 827px;"> |
| 360 |
<table> |
| 361 |
<tbody> |
| 362 |
<tr> |
| 363 |
<td style="vertical-align: top;"><div id="test3_cal"></div></td> |
| 364 |
<td style="vertical-align: top;"><div id="test3_cal2"></div></td> |
| 365 |
<td> |
| 366 |
<table><tbody> |
| 367 |
<tr><td><label for="test3_txt2">TextBox bound to date: (disabled to avoid error)</label></td></tr> |
| 368 |
<tr><td><div id="test3_txt2"></div></td></tr> |
| 369 |
<tr><td><label for="test3_txt2">MVC Output bound to date:</label></td></tr> |
| 370 |
<tr><td><div id="test3_output2"></div></td></tr> |
| 371 |
</tbody></table> |
| 372 |
<table><tbody><tr> |
| 373 |
<td><div id="test3_setdate1"></div></td> |
| 374 |
</tr></tbody></table> |
| 375 |
<table><tbody><tr> |
| 376 |
<td><div id="test3_setdate2"></div></td> |
| 377 |
</tr></tbody></table> |
| 378 |
<table><tbody><tr> |
| 379 |
<td><div id="test3_setdate3"></div></td> |
| 380 |
</tr></tbody></table> |
| 381 |
<table><tbody><tr> |
| 382 |
<td><div id="test3_reset2"></div></td> |
| 383 |
</tr></tbody></table> |
| 384 |
</td> |
| 385 |
</tr> |
| 386 |
</tbody> |
| 387 |
</table> |
| 388 |
</div> |
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
</body> |
| 407 |
</html> |