| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 5 |
<title>Dojo Toolbar Widget Test</title> |
| 6 |
|
| 7 |
<script type="text/javascript" src="boilerplate.js"></script> |
| 8 |
|
| 9 |
<script type="text/javascript"> |
| 10 |
require([ |
| 11 |
"dojo/_base/array", |
| 12 |
"dojo/dom", |
| 13 |
"dojo/parser", |
| 14 |
|
| 15 |
"dijit/Toolbar", |
| 16 |
"dijit/form/Button", |
| 17 |
|
| 18 |
"dijit/ToolbarSeparator", |
| 19 |
"dijit/Declaration", |
| 20 |
"dijit/form/DropDownButton", |
| 21 |
"dijit/form/ComboButton", |
| 22 |
"dijit/form/ToggleButton", |
| 23 |
|
| 24 |
"dijit/ColorPalette", |
| 25 |
"dijit/TooltipDialog", |
| 26 |
"dijit/form/TextBox", |
| 27 |
|
| 28 |
"dijit/Menu", |
| 29 |
"dijit/MenuItem", |
| 30 |
|
| 31 |
"dojo/domReady!" |
| 32 |
], function(array, dom, parser, Toolbar, Button){ |
| 33 |
|
| 34 |
// programatic creation |
| 35 |
array.forEach(["toolbar2", "toolbar3", "toolbar4"], function(toolbarId){ |
| 36 |
var toolbar = new Toolbar({}, dom.byId(toolbarId)); |
| 37 |
array.forEach(["Cut", "Copy", "Paste"], function(label){ |
| 38 |
var button = new Button({ |
| 39 |
id: toolbarId+"."+label, |
| 40 |
// note: should always specify a label, for accessibility reasons. |
| 41 |
// Just set showLabel=false if you don't want it to be displayed normally |
| 42 |
label: label, |
| 43 |
showLabel: (toolbarId != "toolbar2"), |
| 44 |
iconClass: toolbarId == "toolbar4" ? "" : "dijitEditorIcon dijitEditorIcon"+label |
| 45 |
}); |
| 46 |
toolbar.addChild(button); |
| 47 |
}); |
| 48 |
}); |
| 49 |
|
| 50 |
parser.parse(); |
| 51 |
}); |
| 52 |
</script> |
| 53 |
</head> |
| 54 |
<body class="claro"> |
| 55 |
<h1 class="testTitle">Toolbar test</h1> |
| 56 |
|
| 57 |
<span data-dojo-type="dijit/Declaration" data-dojo-props='widgetClass:"ToolbarSectionStart", defaults:{ label: "Label"}'> |
| 58 |
<span data-dojo-type="dijit/ToolbarSeparator"></span><i>${label}:</i> |
| 59 |
</span> |
| 60 |
|
| 61 |
<h2>Toolbar from markup</h2> |
| 62 |
|
| 63 |
<input id="toolbar1Before" value="input before toolbar1"/> |
| 64 |
<div id="toolbar1" data-dojo-type="dijit/Toolbar" |
| 65 |
><div data-dojo-type="ToolbarSectionStart" data-dojo-props='label:"Buttons"'></div |
| 66 |
><div id="toolbar1_cut" data-dojo-type="dijit/form/Button" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconCut", showLabel:false'>Cut</div |
| 67 |
><div id="toolbar1_copy" data-dojo-type="dijit/form/Button" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconCopy", showLabel:true'>Copy</div |
| 68 |
|
| 69 |
><div data-dojo-type="ToolbarSectionStart" data-dojo-props='label:"Toggles"'></div |
| 70 |
><div id="toolbar1_bold" data-dojo-type="dijit/form/ToggleButton" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconBold", showLabel:false'>Bold</div |
| 71 |
><div id="toolbar1_italic" data-dojo-type="dijit/form/ToggleButton" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconItalic", showLabel:true'>Italic</div |
| 72 |
|
| 73 |
> |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
<div data-dojo-type="ToolbarSectionStart" data-dojo-props='label:"Dropdowns"'></div |
| 84 |
><div id="toolbar1_dialog" data-dojo-type="dijit/form/DropDownButton" data-dojo-props='iconClass:"plusIcon", showLabel:true'> |
| 85 |
<span>TooltipDialog</span> |
| 86 |
<div id="tooltipDlg" data-dojo-type="dijit/TooltipDialog" data-dojo-props='title:"Enter Login information", |
| 87 |
execute:function(args){ console.log("submitted w/args:\n" + dojo.toJson(args, true)); }'> |
| 88 |
<table> |
| 89 |
<tr> |
| 90 |
<td><label for="user">User:</label></td> |
| 91 |
<td><input id="user" data-dojo-type=dijit.form.TextBox data-dojo-props='type:"text", name:"user" '/></td> |
| 92 |
</tr> |
| 93 |
<tr> |
| 94 |
<td><label for="password">Password:</label></td> |
| 95 |
<td><input id="password" data-dojo-type=dijit.form.TextBox data-dojo-props='type:"password", name:"pwd"'/></td> |
| 96 |
</tr> |
| 97 |
<tr> |
| 98 |
<td colspan="2" style="text-align:center;"> |
| 99 |
<button data-dojo-type=dijit.form.Button data-dojo-props='type:"submit", name:"submit"'>Login</button></td> |
| 100 |
</tr> |
| 101 |
</table> |
| 102 |
</div |
| 103 |
></div |
| 104 |
><div id="toolbar1_backcolor" data-dojo-type="dijit/form/DropDownButton" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconBackColor", showLabel:true'> |
| 105 |
<span>ColorPalette</span> |
| 106 |
<div id="toolbar1_colorPalette" data-dojo-type="dijit/ColorPalette" data-dojo-props='style:"display: none", palette:"7x10", onChange:function(){ console.log(this.value); }'></div> |
| 107 |
</div |
| 108 |
><div id="toolbar1_forecolor" data-dojo-type="dijit/form/DropDownButton" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconForeColor", showLabel:false'> |
| 109 |
<span>Foreground</span> |
| 110 |
<div id="toolbar1_colorPalette2" data-dojo-type="dijit/ColorPalette" data-dojo-props='style:"display: none", palette:"3x4", onChange:function(){ console.log(this.value); }'></div> |
| 111 |
</div |
| 112 |
|
| 113 |
><div data-dojo-type="ToolbarSectionStart" data-dojo-props='label:"Combos"'></div |
| 114 |
><div id="toolbar1_combo" data-dojo-type="dijit/form/ComboButton" data-dojo-props='optionsTitle:"save options", iconClass:"plusIcon", showLabel:true, |
| 115 |
onClick:function(){ console.log("clicked combo save") }'> |
| 116 |
<span>Menu</span> |
| 117 |
<div id="saveMenu" data-dojo-type="dijit/Menu" data-dojo-props='style:"display: none;"'> |
| 118 |
<div data-dojo-type="dijit/MenuItem" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconSave", |
| 119 |
onClick:function(){ console.log("not actually saving anything, just a test!") }'>Save</div> |
| 120 |
<div data-dojo-type="dijit/MenuItem" |
| 121 |
data-dojo-props='onClick:function(){ console.log("not actually saving anything, just a test!") }'>Save As</div> |
| 122 |
</div> |
| 123 |
</div |
| 124 |
><div id="toolbar1_combo2" data-dojo-type="dijit/form/ComboButton" data-dojo-props='optionsTitle:"save options2", iconClass:"plusIcon", showLabel:false, |
| 125 |
onClick:function(){ console.log("clicked combo save") }'> |
| 126 |
<span>Menu2</span> |
| 127 |
<div id="saveMenu2" data-dojo-type="dijit/Menu" data-dojo-props='style:"display: none;"'> |
| 128 |
<div data-dojo-type="dijit/MenuItem" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconSave", |
| 129 |
onClick:function(){ console.log("not actually saving anything, just a test!") }'>Save</div> |
| 130 |
<div data-dojo-type="dijit/MenuItem" |
| 131 |
data-dojo-props='onClick:function(){ console.log("not actually saving anything, just a test!") }'>Save As</div> |
| 132 |
</div> |
| 133 |
</div |
| 134 |
|
| 135 |
><span data-dojo-type="dijit/ToolbarSeparator"></span |
| 136 |
><div id="toolbar1_insertorderedlist" data-dojo-type="dijit/form/Button" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconInsertOrderedList", showLabel:false'>Ordered list</div |
| 137 |
></div> |
| 138 |
<input id="toolbar1After" value="input after toolbar1"/> |
| 139 |
|
| 140 |
<h2>Toolbar from script with icons only</h2> |
| 141 |
<div id="toolbar2"></div> |
| 142 |
|
| 143 |
<h2>Toolbar from script with text and icons</h2> |
| 144 |
<div id="toolbar3"></div> |
| 145 |
|
| 146 |
<h2>Toolbar from script with text only</h2> |
| 147 |
<div id="toolbar4"></div> |
| 148 |
|
| 149 |
|
| 150 |
<br><br> |
| 151 |
</body> |
| 152 |
</html> |