| 1 | <html> |
| 2 | <head> |
| 3 | <script type="text/javascript" |
| 4 | src="../../../dojo/dojo.js" |
| 5 | data-dojo-config="isDebug: true, parseOnLoad: true"> |
| 6 | </script> |
| 7 | <script type="text/javascript"> |
| 8 | dojo.require("doh.runner"); |
| 9 | dojo.require("dojox.form.DropDownStack"); |
| 10 | dojo.require("dojox.form.RadioStack"); |
| 11 | dojo.require("dijit.form.Button"); |
| 12 | dojo.require("dijit.form.Form"); |
| 13 | dojo.require("dijit.layout.StackContainer"); |
| 14 | dojo.require("dijit.layout.ContentPane"); |
| 15 | dojo.require("dijit.form.TextBox"); |
| 16 | dojo.require("dojo.parser"); |
| 17 | |
| 18 | dojo.addOnLoad(function(){ |
| 19 | doh.register("tests", |
| 20 | [ |
| 21 | function test_getValues(t){ |
| 22 | t.is({ |
| 23 | dropDown: "first", |
| 24 | dropDownFirstBox: "First Value", |
| 25 | radio: "second", |
| 26 | radioSecondBox2: "Radio Another Value", |
| 27 | dual: "second", |
| 28 | dualSecondBox: "Dual First Value on Second (RO)", |
| 29 | dualSecondBox2: "Dual Another Value" |
| 30 | }, form.get("value")); |
| 31 | }, |
| 32 | function test_setValues(t){ |
| 33 | form.set("value", { |
| 34 | dropDown: "first", |
| 35 | dropDownSecondBox: "Changed First Value", |
| 36 | radio: "first", |
| 37 | radioFirstBox: "Changed Radio Value", |
| 38 | radioSecondBox: "Changed disabled value", |
| 39 | dual: "first", |
| 40 | dualFirstBox: "Changed Dual (DIS)", |
| 41 | dualSecondBox: "Changed read only value", |
| 42 | dualSecondBox: "Changed me too" |
| 43 | }); |
| 44 | t.is({ |
| 45 | dropDown: "first", |
| 46 | dropDownFirstBox: "First Value", |
| 47 | radio: "first", |
| 48 | radioFirstBox: "Changed Radio Value", |
| 49 | dual: "first" |
| 50 | }, form.get("value")); |
| 51 | form.set("value", { |
| 52 | dropDown: "second", |
| 53 | radio: "second", |
| 54 | dual: "second"}); |
| 55 | t.is({ |
| 56 | dropDown: "second", |
| 57 | dropDownSecondBox: "Changed First Value", |
| 58 | dropDownSecondBox2: "Another Value", |
| 59 | radio: "second", |
| 60 | radioSecondBox2: "Radio Another Value", |
| 61 | dual: "second", |
| 62 | dualSecondBox: "Changed me too", |
| 63 | dualSecondBox2: "Dual Another Value" |
| 64 | }, form.get("value")); |
| 65 | } |
| 66 | ] |
| 67 | ); |
| 68 | doh.run(); |
| 69 | }); |
| 70 | </script> |
| 71 | <style> |
| 72 | @import url(../../../dojo/resources/dojo.css); |
| 73 | @import url(../../../dijit/themes/tundra/tundra.css); |
| 74 | @import url(../resources/DropDownSelect.css); |
| 75 | @import url(../resources/CheckedMultiSelect.css); |
| 76 | @import url(../../../dijit/tests/css/dijitTests.css); |
| 77 | </style> |
| 78 | </head> |
| 79 | <body class="tundra"> |
| 80 | <h1 class="testTitle">Test: dojox.form.SelectStack</h1> |
| 81 | <form dojoType="dijit.form.Form" data-dojo-id="form"> |
| 82 | <h4 class="testSubtitle">DropDown-based Select</h4> |
| 83 | <select dojoType="dojox.form.DropDownStack" name="dropDown" |
| 84 | stackId="dropDownStack"></select> |
| 85 | <div dojoType="dijit.layout.StackContainer" class="dijitInline" doLayout="false" id="dropDownStack"> |
| 86 | <div title="First" id="first" dojoType="dijit.layout.ContentPane"> |
| 87 | Options for "First": <input dojoType="dijit.form.TextBox" name="dropDownFirstBox" value="First Value" /> |
| 88 | </div> |
| 89 | <div title="Second" id="second" dojoType="dijit.layout.ContentPane"> |
| 90 | Options for "Second": <input dojoType="dijit.form.TextBox" name="dropDownSecondBox" value="First Value on Second" /><br> |
| 91 | More Options for "Second": <input dojoType="dijit.form.TextBox" name="dropDownSecondBox2" value="Another Value" /> |
| 92 | </div> |
| 93 | </div> |
| 94 | <hr> |
| 95 | <h4 class="testSubtitle">Radio-based Select</h4> |
| 96 | <select dojoType="dojox.form.RadioStack" name="radio" |
| 97 | stackId="radioStack" stackPrefix="radio_" value="second"></select> |
| 98 | <div dojoType="dijit.layout.StackContainer" class="dijitInline" doLayout="false" id="radioStack"> |
| 99 | <div title="First" id="radio_first" dojoType="dijit.layout.ContentPane"> |
| 100 | Options for "First": <input dojoType="dijit.form.TextBox" name="radioFirstBox" value="Radio First Value" /> |
| 101 | </div> |
| 102 | <div title="Second" id="radio_second" dojoType="dijit.layout.ContentPane"> |
| 103 | Options for "Second": <input dojoType="dijit.form.TextBox" disabled="disabled" name="radioSecondBox" value="Radio First Value on Second (DIS)" /><br> |
| 104 | More Options for "Second": <input dojoType="dijit.form.TextBox" name="radioSecondBox2" value="Radio Another Value" /> |
| 105 | </div> |
| 106 | </div> |
| 107 | <hr> |
| 108 | <h4 class="testSubtitle">*Two* controllers</h4> |
| 109 | <select dojoType="dojox.form.DropDownStack" stackId="dualStack" stackPrefix="dual_"></select><br> |
| 110 | <div dojoType="dijit.layout.StackContainer" doLayout="false" id="dualStack"> |
| 111 | <div title="First" id="dual_first" dojoType="dijit.layout.ContentPane"> |
| 112 | Options for "First": <input dojoType="dijit.form.TextBox" disabled="disabled" name="dualFirstBox" value="Dual First Value (DIS)" /> |
| 113 | </div> |
| 114 | <div title="Second" selected="true" id="dual_second" dojoType="dijit.layout.ContentPane"> |
| 115 | Options for "Second": <input dojoType="dijit.form.TextBox" readOnly="readOnly" name="dualSecondBox" value="Dual First Value on Second (RO)" /><br> |
| 116 | More Options for "Second": <input dojoType="dijit.form.TextBox" name="dualSecondBox2" value="Dual Another Value" /> |
| 117 | </div> |
| 118 | </div> |
| 119 | <select dojoType="dojox.form.DropDownStack" name="dual" stackId="dualStack" stackPrefix="dual_"></select><br> |
| 120 | <hr> |
| 121 | <button dojoType="dijit.form.Button"> |
| 122 | <script type="dojo/method" data-dojo-event="onClick"> |
| 123 | console.dir(form.get("value")); |
| 124 | </script> |
| 125 | Get Values |
| 126 | </button> |
| 127 | </form> |
| 128 | </body> |
| 129 | </html> |