| 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>TabBar 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/_base/array", |
| 15 | "dojo/dom-construct", // dojo.place |
| 16 | "dojo/_base/window", |
| 17 | "dojo/ready", // dojo.ready |
| 18 | "dijit/registry", // dijit.byId |
| 19 | "doh/runner", //doh functions |
| 20 | "dojox/mobile/bidi/common", |
| 21 | "dojox/mobile/TabBar", |
| 22 | "dojox/mobile/TabBarButton", |
| 23 | "dojox/mobile", // This is a mobile app. |
| 24 | "dojox/mobile/compat", // This mobile app supports running on desktop browsers |
| 25 | "dojox/mobile/parser" // This mobile app uses declarative programming with fast mobile parser |
| 26 | |
| 27 | ], function(has, array, domConst, win, ready, registry, runner, common, TabBar, TabBarButton){ |
| 28 | |
| 29 | function _createTabBarProgrammatically(){ |
| 30 | domConst.create("div", {className:"label", innerHTML:"Segmented Control"}, win.body()); |
| 31 | var tabBar = new TabBar({barType:"segmentedControl"}); |
| 32 | win.body().appendChild(tabBar.domNode); |
| 33 | tabBar.startup(); |
| 34 | |
| 35 | var tabBarButton = new TabBarButton({moveTo:"view1", textDir:"rtl", selected:"true", label:"Hello \u05e9\u05dc\u05d5\u05dd\u0021"}); |
| 36 | tabBar.addChild(tabBarButton); |
| 37 | tabBarButton = new TabBarButton({moveTo:"view2", textDir:"rtl", label:"\u05e9\u05dc\u05d5\u05dd\ - hello!"}); |
| 38 | tabBar.addChild(tabBarButton); |
| 39 | tabBarButton = new TabBarButton({moveTo:"view3", textDir:"rtl", label:"Genius"}); |
| 40 | tabBar.addChild(tabBarButton); |
| 41 | tabBar.resize(); |
| 42 | |
| 43 | return tabBar; |
| 44 | } |
| 45 | ready(function(){ |
| 46 | var tabbar = _createTabBarProgrammatically(); |
| 47 | var btn; |
| 48 | var lre = common.MARK.LRE; |
| 49 | var rle = common.MARK.RLE; |
| 50 | |
| 51 | function getFirstChar(obj){ |
| 52 | var node = obj.labelNode; |
| 53 | var text = node.innerHTML; |
| 54 | return text ? text.charAt(0) : ""; |
| 55 | }; |
| 56 | |
| 57 | runner.register("dojox.mobile.test.bidi.doh.HeadingTests", [ |
| 58 | |
| 59 | function test_LTR_TextDir_tabBarButton(){ |
| 60 | btn = registry.byId("tbb13"); |
| 61 | runner.assertEqual("ltr", btn.get("textDir")); |
| 62 | runner.assertEqual(lre, getFirstChar(btn)); |
| 63 | }, |
| 64 | |
| 65 | function test_RTL_TextDir_tabBarButton(){ |
| 66 | btn = registry.byId("tbb11"); |
| 67 | runner.assertEqual("rtl", btn.get("textDir")); |
| 68 | runner.assertEqual(rle, getFirstChar(btn)); |
| 69 | btn = registry.byId("tbb12"); |
| 70 | }, |
| 71 | |
| 72 | function test_auto_TextDir_tabBarButton(){ |
| 73 | btn = registry.byId("tbb21"); |
| 74 | runner.assertEqual("auto", btn.get("textDir")); |
| 75 | runner.assertEqual(rle, getFirstChar(btn)); |
| 76 | btn = registry.byId("tbb22"); |
| 77 | runner.assertEqual("auto", btn.get("textDir")); |
| 78 | runner.assertEqual(lre, getFirstChar(btn)); |
| 79 | btn = registry.byId("tbb23"); |
| 80 | runner.assertEqual("auto", btn.get("textDir")); |
| 81 | runner.assertEqual(lre, getFirstChar(btn)); |
| 82 | }, |
| 83 | |
| 84 | function test_TextDir_Badge(){ |
| 85 | btn = registry.byId("tbb31"); |
| 86 | runner.assertEqual("auto", btn.badgeObj.textDir); |
| 87 | runner.assertEqual(lre, btn.badgeObj.getValue().charAt(0)); |
| 88 | btn = registry.byId("tbb32"); |
| 89 | runner.assertEqual("auto", btn.badgeObj.textDir); |
| 90 | runner.assertEqual(rle, btn.badgeObj.getValue().charAt(0)); |
| 91 | |
| 92 | }, |
| 93 | |
| 94 | function test_change_textDir(){ |
| 95 | var tb = registry.byId("tab1"); |
| 96 | tb.set("textDir", "rtl"); |
| 97 | runner.assertEqual("rtl", tb.get("textDir")); |
| 98 | btn = registry.byId("tbb13"); |
| 99 | runner.assertEqual("rtl", btn.get("textDir")); |
| 100 | runner.assertEqual(rle, getFirstChar(btn)); |
| 101 | }, |
| 102 | |
| 103 | function test_change_Label(){ |
| 104 | btn = registry.byId("tbb21"); |
| 105 | btn.set("label", "New Label!") |
| 106 | runner.assertEqual("auto", btn.get("textDir")); |
| 107 | runner.assertEqual(lre, getFirstChar(btn)); |
| 108 | btn = registry.byId("tbb22"); |
| 109 | btn.set("label", "\u05e9\u05dc\u05d5\u05dd\u0021\u0021") |
| 110 | runner.assertEqual("auto", btn.get("textDir")); |
| 111 | runner.assertEqual(rle, getFirstChar(btn)); |
| 112 | }, |
| 113 | |
| 114 | function test_program_created_TBButton(){ |
| 115 | var children = tabbar.getChildren(); |
| 116 | array.forEach(children, function(ch){ |
| 117 | runner.assertEqual("rtl", ch.get("textDir")); |
| 118 | runner.assertEqual(rle, getFirstChar(ch)); |
| 119 | }, this); |
| 120 | |
| 121 | } |
| 122 | ]); |
| 123 | runner.run(); |
| 124 | }); |
| 125 | }) |
| 126 | </script> |
| 127 | </head> |
| 128 | <body> |
| 129 | |
| 130 | |
| 131 | <h3> textDir for TabBarButton </h3> |
| 132 | <ul data-dojo-type="dojox.mobile.TabBar" id="tab1" data-dojo-props='barType:"segmentedControl", textDir:"ltr"'> |
| 133 | <li data-dojo-type="dojox.mobile.TabBarButton" id="tbb11" data-dojo-props='selected:true, icon1:"../../images/tab-icon-21.png", icon2:"../../images/tab-icon-21h.png",textDir:"rtl"'>New חדש !</li> |
| 134 | <li data-dojo-type="dojox.mobile.TabBarButton" id="tbb12" data-dojo-props='textDir:"rtl"'>חדש RTL ...</li> |
| 135 | <li data-dojo-type="dojox.mobile.TabBarButton" id="tbb13" data-dojo-props='textDir:"ltr"'>חדש LTR...</li> |
| 136 | </ul> |
| 137 | |
| 138 | <div class="label">textDir RTL in Heading, textDir AUTO in TabBar </div> |
| 139 | <div data-dojo-type="dojox.mobile.Heading" textDir="rtl"> |
| 140 | <ul data-dojo-type="dojox.mobile.TabBar" id="tab2" data-dojo-props='barType:"segmentedControl", textDir:"auto"'> |
| 141 | <li data-dojo-type="dojox.mobile.TabBarButton" id="tbb21" data-dojo-props='selected:true'>חדש Catalog</li> |
| 142 | <li data-dojo-type="dojox.mobile.TabBarButton" id="tbb22" >Share ...</li> |
| 143 | <li data-dojo-type="dojox.mobile.TabBarButton" id="tbb23" >Start חדש!! </li> |
| 144 | </ul> |
| 145 | <span data-dojo-type="dojox.mobile.ToolBarButton" data-dojo-props=''>Button...</span> |
| 146 | </div><br> |
| 147 | <h3> TabBar with badge textDir AUTO</h3> |
| 148 | <ul data-dojo-type="dojox.mobile.TabBar" id="tab3" data-dojo-props='barType:"standardTab", textDir:"auto", closable:true, center:false'> |
| 149 | <li data-dojo-type="dojox.mobile.TabBarButton" id="tbb31" data-dojo-props='selected:true, badge:"New..."'>Dashboard...</li> |
| 150 | <li data-dojo-type="dojox.mobile.TabBarButton" id="tbb32" data-dojo-props='selected:true, badge:"חדש..."'>חדש!</li> |
| 151 | <li data-dojo-type="dojox.mobile.TabBarButton">Today's Main Event</li> |
| 152 | </ul><br> |
| 153 | |
| 154 | <h3> textDir for Mirrored TabBarButton </h3> |
| 155 | <ul data-dojo-type="dojox.mobile.TabBar" data-dojo-props='barType:"segmentedControl"'> |
| 156 | <li data-dojo-type="dojox.mobile.TabBarButton" data-dojo-props='selected:true, icon1:"../../images/tab-icon-21.png", icon2:"../../images/tab-icon-21h.png",textDir:"auto"'>חדש New</li> |
| 157 | <li data-dojo-type="dojox.mobile.TabBarButton" data-dojo-props='textDir:"rtl"'>חדש RTL ...</li> |
| 158 | <li data-dojo-type="dojox.mobile.TabBarButton" data-dojo-props='textDir:"ltr"'>חדש LTR...</li> |
| 159 | </ul> |
| 160 | |
| 161 | <div data-dojo-type="dojox.mobile.Heading" textDir="rtl"> |
| 162 | <ul data-dojo-type="dojox.mobile.TabBar" data-dojo-props='barType:"segmentedControl", textDir:"auto"'> |
| 163 | <li data-dojo-type="dojox.mobile.TabBarButton" data-dojo-props='selected:true'>חדש Catalog</li> |
| 164 | <li data-dojo-type="dojox.mobile.TabBarButton">Share ...</li> |
| 165 | <li data-dojo-type="dojox.mobile.TabBarButton">Start חדש!! </li> |
| 166 | </ul> |
| 167 | <span data-dojo-type="dojox.mobile.ToolBarButton" data-dojo-props=''>Button...</span> |
| 168 | </div><br> |
| 169 | </body> |
| 170 | </html> |