| 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>Switch</title> |
| 8 | |
| 9 | <script type="text/javascript" src="../../../deviceTheme.js" data-dojo-config="mblThemeFiles: ['base']"></script> |
| 10 | <script type="text/javascript" src="../../../../../dojo/dojo.js" data-dojo-config="async: true,parseOnLoad: true, has: {'dojo-bidi': true }"></script> |
| 11 | |
| 12 | <script type="text/javascript"> |
| 13 | require([ |
| 14 | "dijit/registry", |
| 15 | "doh/runner", |
| 16 | "dojo/dom", |
| 17 | "dojo/ready", |
| 18 | "dojo/query", |
| 19 | "dojox/mobile/Switch", |
| 20 | "dojox/mobile", |
| 21 | "dojox/mobile/compat", |
| 22 | "dojox/mobile/parser", |
| 23 | "dojox/mobile/Button" |
| 24 | ], function(registry,runner,dom,ready,query){ |
| 25 | ready(function(){ |
| 26 | runner.register("Bidi Switch", [ |
| 27 | { |
| 28 | name: "mobile", |
| 29 | runTest: function(){ |
| 30 | runner.is(String.fromCharCode(8235), registry.byId('first').right.firstChild.innerHTML.charAt(0), "right text node of first switch item inherits textDir attribute from container"); |
| 31 | runner.is(String.fromCharCode(8235), registry.byId('third').right.firstChild.innerHTML.charAt(0), "text direction of right text node of third switch item has been set to 'rtl' explicitly"); |
| 32 | |
| 33 | registry.byId('second').set("textDir","rtl"); |
| 34 | var node = query(".mblSwitchTextRight",dom.byId('second'))[0]; |
| 35 | runner.is(String.fromCharCode(8235), node.innerHTML.charAt(0), "node had direction changed after change of 'textDir'"); |
| 36 | } |
| 37 | } |
| 38 | ]); |
| 39 | |
| 40 | runner.register("log", function(){ |
| 41 | dom.byId('failures').innerHTML = runner._failureCount; |
| 42 | dom.byId('errors').innerHTML = runner._errorCount; |
| 43 | }); |
| 44 | |
| 45 | runner.run(); |
| 46 | }); |
| 47 | }, |
| 48 | toggleTextDir = function(){ |
| 49 | w2 = dijit.registry.byId("first"); |
| 50 | w2.set("textDir", (w2.get("textDir") !== "rtl") ? "rtl" : "ltr"); |
| 51 | }); |
| 52 | </script> |
| 53 | |
| 54 | <style> |
| 55 | .color1 .mblSwitchBgLeft { |
| 56 | background: -webkit-gradient(linear, left top, left bottom, from(#28B159), to(#75FBAC), color-stop(0.5, #3FEB84), color-stop(0.5, #4CEE8E)); |
| 57 | } |
| 58 | .color1 .mblSwitchBgRight { |
| 59 | background: -webkit-gradient(linear, left top, left bottom, from(#CECECE), to(#FDFDFD), color-stop(0.5, #EEEEEE), color-stop(0.5, #F8F8F8)); |
| 60 | } |
| 61 | .color2 .mblSwitchBgLeft { |
| 62 | background: -webkit-gradient(linear, left top, left bottom, from(#FF9D00), to(#FFCE80), color-stop(0.5, #FFBB4D), color-stop(0.5, #FFC871)); |
| 63 | } |
| 64 | .color2 .mblSwitchBgRight { |
| 65 | background: -webkit-gradient(linear, left top, left bottom, from(#CECECE), to(#FDFDFD), color-stop(0.5, #EEEEEE), color-stop(0.5, #F8F8F8)); |
| 66 | } |
| 67 | .color1 .mblSwitchKnob, |
| 68 | .color2 .mblSwitchKnob { |
| 69 | background: -webkit-gradient(linear, left top, left bottom, from(#999999), to(#FAFAFA), color-stop(0.5, #BBBBBB), color-stop(0.5, #CACACA)); |
| 70 | } |
| 71 | .mblSwitch { |
| 72 | margin-right: 10px; |
| 73 | } |
| 74 | .bold { |
| 75 | font-weight: bold; |
| 76 | } |
| 77 | </style> |
| 78 | </head> |
| 79 | <body style="visibility:hidden;"> |
| 80 | <button data-dojo-type="dojox.mobile.Button" data-dojo-props='type:"button", onClick:function(){ toggleTextDir(); }'>Toggle textDir of first switch</button> |
| 81 | <br> |
| 82 | <div data-dojo-type="dojox/mobile/View"> |
| 83 | <div data-dojo-type="dojox/mobile/RoundRect" data-dojo-props='shadow:true, textDir:"rtl"'> |
| 84 | <span class="bold">Default Shape</span><br> |
| 85 | <div data-dojo-type="dojox/mobile/Switch" data-dojo-props='value:"off"'></div> |
| 86 | <div id="first" class="color1" data-dojo-type="dojox/mobile/Switch" data-dojo-props='value:"on", leftLabel:"Start.", rightLabel:"Stop."'></div> |
| 87 | </div> |
| 88 | |
| 89 | <div data-dojo-type="dojox/mobile/RoundRect" data-dojo-props='shadow:true'> |
| 90 | <span class="bold">Square Shape</span><br> |
| 91 | <div class="mblSwSquareShape" data-dojo-type="dojox/mobile/Switch" data-dojo-props='value:"off"'></div> |
| 92 | <div id="second" class="color2" data-dojo-type="dojox/mobile/Switch" data-dojo-props='value:"on", leftLabel:"Start.", rightLabel:"Stop.", shape:"mblSwSquareShape"'></div> |
| 93 | </div> |
| 94 | |
| 95 | <div data-dojo-type="dojox/mobile/RoundRect" data-dojo-props='shadow:true, textDir:"ltr"'> |
| 96 | <span class="bold">Round Shape 1</span><br> |
| 97 | <div class="mblSwRoundShape1" data-dojo-type="dojox/mobile/Switch" data-dojo-props='value:"off" '></div> |
| 98 | <div id="third" class="color1" data-dojo-type="dojox/mobile/Switch" data-dojo-props='value:"on",textDir:"rtl", leftLabel:"Start.", rightLabel:"Stop.", shape:"mblSwRoundShape1"'></div> |
| 99 | </div> |
| 100 | </div> |
| 101 | <br>Errors: <span id="errors">?</span> |
| 102 | <br>Failures: <span id="failures">?</span> |
| 103 | </body> |
| 104 | </html> |