| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 5 |
<title>MVC DOH Test</title> |
| 6 |
|
| 7 |
<style> |
| 8 |
@import "../../../../dojo/resources/dojo.css"; |
| 9 |
@import "../../../../dijit/tests/css/dijitTests.css"; |
| 10 |
@import "../css/app-format.css"; |
| 11 |
</style> |
| 12 |
|
| 13 |
|
| 14 |
<link id="themeStyles" rel="stylesheet" href="../../../../dijit/themes/claro/claro.css"> |
| 15 |
|
| 16 |
|
| 17 |
<script src="../../../../dojo/dojo.js" type="text/javascript" data-dojo-config="isDebug: 1, async: 1, mvc: {debugBindings: 1, extensionPerWidget: true}"></script> |
| 18 |
<script type="text/javascript" src="./helpers.js"></script> |
| 19 |
<script type="text/javascript" > |
| 20 |
require([ |
| 21 |
"doh/runner", |
| 22 |
"dojo/dom", |
| 23 |
"dojo/number", |
| 24 |
"dojo/parser", |
| 25 |
"dojo/when", |
| 26 |
"dojo/Stateful", |
| 27 |
"dojo/data/ItemFileReadStore", |
| 28 |
"dojo/date/locale", |
| 29 |
"dijit/registry", |
| 30 |
"dijit/form/Button", |
| 31 |
"dijit/form/ComboBox", |
| 32 |
"dijit/form/DateTextBox", |
| 33 |
"dijit/form/FilteringSelect", |
| 34 |
"dijit/form/HorizontalSlider", |
| 35 |
"dijit/form/NumberSpinner", |
| 36 |
"dijit/form/NumberTextBox", |
| 37 |
"dijit/form/TextBox", |
| 38 |
"dijit/form/Select", |
| 39 |
"dijit/form/SimpleTextarea", |
| 40 |
"dijit/form/Textarea", |
| 41 |
"dijit/Calendar", |
| 42 |
"dijit/ColorPalette", |
| 43 |
"dojox/mvc/at", |
| 44 |
"dojox/mvc/atBindingExtension", |
| 45 |
"dojox/mvc/EditModelRefController", |
| 46 |
"dojox/mvc/Output" |
| 47 |
], function(doh, ddom, number, parser, when, Stateful, ItemFileReadStore, locale, registry, Button, |
| 48 |
ComboBox, DateTextBox, FilteringSelect, HorizontalSlider, NumberSpinner, NumberTextBox, |
| 49 |
TextBox, Select, SimpleTextarea, Textarea, Calendar, ColorPalette, |
| 50 |
at, atBindingExtension, EditModelRefController, Output){ |
| 51 |
|
| 52 |
for(var i = 0, l = arguments.length; i < l; ++i){ |
| 53 |
var proto = arguments[i].prototype; |
| 54 |
if((proto || {})._blankGif){ |
| 55 |
atBindingExtension(proto); |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
store = new ItemFileReadStore({ |
| 60 |
data: { |
| 61 |
identifier: "id", |
| 62 |
label: "name", |
| 63 |
items: [ |
| 64 |
{id: "1", name: "one"}, |
| 65 |
{id: "2", name: "two"}, |
| 66 |
{id: "3", name: "three"}, |
| 67 |
{id: "4", name: "four"}, |
| 68 |
{id: "5", name: "five"}, |
| 69 |
{id: "6", name: "six"}, |
| 70 |
{id: "7", name: "seven"}, |
| 71 |
{id: "8", name: "eight"}, |
| 72 |
{id: "9", name: "nine"}, |
| 73 |
{id: "10", name: "ten"}, |
| 74 |
{id: "11", name: "eleven"}, |
| 75 |
{id: "12", name: "twelve"}, |
| 76 |
{id: "13", name: "thirteen"} |
| 77 |
] |
| 78 |
} |
| 79 |
}); |
| 80 |
|
| 81 |
store2 = new ItemFileReadStore({data: { |
| 82 |
identifier: "value", |
| 83 |
label: "label", |
| 84 |
items: [ |
| 85 |
{value: "1", label: "one"}, |
| 86 |
{value: "2", label: "two"}, |
| 87 |
{value: "3", label: "three"}, |
| 88 |
{value: "4", label: "four"}, |
| 89 |
{value: "5", label: "five"}, |
| 90 |
{value: "6", label: "six"}, |
| 91 |
{value: "7", label: "seven"}, |
| 92 |
{value: "8", label: "eigth"}, |
| 93 |
{value: "9", label: "nine"}, |
| 94 |
{value: "10", label: "ten"}, |
| 95 |
{value: "11", label: "eleven"}, |
| 96 |
{value: "12", label: "twelve"}, |
| 97 |
{value: "13", label: "thirteen"}, |
| 98 |
{value: "14", label: "fourteen"} |
| 99 |
] |
| 100 |
}}); |
| 101 |
|
| 102 |
// create models for selects |
| 103 |
selctrl = new EditModelRefController({sourceModel: new Stateful({number: "1"})}); |
| 104 |
decselctrl = new EditModelRefController({sourceModel: new Stateful({number: "1"})}); |
| 105 |
|
| 106 |
// create models for filtering selects |
| 107 |
filctrl = new EditModelRefController({sourceModel: new Stateful({number: "2"})}); |
| 108 |
decfilctrl = new EditModelRefController({sourceModel: new Stateful({number: "2"})}); |
| 109 |
|
| 110 |
// create models for ComboBoxes |
| 111 |
comboctrl = new EditModelRefController({sourceModel: new Stateful({number: "three"})}); |
| 112 |
deccomboctrl = new EditModelRefController({sourceModel: new Stateful({number: "three"})}); |
| 113 |
|
| 114 |
// create a model for DateTextBox |
| 115 |
datectrl = new EditModelRefController({sourceModel: new Stateful({number: new Date(2011, 3, 4)})}); |
| 116 |
decdatectrl = new EditModelRefController({sourceModel: new Stateful({number: new Date(2011, 3, 4)})}); |
| 117 |
|
| 118 |
// create a model for Slider |
| 119 |
sliderctrl = new EditModelRefController({sourceModel: new Stateful({number: "5"})}); |
| 120 |
decsliderctrl = new EditModelRefController({sourceModel: new Stateful({number: "5"})}); |
| 121 |
|
| 122 |
// create a model for NumberSpinner |
| 123 |
numspinctrl = new EditModelRefController({sourceModel: new Stateful({number: 6})}); |
| 124 |
decnumspinctrl = new EditModelRefController({sourceModel: new Stateful({number: 6})}); |
| 125 |
|
| 126 |
// create a model for SimpleTextArea |
| 127 |
simpTActrl = new EditModelRefController({sourceModel: new Stateful({number: "7"})}); |
| 128 |
decsimpTActrl = new EditModelRefController({sourceModel: new Stateful({number: "7"})}); |
| 129 |
|
| 130 |
// create a model for TextArea |
| 131 |
textareactrl = new EditModelRefController({sourceModel: new Stateful({number: "8"})}); |
| 132 |
dectextareactrl = new EditModelRefController({sourceModel: new Stateful({number: "8"})}); |
| 133 |
|
| 134 |
// create a model for dijit.Calendar |
| 135 |
deccalctrl = new EditModelRefController({sourceModel: new Stateful({date: new Date(2011, 3, 4)})}); |
| 136 |
|
| 137 |
// create a model for dijit.ColorPalette |
| 138 |
deccolorctrl = new EditModelRefController({sourceModel: new Stateful({code: "#000000"})}); |
| 139 |
|
| 140 |
nanmodel = new Stateful({num: null}); |
| 141 |
|
| 142 |
dummyDateWid = new DateTextBox({constraints:{datePattern:"MM-dd-yyyy", strict:true}}); |
| 143 |
|
| 144 |
when(parser.parse(), function(){ |
| 145 |
// Handle the programmatic creation of widgets here: |
| 146 |
|
| 147 |
// create the select, textbox, output and button |
| 148 |
var sel = new Select({ |
| 149 |
store: store, |
| 150 |
loadChildrenOnOpen: true, |
| 151 |
value: at(selctrl, "number") |
| 152 |
}, ddom.byId("sel")); |
| 153 |
|
| 154 |
(new TextBox({value: at(selctrl, "number")}, ddom.byId("seltext"))).startup(); |
| 155 |
|
| 156 |
var selOutput = new Output({value: at(selctrl, "number")}, ddom.byId("selOutput")); |
| 157 |
selOutput.startup(); |
| 158 |
|
| 159 |
var reset1 = new Button({ |
| 160 |
onClick: function(){ selctrl.reset(); }, |
| 161 |
id: "selReset", |
| 162 |
label: "Reset" |
| 163 |
}, ddom.byId("reset1")); |
| 164 |
reset1.startup(); |
| 165 |
|
| 166 |
sel.startup(); |
| 167 |
|
| 168 |
// create the filtering select, textbox, output and button |
| 169 |
var filsel = new FilteringSelect({ |
| 170 |
store: store, |
| 171 |
value: at(filctrl, "number") |
| 172 |
}, ddom.byId("filsel")); |
| 173 |
|
| 174 |
var filtext = new TextBox({value: at(filctrl, "number")}, ddom.byId("filtext")); |
| 175 |
|
| 176 |
var filoutput = new Output({value: at(filctrl, "number")}, ddom.byId("filoutput")); |
| 177 |
filoutput.startup(); |
| 178 |
|
| 179 |
var filreset = new Button({ |
| 180 |
onClick: function(){ filctrl.reset(); }, |
| 181 |
id: "filReset", |
| 182 |
label: "Reset" |
| 183 |
}, ddom.byId("filreset")); |
| 184 |
filreset.startup(); |
| 185 |
|
| 186 |
filtext.startup(); |
| 187 |
filsel.startup(); |
| 188 |
|
| 189 |
// create the comboBox, textbox, output and button |
| 190 |
var combo = new ComboBox({ |
| 191 |
store: store, |
| 192 |
value: at(comboctrl, "number") |
| 193 |
}, ddom.byId("combosel")); |
| 194 |
|
| 195 |
var combotext = new TextBox({value: at(comboctrl, "number")}, ddom.byId("combotext")); |
| 196 |
|
| 197 |
var combooutput = new Output({value: at(comboctrl, "number")}, ddom.byId("combooutput")); |
| 198 |
combooutput.startup(); |
| 199 |
|
| 200 |
var comboreset = new Button({ |
| 201 |
onClick: function(){ comboctrl.reset(); }, |
| 202 |
id: "comboReset", |
| 203 |
label: "Reset" |
| 204 |
}, ddom.byId("comboreset")); |
| 205 |
comboreset.startup(); |
| 206 |
|
| 207 |
combotext.startup(); |
| 208 |
combo.startup(); |
| 209 |
|
| 210 |
// create the dijit.form.DateTextBox, textbox, output and button |
| 211 |
var dateWid = new DateTextBox({ |
| 212 |
value: at(datectrl, "number"), |
| 213 |
constraints: dummyDateWid.constraints |
| 214 |
}, ddom.byId("datesel")); |
| 215 |
|
| 216 |
var datetext = new TextBox({ |
| 217 |
value: at(datectrl, "number").transform(dummyDateWid.dateLocaleModule), |
| 218 |
constraints: dummyDateWid.constraints |
| 219 |
}, ddom.byId("datetext")); |
| 220 |
|
| 221 |
var dateoutput = new Output({ |
| 222 |
value: at(datectrl, "number").transform(dummyDateWid.dateLocaleModule), |
| 223 |
constraints: dummyDateWid.constraints |
| 224 |
}, ddom.byId("dateoutput")); |
| 225 |
dateoutput.startup(); |
| 226 |
|
| 227 |
var datereset = new Button({ |
| 228 |
onClick: function(){ datectrl.reset(); }, |
| 229 |
id: "dateReset", |
| 230 |
label: "Reset" |
| 231 |
}, ddom.byId("datereset")); |
| 232 |
datereset.startup(); |
| 233 |
|
| 234 |
datetext.startup(); |
| 235 |
dateWid.startup(); |
| 236 |
|
| 237 |
// create the dijit.form.HorizontalSlider, textbox, output and button |
| 238 |
var sliderWid = new HorizontalSlider({ |
| 239 |
style: {width: "190px"}, |
| 240 |
minimum: 0, |
| 241 |
maximum: 100, |
| 242 |
discreteValues: 21, |
| 243 |
value: at(sliderctrl, "number") // bind to model.number |
| 244 |
}, ddom.byId("slidersel")); |
| 245 |
|
| 246 |
var slidertext = new TextBox({value: at(sliderctrl, "number").transform(number)}, ddom.byId("slidertext")); |
| 247 |
|
| 248 |
var slideroutput = new Output({ value: at(sliderctrl, "number").transform(number)}, ddom.byId("slideroutput")); |
| 249 |
slideroutput.startup(); |
| 250 |
|
| 251 |
var sliderreset = new Button({ |
| 252 |
onClick: function(){ sliderctrl.reset(); }, |
| 253 |
id: "sliderReset", |
| 254 |
label: "Reset" |
| 255 |
}, ddom.byId("sliderreset")); |
| 256 |
sliderreset.startup(); |
| 257 |
|
| 258 |
slidertext.startup(); |
| 259 |
sliderWid.startup(); |
| 260 |
|
| 261 |
// create the dijit.form.NumberSpinner, textbox, output and button |
| 262 |
var numspinWid = new NumberSpinner({value: at(numspinctrl, "number")}, ddom.byId("numspinsel")); |
| 263 |
|
| 264 |
var numspintext = new TextBox({value: at(numspinctrl, "number").transform(number)}, ddom.byId("numspintext")); |
| 265 |
|
| 266 |
var numspinoutput = new Output({value: at(numspinctrl, "number").transform(number)}, ddom.byId("numspinoutput")); |
| 267 |
numspinoutput.startup(); |
| 268 |
|
| 269 |
var numspinreset = new Button({ |
| 270 |
onClick: function(){ numspinctrl.reset(); }, |
| 271 |
id: "numspinReset", |
| 272 |
label: "Reset" |
| 273 |
}, ddom.byId("numspinreset")); |
| 274 |
numspinreset.startup(); |
| 275 |
|
| 276 |
numspintext.startup(); |
| 277 |
numspinWid.startup(); |
| 278 |
|
| 279 |
// create the dijit.form.SimpleTextarea, textbox, output and button |
| 280 |
var simpTAWid = new SimpleTextarea({ |
| 281 |
style: {height: "20px", width: "180px"}, |
| 282 |
value: at(simpTActrl, "number") |
| 283 |
}, ddom.byId("simpTAsel")); |
| 284 |
|
| 285 |
var simpTAtext = new TextBox({value: at(simpTActrl, "number")}, ddom.byId("simpTAtext")); |
| 286 |
|
| 287 |
var simpTAoutput = new Output({value: at(simpTActrl, "number")}, ddom.byId("simpTAoutput")); |
| 288 |
simpTAoutput.startup(); |
| 289 |
|
| 290 |
var simpTAreset = new Button({ |
| 291 |
onClick: function(){ simpTActrl.reset(); }, |
| 292 |
id: "simpTAReset", |
| 293 |
label: "Reset" |
| 294 |
}, ddom.byId("simpTAreset")); |
| 295 |
simpTAreset.startup(); |
| 296 |
|
| 297 |
simpTAtext.startup(); |
| 298 |
simpTAWid.startup(); |
| 299 |
|
| 300 |
// create the dijit.form.Textarea, textbox, output and button |
| 301 |
var textareaWid = new Textarea({value: at(textareactrl, "number")}, ddom.byId("textareasel")); |
| 302 |
|
| 303 |
var textareatext = new TextBox({value: at(textareactrl, "number")}, ddom.byId("textareatext")); |
| 304 |
|
| 305 |
var textareaoutput = new Output({value: at(textareactrl, "number")}, ddom.byId("textareaoutput")); |
| 306 |
textareaoutput.startup(); |
| 307 |
|
| 308 |
var textareareset = new Button({ |
| 309 |
onClick: function(){ textareactrl.reset(); }, |
| 310 |
id: "textareaReset", |
| 311 |
label: "Reset" |
| 312 |
}, ddom.byId("textareareset")); |
| 313 |
textareareset.startup(); |
| 314 |
|
| 315 |
textareatext.startup(); |
| 316 |
textareaWid.startup(); |
| 317 |
|
| 318 |
var numBox = new dijit.form.NumberTextBox({value: at(nanmodel, "num")}, ddom.byId("nannb")); |
| 319 |
|
| 320 |
numBox.startup(); |
| 321 |
|
| 322 |
|
| 323 |
doh.register("Check initial programatic values and bindings for select widget only", [ |
| 324 |
{ |
| 325 |
name: "InitialSelectOnly", |
| 326 |
runTest: function(){ |
| 327 |
var wid, textboxval, outputval; |
| 328 |
wid = registry.byId("sel"); |
| 329 |
textboxval = registry.byId("seltext").value; |
| 330 |
outputval = registry.byId("selOutput").value; |
| 331 |
//console.log("This test was commented out because it will fail if _FromSelectWidget is not updated to setup the store in postCreate instead of startup, see ticket 13372 for details."); |
| 332 |
// Test Select |
| 333 |
doh.is("1",wid.get("value"),"This test will fail if _FromSelectWidget is not updated to setup the store in postCreate instead of startup, see ticket 13372 for details."); |
| 334 |
doh.is(textboxval,wid.get("value"),"wid.get(\"value\") should be set same as textboxval"); |
| 335 |
doh.is(outputval,wid.get("value"),"wid.get(\"value\") should be set same as outputval"); |
| 336 |
} |
| 337 |
} |
| 338 |
]); |
| 339 |
|
| 340 |
|
| 341 |
doh.register("Check initial values and bindings widgets other than select", [ |
| 342 |
{ |
| 343 |
name: "InitialOtherThanSelect", |
| 344 |
runTest: function(){ |
| 345 |
// Test FilteringSelect |
| 346 |
var wid, textboxval, outputval; |
| 347 |
wid = registry.byId("filsel"); |
| 348 |
textboxval = registry.byId("filtext").value; |
| 349 |
outputval = registry.byId("filoutput").value; |
| 350 |
doh.is("2", wid.get("value"), "wid.get(\"value\") should be set"); |
| 351 |
doh.is("two", wid.displayedValue, "wid.displayedValue should be set"); |
| 352 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 353 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 354 |
// Test dijit.form.ComboBox |
| 355 |
wid = registry.byId("combosel"); |
| 356 |
textboxval = registry.byId("combotext").value; |
| 357 |
outputval = registry.byId("combooutput").value; |
| 358 |
doh.is("three", wid.get("value"), "wid.get(\"value\") should be set"); |
| 359 |
doh.is("three", wid.displayedValue, "wid.displayedValue should be set"); |
| 360 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 361 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 362 |
// Test dijit.form.DateTextBox |
| 363 |
wid = registry.byId("datesel"); |
| 364 |
textboxval = registry.byId("datetext").value; |
| 365 |
outputval = registry.byId("dateoutput").value; |
| 366 |
doh.is((new Date(2011, 3, 4)).getTime(), wid.get("value").getTime(), "wid.get(\"value\") should be set it is:" + wid.get("value")); |
| 367 |
doh.is("04-04-2011", wid.displayedValue, "wid.displayedValue should be set it is:" + wid.displayedValue); |
| 368 |
doh.is("04-04-2011", textboxval, "textboxval should be set it is:" + textboxval); |
| 369 |
doh.is("04-04-2011", outputval, "outputval should be set it is:" + outputval); |
| 370 |
// Test dijit.form.HorizontalSlider |
| 371 |
wid = registry.byId("slidersel"); |
| 372 |
textboxval = registry.byId("slidertext").value; |
| 373 |
outputval = registry.byId("slideroutput").value; |
| 374 |
doh.is("5", wid.get("value"), "wid.get(\"value\") should be set"); |
| 375 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 376 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 377 |
// Test dijit.form.NumberSpinner |
| 378 |
wid = registry.byId("numspinsel"); |
| 379 |
textboxval = registry.byId("numspintext").value; |
| 380 |
outputval = registry.byId("numspinoutput").value; |
| 381 |
doh.is("6", wid.displayedValue, "wid.displayedValue should be set"); |
| 382 |
doh.is(textboxval, wid.displayedValue, "wid.displayedValue should be set same as textboxval"); |
| 383 |
doh.is(outputval, wid.displayedValue, "wid.displayedValue should be set same as outputval"); |
| 384 |
// Test dijit.form.SimpleTextarea |
| 385 |
wid = registry.byId("simpTAsel"); |
| 386 |
textboxval = registry.byId("simpTAtext").value; |
| 387 |
outputval = registry.byId("simpTAoutput").value; |
| 388 |
doh.is("7", wid.get("value"), "wid.get(\"value\") should be set"); |
| 389 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 390 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 391 |
// Test dijit.form.Textarea |
| 392 |
wid = registry.byId("textareasel"); |
| 393 |
textboxval = registry.byId("textareatext").value; |
| 394 |
outputval = registry.byId("textareaoutput").value; |
| 395 |
doh.is("8", wid.get("value"), "wid.get(\"value\") should be set"); |
| 396 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 397 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 398 |
} |
| 399 |
}, { |
| 400 |
name: "Initial-declarative", |
| 401 |
runTest: function(){ |
| 402 |
var wid, textboxval, outputval; |
| 403 |
// Test Select |
| 404 |
wid = registry.byId("decsel"); |
| 405 |
textboxval = registry.byId("decseltext").value; |
| 406 |
outputval = registry.byId("decselOutput").value; |
| 407 |
doh.is("1", wid.get("value"), "wid.get(\"value\") should be set"); |
| 408 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 409 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 410 |
// Test FilteringSelect |
| 411 |
wid = registry.byId("decfilsel"); |
| 412 |
textboxval = registry.byId("decfiltext").value; |
| 413 |
outputval = registry.byId("decfilOutput").value; |
| 414 |
doh.is("2", wid.get("value"), "wid.get(\"value\") should be set"); |
| 415 |
doh.is("two", wid.displayedValue, "wid.displayedValue should be set"); |
| 416 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 417 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 418 |
// Test dijit.form.ComboBox |
| 419 |
wid = registry.byId("deccombosel"); |
| 420 |
textboxval = registry.byId("deccombotext").value; |
| 421 |
outputval = registry.byId("deccomboOutput").value; |
| 422 |
doh.is("three",wid.get("value"),"wid.get(\"value\") should be set"); |
| 423 |
doh.is("three",wid.displayedValue,"wid.displayedValue should be set"); |
| 424 |
doh.is(textboxval,wid.get("value"),"wid.get(\"value\") should be set same as textboxval"); |
| 425 |
doh.is(outputval,wid.get("value"),"wid.get(\"value\") should be set same as outputval"); |
| 426 |
// Test dijit.form.DateTextBox |
| 427 |
wid = registry.byId("decdatesel"); |
| 428 |
textboxval = registry.byId("decdatetext").value; |
| 429 |
outputval = registry.byId("decdateOutput").value; |
| 430 |
doh.is((new Date(2011, 3, 4)).getTime(), wid.get("value").getTime(), "wid.get(\"value\") should be set it is:" + wid.get("value")); |
| 431 |
doh.is("04-04-2011", wid.displayedValue, "wid.displayedValue should be set it is:" + wid.displayedValue); |
| 432 |
doh.is("04-04-2011", textboxval, "textboxval should be set it is:" + textboxval); |
| 433 |
doh.is("04-04-2011", outputval, "outputval should be set it is:" + outputval); |
| 434 |
// Test dijit.form.HorizontalSlider |
| 435 |
wid = registry.byId("decslidersel"); |
| 436 |
textboxval = registry.byId("decslidertext").value; |
| 437 |
outputval = registry.byId("decsliderOutput").value; |
| 438 |
doh.is("5", wid.get("value"), "wid.get(\"value\") should be set"); |
| 439 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 440 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 441 |
// Test dijit.form.NumberSpinner |
| 442 |
wid = registry.byId("decnumspinsel"); |
| 443 |
textboxval = registry.byId("decnumspintext").value; |
| 444 |
outputval = registry.byId("decnumspinOutput").value; |
| 445 |
doh.is("6", wid.displayedValue, "wid.displayedValue should be set"); |
| 446 |
doh.is(textboxval, wid.displayedValue, "wid.displayedValue should be set same as textboxval"); |
| 447 |
doh.is(outputval, wid.displayedValue, "wid.displayedValue should be set same as outputval"); |
| 448 |
// Test dijit.form.SimpleTextarea |
| 449 |
wid = registry.byId("decsimpTAsel"); |
| 450 |
textboxval = registry.byId("decsimpTAtext").value; |
| 451 |
outputval = registry.byId("decsimpTAOutput").value; |
| 452 |
doh.is("7", wid.get("value"), "wid.get(\"value\") should be set"); |
| 453 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 454 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 455 |
// Test dijit.form.Textarea |
| 456 |
wid = registry.byId("dectextareasel"); |
| 457 |
textboxval = registry.byId("dectextareatext").value; |
| 458 |
outputval = registry.byId("dectextareaOutput").value; |
| 459 |
doh.is("8", wid.get("value"), "wid.get(\"value\") should be set"); |
| 460 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 461 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 462 |
} |
| 463 |
} |
| 464 |
]); |
| 465 |
|
| 466 |
doh.register("Check initial/updated calendar and colorpalette values", [ |
| 467 |
{ |
| 468 |
name: "Initial-calendar-and-color", |
| 469 |
runTest: function(){ |
| 470 |
var wid, textboxval, outputval; |
| 471 |
// Test Calendar |
| 472 |
wid = registry.byId("deccal"); |
| 473 |
textboxval = registry.byId("deccaltext").value; |
| 474 |
outputval = registry.byId("deccalOutput").value; |
| 475 |
doh.is((new Date(2011, 3, 4)).getTime(), wid.get("value").getTime(), "wid.get(\"value\") should be set it is:" + wid.get("value")); |
| 476 |
doh.is("04-04-2011", textboxval, "1-textboxval should be set"); |
| 477 |
doh.is("04-04-2011", outputval, "1-textboxval should be set"); |
| 478 |
// Test dijit.ColorPalette |
| 479 |
wid = registry.byId("deccolor"); |
| 480 |
textboxval = registry.byId("deccolortext").value; |
| 481 |
outputval = registry.byId("deccolorOutput").value; |
| 482 |
doh.is("#000000", wid.get("value"), "wid.get(\"value\") should be set"); |
| 483 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 484 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 485 |
} |
| 486 |
}, { |
| 487 |
name: "Updated-test-calendar-and-color", |
| 488 |
runTest: function(){ |
| 489 |
var wid, textboxval, outputval; |
| 490 |
// Test Update calendar |
| 491 |
var d = new Date(2011, 10, 10); |
| 492 |
wid = registry.byId("deccal"); |
| 493 |
wid.set("value", d); |
| 494 |
textboxval = registry.byId("deccaltext").value; |
| 495 |
outputval = registry.byId("deccalOutput").value; |
| 496 |
doh.is(d.getTime(), wid.get("value").getTime(), "2-wid.get(\"value\") should be set " + wid.get("value")); |
| 497 |
doh.is("11-10-2011", textboxval, "2-textboxval should be set" + textboxval); |
| 498 |
doh.is("11-10-2011", outputval, "2-textboxval should be set" + outputval); |
| 499 |
// Test dijit.ColorPalette |
| 500 |
// update the text field |
| 501 |
registry.byId("deccolortext").set("value", "#ffffff"); |
| 502 |
wid = registry.byId("deccolor"); |
| 503 |
textboxval = registry.byId("deccolortext").value; |
| 504 |
outputval = registry.byId("deccolorOutput").value; |
| 505 |
doh.is("#ffffff", wid.get("value"), "wid.get(\"value\") should be set"); |
| 506 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 507 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 508 |
|
| 509 |
// Test Reset Calendar |
| 510 |
button = registry.byId("deccalReset"); // reset the model |
| 511 |
button.onClick(); |
| 512 |
wid = registry.byId("deccal"); |
| 513 |
textboxval = registry.byId("deccaltext").value; |
| 514 |
outputval = registry.byId("deccalOutput").value; |
| 515 |
doh.is((new Date(2011, 3, 4)).getTime(), wid.get("value").getTime(), "3-wid.get(\"value\") should be set " + wid.get("value")); |
| 516 |
doh.is("04-04-2011", textboxval, "3-textboxval should be set" + textboxval); |
| 517 |
doh.is("04-04-2011", outputval, "3-textboxval should be set" + outputval); |
| 518 |
// Test reset the dijit.ColorPalette |
| 519 |
button = registry.byId("deccolorReset"); // reset the model |
| 520 |
button.onClick(); |
| 521 |
wid = registry.byId("deccolor"); |
| 522 |
textboxval = registry.byId("deccolortext").value; |
| 523 |
outputval = registry.byId("deccolorOutput").value; |
| 524 |
doh.is("#000000", wid.get("value"), "wid.get(\"value\") should be set"); |
| 525 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 526 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 527 |
} |
| 528 |
} |
| 529 |
]); |
| 530 |
|
| 531 |
// Update and Test all fields |
| 532 |
doh.register("Test update for all values and bindings", [ |
| 533 |
{ |
| 534 |
name: "Update-programatic", |
| 535 |
runTest: function(){ |
| 536 |
// update the text field |
| 537 |
registry.byId("seltext").set("value", "10"); |
| 538 |
var wid, textboxval, outputval; |
| 539 |
// Test Select |
| 540 |
wid = registry.byId("sel"); |
| 541 |
textboxval = registry.byId("seltext").value; |
| 542 |
outputval = registry.byId("selOutput").value; |
| 543 |
doh.is("10", wid.get("value"), "wid.get(\"value\") should be set"); |
| 544 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 545 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 546 |
// Test FilteringSelect |
| 547 |
// update the text field |
| 548 |
registry.byId("filtext").set("value", "10"); |
| 549 |
wid = registry.byId("filsel"); |
| 550 |
textboxval = registry.byId("filtext").value; |
| 551 |
outputval = registry.byId("filoutput").value; |
| 552 |
doh.is("10", wid.get("value"), "wid.get(\"value\") should be set"); |
| 553 |
doh.is("ten", wid.displayedValue, "wid.displayedValue should be set"); |
| 554 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 555 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 556 |
// Test dijit.form.ComboBox |
| 557 |
registry.byId("combotext").set("value", "ten"); |
| 558 |
wid = registry.byId("combosel"); |
| 559 |
textboxval = registry.byId("combotext").value; |
| 560 |
outputval = registry.byId("combooutput").value; |
| 561 |
doh.is("ten", wid.get("value"), "wid.get(\"value\") should be set"); |
| 562 |
doh.is("ten", wid.displayedValue, "wid.displayedValue should be set"); |
| 563 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 564 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 565 |
// Test dijit.form.DateTextBox |
| 566 |
// update the text field |
| 567 |
registry.byId("datetext").set("value", "10-10-2011"); |
| 568 |
wid = registry.byId("datesel"); |
| 569 |
textboxval = registry.byId("datetext").value; |
| 570 |
outputval = registry.byId("dateoutput").value; |
| 571 |
doh.is((new Date(2011, 9, 10)).getTime(), wid.get("value").getTime(), "wid.get(value) should be set " + wid.get("value")); |
| 572 |
doh.is("10-10-2011", textboxval, "2-textboxval should be set" + textboxval); |
| 573 |
doh.is("10-10-2011", outputval, "2-textboxval should be set" + outputval); |
| 574 |
// Test dijit.form.HorizontalSlider |
| 575 |
// update the text field |
| 576 |
registry.byId("slidertext").set("value", "10"); |
| 577 |
wid = registry.byId("slidersel"); |
| 578 |
textboxval = registry.byId("slidertext").value; |
| 579 |
outputval = registry.byId("slideroutput").value; |
| 580 |
doh.is("10", wid.get("value"), "wid.get(value) should be set"); |
| 581 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 582 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 583 |
// Test dijit.form.NumberSpinner |
| 584 |
registry.byId("numspintext").set("value", "10"); |
| 585 |
wid = registry.byId("numspinsel"); |
| 586 |
textboxval = registry.byId("numspintext").value; |
| 587 |
outputval = registry.byId("numspinoutput").value; |
| 588 |
doh.is("10", wid.displayedValue, "wid.displayedValue should be set"); |
| 589 |
doh.is(textboxval, wid.displayedValue, "wid.displayedValue should be set same as textboxval"); |
| 590 |
doh.is(outputval, wid.displayedValue, "wid.displayedValue should be set same as outputval"); |
| 591 |
// Test dijit.form.SimpleTextarea |
| 592 |
registry.byId("simpTAtext").set("value", "10"); |
| 593 |
wid = registry.byId("simpTAsel"); |
| 594 |
textboxval = registry.byId("simpTAtext").value; |
| 595 |
outputval = registry.byId("simpTAoutput").value; |
| 596 |
doh.is("10", wid.get("value"), "wid.get(\"value\") should be set"); |
| 597 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 598 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 599 |
// Test dijit.form.Textarea |
| 600 |
registry.byId("textareatext").set("value", "10"); |
| 601 |
wid = registry.byId("textareasel"); |
| 602 |
textboxval = registry.byId("textareatext").value; |
| 603 |
outputval = registry.byId("textareaoutput").value; |
| 604 |
doh.is("10", wid.get("value"), "wid.get(\"value\") should be set"); |
| 605 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 606 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 607 |
} |
| 608 |
}, { |
| 609 |
name: "Update-declarative", |
| 610 |
runTest: function(){ |
| 611 |
registry.byId("decsel").set("value", "4"); |
| 612 |
var wid, textboxval, outputval; |
| 613 |
// Test Select |
| 614 |
wid = registry.byId("decsel"); |
| 615 |
textboxval = registry.byId("decseltext").value; |
| 616 |
outputval = registry.byId("decselOutput").value; |
| 617 |
doh.is("4", wid.get("value"), "wid.get(\"value\") should be set"); |
| 618 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 619 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 620 |
// Test FilteringSelect |
| 621 |
wid = registry.byId("decfilsel"); |
| 622 |
wid.set("value", "4"); |
| 623 |
textboxval = registry.byId("decfiltext").value; |
| 624 |
outputval = registry.byId("decfilOutput").value; |
| 625 |
doh.is("4", wid.get("value"), "wid.get(\"value\") should be set"); |
| 626 |
doh.is("four", wid.displayedValue, "wid.displayedValue should be set"); |
| 627 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 628 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 629 |
// Test dijit.form.ComboBox |
| 630 |
wid = registry.byId("deccombosel"); |
| 631 |
wid.set("value", "four"); |
| 632 |
textboxval = registry.byId("deccombotext").value; |
| 633 |
outputval = registry.byId("deccomboOutput").value; |
| 634 |
doh.is("four", wid.get("value"), "wid.get(\"value\") should be set"); |
| 635 |
doh.is("four", wid.displayedValue, "wid.displayedValue should be set"); |
| 636 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 637 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 638 |
// Test dijit.form.DateTextBox |
| 639 |
wid = registry.byId("decdatesel"); |
| 640 |
wid.set("value", new Date(2011, 8, 9)); |
| 641 |
textboxval = registry.byId("decdatetext").value; |
| 642 |
outputval = registry.byId("decdateOutput").value; |
| 643 |
doh.is((new Date(2011, 8, 9)).getTime(), wid.get("value").getTime(), "wid.get(\"value\") should be set " + wid.get("value")); |
| 644 |
doh.is("09-09-2011", textboxval, "textboxval should be set" + textboxval); |
| 645 |
doh.is("09-09-2011", outputval, "textboxval should be set" + outputval); |
| 646 |
// Test dijit.form.HorizontalSlider |
| 647 |
wid = registry.byId("decslidersel"); |
| 648 |
wid.set("value", "4"); |
| 649 |
textboxval = registry.byId("decslidertext").value; |
| 650 |
outputval = registry.byId("decsliderOutput").value; |
| 651 |
doh.is("4", wid.get("value"), "wid.get(\"value\") should be set"); |
| 652 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 653 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 654 |
// Test dijit.form.NumberSpinner |
| 655 |
wid = registry.byId("decnumspinsel"); |
| 656 |
wid.set("displayedValue", "4"); |
| 657 |
textboxval = registry.byId("decnumspintext").value; |
| 658 |
outputval = registry.byId("decnumspinOutput").value; |
| 659 |
doh.is("4", wid.displayedValue, "wid.displayedValue should be set"); |
| 660 |
doh.is(textboxval, wid.displayedValue, "wid.displayedValue should be set same as textboxval"); |
| 661 |
doh.is(outputval, wid.displayedValue, "wid.displayedValue should be set same as outputval"); |
| 662 |
// Test dijit.form.SimpleTextarea |
| 663 |
wid = registry.byId("decsimpTAsel"); |
| 664 |
wid.set("value", "4"); |
| 665 |
textboxval = registry.byId("decsimpTAtext").value; |
| 666 |
outputval = registry.byId("decsimpTAOutput").value; |
| 667 |
doh.is("4", wid.get("value"), "wid.get(\"value\") should be set"); |
| 668 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 669 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 670 |
// Test dijit.form.Textarea |
| 671 |
wid = registry.byId("dectextareasel"); |
| 672 |
wid.set("value","4"); // update widget value |
| 673 |
textboxval = registry.byId("dectextareatext").value; |
| 674 |
outputval = registry.byId("dectextareaOutput").value; |
| 675 |
doh.is("4", wid.get("value"), "wid.get(\"value\") should be set"); |
| 676 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 677 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 678 |
} |
| 679 |
} |
| 680 |
]); |
| 681 |
|
| 682 |
// Test RESET for all fields |
| 683 |
doh.register("Test reset for all values and bindings", [ |
| 684 |
{ |
| 685 |
name: "Reset-programatic", |
| 686 |
runTest: function(){ |
| 687 |
// reset the model |
| 688 |
var button = registry.byId("selReset"); |
| 689 |
button.onClick(); |
| 690 |
var wid, textboxval, outputval; |
| 691 |
// Test Select |
| 692 |
wid = registry.byId("sel"); |
| 693 |
textboxval = registry.byId("seltext").value; |
| 694 |
outputval = registry.byId("selOutput").value; |
| 695 |
doh.is("1", wid.get("value"), "wid.get(\"value\") should be set"); |
| 696 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 697 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 698 |
// Test FilteringSelect |
| 699 |
button = registry.byId("filReset"); |
| 700 |
button.onClick(); |
| 701 |
wid = registry.byId("filsel"); |
| 702 |
textboxval = registry.byId("filtext").value; |
| 703 |
outputval = registry.byId("filoutput").value; |
| 704 |
doh.is("2", wid.get("value"), "wid.get(\"value\") should be set"); |
| 705 |
doh.is("two", wid.displayedValue, "wid.displayedValue should be set"); |
| 706 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 707 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 708 |
// Test dijit.form.ComboBox |
| 709 |
button = registry.byId("comboReset"); |
| 710 |
button.onClick(); |
| 711 |
wid = registry.byId("combosel"); |
| 712 |
textboxval = registry.byId("combotext").value; |
| 713 |
outputval = registry.byId("combooutput").value; |
| 714 |
doh.is("three", wid.get("value"), "wid.get(\"value\") should be set"); |
| 715 |
doh.is("three", wid.displayedValue, "wid.displayedValue should be set"); |
| 716 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 717 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 718 |
// Test dijit.form.DateTextBox |
| 719 |
button = registry.byId("dateReset"); |
| 720 |
button.onClick(); |
| 721 |
wid = registry.byId("datesel"); |
| 722 |
textboxval = registry.byId("datetext").value; |
| 723 |
outputval = registry.byId("dateoutput").value; |
| 724 |
doh.is((new Date(2011, 3, 4)).getTime(), wid.get("value").getTime(), "wid.get(\"value\") should be set " + wid.get("value")); |
| 725 |
doh.is("04-04-2011", textboxval, "textboxval should be set" + textboxval); |
| 726 |
doh.is("04-04-2011", outputval, "textboxval should be set" + outputval); |
| 727 |
// test a second reset... |
| 728 |
button.onClick(); |
| 729 |
doh.is((new Date(2011, 3, 4)).getTime(), wid.get("value").getTime(), "wid.get(\"value\") should be set " + wid.get("value")); |
| 730 |
doh.is("04-04-2011", textboxval, "textboxval should be set" + textboxval); |
| 731 |
doh.is("04-04-2011", outputval, "textboxval should be set" + outputval); |
| 732 |
// Test dijit.form.HorizontalSlider |
| 733 |
button = registry.byId("sliderReset"); |
| 734 |
button.onClick(); |
| 735 |
wid = registry.byId("slidersel"); |
| 736 |
textboxval = registry.byId("slidertext").value; |
| 737 |
outputval = registry.byId("slideroutput").value; |
| 738 |
doh.is("5", wid.get("value"), "wid.get(\"value\") should be set"); |
| 739 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 740 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 741 |
// Test dijit.form.NumberSpinner |
| 742 |
button = registry.byId("numspinReset"); |
| 743 |
button.onClick(); |
| 744 |
wid = registry.byId("numspinsel"); |
| 745 |
textboxval = registry.byId("numspintext").value; |
| 746 |
outputval = registry.byId("numspinoutput").value; |
| 747 |
doh.is("6", wid.displayedValue, "wid.displayedValue should be set"); |
| 748 |
doh.is(textboxval, wid.displayedValue, "wid.displayedValue should be set same as textboxval"); |
| 749 |
doh.is(outputval, wid.displayedValue, "wid.displayedValue should be set same as outputval"); |
| 750 |
// Test dijit.form.SimpleTextarea |
| 751 |
button = registry.byId("simpTAReset"); |
| 752 |
button.onClick(); |
| 753 |
wid = registry.byId("simpTAsel"); |
| 754 |
textboxval = registry.byId("simpTAtext").value; |
| 755 |
outputval = registry.byId("simpTAoutput").value; |
| 756 |
doh.is("7", wid.get("value"), "wid.get(\"value\") should be set"); |
| 757 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 758 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 759 |
// Test dijit.form.Textarea |
| 760 |
button = registry.byId("textareaReset"); |
| 761 |
button.onClick(); |
| 762 |
wid = registry.byId("textareasel"); |
| 763 |
textboxval = registry.byId("textareatext").value; |
| 764 |
outputval = registry.byId("textareaoutput").value; |
| 765 |
doh.is("8", wid.get("value"), "wid.get(\"value\") should be set"); |
| 766 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 767 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 768 |
} |
| 769 |
}, { |
| 770 |
name: "Reset-declarative", |
| 771 |
runTest: function(){ |
| 772 |
var button = registry.byId("decselReset"); // reset the model |
| 773 |
button.onClick(); |
| 774 |
var wid, textboxval, outputval; |
| 775 |
// Test Select |
| 776 |
wid = registry.byId("decsel"); |
| 777 |
textboxval = registry.byId("decseltext").value; |
| 778 |
outputval = registry.byId("decselOutput").value; |
| 779 |
doh.is("1", wid.get("value"), "wid.get(\"value\") should be set"); |
| 780 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 781 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 782 |
// Test FilteringSelect |
| 783 |
button = registry.byId("decfilReset"); // reset the model |
| 784 |
button.onClick(); |
| 785 |
wid = registry.byId("decfilsel"); |
| 786 |
textboxval = registry.byId("decfiltext").value; |
| 787 |
outputval = registry.byId("decfilOutput").value; |
| 788 |
doh.is("2", wid.get("value"), "wid.get(\"value\") should be set"); |
| 789 |
doh.is("two", wid.displayedValue, "wid.displayedValue should be set"); |
| 790 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 791 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 792 |
// Test dijit.form.ComboBox |
| 793 |
button = registry.byId("deccomboReset"); // reset the model |
| 794 |
button.onClick(); |
| 795 |
wid = registry.byId("deccombosel"); |
| 796 |
textboxval = registry.byId("deccombotext").value; |
| 797 |
outputval = registry.byId("deccomboOutput").value; |
| 798 |
doh.is("three", wid.get("value"), "wid.get(\"value\") should be set"); |
| 799 |
doh.is("three", wid.displayedValue, "wid.displayedValue should be set"); |
| 800 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 801 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 802 |
// Test dijit.form.DateTextBox |
| 803 |
button = registry.byId("decdateReset"); // reset the model |
| 804 |
button.onClick(); |
| 805 |
wid = registry.byId("decdatesel"); |
| 806 |
textboxval = registry.byId("decdatetext").value; |
| 807 |
outputval = registry.byId("decdateOutput").value; |
| 808 |
doh.is((new Date(2011, 3, 4)).getTime(), wid.get("value").getTime(), "wid.get(\"value\") should be set " + wid.get("value")); |
| 809 |
doh.is("04-04-2011", textboxval, "textboxval should be set" + textboxval); |
| 810 |
doh.is("04-04-2011", outputval, "textboxval should be set" + outputval); |
| 811 |
// Test dijit.form.HorizontalSlider |
| 812 |
button = registry.byId("decsliderReset"); // reset the model |
| 813 |
button.onClick(); |
| 814 |
wid = registry.byId("decslidersel"); |
| 815 |
textboxval = registry.byId("decslidertext").value; |
| 816 |
outputval = registry.byId("decsliderOutput").value; |
| 817 |
doh.is("5", wid.get("value"), "wid.get(\"value\") should be set"); |
| 818 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 819 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 820 |
// Test dijit.form.NumberSpinner |
| 821 |
button = registry.byId("decnumspinReset"); // reset the model |
| 822 |
button.onClick(); |
| 823 |
wid = registry.byId("decnumspinsel"); |
| 824 |
textboxval = registry.byId("decnumspintext").value; |
| 825 |
outputval = registry.byId("decnumspinOutput").value; |
| 826 |
doh.is("6", wid.displayedValue, "wid.displayedValue should be set"); |
| 827 |
doh.is(textboxval, wid.displayedValue, "wid.displayedValue should be set same as textboxval"); |
| 828 |
doh.is(outputval, wid.displayedValue, "wid.displayedValue should be set same as outputval"); |
| 829 |
// Test dijit.form.SimpleTextarea |
| 830 |
button = registry.byId("decsimpTAReset"); // reset the model |
| 831 |
button.onClick(); |
| 832 |
wid = registry.byId("decsimpTAsel"); |
| 833 |
textboxval = registry.byId("decsimpTAtext").value; |
| 834 |
outputval = registry.byId("decsimpTAOutput").value; |
| 835 |
doh.is("7", wid.get("value"), "wid.get(\"value\") should be set"); |
| 836 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 837 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 838 |
// Test dijit.form.Textarea |
| 839 |
button = registry.byId("dectextareaReset"); // reset the model |
| 840 |
button.onClick(); |
| 841 |
wid = registry.byId("dectextareasel"); |
| 842 |
textboxval = registry.byId("dectextareatext").value; |
| 843 |
outputval = registry.byId("dectextareaOutput").value; |
| 844 |
doh.is("8", wid.get("value"), "wid.get(\"value\") should be set"); |
| 845 |
doh.is(textboxval, wid.get("value"), "wid.get(\"value\") should be set same as textboxval"); |
| 846 |
doh.is(outputval, wid.get("value"), "wid.get(\"value\") should be set same as outputval"); |
| 847 |
} |
| 848 |
} |
| 849 |
]); |
| 850 |
|
| 851 |
// Test reset all declarative |
| 852 |
doh.register("Test NaN values and bindings", [ |
| 853 |
{ |
| 854 |
name: "NaN-test", |
| 855 |
runTest: function(){ |
| 856 |
var button = registry.byId("decselReset"); // reset the model |
| 857 |
button.onClick(); |
| 858 |
var wid, wid2; |
| 859 |
|
| 860 |
// test for NaN stuff here, uses nanmodel, without fix for ticket 14190 FF crashes |
| 861 |
wid = registry.byId("nannb"); |
| 862 |
wid.focus(); |
| 863 |
wid2 = registry.byId("textareatext"); |
| 864 |
wid2.focus(); |
| 865 |
wid = registry.byId("nannb"); |
| 866 |
wid.focus(); |
| 867 |
wid2.focus(); |
| 868 |
doh.t(isNaN(wid.get("value")), "isNaN(wid.get(\"value\") should be true"); |
| 869 |
} |
| 870 |
} |
| 871 |
]); |
| 872 |
|
| 873 |
doh.run(); |
| 874 |
}); |
| 875 |
}); |
| 876 |
</script> |
| 877 |
</head> |
| 878 |
<body class="claro"> |
| 879 |
<script type="dojo/require">at: "dojox/mvc/at"</script> |
| 880 |
<div id="wrapper"> |
| 881 |
<div id="header" style="margin-top: 0px;"> |
| 882 |
<div id="navigation" style="margin-top: 0px;"></div> |
| 883 |
<div id="headerInsert" style="margin-top: 0px;"> |
| 884 |
<h2>Data-bound Form Element Kitchen Sink MVC test</h2> |
| 885 |
</div> |
| 886 |
</div> |
| 887 |
<div id="main" style="margin-top: 0px;"> |
| 888 |
<div id="leftNav"></div> |
| 889 |
<div id="mainContent"> |
| 890 |
|
| 891 |
<h2 style="margin-top: 0px;">Programmatic creation of Form elements:</h2> |
| 892 |
<table> |
| 893 |
<tbody> |
| 894 |
<tr> |
| 895 |
<td><label>Widget</label></td> |
| 896 |
<td><label></label></td> |
| 897 |
<td><label>Textbox</label></td> |
| 898 |
<td><label>Output</label></td> |
| 899 |
<td><label>Model Reset</label></td> |
| 900 |
</tr> |
| 901 |
<tr> |
| 902 |
<td><label for="sel">Select:</label></td> |
| 903 |
<td><div id="sel"></div></td> |
| 904 |
<td><div id="seltext"></div></td> |
| 905 |
<td><div id="selOutput"></div></td> |
| 906 |
<td><div id="reset1" ></div></td> |
| 907 |
</tr> |
| 908 |
<tr> |
| 909 |
<td><label for="filsel">FilteringSelect:</label></td> |
| 910 |
<td><div id="filsel"></div></td> |
| 911 |
<td><div id="filtext"></div></td> |
| 912 |
<td><div id="filoutput"></div></td> |
| 913 |
<td><div id="filreset"></div></td> |
| 914 |
</tr> |
| 915 |
<tr> |
| 916 |
<td><label for="combosel">ComboBox:</label></td> |
| 917 |
<td><div id="combosel"></div></td> |
| 918 |
<td><div id="combotext"></div></td> |
| 919 |
<td><div id="combooutput"></div></td> |
| 920 |
<td><div id="comboreset"></div></td> |
| 921 |
</tr> |
| 922 |
<tr> |
| 923 |
<td><label for="datesel">DateTextBox:</label></td> |
| 924 |
<td><div id="datesel"></div></td> |
| 925 |
<td><div id="datetext"></div></td> |
| 926 |
<td><div id="dateoutput"></div></td> |
| 927 |
<td><div id="datereset"></div></td> |
| 928 |
</tr> |
| 929 |
<tr> |
| 930 |
<td><label for="slidersel">Slider:</label></td> |
| 931 |
<td><div id="slidersel"></div></td> |
| 932 |
<td><div id="slidertext"></div></td> |
| 933 |
<td><div id="slideroutput"></div></td> |
| 934 |
<td><div id="sliderreset"></div></td> |
| 935 |
</tr> |
| 936 |
<tr> |
| 937 |
<td><label for="numspinsel">NumberSpinner:</label></td> |
| 938 |
<td><div id="numspinsel"></div></td> |
| 939 |
<td><div id="numspintext"></div></td> |
| 940 |
<td><div id="numspinoutput"></div></td> |
| 941 |
<td><div id="numspinreset"></div></td> |
| 942 |
</tr> |
| 943 |
<tr> |
| 944 |
<td><label for="simpTAsel">SimpleTextArea:</label></td> |
| 945 |
<td><div id="simpTAsel"></div></td> |
| 946 |
<td><div id="simpTAtext"></div></td> |
| 947 |
<td><div id="simpTAoutput"></div></td> |
| 948 |
<td><div id="simpTAreset"></div></td> |
| 949 |
</tr> |
| 950 |
<tr> |
| 951 |
<td><label for="textareasel">TextArea:</label></td> |
| 952 |
<td><div id="textareasel"></div></td> |
| 953 |
<td><div id="textareatext"></div></td> |
| 954 |
<td><div id="textareaoutput"></div></td> |
| 955 |
<td><div id="textareareset"></div></td> |
| 956 |
</tr> |
| 957 |
<tr> |
| 958 |
<td><label for="nannb">TextBox nan test:</label></td> |
| 959 |
<td><div id="nannb"></div></td> |
| 960 |
</tr> |
| 961 |
</tbody> |
| 962 |
</table> |
| 963 |
|
| 964 |
<h2>Declarative creation of Form elements:</h2> |
| 965 |
<table> |
| 966 |
<tbody> |
| 967 |
<tr> |
| 968 |
<td><label>Widget</label></td> |
| 969 |
<td><label></label></td> |
| 970 |
<td><label>Textbox</label></td> |
| 971 |
<td><label>Output</label></td> |
| 972 |
<td><label>Model Reset</label></td> |
| 973 |
</tr> |
| 974 |
<tr> |
| 975 |
<td><label for="decsel">Select:</label></td> |
| 976 |
<td> |
| 977 |
<select id="decsel" style="width: 188px;" |
| 978 |
data-dojo-id="decsel" data-dojo-type="dijit/form/Select" |
| 979 |
data-dojo-props="name: 'decsel', value: at(decselctrl, 'number')"> |
| 980 |
<option value="1">one</option> |
| 981 |
<option value="2">two</option> |
| 982 |
<option value="3">three</option> |
| 983 |
<option value="4">four</option> |
| 984 |
</select> |
| 985 |
</td> |
| 986 |
<td> |
| 987 |
<input class="cell" id="decseltext" data-dojo-type="dijit/form/TextBox" |
| 988 |
data-dojo-props="value: at(decselctrl, 'number')"></input> |
| 989 |
</td> |
| 990 |
<td><span id="decselOutput" data-dojo-type="dojox/mvc/Output" data-dojo-props="value: at(decselctrl, 'number')"></span></td> |
| 991 |
<td> |
| 992 |
<button id="decselReset" type="button" data-dojo-type="dijit/form/Button" |
| 993 |
data-dojo-props="onClick: function(){decselctrl.reset();}">Reset</button> |
| 994 |
</td> |
| 995 |
</tr> |
| 996 |
<tr> |
| 997 |
<td><label for="decfilsel">FilteringSelect:</label></td> |
| 998 |
<td> |
| 999 |
<input id="decfilsel" data-dojo-type="dijit/form/FilteringSelect" |
| 1000 |
data-dojo-props="store: store, value: at(decfilctrl, 'number')"> |
| 1001 |
</td> |
| 1002 |
<td> |
| 1003 |
<input id="decfiltext" data-dojo-type="dijit/form/TextBox" |
| 1004 |
data-dojo-props="value: at(decfilctrl, 'number')"></input> |
| 1005 |
</td> |
| 1006 |
<td><span id="decfilOutput" data-dojo-type="dojox/mvc/Output" data-dojo-props="value: at(decfilctrl, 'number')"></span></td> |
| 1007 |
<td> |
| 1008 |
<button id="decfilReset" type="button" data-dojo-type="dijit/form/Button" |
| 1009 |
data-dojo-props="onClick: function(){decfilctrl.reset();}">Reset</button> |
| 1010 |
</td> |
| 1011 |
</tr> |
| 1012 |
<tr> |
| 1013 |
<td><label for="deccombosel">ComboBox:</label></td> |
| 1014 |
<td> |
| 1015 |
<input id="deccombosel" data-dojo-type="dijit/form/ComboBox" |
| 1016 |
data-dojo-props="store: store, value: at(deccomboctrl, 'number')"> |
| 1017 |
</td> |
| 1018 |
<td> |
| 1019 |
<input id="deccombotext" data-dojo-type="dijit/form/TextBox" |
| 1020 |
data-dojo-props="value: at(deccomboctrl, 'number')"></input> |
| 1021 |
</td> |
| 1022 |
<td><span id="deccomboOutput" data-dojo-type="dojox/mvc/Output" data-dojo-props="value: at(deccomboctrl, 'number')"></span></td> |
| 1023 |
<td> |
| 1024 |
<button id="deccomboReset" type="button" data-dojo-type="dijit/form/Button" |
| 1025 |
data-dojo-props="onClick: function(){deccomboctrl.reset();}">Reset</button> |
| 1026 |
</td> |
| 1027 |
</tr> |
| 1028 |
<tr> |
| 1029 |
<td><label for="datesel">DateTextBox:</label></td> |
| 1030 |
<td> |
| 1031 |
<input id="decdatesel" data-dojo-type="dijit/form/DateTextBox" |
| 1032 |
data-dojo-props="store: store, value: at(decdatectrl, 'number'), constraints: dummyDateWid.constraints"> |
| 1033 |
</td> |
| 1034 |
<td> |
| 1035 |
<input id="decdatetext" data-dojo-type="dijit/form/TextBox" |
| 1036 |
data-dojo-props="value: at(decdatectrl, 'number').transform(dummyDateWid.dateLocaleModule), |
| 1037 |
constraints: dummyDateWid.constraints"></input> |
| 1038 |
</td> |
| 1039 |
<td> |
| 1040 |
<span id="decdateOutput" data-dojo-type="dojox/mvc/Output" |
| 1041 |
data-dojo-props="value: at(decdatectrl, 'number').transform(dummyDateWid.dateLocaleModule), |
| 1042 |
constraints: dummyDateWid.constraints"></span> |
| 1043 |
</td> |
| 1044 |
<td> |
| 1045 |
<button id="decdateReset" type="button" data-dojo-type="dijit/form/Button" |
| 1046 |
data-dojo-props="onClick: function(){decdatectrl.reset();}">Reset</button> |
| 1047 |
</td> |
| 1048 |
</tr> |
| 1049 |
<tr> |
| 1050 |
<td><label for="decslidersel">Slider:</label></td> |
| 1051 |
<td> |
| 1052 |
<input id="decslidersel" data-dojo-type="dijit/form/HorizontalSlider" |
| 1053 |
data-dojo-props="store: store, value: at(decsliderctrl, 'number'), |
| 1054 |
style: {width: '190px'}, |
| 1055 |
minimum: 0, |
| 1056 |
maximum: 100, |
| 1057 |
discreteValues: 21"> |
| 1058 |
</td> |
| 1059 |
<td> |
| 1060 |
<input id="decslidertext" data-dojo-type="dijit/form/TextBox" |
| 1061 |
data-dojo-props="value: at(decsliderctrl, 'number').transform(dojo.number)"> |
| 1062 |
</td> |
| 1063 |
<td> |
| 1064 |
<span id="decsliderOutput" data-dojo-type="dojox/mvc/Output" |
| 1065 |
data-dojo-props="value: at(decsliderctrl, 'number').transform(dojo.number)"></span> |
| 1066 |
</td> |
| 1067 |
<td> |
| 1068 |
<button id="decsliderReset" type="button" data-dojo-type="dijit/form/Button" |
| 1069 |
data-dojo-props="onClick: function(){decsliderctrl.reset();}">Reset</button> |
| 1070 |
</td> |
| 1071 |
</tr> |
| 1072 |
<tr> |
| 1073 |
<td><label for="decnumspinsel">NumberSpinner:</label></td> |
| 1074 |
<td> |
| 1075 |
<input id="decnumspinsel" data-dojo-type="dijit/form/NumberSpinner" |
| 1076 |
data-dojo-props="store:store, value: at(decnumspinctrl, 'number')"> |
| 1077 |
</td> |
| 1078 |
<td> |
| 1079 |
<input id="decnumspintext" data-dojo-type="dijit/form/TextBox" |
| 1080 |
data-dojo-props="value: at(decnumspinctrl, 'number').transform(dojo.number)"> |
| 1081 |
</td> |
| 1082 |
<td> |
| 1083 |
<span id="decnumspinOutput" data-dojo-type="dojox/mvc/Output" |
| 1084 |
data-dojo-props="value: at(decnumspinctrl, 'number').transform(dojo.number)"></span> |
| 1085 |
</td> |
| 1086 |
<td> |
| 1087 |
<button id="decnumspinReset" type="button" data-dojo-type="dijit/form/Button" |
| 1088 |
data-dojo-props="onClick: function(){decnumspinctrl.reset();}">Reset</button> |
| 1089 |
</td> |
| 1090 |
</tr> |
| 1091 |
<tr> |
| 1092 |
<td><label for="decsimpTAsel">SimpleTextArea:</label></td> |
| 1093 |
<td> |
| 1094 |
<input id="decsimpTAsel" data-dojo-type="dijit/form/Textarea" |
| 1095 |
data-dojo-props="store:store, value: at(decsimpTActrl, 'number')"> |
| 1096 |
</td> |
| 1097 |
<td> |
| 1098 |
<input id="decsimpTAtext" data-dojo-type="dijit/form/TextBox" |
| 1099 |
data-dojo-props="value: at(decsimpTActrl, 'number')"> |
| 1100 |
</td> |
| 1101 |
<td><span id="decsimpTAOutput" data-dojo-type="dojox/mvc/Output" data-dojo-props="value: at(decsimpTActrl, 'number')"></span></td> |
| 1102 |
<td> |
| 1103 |
<button id="decsimpTAReset" type="button" data-dojo-type="dijit/form/Button" |
| 1104 |
data-dojo-props="onClick: function(){decsimpTActrl.reset();}">Reset</button> |
| 1105 |
</td> |
| 1106 |
</tr> |
| 1107 |
<tr> |
| 1108 |
<td><label for="dectextareasel">TextArea:</label></td> |
| 1109 |
<td> |
| 1110 |
<input id="dectextareasel" data-dojo-type="dijit/form/Textarea" |
| 1111 |
data-dojo-props="store:store, value: at(dectextareactrl, 'number')"> |
| 1112 |
</td> |
| 1113 |
<td> |
| 1114 |
<input id="dectextareatext" data-dojo-type="dijit/form/TextBox" |
| 1115 |
data-dojo-props="value: at(dectextareactrl, 'number')"> |
| 1116 |
</td> |
| 1117 |
<td><span id="dectextareaOutput" data-dojo-type="dojox/mvc/Output" data-dojo-props="value: at(dectextareactrl, 'number')"></span></td> |
| 1118 |
<td> |
| 1119 |
<button id="dectextareaReset" type="button" data-dojo-type="dijit/form/Button" |
| 1120 |
data-dojo-props="onClick: function(){dectextareactrl.reset();}">Reset</button> |
| 1121 |
</td> |
| 1122 |
</tr> |
| 1123 |
</tbody> |
| 1124 |
</table> |
| 1125 |
|
| 1126 |
<h2>Test data-bound dijit.Calendar:</h2> |
| 1127 |
<table> |
| 1128 |
<tbody> |
| 1129 |
<tr> |
| 1130 |
<td><label>Widget</label></td> |
| 1131 |
<td><label></label></td> |
| 1132 |
<td><label>Textbox</label></td> |
| 1133 |
<td><label>Output</label></td> |
| 1134 |
<td><label>Model Reset</label></td> |
| 1135 |
</tr> |
| 1136 |
<tr> |
| 1137 |
<td><label for="deccal">Calendar:</label></td> |
| 1138 |
<td> |
| 1139 |
<input class="cell" id="deccal" data-dojo-id="deccal" data-dojo-type="dijit/Calendar" |
| 1140 |
data-dojo-props="value: at(deccalctrl, 'date')"> |
| 1141 |
</td> |
| 1142 |
<td> |
| 1143 |
<input class="cell" id="deccaltext" data-dojo-type="dijit/form/TextBox" |
| 1144 |
data-dojo-props="value: at(deccalctrl, 'date').transform(dummyDateWid.dateLocaleModule), |
| 1145 |
constraints: dummyDateWid.constraints"> |
| 1146 |
</td> |
| 1147 |
<td> |
| 1148 |
<span id="deccalOutput" data-dojo-type="dojox/mvc/Output" |
| 1149 |
data-dojo-props="value: at(deccalctrl, 'date').transform(dummyDateWid.dateLocaleModule), |
| 1150 |
constraints: dummyDateWid.constraints"></span> |
| 1151 |
</td> |
| 1152 |
<td> |
| 1153 |
<button id="deccalReset" type="button" data-dojo-type="dijit/form/Button" |
| 1154 |
data-dojo-props="onClick: function(){deccalctrl.reset();}">Reset</button> |
| 1155 |
</td> |
| 1156 |
</tr> |
| 1157 |
<tr> |
| 1158 |
<td><label for="deccolor">ColorPalette:</label></td> |
| 1159 |
<td> |
| 1160 |
<div id="deccolor" data-dojo-type="dijit/ColorPalette" |
| 1161 |
data-dojo-props="palette: '3x4', value: at(deccolorctrl, 'code')"> |
| 1162 |
</div> |
| 1163 |
</td> |
| 1164 |
<td> |
| 1165 |
<input class="cell" id="deccolortext" data-dojo-type="dijit/form/TextBox" |
| 1166 |
data-dojo-props="value: at(deccolorctrl, 'code')"></input> |
| 1167 |
</td> |
| 1168 |
<td><span id="deccolorOutput" data-dojo-type="dojox/mvc/Output" data-dojo-props="value: at(deccolorctrl, 'code')"></span></td> |
| 1169 |
<td> |
| 1170 |
<button id="deccolorReset" type="button" data-dojo-type="dijit/form/Button" |
| 1171 |
data-dojo-props="onClick: function(){deccolorctrl.reset();}">Reset</button> |
| 1172 |
</td> |
| 1173 |
</tr> |
| 1174 |
</tbody> |
| 1175 |
</table> |
| 1176 |
</div> |
| 1177 |
</div> |
| 1178 |
</div> |
| 1179 |
</body> |
| 1180 |
</html> |