Debian Codegraph @

dijit/tests/form/ToggleButtonMixin.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>_ToggleButtonMixin 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 .mblRedButtonChecked {
26 border-style: inset;
27 }
28 </style>
29 <link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/claro/claro.css"/>
30
31 <script type="text/javascript" src="../../../dojo/dojo.js"
32 data-dojo-config="parseOnLoad: true, isDebug: true"></script>
33
34 <script type="text/javascript">
35 dojo.require("doh.runner");
36 dojo.require("dijit.dijit"); // optimize: load dijit layer
37 dojo.require("dijit.form.ToggleButton");
38 dojo.require("dojox.mobile.ToggleButton");
39
40 dojo.ready(function(){
41
42 doh.register("attributes", [
43 {
44 name: "dijit",
45 runTest: function(){
46 var dijit_attributes = dijit.byId('dijit_attributes');
47 doh.t(dijit_attributes.get('checked'), "dijit original get('checked')");
48 doh.t(dojo.hasClass(dijit_attributes.domNode, dijit_attributes.baseClass+"Checked"), "dijit baseClass checked");
49 dijit_attributes.set('checked', false);
50 doh.f(dijit_attributes.get('checked'), "dijit get('checked')");
51 doh.f(dojo.hasClass(dijit_attributes.domNode, dijit_attributes.baseClass+"Checked"), "dijit baseClass not checked");
52 doh.t(dojo.hasClass(dijit_attributes.domNode, dijit_attributes.baseClass), "dijit baseClass");
53 doh.t(dojo.hasClass(dijit_attributes.domNode, "mblRedButton"), "dijit original class");
54 }
55 },
56 {
57 name: "mobile",
58 runTest: function(){
59 var mobile_attributes = dijit.byId('mobile_attributes');
60 doh.t(mobile_attributes.get('checked'), "mobile original get('checked')");
61 doh.t(dojo.hasClass(mobile_attributes.domNode, mobile_attributes.baseClass+"Checked"), "mobile baseClass checked");
62 mobile_attributes.set('checked', false);
63 doh.f(mobile_attributes.get('checked'), "mobile get('checked')");
64 doh.f(dojo.hasClass(mobile_attributes.domNode, mobile_attributes.baseClass+"Checked"), "mobile baseClass not checked");
65 doh.t(dojo.hasClass(mobile_attributes.domNode, mobile_attributes.baseClass), "mobile baseClass");
66 doh.t(dojo.hasClass(mobile_attributes.domNode, "mblRedButton"), "mobile original class");
67 }
68 }
69 ]);
70
71 doh.register("events", [
72 {
73 name: "dijit",
74 timeout: 2000,
75 runTest: function(){
76 var
77 d = new doh.Deferred(),
78 dijit_events = dijit.byId('dijit_events'),
79 calledOnClick = false,
80 nop = function(){ return false; };
81
82 function onChange(v){
83 dijit_events.set('onChange', nop);
84 d.callback(true);
85 }
86 dijit_events.set('onChange', onChange);
87 dijit_events._onClick({
88 preventDefault: nop,
89 stopPropagation: nop
90 });
91
92 return d;
93 }
94 },
95 {
96 name: "mobile",
97 timeout: 2000,
98 runTest: function(){
99 var
100 d = new doh.Deferred(),
101 mobile_events = dijit.byId('mobile_events'),
102 nop = function(){ return false; };
103
104 function onChange(){
105 mobile_events.set('onChange', nop);
106 d.callback(true);
107 }
108 mobile_events.set("onChange", onChange);
109 setTimeout(function(){
110 mobile_events.focusNode.click({
111 preventDefault: nop,
112 stopPropagation: nop
113 });
114 }, 0);
115
116 return d;
117 }
118 }
119 ]);
120
121 doh.register("programmatic", [
122 {
123 name: "dijit",
124 timeout: 2000,
125 runTest: function(){
126 new dijit.form.ToggleButton({id:"dijit_programmatic", type:"button", checked:true, label:"No srcNodeRef", "aria-label":"dijit_programmatic"}).placeAt("dijit_programmatic_container", "first");
127 var dijit_programmatic = dijit.byId('dijit_programmatic');
128 var pos = dojo.position(dijit_programmatic.domNode, true);
129 doh.t(pos.w > 0 && pos.h > 0 && pos.x > 0 && pos.y > 0, 'dijit position');
130 doh.t(dijit_programmatic.get('checked'), 'dijit widget checked');
131 }
132 },
133 {
134 name: "mobile",
135 timeout: 2000,
136 runTest: function(){
137 new dojox.mobile.ToggleButton({id:"mobile_programmatic", type:"button", checked:true, label:"No srcNodeRef", "aria-label":"mobile_programmatic"}).placeAt("mobile_programmatic_container", "first");
138 var mobile_programmatic = dijit.byId('mobile_programmatic');
139 var pos = dojo.position(mobile_programmatic.domNode, true);
140 doh.t(pos.w > 0 && pos.h > 0 && pos.x > 0 && pos.y > 0, 'mobile position');
141 doh.t(mobile_programmatic.get('checked'), 'mobile widget checked');
142 }
143 }
144 ]);
145
146 doh.run();
147 });
148 </script>
149 </head>
150 <body class="claro" role="main">
151 <h1 class="testTitle">_ToggleButtonMixin (dijit and mobile) non-robot tests</h1>
152
153 <table id="table">
154 <tr>
155 <th class="layout">&nbsp;</th>
156 <th class="layout">dijit</th>
157 <th class="layout">mobile</th>
158 </tr>
159 <tr>
160 <td class="layout">attributes</td>
161 <td class="layout"><input id="dijit_attributes" data-dojo-type="dijit/form/ToggleButton" data-dojo-props='type:"button", checked: true, label:"original", "class":"mblRedButton"'/></td>
162 <td class="layout"><button type="button" class="mblRedButton" checked id="mobile_attributes" dojoType="dojox.mobile.ToggleButton" label="original"/></td>
163 </tr>
164 <tr>
165 <tr>
166 <td class="layout">Events</td>
167 <td class="layout"><button id="dijit_events" data-dojo-type="dijit/form/ToggleButton" data-dojo-props='type:"button", onClick:function(){ return true; }'>innerHTML</button></td>
168 <td class="layout"><button type="button" id="mobile_events" data-dojo-type="dojox.mobile.ToggleButton" data-dojo-props='type:"button", onClick:function(){ return true; }'>innerHTML</button></td>
169 </tr>
170 <tr>
171 <td class="layout">Programmatic</td>
172 <td class="layout" id="dijit_programmatic_container"></td>
173 <td class="layout" id="mobile_programmatic_container"></td>
174 </tr>
175 </table>
176 </body>
177 </html>