| 1 | <!DOCTYPE HTML> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta http-equiv="content-type" content="text/html; charset=utf-8"/> |
| 5 | <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" /> |
| 6 | <meta name="apple-mobile-web-app-capable" content="yes" /> |
| 7 | <title>Button Bidi Tests</title> |
| 8 | <script type="text/javascript" src="../../../deviceTheme.js"></script> |
| 9 | <script type="text/javascript" src="../../../../../dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: true, has: {'dojo-bidi': true }"></script> |
| 10 | <script language="JavaScript" type="text/javascript"> |
| 11 | |
| 12 | require([ |
| 13 | "dojo/sniff", |
| 14 | "dojo/dom-construct", // dojo.place |
| 15 | "dojo/ready", // dojo.ready |
| 16 | "dijit/registry", // dijit.byId |
| 17 | "doh/runner", //doh functions, |
| 18 | "dojo/_base/window", |
| 19 | "dojox/mobile/bidi/common", |
| 20 | "dojox/mobile/Button", |
| 21 | "dojox/mobile", // This is a mobile app. |
| 22 | "dojox/mobile/View", // This mobile app uses mobile view |
| 23 | "dojox/mobile/compat", // This mobile app supports running on desktop browsers |
| 24 | "dojox/mobile/parser" // This mobile app uses declarative programming with fast mobile parser |
| 25 | ], function(has, domConst, ready, registry, runner, win, common, Button){ |
| 26 | |
| 27 | function _createButtonProgrammatically(){ |
| 28 | var demoWidget = new Button({"class":"redButton", style:"width:180px", label:"Pragramm Button!", id:"btn1", textDir:"rtl"}); |
| 29 | win.body().appendChild(demoWidget.domNode); |
| 30 | win.body().appendChild(domConst.create("br")); |
| 31 | return demoWidget; |
| 32 | } |
| 33 | ready(function(){ |
| 34 | var lre = common.MARK.LRE; |
| 35 | var rle = common.MARK.RLE; |
| 36 | |
| 37 | var button1 = _createButtonProgrammatically(); |
| 38 | var button2 = registry.byId("btn2"); |
| 39 | var button3 = registry.byId("btn3"); |
| 40 | var button4 = registry.byId("btn4"); |
| 41 | var button5 = registry.byId("btn5"); |
| 42 | var button6 = registry.byId("btn6"); |
| 43 | |
| 44 | function getFirstChar(btn){ |
| 45 | var text = btn.domNode.innerHTML; |
| 46 | return text ? text.charAt(0) : ""; |
| 47 | }; |
| 48 | |
| 49 | runner.register("dojox.mobile.test.bidi.doh.ButtonTests", [ |
| 50 | |
| 51 | function test_LTR_TextDir(){ |
| 52 | runner.assertEqual("ltr", button3.get("textDir"), "button textDir should be ltr"); |
| 53 | runner.assertEqual(lre, getFirstChar(button3), "first char should be lte"); |
| 54 | }, |
| 55 | |
| 56 | function test_RTL_TextDir(){ |
| 57 | runner.assertEqual( "rtl", button1.get("textDir"), "button textDir should be rtl"); |
| 58 | runner.assertEqual(rle, getFirstChar(button1), "first char should be rle button1"); |
| 59 | runner.assertEqual("rtl", button2.get("textDir"), "button textDir should be rtl"); |
| 60 | runner.assertEqual(rle, getFirstChar(button2), "first char should be rle button2"); |
| 61 | runner.assertEqual("rtl", button6.get("textDir"), "button textDir should be rtl"); |
| 62 | runner.assertEqual(rle, getFirstChar(button6), "first char should be rle button6"); |
| 63 | }, |
| 64 | |
| 65 | function test_auto_TextDir(){ |
| 66 | runner.assertEqual("auto", button4.get("textDir"), "button textDir should be auto"); |
| 67 | runner.assertEqual(rle, getFirstChar(button4), "first char should be rle button4"); |
| 68 | }, |
| 69 | |
| 70 | function test_change_textDir(){ |
| 71 | button1.set("textDir", "ltr"); |
| 72 | runner.assertEqual("ltr", button1.get("textDir")); |
| 73 | runner.assertEqual(lre, getFirstChar(button1)); |
| 74 | button1.set("textDir", "rtl"); |
| 75 | button2.set("textDir", "auto"); |
| 76 | runner.assertEqual("auto", button2.get("textDir")); |
| 77 | runner.assertEqual(rle, getFirstChar(button2)); |
| 78 | button2.set("textDir", "rtl"); |
| 79 | button3.set("textDir", "rtl"); |
| 80 | runner.assertEqual("rtl", button3.get("textDir")); |
| 81 | runner.assertEqual(rle, getFirstChar(button3)); |
| 82 | button3.set("textDir", "ltr"); |
| 83 | }, |
| 84 | |
| 85 | function test_change_Label(){ |
| 86 | button4.set("label", "New label..."); |
| 87 | runner.assertEqual("auto", button4.get("textDir")); |
| 88 | runner.assertEqual(lre, getFirstChar(button4)); |
| 89 | } |
| 90 | ]); |
| 91 | runner.run(); |
| 92 | }); |
| 93 | }) |
| 94 | </script> |
| 95 | </head> |
| 96 | <body> |
| 97 | <h1 data-dojo-type="dojox.mobile.Heading">Button</h1> |
| 98 | <button data-dojo-type="dojox.mobile.Button" id="btn2" class="mblBlueButton" data-dojo-props='textDir:"rtl"'>חדש blue RTL...</button> |
| 99 | textDir RTL |
| 100 | <hr> |
| 101 | <button data-dojo-type="dojox.mobile.Button" id="btn3" data-dojo-props='textDir:"ltr"' class="mblRedButton">חדש red default LTR...</button> |
| 102 | textDir LTR |
| 103 | <hr> |
| 104 | <button data-dojo-type="dojox.mobile.Button" id="btn4" textDir="auto" disabled>חדש AUTO ...</button> |
| 105 | textDir AUTO |
| 106 | <hr> |
| 107 | <button data-dojo-type="dojox.mobile.Button" id="btn5" disabled>חדש ...</button> |
| 108 | textDir not set |
| 109 | <hr> |
| 110 | <button data-dojo-type="dojox.mobile.Button" id="btn6" class="mblRedButton" data-dojo-props='label:"חדש -new !", textDir:"rtl"'></button> |
| 111 | textDir RTL |
| 112 | </body> |
| 113 | </html> |