Debian Codegraph @

dojox/mobile/tests/doh/textbox/TextBoxTests.html

raw symbols SCIP
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>TextBox 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"></script>
10 <script language="JavaScript" type="text/javascript">
11 var WIDGET_CLASSNAME1 = "mblTextBox";
12 var WIDGET_ANCHOR_CLASSNAME1 = "mblListItemAnchor";
13 var WIDGET_ANCHOR_CLASSNAME2 = "mblListItemAnchorNoIcon";
14 var WIDGET_ICON_CLASSNAME1 = "mblListItemIcon";
15 var WIDGET_RIGHTICON_CLASSNAME1 = "mblListItemRightIcon";
16 var WIDGET_DOMBUTTON_ARROW = "mblDomButtonArrow";
17 var WIDGET_DOMBUTTON_BLUEPLUS = "mblDomButtonBluePlus";
18 var WIDGET_DOMBUTTON_CHECKBOX_ON = "mblDomButtonCheckboxOn";
19 var WIDGET_VALUE = "";
20 var WIDGET_NEW_VALUE = "123456789";
21
22 require([
23 "dojo/_base/connect",
24 "dojo/dom-construct", // dojo.place
25 "dojo/dom-class", // dojo.hasClass
26 "dojo/ready", // dojo.ready
27 "dijit/registry", // dijit.byId
28 "dojo/string", // dojo.trim
29 "doh/runner", //doh functions
30 "dojox/mobile/TextBox",
31 "dojox/mobile", // This is a mobile app.
32 "dojox/mobile/View", // This mobile app uses mobile view
33 "dojox/mobile/compat", // This mobile app supports running on desktop browsers
34 "dojox/mobile/parser" // This mobile app uses declarative programming with fast mobile parser
35 ], function(connect, domConst, domClass, ready, registry, string, runner, TextBox){
36
37 function _createTextBoxDeclaratively(widgetId) {
38 return registry.byId(widgetId);
39 };
40
41 function _createTextBoxProgrammatically(placeHolderId, widgetId){
42 var r = new TextBox({id:widgetId, maxLength:"9", placeHolder:"max 9 chars", selectOnClick:"true"});
43 runner.assertNotEqual(null, r);
44 domConst.place(r.domNode, placeHolderId, "replace");
45 r.startup();
46
47 return r;
48 };
49
50 function _createTextBoxProgrammaticallyWithSourceNodeReference(widgetId){
51 // Create IconContainer
52 var r = new TextBox({selectOnClick:"true"}, widgetId);
53 r.startup();
54
55 return r;
56 };
57
58 function _assertCorrectTextBox(widget, noIcon, rightIcon, rightIcon2, rightText, boxText){
59 runner.assertNotEqual(null, widget, "TextBox: Did not instantiate. id=" + widget.domNode.id);
60 runner.assertTrue(domClass.contains(widget.domNode, WIDGET_CLASSNAME1), WIDGET_CLASSNAME1 + " id=" + widget.domNode.id);
61 runner.assertEqual(WIDGET_VALUE, widget.textbox.value);
62 runner.assertEqual(WIDGET_VALUE, widget.get('value'));
63 widget.set('value', WIDGET_NEW_VALUE);
64 runner.assertEqual(WIDGET_NEW_VALUE, widget.get('value'));
65 runner.assertEqual(WIDGET_NEW_VALUE, widget.textbox.value);
66 };
67
68 function _showView2(){
69 var view1 = registry.byId("view1");
70 view1.performTransition("view2", 1, "none");
71 };
72
73 ready(function(){
74 runner.register("dojox.mobile.test.doh.TextBox", [
75 {
76 name: "TextBox Verification1",
77 timeout: 4000,
78 runTest: function(){
79 var widget1 = _createTextBoxDeclaratively("view1-TextBox1");
80 var widget2 = _createTextBoxProgrammatically("view1-TextBox2Place", "view1-TextBox2");
81 var widget3 = _createTextBoxProgrammaticallyWithSourceNodeReference("view1-TextBox3");
82
83 _assertCorrectTextBox(widget1);
84 _assertCorrectTextBox(widget2);
85 _assertCorrectTextBox(widget3);
86 }
87 },
88 {
89 name: "TextBox Verification2",
90 timeout: 4000,
91 runTest: function(){
92 var widget1 = _createTextBoxDeclaratively("view2-TextBox1");
93 var widget2 = _createTextBoxProgrammatically("view2-TextBox2Place", "view2-TextBox2");
94 var widget3 = _createTextBoxProgrammaticallyWithSourceNodeReference("view2-TextBox3");
95
96 var d = new runner.Deferred();
97 var handle2 = connect.subscribe("/dojox/mobile/afterTransitionIn", d.getTestCallback(function(view){
98 if(view.id=="view2"){
99 connect.unsubscribe(handle2);
100 }
101 _assertCorrectTextBox(widget1);
102 _assertCorrectTextBox(widget2);
103 _assertCorrectTextBox(widget3);
104 }));
105 _showView2();
106 return d;
107 }
108 }
109 ]);
110 runner.run();
111 });
112 })
113 </script>
114 </head>
115 <body style="visibility:hidden;">
116 <div id="view1" data-dojo-type="dojox.mobile.View" data-dojo-props='selected:"true"'>
117 <h1>View1</h1>
118 <table>
119 <tr>
120 <td valign="top"><span class="bold">TextBox</span></td>
121 <td align="right"><input id="view1-TextBox1" data-dojo-type="dojox.mobile.TextBox" maxLength="9" placeHolder="max 9 chars" data-dojo-props='selectOnClick:"true"'></td>
122 </tr>
123 </table>
124 <table>
125 <tr>
126 <td valign="top"><span class="bold">TextBox</span></td>
127 <td align="right"><div id="view1-TextBox2Place"></div></td>
128 </tr>
129 </table>
130 <table>
131 <tr>
132 <td valign="top"><span class="bold">TextBox</span></td>
133 <td align="right"><input id="view1-TextBox3" maxLength="9" placeHolder="max 9 chars"></td>
134 </tr>
135 </table>
136 </div>
137 <div id="view2" data-dojo-type="dojox.mobile.View">
138 <h1>View2</h1>
139 <table>
140 <tr>
141 <td valign="top"><span class="bold">TextBox</span></td>
142 <td align="right"><input id="view2-TextBox1" data-dojo-type="dojox.mobile.TextBox" maxLength="9" placeHolder="max 9 chars" data-dojo-props='selectOnClick:"true"'></td>
143 </tr>
144 </table>
145 <table>
146 <tr>
147 <td valign="top"><span class="bold">TextBox</span></td>
148 <td align="right"><div id="view2-TextBox2Place"></div></td>
149 </tr>
150 </table>
151 <table>
152 <tr>
153 <td valign="top"><span class="bold">TextBox</span></td>
154 <td align="right"><input id="view2-TextBox3" maxLength="9" placeHolder="max 9 chars"></td>
155 </tr>
156 </table>
157 </div>
158 </body>
159 </html>