| 1 |
<!DOCTYPE html> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 5 |
<title>Dojo Button Widget Test</title> |
| 6 |
|
| 7 |
<style type="text/css"> |
| 8 |
@import "../../themes/claro/document.css"; |
| 9 |
@import "../css/dijitTests.css"; |
| 10 |
|
| 11 |
/* group multiple buttons in a row */ |
| 12 |
.box { |
| 13 |
display: block; |
| 14 |
text-align: center; |
| 15 |
} |
| 16 |
BUTTON, INPUT, |
| 17 |
.box .dijit { |
| 18 |
margin-right: 10px; |
| 19 |
vertical-align: middle; |
| 20 |
} |
| 21 |
.acmeButton .dijitButtonNode { |
| 22 |
background: rgb(96,96,96) !important; |
| 23 |
color: white !important; |
| 24 |
padding: 10px !important; |
| 25 |
font-size: x-large !important; |
| 26 |
padding-top: 10px !important; |
| 27 |
padding-bottom: 10px !important; |
| 28 |
border: 2px inset rgb(96,96,96); |
| 29 |
} |
| 30 |
.acmeButtonHover .dijitButtonNode { |
| 31 |
background-color: rgb(89,94,111) !important; |
| 32 |
color: cyan !important; |
| 33 |
} |
| 34 |
.acmeButtonFocused .dijitButtonNode { |
| 35 |
border: yellow inset 2px; |
| 36 |
} |
| 37 |
.acmeButtonActive .dijitButtonNode { |
| 38 |
background-color: white !important; |
| 39 |
color: black !important; |
| 40 |
border: 2px solid black !important; |
| 41 |
} |
| 42 |
</style> |
| 43 |
|
| 44 |
|
| 45 |
<link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/claro/claro.css"/> |
| 46 |
|
| 47 |
|
| 48 |
<script type="text/javascript" src="../../../dojo/dojo.js" |
| 49 |
data-dojo-config="isDebug: true, parseOnLoad: true"></script> |
| 50 |
|
| 51 |
|
| 52 |
<script type="text/javascript" src="../_testCommon.js"></script> |
| 53 |
|
| 54 |
<script type="text/javascript"> |
| 55 |
dojo.require("dijit.dijit"); // optimize: load dijit layer |
| 56 |
|
| 57 |
dojo.require("dijit.ColorPalette"); |
| 58 |
dojo.require("dijit.Tooltip"); |
| 59 |
|
| 60 |
dojo.require("dijit.Dialog"); |
| 61 |
dojo.require("dijit.Menu"); |
| 62 |
dojo.require("dijit.MenuItem"); |
| 63 |
dojo.require("dijit.PopupMenuItem"); |
| 64 |
dojo.require("dijit.MenuSeparator"); |
| 65 |
|
| 66 |
dojo.require("dijit.form.Button"); |
| 67 |
dojo.require("dijit.form.DropDownButton"); |
| 68 |
dojo.require("dijit.form.ComboButton"); |
| 69 |
dojo.require("dijit.form.ToggleButton"); |
| 70 |
|
| 71 |
dojo.require("dijit.form.Form"); |
| 72 |
dojo.require("dijit.form.TextBox"); |
| 73 |
|
| 74 |
dojo.require("dojo.parser"); |
| 75 |
|
| 76 |
dojo.ready(99, function(){ |
| 77 |
ViewButton = dojo.declare([dijit.form.Button], { |
| 78 |
label: "View" |
| 79 |
}); |
| 80 |
}); |
| 81 |
</script> |
| 82 |
</head> |
| 83 |
<body class="claro" role="main"> |
| 84 |
<h1 class="testTitle">Dijit Button Test</h1> |
| 85 |
<h2>Simple, drop down & combo buttons</h2> |
| 86 |
<p> |
| 87 |
Buttons can do an action, display a menu, or both: |
| 88 |
</p> |
| 89 |
<p class="box"> |
| 90 |
<button id="button" onclick="console.log('clicked native button');"><button></button> |
| 91 |
<input id="input" type="button" value="<input type='button'>" onclick="console.log('clicked native input button');"/> |
| 92 |
<button data-dojo-type="dijit/form/Button" id="T1465" data-dojo-props='onClick:function(){ console.log("clicked simple"); }, iconClass:"plusIcon", value:"Create"'> |
| 93 |
Create |
| 94 |
</button> |
| 95 |
<span data-dojo-type="dijit/Tooltip" data-dojo-props='connectId:["1465"]'>tooltip on button</span> |
| 96 |
<button data-dojo-type="ViewButton" id="T1466" title="view title" data-dojo-props='onClick:function(){ console.log("clicked simple"); }'> |
| 97 |
</button> |
| 98 |
<button id="comboCreate" title="creative title" data-dojo-type="dijit/form/ComboButton" data-dojo-props='optionsTitle:"save options", onClick:function(){ console.log("clicked combo create") }, |
| 99 |
iconClass:"plusIcon"'> |
| 100 |
<span>Create</span> |
| 101 |
<span id="createMenu" data-dojo-type="dijit/Menu"> |
| 102 |
<span data-dojo-type="dijit/MenuItem" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconSave", |
| 103 |
onClick:function(){ console.log("not actually saving anything, just a test!"); }'>Create blank</span> |
| 104 |
<span data-dojo-type="dijit/MenuItem" |
| 105 |
data-dojo-props='onClick:function(){ console.log("not actually saving anything, just a test!"); }'>Create from template</span> |
| 106 |
</span> |
| 107 |
</button> |
| 108 |
<button id="edit" title="edit title" value="Edit" data-dojo-type="dijit/form/DropDownButton" data-dojo-props='iconClass:"noteIcon"'> |
| 109 |
<span>Edit<b>!</b></span> |
| 110 |
<span id="editMenu" data-dojo-type="dijit/Menu" > |
| 111 |
<span id="cut" data-dojo-type="dijit/MenuItem" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconCut", |
| 112 |
onClick:function(){ console.log("not actually cutting anything, just a test!"); }'>Cut</span> |
| 113 |
<span id="copy" data-dojo-type="dijit/MenuItem" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconCopy", |
| 114 |
onClick:function(){ console.log("not actually copying anything, just a test!"); }'>Copy</span> |
| 115 |
<span id="paste" data-dojo-type="dijit/MenuItem" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconPaste", |
| 116 |
onClick:function(){ console.log("not actually pasting anything, just a test!"); }'>Paste</span> |
| 117 |
<span data-dojo-type="dijit/MenuSeparator"></span> |
| 118 |
<span data-dojo-type="dijit/PopupMenuItem"> |
| 119 |
<span>Submenu</span> |
| 120 |
<span id="submenu2" data-dojo-type="dijit/Menu" > |
| 121 |
<span data-dojo-type="dijit/MenuItem" data-dojo-props='onClick:function(){ console.log("Submenu 1!"); }'>Submenu Item One</span> |
| 122 |
<span data-dojo-type="dijit/MenuItem" data-dojo-props='onClick:function(){ console.log("Submenu 2!"); }'>Submenu Item Two</span> |
| 123 |
<span data-dojo-type="dijit/PopupMenuItem"> |
| 124 |
<span>Deeper Submenu</span> |
| 125 |
<span id="submenu4" data-dojo-type="dijit/Menu" > |
| 126 |
<span data-dojo-type="dijit/MenuItem" data-dojo-props='onClick:function(){ console.log("Sub-submenu 1!"); }'>Sub-sub-menu Item One</span> |
| 127 |
<span data-dojo-type="dijit/MenuItem" data-dojo-props='onClick:function(){ console.log("Sub-submenu 2!"); }'>Sub-sub-menu Item Two</span> |
| 128 |
</span> |
| 129 |
</span> |
| 130 |
</span> |
| 131 |
</span> |
| 132 |
</span> |
| 133 |
</button> |
| 134 |
<button id="color" data-dojo-type="dijit/form/DropDownButton" data-dojo-props='iconClass:"noteIcon", value:"color"'> |
| 135 |
<span>Color</span> |
| 136 |
<span id="colorPalette" data-dojo-type="dijit/ColorPalette" |
| 137 |
data-dojo-props='palette:"3x4", onChange:function(val){ console.log(val); }'></span> |
| 138 |
</button> |
| 139 |
<button id="save" data-dojo-type="dijit/form/ComboButton" data-dojo-props='optionsTitle:"save options", onClick:function(){ console.log("clicked combo save"); }, |
| 140 |
iconClass:"plusBlockIcon"'> |
| 141 |
<span>Save</span> |
| 142 |
<span id="saveMenu" data-dojo-type="dijit/Menu"> |
| 143 |
<span id="saveMenuItem" data-dojo-type="dijit/MenuItem" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconSave", |
| 144 |
onClick:function(){ console.log("not actually saving anything, just a test!"); }'>Save</span> |
| 145 |
<span id="saveAs" data-dojo-type="dijit/MenuItem" data-dojo-props='onClick:function(){ console.log("not actually saving anything, just a test!"); }'>Save As</span> |
| 146 |
</span> |
| 147 |
</button> |
| 148 |
<button id="disabled" disabled data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ console.log("clicked simple"); }, iconClass:"plusIcon"'> |
| 149 |
Disabled |
| 150 |
</button> |
| 151 |
</p> |
| 152 |
<br style="clear:both;"/> |
| 153 |
<h2>DropDownButtons with different drop down positions</h2> |
| 154 |
<button id="dropdown_default" value="color" data-dojo-type="dijit/form/DropDownButton" data-dojo-props='iconClass:"noteIcon"'> |
| 155 |
<span>Default (below)</span> |
| 156 |
<span data-dojo-type="dijit/ColorPalette" |
| 157 |
data-dojo-props='palette:"3x4", onChange:function(val){ console.log(val); }'></span> |
| 158 |
</button> |
| 159 |
<button id="dropdown_up" value="color" data-dojo-type="dijit/form/DropDownButton" data-dojo-props='dropDownPosition:["above"], iconClass:"noteIcon"'> |
| 160 |
<span>Above</span> |
| 161 |
<span data-dojo-type="dijit/ColorPalette" |
| 162 |
data-dojo-props='palette:"3x4", onChange:function(val){ console.log(val); }'></span> |
| 163 |
</button> |
| 164 |
<button id="dropdown_before" value="color" data-dojo-type="dijit/form/DropDownButton" data-dojo-props='dropDownPosition:["before"], iconClass:"noteIcon"'> |
| 165 |
<span>Before</span> |
| 166 |
<span data-dojo-type="dijit/ColorPalette" |
| 167 |
data-dojo-props='palette:"3x4", onChange:function(val){ console.log(val); }'></span> |
| 168 |
</button> |
| 169 |
<button id="dropdown_after" value="color" data-dojo-type="dijit/form/DropDownButton" data-dojo-props='dropDownPosition:["after"], iconClass:"noteIcon"'> |
| 170 |
<span>After</span> |
| 171 |
<span data-dojo-type="dijit/ColorPalette" |
| 172 |
data-dojo-props='palette:"3x4", onChange:function(val){ console.log(val); }'></span> |
| 173 |
</button> |
| 174 |
<h2>ComboButtons with different drop down positions</h2> |
| 175 |
<button id="combo_default" data-dojo-type="dijit/form/ComboButton" data-dojo-props='optionsTitle:"save options", onClick:function(){ console.log("clicked combo save") }, |
| 176 |
iconClass:"plusBlockIcon"'> |
| 177 |
<span>Default (below)</span> |
| 178 |
<span data-dojo-type="dijit/Menu"> |
| 179 |
<span data-dojo-type="dijit/MenuItem" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconSave", |
| 180 |
onClick:function(){ console.log("not actually saving anything, just a test!"); }'>Save</span> |
| 181 |
<span data-dojo-type="dijit/MenuItem" |
| 182 |
data-dojo-props='onClick:function(){ console.log("not actually saving anything, just a test!"); }'>Save As</span> |
| 183 |
</span> |
| 184 |
</button> |
| 185 |
<button id="combo_above" data-dojo-type="dijit/form/ComboButton" data-dojo-props='dropDownPosition:["above"], optionsTitle:"save options", onClick:function(){ console.log("clicked combo save"); }, |
| 186 |
iconClass:"plusBlockIcon"'> |
| 187 |
<span>Up</span> |
| 188 |
<span data-dojo-type="dijit/Menu"> |
| 189 |
<span data-dojo-type="dijit/MenuItem" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconSave", |
| 190 |
onClick:function(){ console.log("not actually saving anything, just a test!"); }'>Save</span> |
| 191 |
<span data-dojo-type="dijit/MenuItem" |
| 192 |
data-dojo-props='onClick:function(){ console.log("not actually saving anything, just a test!"); }'>Save As</span> |
| 193 |
</span> |
| 194 |
</button> |
| 195 |
<button id="combo_before" data-dojo-type="dijit/form/ComboButton" data-dojo-props='dropDownPosition:["before"], optionsTitle:"save options", onClick:function(){ console.log("clicked combo save"); }, |
| 196 |
iconClass:"plusBlockIcon"'> |
| 197 |
<span>Before</span> |
| 198 |
<span data-dojo-type="dijit/Menu"> |
| 199 |
<span data-dojo-type="dijit/MenuItem" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconSave", |
| 200 |
onClick:function(){ console.log("not actually saving anything, just a test!"); }'>Save</span> |
| 201 |
<span data-dojo-type="dijit/MenuItem" |
| 202 |
data-dojo-props='onClick:function(){ console.log("not actually saving anything, just a test!"); }'>Save As</span> |
| 203 |
</span> |
| 204 |
</button> |
| 205 |
<button id="combo_after" data-dojo-type="dijit/form/ComboButton" data-dojo-props='dropDownPosition:["after"], optionsTitle:"save options", onClick:function(){ console.log("clicked combo save"); }, |
| 206 |
iconClass:"plusBlockIcon"'> |
| 207 |
<span>After</span> |
| 208 |
<span data-dojo-type="dijit/Menu"> |
| 209 |
<span data-dojo-type="dijit/MenuItem" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconSave", |
| 210 |
onClick:function(){ console.log("not actually saving anything, just a test!"); }'>Save</span> |
| 211 |
<span data-dojo-type="dijit/MenuItem" |
| 212 |
data-dojo-props='onClick:function(){ console.log("not actually saving anything, just a test!"); }'>Save As</span> |
| 213 |
</span> |
| 214 |
</button> |
| 215 |
<h2>Buttons with no text label</h2> |
| 216 |
<p>Buttons have showLabel=false so text is not displayed. If no title attribute supplied, Should have label as title attribute displayed on mouse over</p> |
| 217 |
<div class="box"> |
| 218 |
<button id="buttonNoLabel" title="title attrib rather than label" data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ console.log("clicked simple button with no text label"); }, |
| 219 |
iconClass:"plusIcon", showLabel:false'> |
| 220 |
<span><b>Rich</b><i> Text</i> Test!</span> |
| 221 |
</button> |
| 222 |
<div id="dropDownNoLabel" title="color title" data-dojo-type="dijit/form/DropDownButton" data-dojo-props='iconClass:"noteIcon", showLabel:false'> |
| 223 |
<span>Color</span> |
| 224 |
<div id="colorPalette2" data-dojo-type="dijit/ColorPalette" |
| 225 |
data-dojo-props='palette:"3x4", onChange:function(val){ console.log(val); }'> |
| 226 |
</div> |
| 227 |
</div> |
| 228 |
<div id="comboNoLabel" title="save title" data-dojo-type="dijit/form/ComboButton" data-dojo-props='optionsTitle:"save options", onClick:function(){ console.log("clicked combo save"); }, |
| 229 |
iconClass:"plusBlockIcon", showLabel:false'> |
| 230 |
<span>Save</span> |
| 231 |
<div id="saveMenu2" data-dojo-type="dijit/Menu"> |
| 232 |
<div data-dojo-type="dijit/MenuItem" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconSave", |
| 233 |
onClick:function(){ console.log("not actually saving anything, just a test!"); }'>Save</div> |
| 234 |
<div data-dojo-type="dijit/MenuItem" |
| 235 |
data-dojo-props='onClick:function(){ console.log("not actually saving anything, just a test!"); }'>Save As</div> |
| 236 |
</div> |
| 237 |
</div> |
| 238 |
</div> |
| 239 |
<br style="clear:both;"/> |
| 240 |
<h2>Toggle buttons</h2> |
| 241 |
<p>The button CSS as well as the icon CSS can change on toggle </p> |
| 242 |
<div class="box"> |
| 243 |
<button id="toggle1" checked data-dojo-type="dijit/form/ToggleButton" data-dojo-props=' |
| 244 |
onChange:function(val){ |
| 245 |
console.log("toggled button checked="+val); |
| 246 |
this.set("label", val ? "toggle me off" : "toggle me on"); |
| 247 |
}, iconClass:"dijitCheckBoxIcon"'> |
| 248 |
Toggle me off |
| 249 |
</button> |
| 250 |
<button id="toggle2" data-dojo-type="dijit/form/ToggleButton" |
| 251 |
data-dojo-props='onChange:function(val){ console.log("toggled button checked="+val); }, iconClass:"dijitRadioIcon"'> |
| 252 |
Toggle me |
| 253 |
</button> |
| 254 |
</div> |
| 255 |
<br style="clear:both;"/> |
| 256 |
<h2>Sizing</h2> |
| 257 |
<p>Short button, tall buttons, big buttons, small buttons... |
| 258 |
These buttons size to their content (just like <button>).</p> |
| 259 |
<div class="box"> |
| 260 |
<button data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ console.log("big"); }, iconClass:"flatScreenIcon"'> |
| 261 |
<span style="font-size:xx-large">big</span> |
| 262 |
</button> |
| 263 |
<button id="smallButton1" data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ console.log("small"); }'> |
| 264 |
<img src="../images/arrowSmall.gif" alt="small" width="15" height="5"/> |
| 265 |
<span style="font-size:x-small">small</span> |
| 266 |
</button> |
| 267 |
<button data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ console.log("long"); }'> |
| 268 |
<img src="../images/tube.gif" alt="long" width="150" height="16"/> |
| 269 |
long |
| 270 |
</button> |
| 271 |
<button data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ console.log("tall"); }'> |
| 272 |
<img src="../images/tubeTall.gif" alt="tall" height="75" width="35"/><br> |
| 273 |
<span style="font-size:medium">tall</span> |
| 274 |
</button> |
| 275 |
<div style="clear: both;"></div> |
| 276 |
</div> |
| 277 |
<br style="clear:both;"/> |
| 278 |
<h2>Customized buttons</h2> |
| 279 |
<p>Dojo users can customize styles. Here's an example:</p> |
| 280 |
<div class="box"> |
| 281 |
<button data-dojo-type="dijit/form/Button" data-dojo-props='baseClass:"acmeButton", onClick:function(){ console.log("short"); }'> |
| 282 |
short |
| 283 |
</button> |
| 284 |
<button data-dojo-type="dijit/form/Button" data-dojo-props='baseClass:"acmeButton", onClick:function(){ console.log("longer"); }'> |
| 285 |
bit longer |
| 286 |
</button> |
| 287 |
<button data-dojo-type="dijit/form/Button" data-dojo-props='baseClass:"acmeButton", onClick:function(){ console.log("longer yet"); }'> |
| 288 |
ridiculously long |
| 289 |
</button> |
| 290 |
<div style="clear: both;"></div> |
| 291 |
</div> |
| 292 |
<h2>Toggling the display test</h2> |
| 293 |
<p> |
| 294 |
(Ticket <a href="http://trac.dojotoolkit.org/ticket/403">#403</a>) |
| 295 |
</p> |
| 296 |
<div class="box"> |
| 297 |
<button data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ dojo.byId("hiddenNode").style.display="inline"; }'> |
| 298 |
Show Hidden Buttons |
| 299 |
</button> |
| 300 |
</div> |
| 301 |
<div class="box" style="display:none;" id="hiddenNode"> |
| 302 |
<button data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ console.log("clicked simple"); }, iconClass:"plusIcon"'> |
| 303 |
Create |
| 304 |
</button> |
| 305 |
<button data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ console.log("clicked simple"); }, iconClass:"plusIcon"'> |
| 306 |
Create |
| 307 |
</button> |
| 308 |
</div> |
| 309 |
<div style="clear: both;"></div> |
| 310 |
<h2>Programatically changing buttons</h2> |
| 311 |
<p>clicking the buttons below will change the buttons above</p> |
| 312 |
<script type="text/javascript"> |
| 313 |
// FIXME: doesn't the manager have a function for filtering by type? |
| 314 |
function forEachButton(func){ |
| 315 |
dijit.registry.filter(function(widget){ return widget instanceof dijit.form.Button; }).forEach(func); |
| 316 |
} |
| 317 |
var disabled = false; |
| 318 |
function toggleDisabled(){ |
| 319 |
disabled =! disabled; |
| 320 |
forEachButton(function(widget){ widget.set('disabled',disabled); }); |
| 321 |
dojo.byId("toggle").innerHTML= disabled ? "Enable all" : "Disable all"; |
| 322 |
} |
| 323 |
var labels=["<img src='../images/note.gif' width='20' height='20'/>All", "<i>work</i>", "and no", "<span style='font-size: 40pt;'>play</span>", |
| 324 |
"<span style='color: red'>makes</span>", "Jack", "<span style='font-size: 20pt;'>a</span>", "dull", |
| 325 |
"<img src='../images/plus.gif' width='16' height='16'/>boy"]; |
| 326 |
var idx = 0; |
| 327 |
function changeLabels(){ |
| 328 |
forEachButton(function(widget){ |
| 329 |
widget.set('label', labels[idx++ % labels.length]); |
| 330 |
}); |
| 331 |
} |
| 332 |
function getLabels(){ |
| 333 |
forEachButton(function(widget){ |
| 334 |
console.log(widget.get('label')); |
| 335 |
}); |
| 336 |
} |
| 337 |
</script> |
| 338 |
<div> |
| 339 |
<button id="toggle" onclick='toggleDisabled()'>Disable all</button> |
| 340 |
<button id="changeLabels" onclick='changeLabels()'>Change labels</button> |
| 341 |
<button onclick='getLabels()'>Get labels</button> |
| 342 |
<button onclick='location.reload()'>Revert</button> |
| 343 |
</div> |
| 344 |
<h3>Button instantiated via javacript:</h3> |
| 345 |
<p id="buttonContainer" style="display: none;"></p> |
| 346 |
<script type="text/javascript"> |
| 347 |
// See if we can make a button in script and attach it to the DOM ourselves. |
| 348 |
dojo.ready(function(){ |
| 349 |
var widget = new dijit.form.Button({ |
| 350 |
label: "hello!", |
| 351 |
name: "programmatic" |
| 352 |
}); |
| 353 |
widget.placeAt("buttonContainer"); // place in page |
| 354 |
|
| 355 |
var widget2 = new dijit.form.Button({ |
| 356 |
label: "hello!", |
| 357 |
name: "programmatic" |
| 358 |
}); |
| 359 |
widget2.set("label", "i'm programmatic too"); // change label (for testing) |
| 360 |
widget2.placeAt("buttonContainer"); // place in page |
| 361 |
}); |
| 362 |
</script> |
| 363 |
<h3>DropDownButton instantiated via javacript:</h3> |
| 364 |
<div id="dropdownButtonContainer"></div> |
| 365 |
<script type="text/javascript"> |
| 366 |
// See if we can make a drop down button in script and attach it to the DOM ourselves. |
| 367 |
function createButton(){ |
| 368 |
var menu = new dijit.Menu({ }); |
| 369 |
menu.domNode.style.display="none"; |
| 370 |
var menuItem1 = new dijit.MenuItem({ |
| 371 |
label: "Save", |
| 372 |
iconClass:"dijitEditorIcon dijitEditorIconSave", |
| 373 |
onClick: function(){ alert('save'); } |
| 374 |
}); |
| 375 |
menu.addChild(menuItem1); |
| 376 |
|
| 377 |
var menuItem2 = new dijit.MenuItem({ |
| 378 |
label: "Cut", |
| 379 |
iconClass:"dijitEditorIcon dijitEditorIconCut", |
| 380 |
onClick: function(){ alert('cut'); } |
| 381 |
}); |
| 382 |
menu.addChild(menuItem2); |
| 383 |
|
| 384 |
var params = { |
| 385 |
label: "hello!", |
| 386 |
name: "programmatic2", |
| 387 |
dropDown: menu, |
| 388 |
id: "progButton" |
| 389 |
}; |
| 390 |
var widget = new dijit.form.DropDownButton(params); |
| 391 |
dojo.byId("dropdownButtonContainer").appendChild(widget.domNode); |
| 392 |
dojo.byId("createButton").disabled = true; |
| 393 |
dojo.byId("destroyButton").disabled = false; |
| 394 |
} |
| 395 |
function destroyButton(){ |
| 396 |
var button = dijit.byId("progButton"); |
| 397 |
button.destroyRecursive(); |
| 398 |
dojo.byId("createButton").disabled = false; |
| 399 |
dojo.byId("destroyButton").disabled = true; |
| 400 |
} |
| 401 |
</script> |
| 402 |
<button id="createButton" onclick="createButton();">create dropdown button</button> |
| 403 |
<button id="destroyButton" onclick="destroyButton();">destroy dropdown button</button> |
| 404 |
|
| 405 |
<h3>Submit and Reset Buttons</h3> |
| 406 |
<div>Testing that submit and reset buttons work properly. OnSubmit and OnReset handlers |
| 407 |
for the form just output to the console. |
| 408 |
</div> |
| 409 |
<form id="testForm" encType="multipart/form-data" name="testForm" action="../formAction.html" method="" data-dojo-type="dijit/form/Form"> |
| 410 |
<script type="dojo/method" data-dojo-event="onReset"> |
| 411 |
console.log("testForm onReset invoked"); |
| 412 |
</script> |
| 413 |
<script type="dojo/method" data-dojo-event="onSubmit"> |
| 414 |
console.log("testForm onSubmit invoked - not really submitting"); |
| 415 |
return false; |
| 416 |
</script> |
| 417 |
<label for="testName">Name: </label><input id="testName" data-dojo-type="dijit/form/TextBox" data-dojo-props='name:"testName", value:""'/><br> |
| 418 |
<button id="bSubmit" data-dojo-type="dijit/form/Button" data-dojo-props='type:"submit" '>Submit</button> |
| 419 |
<button id="bReset" data-dojo-type="dijit/form/Button" data-dojo-props='type:"reset" '>Reset</button> |
| 420 |
</form> |
| 421 |
|
| 422 |
<h3>onClick Tests</h3> |
| 423 |
<div>Testing that onClick works properly |
| 424 |
</div> |
| 425 |
<form> |
| 426 |
<label for="onClickName">Value: </label><input id="onClickName" name="onClickName" value="RESET"/><br> |
| 427 |
<button id="reset1" type="reset" data-dojo-type="dijit/form/Button">Reset with no onClick handler should reset</button> |
| 428 |
<button type="reset" id="reset1N">Native Reset with no onClick handler should reset</button><br> |
| 429 |
<button id="reset2" type="reset" data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ return false }'>Reset with "return false" onClick handler should not reset</button> |
| 430 |
<button type="reset" id="reset2N" onClick="return false;">Native Reset with "return false" onClick handler should not reset</button><br> |
| 431 |
<button id="reset3" type="reset" data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ return true }'>Reset with "return true" onClick handler should reset</button> |
| 432 |
<button type="reset" id="reset3N" onClick="return true;">Native Reset with "return true" onClick handler should reset</button><br> |
| 433 |
<button id="reset4" type="reset" data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ return }'>Reset with "return" onClick handler should reset</button> |
| 434 |
<button type="reset" id="reset4N" onClick="return;">Native Reset with "return" onClick handler should reset</button><br> |
| 435 |
<button id="reset5" type="reset" data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ }'>Reset with "" onClick handler should reset</button> |
| 436 |
<button type="reset" id="reset5N" onClick="">Native Reset with "" onClick handler should reset</button><br> |
| 437 |
</form> |
| 438 |
|
| 439 |
<h3>Submit/value test</h3> |
| 440 |
<script> |
| 441 |
submittedValues = function(values){ |
| 442 |
for(var i in values){ |
| 443 |
document.getElementById('buttonName').value = i; |
| 444 |
document.getElementById('buttonValue').value = values[i]; |
| 445 |
} |
| 446 |
}; |
| 447 |
</script> |
| 448 |
<form id="myForm" data-dojo-type="dijit/form/Form" encType="multipart/form-data" action="../formAction.html" method="" target="formSubmitIframe"> |
| 449 |
<button id="SubmitPlain" data-dojo-type="dijit/form/Button" name="Plain" type="submit" value="Plain Submit">Plain Submit</button> |
| 450 |
<button id="SubmitCombo" data-dojo-type="dijit/form/ComboButton" name="Combo" type="submit" value="Combo Submit" |
| 451 |
data-dojo-props="label: 'Combo Submit'"> |
| 452 |
<span data-dojo-type="dijit/Menu"> |
| 453 |
<span id="SubmitComboMenuItem" data-dojo-type="dijit/MenuItem" data-dojo-props='onClick:function(){ dijit.byId("myForm").submit(); }'>Combo MenuItem Submit</span> |
| 454 |
</span> |
| 455 |
</button> |
| 456 |
<button id="SubmitDropDown" data-dojo-type="dijit/form/DropDownButton" name="DropDown" type="submit" value="DropDown Submit"> |
| 457 |
DropDown Submit |
| 458 |
<span data-dojo-type="dijit/Menu"> |
| 459 |
<span id="SubmitDropDownMenuItem" data-dojo-type="dijit/MenuItem" data-dojo-props='onClick:function(){ dijit.byId("myForm").submit(); }'>DropDown MenuItem Submit</span> |
| 460 |
</span> |
| 461 |
</button> |
| 462 |
<button id="SubmitDisabled" data-dojo-type="dijit/form/Button" name="Disabled" type="submit" disabled value="Disabled Submit">Disabled Submit</button> |
| 463 |
</form> |
| 464 |
<br> |
| 465 |
<label for="buttonName">Submitted name:</label><input id="buttonName"/><br> |
| 466 |
<label for="buttonValue">Submitted value:</label><input id="buttonValue"/> |
| 467 |
<br> |
| 468 |
<iframe name="formSubmitIframe" src="about:blank" onload="if(this.values) submittedValues(this.values);" style="display:none;"></iframe> |
| 469 |
|
| 470 |
|
| 471 |
<p>Tests for bubbling:</p> |
| 472 |
<div id="bubbleContainer" style="border: solid #aaa 3px"> |
| 473 |
<button type="button" data-dojo-type="dijit/form/Button" id="bubble1">1</button> |
| 474 |
<button type="button" data-dojo-type="dijit/form/Button" id="bubble2">2</button> |
| 475 |
<button type="button" data-dojo-type="dijit/form/Button" id="bubble3">3</button> |
| 476 |
</div> |
| 477 |
<script> |
| 478 |
require(["dojo/dom", "dojo/on", "dijit/registry"], function(dom, on, registry){ |
| 479 |
on(dom.byId("bubbleContainer"), "click", function(evt){ |
| 480 |
var widget = registry.getEnclosingWidget(evt.target); |
| 481 |
if(widget){ |
| 482 |
console.log("click on widget " + widget.id); |
| 483 |
} |
| 484 |
}); |
| 485 |
}); |
| 486 |
</script> |
| 487 |
</body> |
| 488 |
</html> |