2150 |
mathias |
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
|
|
2 |
"http://www.w3.org/TR/html4/strict.dtd">
|
|
|
3 |
<html>
|
|
|
4 |
<head>
|
|
|
5 |
<title>Dojo Button Widget Test</title>
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
<script type="text/javascript" src="../../../dojo/dojo.js"
|
|
|
9 |
djConfig="isDebug: true, parseOnLoad: true"></script>
|
|
|
10 |
<script type="text/javascript" src="../_testCommon.js"></script>
|
|
|
11 |
|
|
|
12 |
<script type="text/javascript">
|
|
|
13 |
dojo.require("dijit.ColorPalette");
|
|
|
14 |
dojo.require("dijit.Menu");
|
|
|
15 |
dojo.require("dijit.Tooltip");
|
|
|
16 |
dojo.require("dijit.form.Button");
|
|
|
17 |
dojo.require("dojo.parser");
|
|
|
18 |
</script>
|
|
|
19 |
<style type="text/css">
|
|
|
20 |
@import "../../../dojo/resources/dojo.css";
|
|
|
21 |
@import "../css/dijitTests.css";
|
|
|
22 |
|
|
|
23 |
/* group multiple buttons in a row */
|
|
|
24 |
.box {
|
|
|
25 |
display: block;
|
|
|
26 |
text-align: center;
|
|
|
27 |
}
|
|
|
28 |
.box .dojoButton {
|
|
|
29 |
margin-right: 10px;
|
|
|
30 |
}
|
|
|
31 |
.dojoButtonContents {
|
|
|
32 |
font-size: 1.6em;
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
/* todo: find good color for disabled menuitems, and teset */
|
|
|
36 |
.dojoMenuItem2Disabled .dojoMenuItem2Label span,
|
|
|
37 |
.dojoMenuItem2Disabled .dojoMenuItem2Accel span {
|
|
|
38 |
color: ThreeDShadow;
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
.dojoMenuItem2Disabled .dojoMenuItem2Label span span,
|
|
|
42 |
.dojoMenuItem2Disabled .dojoMenuItem2Accel span span {
|
|
|
43 |
color: ThreeDHighlight;
|
|
|
44 |
}
|
|
|
45 |
</style>
|
|
|
46 |
</head>
|
|
|
47 |
<body>
|
|
|
48 |
<h1 class="testTitle">Dijit Button Test</h1>
|
|
|
49 |
<h2>Simple, drop down & combo buttons</h2>
|
|
|
50 |
<p>
|
|
|
51 |
Buttons can do an action, display a menu, or both:
|
|
|
52 |
</p>
|
|
|
53 |
<div class="box">
|
|
|
54 |
<button id="1465" dojoType="dijit.form.Button" onClick='console.log("clicked simple")' iconClass="plusIcon">
|
|
|
55 |
Create
|
|
|
56 |
</button>
|
|
|
57 |
<span dojoType="dijit.Tooltip" connectId="1465">tooltip on button</span>
|
|
|
58 |
<div dojoType="dijit.form.DropDownButton" iconClass="noteIcon">
|
|
|
59 |
<span>Edit<b>!</b></span>
|
|
|
60 |
<div dojoType="dijit.Menu">
|
|
|
61 |
<div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCut"
|
|
|
62 |
onClick="console.log('not actually cutting anything, just a test!')">Cut</div>
|
|
|
63 |
<div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCopy"
|
|
|
64 |
onClick="console.log('not actually copying anything, just a test!')">Copy</div>
|
|
|
65 |
<div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconPaste"
|
|
|
66 |
onClick="console.log('not actually pasting anything, just a test!')">Paste</div>
|
|
|
67 |
<div dojoType="dijit.MenuSeparator"></div>
|
|
|
68 |
<div dojoType="dijit.PopupMenuItem">
|
|
|
69 |
<span>Submenu</span>
|
|
|
70 |
<div dojoType="dijit.Menu" id="submenu2">
|
|
|
71 |
<div dojoType="dijit.MenuItem" onClick="console.log('Submenu 1!')">Submenu Item One</div>
|
|
|
72 |
<div dojoType="dijit.MenuItem" onClick="console.log('Submenu 2!')">Submenu Item Two</div>
|
|
|
73 |
<div dojoType="dijit.PopupMenuItem">
|
|
|
74 |
<span>Deeper Submenu</span>
|
|
|
75 |
<div dojoType="dijit.Menu" id="submenu4"">
|
|
|
76 |
<div dojoType="dijit.MenuItem" onClick="console.log('Sub-submenu 1!')">Sub-sub-menu Item One</div>
|
|
|
77 |
<div dojoType="dijit.MenuItem" onClick="console.log('Sub-submenu 2!')">Sub-sub-menu Item Two</div>
|
|
|
78 |
</div>
|
|
|
79 |
</div>
|
|
|
80 |
</div>
|
|
|
81 |
</div>
|
|
|
82 |
</div>
|
|
|
83 |
</div>
|
|
|
84 |
<div dojoType="dijit.form.DropDownButton" iconClass="noteIcon">
|
|
|
85 |
<span>Color</span>
|
|
|
86 |
<div dojoType="dijit.ColorPalette" id="colorPalette" style="display: none" palette="3x4"
|
|
|
87 |
onChange="console.log(this.value);"></div>
|
|
|
88 |
</div>
|
|
|
89 |
<div dojoType="dijit.form.ComboButton" optionsTitle='save options' onClick='console.log("clicked combo save")'
|
|
|
90 |
iconClass="plusBlockIcon">
|
|
|
91 |
<span>Save</span>
|
|
|
92 |
<div dojoType="dijit.Menu" id="saveMenu" style="display: none;">
|
|
|
93 |
<div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconSave"
|
|
|
94 |
onClick="console.log('not actually saving anything, just a test!')">Save</div>
|
|
|
95 |
<div dojoType="dijit.MenuItem"
|
|
|
96 |
onClick="console.log('not actually saving anything, just a test!')">Save As</div>
|
|
|
97 |
</div>
|
|
|
98 |
</div>
|
|
|
99 |
<button dojoType="dijit.form.Button" onClick='console.log("clicked simple")' disabled='true' iconClass="plusIcon">
|
|
|
100 |
Disabled
|
|
|
101 |
</button>
|
|
|
102 |
</div>
|
|
|
103 |
<br clear=both>
|
|
|
104 |
<h2>Buttons with no text label</h2>
|
|
|
105 |
<p>Buttons have showLabel=false so text is not displayed. Should have title attribute displayed on mouse over</p>
|
|
|
106 |
<div class="box">
|
|
|
107 |
<button id="1466" dojoType="dijit.form.Button" onClick='console.log("clicked simple button with no text label")'
|
|
|
108 |
iconClass="plusIcon" showLabel="false">
|
|
|
109 |
<span><b>Rich</b><i> Text</i> Test!</span>
|
|
|
110 |
</button>
|
|
|
111 |
<div dojoType="dijit.form.DropDownButton" iconClass="noteIcon" showLabel="false">
|
|
|
112 |
<span>Color</span>
|
|
|
113 |
<div dojoType="dijit.ColorPalette" id="colorPalette2" style="display: none" palette="3x4"
|
|
|
114 |
onChange="console.log(this.value);">
|
|
|
115 |
</div>
|
|
|
116 |
</div>
|
|
|
117 |
<div dojoType="dijit.form.ComboButton" optionsTitle='save options' onClick='console.log("clicked combo save")'
|
|
|
118 |
iconClass="plusBlockIcon" showLabel="false">
|
|
|
119 |
<span>Save</span>
|
|
|
120 |
<div dojoType="dijit.Menu" id="saveMenu2" style="display: none;">
|
|
|
121 |
<div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconSave"
|
|
|
122 |
onClick="console.log('not actually saving anything, just a test!')">Save</div>
|
|
|
123 |
<div dojoType="dijit.MenuItem"
|
|
|
124 |
onClick="console.log('not actually saving anything, just a test!')">Save As</div>
|
|
|
125 |
</div>
|
|
|
126 |
</div>
|
|
|
127 |
</div>
|
|
|
128 |
<br clear=both>
|
|
|
129 |
<h2>Toggle buttons</h2>
|
|
|
130 |
<p>The button CSS as well as the icon CSS can change on toggle </p>
|
|
|
131 |
<div class="box">
|
|
|
132 |
<button dojoType="dijit.form.ToggleButton" onChange="console.log('toggled button checked='+arguments[0]);" iconClass="dijitCheckBoxIcon">
|
|
|
133 |
Toggle me
|
|
|
134 |
</button>
|
|
|
135 |
<button dojoType="dijit.form.ToggleButton" onChange="console.log('toggled button checked='+arguments[0]);" iconClass="dijitRadioIcon">
|
|
|
136 |
Toggle me
|
|
|
137 |
</button>
|
|
|
138 |
</div>
|
|
|
139 |
<br clear=both>
|
|
|
140 |
<h2>Sizing</h2>
|
|
|
141 |
<p>Short button, tall buttons, big buttons, small buttons...
|
|
|
142 |
These buttons size to their content (just like <button>).</p>
|
|
|
143 |
<div class="box">
|
|
|
144 |
<button dojoType="dijit.form.Button" onclick='console.log("big");' iconClass="flatScreenIcon">
|
|
|
145 |
<span style="font-size:xx-large">big</span>
|
|
|
146 |
</button>
|
|
|
147 |
<button id="smallButton1" dojoType="dijit.form.Button" onclick='console.log("small");'>
|
|
|
148 |
<img src="../images/arrowSmall.gif" width="15" height="5">
|
|
|
149 |
<span style="font-size:x-small">small</span>
|
|
|
150 |
</button>
|
|
|
151 |
<button dojoType="dijit.form.Button" onclick='console.log("long");'>
|
|
|
152 |
<img src="../images/tube.gif" width="150" height="16">
|
|
|
153 |
long
|
|
|
154 |
</button>
|
|
|
155 |
<button dojoType="dijit.form.Button" onclick='console.log("tall");' width2height="0.1">
|
|
|
156 |
<img src="../images/tubeTall.gif" height="75" width="35"><br>
|
|
|
157 |
<span style="font-size:medium">tall</span>
|
|
|
158 |
</button>
|
|
|
159 |
<div style="clear: both;"></div>
|
|
|
160 |
</div>
|
|
|
161 |
<br clear=both>
|
|
|
162 |
<h2>Customized buttons</h2>
|
|
|
163 |
<p>Dojo users can mix in their styles.
|
|
|
164 |
Here's an example:</p>
|
|
|
165 |
<style>
|
|
|
166 |
.dc {
|
|
|
167 |
font-size: x-large !important;
|
|
|
168 |
padding-top: 10px !important;
|
|
|
169 |
padding-bottom: 10px !important;
|
|
|
170 |
}
|
|
|
171 |
.Acme *,
|
|
|
172 |
.Acme {
|
|
|
173 |
background: rgb(96,96,96) !important;
|
|
|
174 |
color: white !important;
|
|
|
175 |
padding: 10px !important;
|
|
|
176 |
}
|
|
|
177 |
.Acme:hover *,
|
|
|
178 |
.Acme:hover {
|
|
|
179 |
background-color: rgb(89,94,111) !important;
|
|
|
180 |
color: cyan !important;
|
|
|
181 |
}
|
|
|
182 |
.Acme:active *,
|
|
|
183 |
.Acme:active {
|
|
|
184 |
background-color: white !important;
|
|
|
185 |
color: black !important;
|
|
|
186 |
}
|
|
|
187 |
</style>
|
|
|
188 |
<div class="box">
|
|
|
189 |
<button dojoType="dijit.form.Button" class="Acme" onclick='console.log("short");'>
|
|
|
190 |
<div class="dc">short</div>
|
|
|
191 |
</button>
|
|
|
192 |
<button dojoType="dijit.form.Button" class="Acme" onclick='console.log("longer");'>
|
|
|
193 |
<div class="dc">bit longer</div>
|
|
|
194 |
</button>
|
|
|
195 |
<button dojoType="dijit.form.Button" class="Acme" onclick='console.log("longer yet");'>
|
|
|
196 |
<div class="dc">ridiculously long</div>
|
|
|
197 |
</button>
|
|
|
198 |
<div style="clear: both;"></div>
|
|
|
199 |
</div>
|
|
|
200 |
<h2>Toggling the display test</h2>
|
|
|
201 |
<p>
|
|
|
202 |
(Ticket <a href="http://trac.dojotoolkit.org/ticket/403">#403</a>)
|
|
|
203 |
</p>
|
|
|
204 |
<div class="box">
|
|
|
205 |
<button dojoType="dijit.form.Button" onclick='dojo.byId("hiddenNode").style.display="inline";'>
|
|
|
206 |
Show Hidden Buttons
|
|
|
207 |
</button>
|
|
|
208 |
</div>
|
|
|
209 |
<div class="box" style="display:none;" id="hiddenNode">
|
|
|
210 |
<button dojoType="dijit.form.Button" onclick='console.log("clicked simple")' iconClass="plusIcon">
|
|
|
211 |
Create
|
|
|
212 |
</button>
|
|
|
213 |
<button dojoType="dijit.form.Button" onclick='console.log("clicked simple")' iconClass="plusIcon">
|
|
|
214 |
Create
|
|
|
215 |
</button>
|
|
|
216 |
</div>
|
|
|
217 |
<div style="clear: both;"></div>
|
|
|
218 |
<h2>Programatically changing buttons</h2>
|
|
|
219 |
<p>clicking the buttons below will change the buttons above</p>
|
|
|
220 |
<script type="text/javascript">
|
|
|
221 |
// FIXME: doesn't the manager have a function for filtering by type?
|
|
|
222 |
function forEachButton(func){
|
|
|
223 |
dijit.registry.filter(function(widget){ return widget instanceof dijit.form.Button; }).forEach(func);
|
|
|
224 |
}
|
|
|
225 |
var disabled=false;
|
|
|
226 |
function toggleDisabled(){
|
|
|
227 |
disabled=!disabled;
|
|
|
228 |
forEachButton(function(widget){ widget.setDisabled(disabled); });
|
|
|
229 |
dojo.byId("toggle").innerHTML= disabled ? "Enable all" : "Disable all";
|
|
|
230 |
}
|
|
|
231 |
var labels=["<img src='../images/note.gif' width='20' height='20'>All", "<i>work</i>", "and no", "<h1>play</h1>",
|
|
|
232 |
"<span style='color: red'>makes</span>", "Jack", "<h3>a</h3>", "dull",
|
|
|
233 |
"<img src='../images/plus.gif' width='16' height='16'>boy"];
|
|
|
234 |
var idx=0;
|
|
|
235 |
function changeLabels(){
|
|
|
236 |
forEachButton(function(widget){
|
|
|
237 |
widget.setLabel( labels[idx++ % labels.length]);
|
|
|
238 |
});
|
|
|
239 |
}
|
|
|
240 |
</script>
|
|
|
241 |
<div>
|
|
|
242 |
<button id="toggle" onclick='toggleDisabled()'>Disable all</button>
|
|
|
243 |
<button onclick='changeLabels()'>Change labels</button>
|
|
|
244 |
<button onclick='location.reload()'>Revert</button>
|
|
|
245 |
</div>
|
|
|
246 |
<h3>Button instantiated via javacript:</h3>
|
|
|
247 |
<div id="buttonContainer"></div>
|
|
|
248 |
<script type="text/javascript">
|
|
|
249 |
// See if we can make a button in script and attach it to the DOM ourselves.
|
|
|
250 |
dojo.addOnLoad(function(){
|
|
|
251 |
var params = {
|
|
|
252 |
label: "hello!",
|
|
|
253 |
name: "programmatic"
|
|
|
254 |
};
|
|
|
255 |
var widget = new dijit.form.Button(params, document.getElementById("buttonContainer"));
|
|
|
256 |
});
|
|
|
257 |
</script>
|
|
|
258 |
<div id="dropdownButtonContainer"></div>
|
|
|
259 |
<script type="text/javascript">
|
|
|
260 |
// See if we can make a drop down button in script and attach it to the DOM ourselves.
|
|
|
261 |
dojo.addOnLoad(function(){
|
|
|
262 |
var menu = new dijit.Menu({ });
|
|
|
263 |
menu.domNode.style.display="none";
|
|
|
264 |
var menuItem1 = new dijit.MenuItem({
|
|
|
265 |
label: "Save",
|
|
|
266 |
iconClass:"dijitEditorIcon dijitEditorIconSave",
|
|
|
267 |
onClick: function(){ alert('save'); }
|
|
|
268 |
});
|
|
|
269 |
menu.addChild(menuItem1);
|
|
|
270 |
|
|
|
271 |
var menuItem2 = new dijit.MenuItem({
|
|
|
272 |
label: "Cut",
|
|
|
273 |
iconClass:"dijitEditorIcon dijitEditorIconCut",
|
|
|
274 |
onClick: function(){ alert('cut'); }
|
|
|
275 |
});
|
|
|
276 |
menu.addChild(menuItem2);
|
|
|
277 |
|
|
|
278 |
var params = {
|
|
|
279 |
label: "hello!",
|
|
|
280 |
name: "programmatic2",
|
|
|
281 |
dropDown: menu
|
|
|
282 |
};
|
|
|
283 |
var widget = new dijit.form.DropDownButton(params, document.getElementById("dropdownButtonContainer"));
|
|
|
284 |
});
|
|
|
285 |
</script>
|
|
|
286 |
</body>
|
|
|
287 |
</html>
|