Debian Codegraph @

dijit/tests/form/ButtonMixin.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
5 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
6 <title>_ButtonMixin tests</title>
7
8 <style type="text/css">
9 @import "../../themes/claro/document.css";
10 @import "../../themes/dijit.css";
11
12 #table {
13 margin: 0;
14 padding: 2px;
15 }
16 #table, .dijit, BUTTON {
17 font-family: monospace;
18 font-size: 12pt;
19 }
20 #table .layout {
21 padding: 2px;
22 font-size: 100%;
23 margin: 0;
24 }
25 </style>
26 <link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/claro/claro.css"/>
27
28 <script type="text/javascript" src="../../../dojo/dojo.js"
29 data-dojo-config="parseOnLoad: true, isDebug: true"></script>
30
31 <script type="text/javascript">
32 dojo.require("doh.runner");
33 dojo.require("dijit.dijit"); // optimize: load dijit layer
34 dojo.require("dijit.Dialog");
35 dojo.require("dijit.form.Button");
36 dojo.require("dojox.mobile.Button");
37
38 dojo.ready(function(){
39
40 doh.register("attributes", [
41 {
42 name: "dijit",
43 runTest: function(){
44 var dijit_attributes = dijit.byId('dijit_attributes');
45 doh.is("original", dijit_attributes.get('label'), "dijit original get('label')");
46 dijit_attributes.set('label', "label");
47 doh.is("label", dijit_attributes.get('label'), "dijit get('label')");
48 doh.t(dojo.hasClass(dijit_attributes.domNode, dijit_attributes.baseClass), "dijit baseClass");
49 doh.t(dojo.hasClass(dijit_attributes.domNode, "mblRedButton"), "dijit original class");
50 dijit_attributes.set('class', "mblBlueButton");
51 doh.t(dojo.hasClass(dijit_attributes.domNode, "mblBlueButton"), "dijit new class");
52 }
53 },
54 {
55 name: "mobile",
56 runTest: function(){
57 var mobile_attributes = dijit.byId('mobile_attributes');
58 doh.is("original", mobile_attributes.get('label'), "mobile original get('label')");
59 mobile_attributes.set('label', "label");
60 doh.is("label", mobile_attributes.get('label'), "mobile get('label')");
61 doh.t(dojo.hasClass(mobile_attributes.domNode, mobile_attributes.baseClass), "mobile baseClass");
62 doh.t(dojo.hasClass(mobile_attributes.domNode, "mblRedButton"), "mobile original class");
63 mobile_attributes.set('class', "mblBlueButton");
64 doh.t(dojo.hasClass(mobile_attributes.domNode, "mblBlueButton"), "mobile new class");
65 }
66 }
67 ]);
68
69 doh.register("programmatic", [
70 {
71 name: "dijit",
72 timeout: 2000,
73 runTest: function(){
74 new dijit.form.Button({id:"dijit_programmatic", type:"button", label:"No srcNodeRef"}).placeAt("dijit_programmatic_container", "first");
75 var dijit_programmatic = dijit.byId('dijit_programmatic');
76 var pos = dojo.position(dijit_programmatic.domNode, true);
77 doh.t(pos.w > 0 && pos.h > 0 && pos.x > 0 && pos.y > 0, 'dijit position');
78 doh.is("No srcNodeRef", dijit_programmatic.get('label'), 'dijit widget label');
79 }
80 },
81 {
82 name: "mobile",
83 timeout: 2000,
84 runTest: function(){
85 new dojox.mobile.Button({id:"mobile_programmatic", type:"button", label:"No srcNodeRef"}).placeAt("mobile_programmatic_container", "first");
86 var mobile_programmatic = dijit.byId('mobile_programmatic');
87 var pos = dojo.position(mobile_programmatic.domNode, true);
88 doh.t(pos.w > 0 && pos.h > 0 && pos.x > 0 && pos.y > 0, 'mobile position');
89 doh.is("No srcNodeRef", mobile_programmatic.get('label'), 'mobile widget label');
90 }
91 }
92 ]);
93
94 var runTests = function(t,i){
95 var d = new doh.Deferred(),
96 form = document.getElementById('myform'),
97 clicks = document.getElementById('clicks'),
98 submits = document.getElementById('submits'),
99 bubbles = document.getElementById('bubbles');
100 form.reset();
101 document.getElementById('native'+i).click();
102 setTimeout(function(){
103 var nativeClicks = clicks.value;
104 var nativeSubmits = submits.value;
105 var nativeBubbles = bubbles.value;
106 form.reset();
107 document.getElementById('widget'+i).click();
108 setTimeout(function(){
109 var widgetClicks = clicks.value;
110 var widgetSubmits = submits.value;
111 var widgetBubbles = bubbles.value;
112 form.reset();
113 document.getElementById('mobile'+i).click();
114 setTimeout(function(){
115 var mobileClicks = clicks.value;
116 var mobileSubmits = submits.value;
117 var mobileBubbles = bubbles.value;
118 form.reset();
119 document.getElementById('dialogButton'+i).click();
120 setTimeout(d.getTestCallback(function(){
121 var dialogClicks = clicks.value;
122 var dialogSubmits = submits.value;
123 var dialogBubbles = bubbles.value;
124 t.is(nativeClicks, widgetClicks, "widget clicks");
125 t.is(nativeSubmits, widgetSubmits, "widget submits");
126 t.is(nativeBubbles, widgetBubbles, "widget bubbles");
127 t.isNot("000", widgetClicks+""+widgetSubmits+""+widgetBubbles, "not all 0");
128 t.is(nativeClicks, mobileClicks, "mobile clicks");
129 t.is(nativeSubmits, mobileSubmits, "mobile submits");
130 t.is(nativeBubbles, mobileBubbles, "mobile bubbles");
131 t.is(nativeClicks, dialogClicks, "dialog clicks");
132 t.is(nativeSubmits, dialogSubmits, "dialog submits");
133 t.is(nativeBubbles, dialogBubbles, "dialog bubbles");
134 }), 0);
135 }, 0);
136 }, 0);
137 }, 0);
138 return d;
139 };
140
141 doh.register("click behavior", [
142 {
143 name: "return true",
144 timeout: 1000,
145 runTest: function(t){
146 runTests(t,1);
147 }
148 },
149 {
150 name: "return false",
151 timeout: 1000,
152 runTest: function(t){
153 runTests(t,2);
154 }
155 },
156 {
157 name: "stopProgation + return true",
158 timeout: 1000,
159 runTest: function(t){
160 runTests(t,3);
161 }
162 },
163 {
164 name: "stopProgation + return false",
165 timeout: 1000,
166 runTest: function(t){
167 runTests(t,4);
168 }
169 },
170 {
171 name: "preventDefault + return true",
172 timeout: 1000,
173 runTest: function(t){
174 runTests(t,5);
175 }
176 },
177 {
178 name: "preventDefault + return false",
179 timeout: 1000,
180 runTest: function(t){
181 runTests(t,6);
182 }
183 }
184 ]);
185
186 doh.run();
187 });
188 </script>
189 </head>
190 <body class="claro" role="main">
191 <h1 class="testTitle">_ButtonMixin (dijit and mobile) non-robot tests</h1>
192
193 <table id="table">
194 <tr>
195 <th class="layout">&nbsp;</th>
196 <th class="layout">dijit</th>
197 <th class="layout">mobile</th>
198 </tr>
199 <tr>
200 <td class="layout">attributes</td>
201 <td class="layout"><input id="dijit_attributes" data-dojo-type="dijit/form/Button" data-dojo-props='type:"button", label:"original", "class":"mblRedButton"'/></td>
202 <td class="layout"><button type="button" class="mblRedButton" id="mobile_attributes" dojoType="dojox.mobile.Button" label="original"/></td>
203 </tr>
204 <tr>
205 <td class="layout">Programmatic</td>
206 <td class="layout" id="dijit_programmatic_container"></td>
207 <td class="layout" id="mobile_programmatic_container"></td>
208 </tr>
209 </table>
210 <form id="myform" method="get" onsubmit="document.getElementById('submits').value++;return false" onclick="document.getElementById('bubbles').value++;return true;" style="border:1px solid black;margin:10px 0;">
211 <legend>Compare native and widget click event behavior:</legend>
212 <label for="submits">Submits</label><input id="submits" size="4" disabled value="0">
213 <label for="bubbles">Bubbles</label><input id="bubbles" size="4" disabled value="0">
214 <label for="clicks">Clicks</label><input id="clicks" size="4" disabled value="0">
215 <input type="reset" id="formContainerReset">
216 <br>
217 <button id="native1" type="submit" onclick="document.getElementById('clicks').value++;return true;">native return true</button>
218 <button id="widget1" type="submit" onclick="document.getElementById('clicks').value++;return true;" data-dojo-type="dijit/form/Button">widget return true</button>
219 <button id="mobile1" type="submit" onclick="document.getElementById('clicks').value++;return true;" data-dojo-type="dojox/mobile/Button">mobile return true</button>
220 <button id="dialog1" type="button" onclick="arguments[0].stopPropagation();arguments[0].preventDefault();document.getElementById('dialogButton1').click();return false;" data-dojo-type="dijit/form/Button">dialog return true</button>
221 <br>
222 <button id="native2" type="submit" onclick="document.getElementById('clicks').value++;return false;">native return false</button>
223 <button id="widget2" type="submit" onclick="document.getElementById('clicks').value++;return false;" data-dojo-type="dijit/form/Button">widget return false</button>
224 <button id="mobile2" type="submit" onclick="document.getElementById('clicks').value++;return false;" data-dojo-type="dojox/mobile/Button">mobile return false</button>
225 <button id="dialog2" type="button" onclick="arguments[0].stopPropagation();arguments[0].preventDefault();document.getElementById('dialogButton2').click();return false;" data-dojo-type="dijit/form/Button">dialog return false</button>
226 <br>
227 <button id="native3" type="submit" onclick="document.getElementById('clicks').value++;arguments[0].stopPropagation();return true;">native stopPropagation + return true</button>
228 <button id="widget3" type="submit" onclick="document.getElementById('clicks').value++;arguments[0].stopPropagation();return true;" data-dojo-type="dijit/form/Button">widget stopPropagation + return true</button>
229 <button id="mobile3" type="submit" onclick="document.getElementById('clicks').value++;arguments[0].stopPropagation();return true;" data-dojo-type="dojox/mobile/Button">mobile stopPropagation + return true</button>
230 <button id="dialog3" type="button" onclick="arguments[0].stopPropagation();arguments[0].preventDefault();document.getElementById('dialogButton3').click();return false;" data-dojo-type="dijit/form/Button">dialog stopPropagation + return true</button>
231 <br>
232 <button id="native4" type="submit" onclick="document.getElementById('clicks').value++;arguments[0].stopPropagation();return false;">native stopPropagation + return false</button>
233 <button id="widget4" type="submit" onclick="document.getElementById('clicks').value++;arguments[0].stopPropagation();return false;" data-dojo-type="dijit/form/Button">widget stopPropagation + return false</button>
234 <button id="mobile4" type="submit" onclick="document.getElementById('clicks').value++;arguments[0].stopPropagation();return false;" data-dojo-type="dojox/mobile/Button">mobile stopPropagation + return false</button>
235 <button id="dialog4" type="button" onclick="arguments[0].stopPropagation();arguments[0].preventDefault();document.getElementById('dialogButton4').click();return false;" data-dojo-type="dijit/form/Button">dialog stopPropagation + return false</button>
236 <br>
237 <button id="native5" type="submit" onclick="document.getElementById('clicks').value++;arguments[0].preventDefault();return true;">native preventDefault + return true</button>
238 <button id="widget5" type="submit" onclick="document.getElementById('clicks').value++;arguments[0].preventDefault();return true;" data-dojo-type="dijit/form/Button">widget preventDefault + return true</button>
239 <button id="mobile5" type="submit" onclick="document.getElementById('clicks').value++;arguments[0].preventDefault();return true;" data-dojo-type="dojox/mobile/Button">mobile preventDefault + return true</button>
240 <button id="dialog5" type="button" onclick="arguments[0].stopPropagation();arguments[0].preventDefault();document.getElementById('dialogButton5').click();return false;" data-dojo-type="dijit/form/Button">dialog preventDefault + return true</button>
241 <br>
242 <button id="native6" type="submit" onclick="document.getElementById('clicks').value++;arguments[0].preventDefault();return false;">native preventDefault + return false</button>
243 <button id="widget6" type="submit" onclick="document.getElementById('clicks').value++;arguments[0].preventDefault();return false;" data-dojo-type="dijit/form/Button">widget preventDefault + return false</button>
244 <button id="mobile6" type="submit" onclick="document.getElementById('clicks').value++;arguments[0].preventDefault();return false;" data-dojo-type="dojox/mobile/Button">mobile preventDefault + return false</button>
245 <button id="dialog6" type="button" onclick="arguments[0].stopPropagation();arguments[0].preventDefault();document.getElementById('dialogButton6').click();return false;" data-dojo-type="dijit/form/Button">dialog preventDefault + return false</button>
246 </form>
247 <div data-dojo-type="dijit/Dialog" onExecute="document.getElementById('submits').value++;return false" onclick="document.getElementById('bubbles').value++;return true;">
248 <button id="dialogButton1" type="submit" onclick="document.getElementById('clicks').value++;return true;" data-dojo-type="dijit/form/Button"></button>
249 <button id="dialogButton2" type="submit" onclick="document.getElementById('clicks').value++;return false;" data-dojo-type="dijit/form/Button"></button>
250 <button id="dialogButton3" type="submit" onclick="document.getElementById('clicks').value++;arguments[0].stopPropagation();return true;" data-dojo-type="dijit/form/Button"></button>
251 <button id="dialogButton4" type="submit" onclick="document.getElementById('clicks').value++;arguments[0].stopPropagation();return false;" data-dojo-type="dijit/form/Button"></button>
252 <button id="dialogButton5" type="submit" onclick="document.getElementById('clicks').value++;arguments[0].preventDefault();return true;" data-dojo-type="dijit/form/Button"></button>
253 <button id="dialogButton6" type="submit" onclick="document.getElementById('clicks').value++;arguments[0].preventDefault();return false;" data-dojo-type="dijit/form/Button"></button>
254 </div>
255 </body>
256 </html>