test_Button-programmatic.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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>PROGRAMMATIC - Dojo Button 100 Test</title>
  6. <script type="text/javascript" src="../../dojo/dojo.js" XdjConfig='isDebug: true, debugAtAllCosts: true'></script>
  7. <script type="text/javascript">
  8. dojo.require("dijit.form.Button");
  9. dojo.require("dojo.parser");
  10. logMessage = window.alert;
  11. </script>
  12. <style>
  13. @import "../themes/tundra/tundra.css";
  14. /* group multiple buttons in a row */
  15. .box {
  16. display: block;
  17. text-align: center;
  18. }
  19. .box .dojoButton {
  20. width:80px;
  21. margin-right: 10px;
  22. }
  23. .dojoButtonContents {
  24. font-size: 1.6em;
  25. }
  26. #buttonContainer {
  27. border:1px solid black;
  28. width:100%;
  29. }
  30. #results {
  31. color:darkred;
  32. }
  33. </style>
  34. </head>
  35. <body class=tundra>
  36. <h2>Creating dojot.form.buttons programmatically</h2>
  37. <h3 id="results"></h3>
  38. <div id="buttonContainer" class='box'></div>
  39. <br>
  40. Pass "?count=<i><b>n</b></i>" in the query string to change the number of buttons.
  41. <script type="text/javascript">
  42. // See if we can make a widget in script and attach it to the DOM ourselves.
  43. function makeEm() {
  44. var queryCount = location.search.match(/count=(\d*)/);
  45. var count = (queryCount ? parseInt(queryCount[1]) : 100);
  46. var container = dojo.byId("buttonContainer");
  47. var t0 = new Date().getTime();
  48. for (var i = 1; i <= count; i++) {
  49. var it =
  50. new dijit.form.Button(
  51. {label:"Button "+i, onclick:'logMessage("clicked simple")'}
  52. );
  53. container.appendChild(it.domNode);
  54. it.domNode.style.display = '';
  55. }
  56. var t1 = new Date().getTime();
  57. dojo.byId("results").innerHTML = "It took " + (t1 - t0) + " msec to create " + count + " Buttons programmatically.";
  58. }
  59. dojo.addOnLoad(makeEm);
  60. </script>
  61. </body>
  62. </html>