| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 5 |
<title>Bidi BTD in Select</title> |
| 6 |
|
| 7 |
|
| 8 |
<link id="themeStyles" rel="stylesheet" href="../../../../dijit/themes/claro/claro.css"/> |
| 9 |
|
| 10 |
<style> |
| 11 |
@import url(../../../themes/claro/document.css); |
| 12 |
@import url(../../css/dijitTests.css); |
| 13 |
</style> |
| 14 |
|
| 15 |
|
| 16 |
<script type="text/javascript" src="../../../../dojo/dojo.js" |
| 17 |
data-dojo-config="isDebug: true, has: { 'dojo-bidi': true }"></script> |
| 18 |
|
| 19 |
|
| 20 |
<script type="text/javascript" src="../../_testCommon.js"></script> |
| 21 |
|
| 22 |
<script type="text/javascript"> |
| 23 |
require([ |
| 24 |
"doh/runner", |
| 25 |
"dojo/parser", |
| 26 |
"dijit/registry", |
| 27 |
"dijit/form/Select", |
| 28 |
"dijit/form/Button", |
| 29 |
"dijit/form/Form", |
| 30 |
"dijit/Dialog", |
| 31 |
"dojo/domReady!" |
| 32 |
], function(doh, parser, registry, Select){ |
| 33 |
|
| 34 |
var numOptions = 0; |
| 35 |
var numChanges = 0; |
| 36 |
var addNum = 10; |
| 37 |
|
| 38 |
function testSelectWidget(element, formDir,elementTextDir,isfirstChildLatin){ |
| 39 |
doh.is(registry.byId(element).get("textDir"), elementTextDir); |
| 40 |
doh.is(registry.byId(element).dir, formDir); |
| 41 |
var t_dir = elementTextDir; |
| 42 |
if(t_dir == "auto") |
| 43 |
t_dir = isfirstChildLatin? "ltr" : "rtl"; |
| 44 |
doh.is(registry.byId(element).containerNode.dir, t_dir); |
| 45 |
} |
| 46 |
|
| 47 |
function testDropdownList(elementName){ |
| 48 |
var element = registry.byId(elementName); |
| 49 |
var elementTextDir = element.get("textDir"); |
| 50 |
var itemTextDir = elementTextDir; |
| 51 |
element.loadDropDown(function(){}); |
| 52 |
var list = element.dropDown.getChildren(); |
| 53 |
dojo.forEach(list, function(entry){ |
| 54 |
if(elementTextDir == "auto"){ |
| 55 |
itemTextDir = element._checkContextual(entry.label.replace(/<[^>]*>/gm," ")); |
| 56 |
} |
| 57 |
doh.is(itemTextDir,entry.textDirNode.dir); |
| 58 |
}); |
| 59 |
} |
| 60 |
|
| 61 |
var programmatic1 = new Select({ |
| 62 |
options: [ |
| 63 |
{ label: 'foo!', value: 'foo!'}, |
| 64 |
{ label: 'bar', value: 'bar' }, |
| 65 |
{ label: 'x !', value: 'x !', selected: true }, |
| 66 |
{ label: '\u05D0\u05D1\u05D2!', value: '\u05D0\u05D1\u05D2!' } |
| 67 |
] |
| 68 |
}); |
| 69 |
programmatic1.placeAt('testProgramatic1'); |
| 70 |
programmatic1.set("textDir",'ltr'); |
| 71 |
|
| 72 |
var programmatic2 = new Select({ |
| 73 |
options: [ |
| 74 |
{ label: 'foo!', value: 'foo!'}, |
| 75 |
{ label: 'bar', value: 'bar' }, |
| 76 |
{ label: 'x !', value: 'x !', selected: true }, |
| 77 |
{ label: '\u05D0\u05D1\u05D2!', value: '\u05D0\u05D1\u05D2!' } |
| 78 |
] |
| 79 |
}); |
| 80 |
programmatic2.placeAt('testProgramatic2'); |
| 81 |
programmatic2.set("textDir",'rtl'); |
| 82 |
|
| 83 |
var programmatic3 = new Select({ |
| 84 |
options: [ |
| 85 |
{ label: 'foo!', value: 'foo!'}, |
| 86 |
{ label: 'bar', value: 'bar' }, |
| 87 |
{ label: 'x !', value: 'x !', selected: true }, |
| 88 |
{ label: '\u05D0\u05D1\u05D2!', value: '\u05D0\u05D1\u05D2!' } |
| 89 |
] |
| 90 |
}); |
| 91 |
programmatic3.placeAt('testProgramatic3'); |
| 92 |
programmatic3.set("textDir",'auto'); |
| 93 |
|
| 94 |
doh.register("parse", function(){ |
| 95 |
return parser.parse(); |
| 96 |
}); |
| 97 |
|
| 98 |
doh.register("dijit.tests._BidiSupport.form.Select in LTR form", [ |
| 99 |
{name:"LTR form, Auto/Hebrew", runTest:function(){testSelectWidget("s10","ltr","auto",false);}}, |
| 100 |
{name:"LTR form, Auto/English",runTest:function(){testSelectWidget("s11","ltr","auto",true);}}, |
| 101 |
{name:"LTR form, LTR",runTest:function(){testSelectWidget("s12","ltr","ltr",true);}}, |
| 102 |
{name:"LTR form, RTL",runTest:function(){testSelectWidget("s13","ltr","rtl",true);}} |
| 103 |
]); |
| 104 |
|
| 105 |
doh.register("Bidi dropdown list in Select, LTR form", [ |
| 106 |
{name:"LTR form, Auto/Hebrew", runTest:function(){testDropdownList("s10");}}, |
| 107 |
{name:"LTR form, Auto/English",runTest:function(){testDropdownList("s11");}}, |
| 108 |
{name:"LTR form, LTR",runTest:function(){testDropdownList("s12");}}, |
| 109 |
{name:"LTR form, RTL",runTest:function(){testDropdownList("s13");}} |
| 110 |
]); |
| 111 |
|
| 112 |
doh.register("dijit.tests._BidiSupport.form.Select in RTL form", [ |
| 113 |
{name:"RTL form, Auto/Hebrew", runTest:function(){testSelectWidget("s10R","rtl","auto",false);}}, |
| 114 |
{name:"RTL form, Auto/English",runTest:function(){testSelectWidget("s11R","rtl","auto",true);}}, |
| 115 |
{name:"RTL form, LTR",runTest:function(){testSelectWidget("s12R","rtl","ltr",true);}}, |
| 116 |
{name:"RTL form, RTL",runTest:function(){testSelectWidget("s13R","rtl","rtl",true);}} |
| 117 |
]); |
| 118 |
|
| 119 |
doh.register("Bidi dropdown list in Select, RTL form", [ |
| 120 |
{name:"LTR form, Auto/Hebrew", runTest:function(){testDropdownList("s10R");}}, |
| 121 |
{name:"LTR form, Auto/English",runTest:function(){testDropdownList("s11R");}}, |
| 122 |
{name:"LTR form, LTR",runTest:function(){testDropdownList("s12R");}}, |
| 123 |
{name:"LTR form, RTL",runTest:function(){testDropdownList("s13R");}} |
| 124 |
]); |
| 125 |
|
| 126 |
doh.register("dijit.tests._BidiSupport.form.Select, rich text (auto)", [ |
| 127 |
{name:"Rich text Auto/English Select",runTest:function(){testSelectWidget("s4","ltr","auto",true);}}, |
| 128 |
{name:"Rich text Auto/Hebrew Select", runTest:function(){testSelectWidget("s5","ltr","auto",false);}}, |
| 129 |
{name:"Rich text Auto/English Dropdown",runTest:function(){testDropdownList("s4");}}, |
| 130 |
{name:"Rich text Auto/Hebrew Dropdown", runTest:function(){testDropdownList("s5");}} |
| 131 |
|
| 132 |
]); |
| 133 |
|
| 134 |
doh.run(); |
| 135 |
}); |
| 136 |
</script> |
| 137 |
</head> |
| 138 |
<body class="claro"> |
| 139 |
<h1 id="_title" class="testTitle">Test: dijit/form/Select <i>BIDI</i></h1> |
| 140 |
|
| 141 |
<form id="form" data-dojo-id="formL" data-dojo-type="dijit/form/Form" method="get" |
| 142 |
onSubmit="return this.validate();"> |
| 143 |
<div dir="ltr"> |
| 144 |
<h2>dijit/form/Select LTR form</h2> |
| 145 |
<h4 class="testSubtitle">Setting Defaults</h4> |
| 146 |
|
| 147 |
<label for="s10">Test AUTO: </label> |
| 148 |
<select id="s10" data-dojo-id="s10" data-dojo-type="dijit/form/Select" data-dojo-props='name:"s10" , textDir:"auto", style:{width:"150px"}'> |
| 149 |
<option value="TN">START חדש!</option> |
| 150 |
<option value="TM" selected="selected">חדש END !</option> |
| 151 |
<option value="VA">Hello AUTO!!</option> |
| 152 |
<option value="WA">חדש.</option> |
| 153 |
<option value="FL">NEW!</option> |
| 154 |
</select> |
| 155 |
<select id="s11" data-dojo-id="s11" data-dojo-type="dijit/form/Select" data-dojo-props='name:"s11" , textDir:"auto", style:{width:"150px"}'> |
| 156 |
<option value="TN">START חדש!</option> |
| 157 |
<option value="TM">חדש END !</option> |
| 158 |
<option value="VA" selected="selected">Hello AUTO!!</option> |
| 159 |
<option value="WA">חדש.</option> |
| 160 |
<option value="FL">NEW!</option> |
| 161 |
</select> |
| 162 |
<br> |
| 163 |
<label for="s12">Test LTR: </label> |
| 164 |
<select id="s12" data-dojo-id="s12" data-dojo-type="dijit/form/Select" data-dojo-props='name:"s12" , textDir:"ltr", style:{width:"150px"}'> |
| 165 |
<option value="TN">START חדש!</option> |
| 166 |
<option value="TM">חדש END !</option> |
| 167 |
<option value="VA" selected="selected">Hello LTR!!</option> |
| 168 |
<option value="WA">חדש.</option> |
| 169 |
<option value="FL">NEW!</option> |
| 170 |
</select> |
| 171 |
|
| 172 |
<label for="s13">Test RTL: </label> |
| 173 |
<select id="s13" data-dojo-id="s13" data-dojo-type="dijit/form/Select" data-dojo-props='name:"s13" , textDir:"rtl", style:{width:"150px"}'> |
| 174 |
<option value="TN">START חדש!</option> |
| 175 |
<option value="TM">חדש END !</option> |
| 176 |
<option value="VA" selected="selected">Hello RTL!!</option> |
| 177 |
<option value="WA">חדש.</option> |
| 178 |
<option value="FL">NEW!</option> |
| 179 |
</select> |
| 180 |
|
| 181 |
<hr> |
| 182 |
<h4 class="testSubtitle"> </h4> |
| 183 |
<label>Rich Text (AUTO): |
| 184 |
<span id="s4" data-dojo-id="s4" data-dojo-type="dijit/form/Select" data-dojo-props='name:"s4", value:"AK" , textDir:"auto", style:{width:"150px"}'> |
| 185 |
<span data-dojo-value="AL"><b>Alabama.</b></span> |
| 186 |
<span data-dojo-value="AK"><span style="color:red;">A</span><span style="color:orange;">l</span><span style="color:yellow;">a</span><span style="color:green;">s</span><span style="color:blue;">k</span><span style="color:purple;">a.</span></span> |
| 187 |
<span data-dojo-value="AZ"><i>Arizona.</i></span> |
| 188 |
<span data-dojo-value="IL"><b><i>חדש.</i></b></span> |
| 189 |
<span data-dojo-value="AR"><span class="ark">Arkansas.</span></span> |
| 190 |
<span data-dojo-value="CA"><span style="font-size:25%">C</span><span style="font-size:50%">a</span><span style="font-size:75%">l</span><span style="font-size:90%">i</span><span style="font-size:100%">f</span><span style="font-size:125%">o</span><span style="font-size:133%">r</span><span style="font-size:150%">n</span><span style="font-size:175%">i</span><span style="font-size:200%">a.</span></span> |
| 191 |
<button value="NM" disabled="disabled">New<br> Mexico</button> |
| 192 |
</span></label> |
| 193 |
|
| 194 |
<label> |
| 195 |
<span id="s5" data-dojo-id="s5" data-dojo-type="dijit/form/Select" data-dojo-props='name:"s5", value:"IL" , textDir:"auto", style:{width:"150px"}'> |
| 196 |
<span data-dojo-value="AL"><b>Alabama.</b></span> |
| 197 |
<span data-dojo-value="AK"><span style="color:red;">A</span><span style="color:orange;">l</span><span style="color:yellow;">a</span><span style="color:green;">s</span><span style="color:blue;">k</span><span style="color:purple;">a.</span></span> |
| 198 |
<span data-dojo-value="AZ"><i>Arizona.</i></span> |
| 199 |
<span data-dojo-value="IL"><b><i>חדש.</i></b></span> |
| 200 |
<span data-dojo-value="AR"><span class="ark">Arkansas.</span></span> |
| 201 |
<span data-dojo-value="CA"><span style="font-size:25%">C</span><span style="font-size:50%">a</span><span style="font-size:75%">l</span><span style="font-size:90%">i</span><span style="font-size:100%">f</span><span style="font-size:125%">o</span><span style="font-size:133%">r</span><span style="font-size:150%">n</span><span style="font-size:175%">i</span><span style="font-size:200%">a.</span></span> |
| 202 |
<button value="NM" disabled="disabled">New<br> Mexico</button> |
| 203 |
</span></label> |
| 204 |
|
| 205 |
|
| 206 |
</div> |
| 207 |
</form> |
| 208 |
|
| 209 |
|
| 210 |
<form id="formR" data-dojo-id="form" data-dojo-type="dijit/form/Form" method="get" > |
| 211 |
<div dir="rtl"> |
| 212 |
<h2>dijit/form/Select RTL form</h2> |
| 213 |
<h4 class="testSubtitle">Setting Defaults</h4> |
| 214 |
|
| 215 |
<label for="s10R">Test AUTO: </label> |
| 216 |
<select id="s10R" data-dojo-id="s10R" data-dojo-type="dijit/form/Select" data-dojo-props='name:"s10R" , textDir:"auto"'> |
| 217 |
<option value="TN">START חדש!</option> |
| 218 |
<option value="TM" selected="selected">חדש END !</option> |
| 219 |
<option value="VA">Hello AUTO!!</option> |
| 220 |
<option value="WA">חדש.</option> |
| 221 |
<option value="FL">NEW!</option> |
| 222 |
</select> |
| 223 |
<select id="s11R" data-dojo-id="s11" data-dojo-type="dijit/form/Select" data-dojo-props='name:"s11R" , textDir:"auto"'> |
| 224 |
<option value="TN">START חדש!</option> |
| 225 |
<option value="TM">חדש END !</option> |
| 226 |
<option value="VA" selected="selected">Hello AUTO!!</option> |
| 227 |
<option value="WA">חדש.</option> |
| 228 |
<option value="FL">NEW!</option> |
| 229 |
</select> |
| 230 |
<br> |
| 231 |
<label for="s12R">Test LTR: </label> |
| 232 |
<select id="s12R" data-dojo-id="s12R" data-dojo-type="dijit/form/Select" data-dojo-props='name:"s12R" , textDir:"ltr"'> |
| 233 |
<option value="TN">START חדש!</option> |
| 234 |
<option value="TM">חדש END !</option> |
| 235 |
<option value="VA" selected="selected">Hello LTR!!</option> |
| 236 |
<option value="WA">חדש.</option> |
| 237 |
<option value="FL">NEW!</option> |
| 238 |
</select> |
| 239 |
<br> |
| 240 |
<label for="s13R">Test RTL: </label> |
| 241 |
<select id="s13R" data-dojo-id="s13R" data-dojo-type="dijit/form/Select" data-dojo-props='name:"s13R" , textDir:"rtl"'> |
| 242 |
<option value="TN">START חדש!</option> |
| 243 |
<option value="TM">חדש END !</option> |
| 244 |
<option value="VA" selected="selected">Hello RTL!!</option> |
| 245 |
<option value="WA">חדש.</option> |
| 246 |
<option value="FL">NEW!</option> |
| 247 |
</select> |
| 248 |
|
| 249 |
<hr> |
| 250 |
<h4 class="testSubtitle"> </h4> |
| 251 |
<label>Rich Text (AUTO): |
| 252 |
<span id="s4R" data-dojo-id="s4R" data-dojo-type="dijit/form/Select" data-dojo-props='name:"s4R", value:"AK" , textDir:"auto"'> |
| 253 |
<span data-dojo-value="AL"><b>Alabama.</b></span> |
| 254 |
<span data-dojo-value="AK"><span style="color:red;">A</span><span style="color:orange;">l</span><span style="color:yellow;">a</span><span style="color:green;">s</span><span style="color:blue;">k</span><span style="color:purple;">a.</span></span> |
| 255 |
<span data-dojo-value="AZ"><i>Arizona.</i></span> |
| 256 |
<span data-dojo-value="IL"><b><i>חדש.</i></b></span> |
| 257 |
<span data-dojo-value="AR"><span class="ark">Arkansas.</span></span> |
| 258 |
<span data-dojo-value="CA"><span style="font-size:25%">C</span><span style="font-size:50%">a</span><span style="font-size:75%">l</span><span style="font-size:90%">i</span><span style="font-size:100%">f</span><span style="font-size:125%">o</span><span style="font-size:133%">r</span><span style="font-size:150%">n</span><span style="font-size:175%">i</span><span style="font-size:200%">a.</span></span> |
| 259 |
<button value="NM" disabled="disabled">New<br> Mexico</button> |
| 260 |
</span></label> |
| 261 |
|
| 262 |
<label> |
| 263 |
<span id="s5R" data-dojo-id="s5" data-dojo-type="dijit/form/Select" data-dojo-props='name:"s5R", value:"IL" , textDir:"auto"'> |
| 264 |
<span data-dojo-value="AL"><b>Alabama.</b></span> |
| 265 |
<span data-dojo-value="AK"><span style="color:red;">A</span><span style="color:orange;">l</span><span style="color:yellow;">a</span><span style="color:green;">s</span><span style="color:blue;">k</span><span style="color:purple;">a.</span></span> |
| 266 |
<span data-dojo-value="AZ"><i>Arizona.</i></span> |
| 267 |
<span data-dojo-value="IL"><b><i>חדש.</i></b></span> |
| 268 |
<span data-dojo-value="AR"><span class="ark">Arkansas.</span></span> |
| 269 |
<span data-dojo-value="CA"><span style="font-size:25%">C</span><span style="font-size:50%">a</span><span style="font-size:75%">l</span><span style="font-size:90%">i</span><span style="font-size:100%">f</span><span style="font-size:125%">o</span><span style="font-size:133%">r</span><span style="font-size:150%">n</span><span style="font-size:175%">i</span><span style="font-size:200%">a.</span></span> |
| 270 |
<button value="NM" disabled="disabled">New<br> Mexico</button> |
| 271 |
</span></label> |
| 272 |
|
| 273 |
</div> |
| 274 |
</form> |
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
<hr> |
| 279 |
<h4 class="testSubtitle">Widgets created programmatically:</h4><br> |
| 280 |
<span id="testProgramatic1">LTR: </span> |
| 281 |
<span id="testProgramatic2"> RTL: </span> |
| 282 |
<span id="testProgramatic3"> AUTO: </span> |
| 283 |
|
| 284 |
|
| 285 |
<div data-dojo-type="dijit/Dialog" id="dlg1"> |
| 286 |
<div data-dojo-type="dijit/form/Select" id="dlg1Select"required="true"></div> |
| 287 |
<div data-dojo-type="dijit/form/Button" id="dlg1ValidateBtn"> |
| 288 |
<script type=dojo/method data-dojo-event="onClick"> |
| 289 |
var dlg1 = dijit.byId("dlg1"); |
| 290 |
if(dlg1.validate()){ |
| 291 |
dlg1.hide(); |
| 292 |
} |
| 293 |
</script> |
| 294 |
validate and close |
| 295 |
</div> |
| 296 |
</div> |
| 297 |
|
| 298 |
</body> |
| 299 |
</html> |