test_Toolbar.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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 Toolbar Widget Test</title>
  6. <script type="text/javascript" src="../../dojo/dojo.js"
  7. djConfig="parseOnLoad: true, isDebug: true"></script>
  8. <script type="text/javascript" src="_testCommon.js"></script>
  9. <script type="text/javascript">
  10. dojo.require("dijit.form.Button");
  11. dojo.require("dijit.ColorPalette");
  12. dojo.require("dijit.Dialog");
  13. dojo.require("dijit.Toolbar");
  14. dojo.require("dijit.form.Button");
  15. dojo.require("dijit.form.TextBox");
  16. dojo.require("dijit.Menu");
  17. dojo.require("dojo.parser");
  18. </script>
  19. <!-- programatic creation -->
  20. <script>
  21. function init(){
  22. dojo.forEach(["toolbar2", "toolbar3", "toolbar4"], function(toolbarId){
  23. var toolbar = new dijit.Toolbar({}, dojo.byId(toolbarId));
  24. dojo.forEach(["Cut", "Copy", "Paste"], function(label){
  25. var button = new dijit.form.Button({id: toolbarId+"."+label, label: label, iconClass: "dijitEditorIcon dijitEditorIcon"+label, showLabel: (toolbarId == "toolbar2" ? false : true)});
  26. toolbar.addChild(button);
  27. });
  28. });
  29. }
  30. dojo.addOnLoad(init);
  31. </script>
  32. <style type="text/css">
  33. @import "../../dojo/resources/dojo.css";
  34. @import "css/dijitTests.css";
  35. .dijitToolbar .dijitButton, .dijitToolbar .dijitDropDownButton { margin: 0px; }
  36. .dijitToolbar .dijitToggleButtonSelected BUTTON, .dijitToolbar .dijitToggleButtonSelectedHover BUTTON { border-width: 3px; }
  37. </style>
  38. <!-- To turn off display of text use showLabel=false attribute on button
  39. to turn off display or icon, add your own classes and/or CSS rules -->
  40. <style>
  41. .toolbarWithNoImages .dijitButtonContents .dijitInline,
  42. .toolbarWithNoImages .dijitButtonContents .dijitInline {
  43. display: none;
  44. }
  45. .menuBar .dijitA11yDownArrow { display: none; }
  46. </style>
  47. </head>
  48. <body>
  49. <h1 class="testTitle">Toolbar test</h1>
  50. <h2>Toolbar from markup</h2>
  51. <div id="toolbar1" dojoType="dijit.Toolbar"
  52. ><div dojoType="dijit.form.Button" id="toolbar1.cut" iconClass="dijitEditorIcon dijitEditorIconCut" showLabel="false">Cut</div
  53. ><div dojoType="dijit.form.Button" id="toolbar1.copy" iconClass="dijitEditorIcon dijitEditorIconCopy" showLabel="false">Copy</div
  54. ><div dojoType="dijit.form.Button" id="toolbar1.paste" iconClass="dijitEditorIcon dijitEditorIconPaste" showLabel="false">Paste</div
  55. ><span dojoType="dijit.ToolbarSeparator"></span
  56. ><div dojoType="dijit.form.ToggleButton" id="toolbar1.bold" iconClass="dijitEditorIcon dijitEditorIconBold" showLabel="false">Bold</div
  57. ><div dojoType="dijit.form.ToggleButton" id="toolbar1.italic" iconClass="dijitEditorIcon dijitEditorIconItalic" showLabel="false">Italic</div
  58. ><div dojoType="dijit.form.ToggleButton" id="toolbar1.underline" iconClass="dijitEditorIcon dijitEditorIconUnderline" showLabel="false">Underline</div
  59. ><div dojoType="dijit.form.ToggleButton" id="toolbar1.strikethrough" iconClass="dijitEditorIcon dijitEditorIconStrikethrough" showLabel="false">Strikethrough</div
  60. ><!--
  61. <span dojoType="dijit.ToolbarSeparator">&nbsp;</span>
  62. <span dojo:type="ToolbarButtonGroup" name="justify" defaultButton="justifyleft" preventDeselect="true" showLabel="false">
  63. <div dojoType="dijit.form.ToggleButton" iconClass="dijitEditorIcon dijitEditorIconJustifyLeft" name="justify" showLabel="false">Left</div>
  64. <div dojoType="dijit.form.ToggleButton" iconClass="dijitEditorIcon dijitEditorIconJustifyRight" name="justify" showLabel="false">Right</div>
  65. <div dojoType="dijit.form.ToggleButton" iconClass="dijitEditorIcon dijitEditorIconJustifyCenter" name="justify" showLabel="false">Center</div>
  66. </span>
  67. --><span dojoType="dijit.ToolbarSeparator">&nbsp;</span
  68. ><div dojoType="dijit.form.Button" id="toolbar1.insertorderedlist" iconClass="dijitEditorIcon dijitEditorIconInsertOrderedList" showLabel="false">Ordered list</div
  69. ><div dojoType="dijit.form.Button" id="toolbar1.insertunorderedlist" iconClass="dijitEditorIcon dijitEditorIconInsertUnorderedList" showLabel="false">Unordered list</div
  70. ><div dojoType="dijit.form.Button" id="toolbar1.indent" iconClass="dijitEditorIcon dijitEditorIconIndent" showLabel="false">Indent</div
  71. ><div dojoType="dijit.form.Button" id="toolbar1.outdent" iconClass="dijitEditorIcon dijitEditorIconOutdent" showLabel="false">Outdent</div
  72. ><span dojoType="dijit.ToolbarSeparator"></span
  73. ><div dojoType="dijit.form.DropDownButton" id="toolbar1.dialog">
  74. <span>Login</span>
  75. <div dojoType="dijit.TooltipDialog" id="tooltipDlg" title="Enter Login information"
  76. execute="alert('submitted w/args:\n' + dojo.toJson(arguments[0], true));">
  77. <table>
  78. <tr>
  79. <td><label for="user">User:</label></td>
  80. <td><input dojoType=dijit.form.TextBox type="text" name="user" ></td>
  81. </tr>
  82. <tr>
  83. <td><label for="pwd">Password:</label></td>
  84. <td><input dojoType=dijit.form.TextBox type="password" name="pwd"></td>
  85. </tr>
  86. <tr>
  87. <td colspan="2" align="center">
  88. <button dojoType=dijit.form.Button type="submit" name="submit">Login</button></td>
  89. </tr>
  90. </table>
  91. </div></div><div dojoType="dijit.form.DropDownButton" id="toolbar1.backcolor" iconClass="dijitEditorIcon dijitEditorIconBackColor" showLabel="false">
  92. <span>Background</span>
  93. <div dojoType="dijit.ColorPalette" id="toolbar1.colorPalette" style="display: none" palette="3x4" onChange="console.log(this.value);"></div>
  94. </div
  95. ><div dojoType="dijit.form.DropDownButton" id="toolbar1.forecolor" iconClass="dijitEditorIcon dijitEditorIconForeColor" showLabel="false">
  96. <span>Foreground</span>
  97. <div dojoType="dijit.ColorPalette" id="toolbar1.colorPalette2" style="display: none" palette="3x4" onChange="console.log(this.value);"></div>
  98. </div
  99. ><span dojoType="dijit.ToolbarSeparator"></span
  100. ><div dojoType="dijit.form.ComboButton" optionsTitle='save options' onClick='console.log("clicked combo save")'>
  101. <span>Save</span>
  102. <div dojoType="dijit.Menu" id="saveMenu" style="display: none;">
  103. <div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconSave"
  104. onClick="console.log('not actually saving anything, just a test!')">Save</div>
  105. <div dojoType="dijit.MenuItem"
  106. onClick="console.log('not actually saving anything, just a test!')">Save As</div>
  107. </div>
  108. </div
  109. ></div>
  110. <h2>Toolbar that looks like MenuBar</h2>
  111. <div id="menubar" dojoType="dijit.Toolbar" class="menuBar">
  112. <div dojoType="dijit.form.DropDownButton">
  113. <span>File</span>
  114. <div dojoType="dijit.Menu">
  115. <div dojoType="dijit.MenuItem">New</div>
  116. <div dojoType="dijit.MenuItem">Open</div>
  117. <div dojoType="dijit.MenuSeparator"></div>
  118. <div dojoType="dijit.MenuItem" iconClass="dijitEditorIconSave">Save</div>
  119. <div dojoType="dijit.MenuItem">Save As...</div>
  120. </div>
  121. </div>
  122. <div dojoType="dijit.form.DropDownButton">
  123. <span>Edit</span>
  124. <div dojoType="dijit.Menu">
  125. <div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCut"
  126. onClick="console.log('not actually cutting anything, just a test!')">Cut</div>
  127. <div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCopy"
  128. onClick="console.log('not actually copying anything, just a test!')">Copy</div>
  129. <div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconPaste"
  130. onClick="console.log('not actually pasting anything, just a test!')">Paste</div>
  131. </div>
  132. </div>
  133. <div dojoType="dijit.form.DropDownButton">
  134. <span>View</span>
  135. <div dojoType="dijit.Menu">
  136. <div dojoType="dijit.MenuItem">Normal</div>
  137. <div dojoType="dijit.MenuItem">Outline</div>
  138. <div dojoType="dijit.PopupMenuItem">
  139. <span>Zoom</span>
  140. <div dojoType="dijit.Menu" id="submenu2">
  141. <div dojoType="dijit.MenuItem">50%</div>
  142. <div dojoType="dijit.MenuItem">75%</div>
  143. <div dojoType="dijit.MenuItem">100%</div>
  144. <div dojoType="dijit.MenuItem">150%</div>
  145. <div dojoType="dijit.MenuItem">200%</div>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. <div dojoType="dijit.form.DropDownButton">
  151. <span>Help</span>
  152. <div dojoType="dijit.Menu">
  153. <div dojoType="dijit.MenuItem">Help Topics</div>
  154. <div dojoType="dijit.MenuItem">About Dijit</div>
  155. </div>
  156. </div>
  157. </div>
  158. <h2>Toolbar from script</h2>
  159. <div id="toolbar2"></div>
  160. <h2>Toolbar with text and icons</h2>
  161. <div id="toolbar3"></div>
  162. <h2>Toolbar with text only</h2>
  163. <div id="toolbar4" class="toolbarWithNoImages"></div>
  164. </body>
  165. </html>