dimensionpicker.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <!DOCTYPE html>
  2. <html>
  3. <!--
  4. Copyright 2010 The Closure Library Authors. All Rights Reserved.
  5. Use of this source code is governed by the Apache License, Version 2.0.
  6. See the COPYING file for details.
  7. -->
  8. <head>
  9. <title>goog.ui.DimensionPicker</title>
  10. <script src="../base.js"></script>
  11. <script>
  12. goog.require('goog.debug.DivConsole');
  13. goog.require('goog.debug.LogManager');
  14. goog.require('goog.dom');
  15. goog.require('goog.events');
  16. goog.require('goog.log');
  17. goog.require('goog.object');
  18. goog.require('goog.ui.Component.EventType');
  19. goog.require('goog.ui.DimensionPicker');
  20. </script>
  21. <link rel="stylesheet" href="css/demo.css">
  22. <link rel="stylesheet" href="../css/dimensionpicker.css">
  23. <style>
  24. .goog-dimension-picker div.goog-dimension-picker-highlighted {
  25. background: url(../images/dimension-highlighted.png);
  26. }
  27. .goog-dimension-picker-unhighlighted {
  28. background: url(../images/dimension-unhighlighted.png);
  29. }
  30. </style>
  31. </head>
  32. <body>
  33. <h1>goog.ui.DimensionPicker</h1>
  34. <table border="0" cellpadding="0" cellspacing="4" width="100%">
  35. <tbody>
  36. <tr valign="top">
  37. <td width="67%">
  38. <fieldset>
  39. <legend>Demo of the <strong>goog.ui.DimensionPicker</strong>
  40. component:
  41. </legend>
  42. <br/>
  43. <label id="p1">This is a 10x8 picker:</label>
  44. <label>You selected <span id="p1_value">nothing</span></label><br/>
  45. <label>The below picker is a decorated DIV:</label>
  46. <div id="decorateTarget" class="goog-dimension-picker"></div>
  47. </fieldset>
  48. <br/>
  49. <br/>
  50. </td>
  51. <td width="33%">
  52. <!-- Event log. -->
  53. <fieldset class="goog-debug-panel">
  54. <legend>Event Log</legend>
  55. <div id="log"></div>
  56. </fieldset>
  57. </td>
  58. </tr>
  59. </tbody>
  60. </table>
  61. <br/>
  62. <div id="perf"></div>
  63. <script>
  64. var timer = goog.now();
  65. // Set up a logger.
  66. goog.debug.LogManager.getRoot().setLevel(goog.log.Level.ALL);
  67. var logger = goog.log.getLogger('demo');
  68. var logconsole = new goog.debug.DivConsole(goog.dom.getElement('log'));
  69. logconsole.setCapturing(true);
  70. var EVENTS = goog.object.getValues(goog.ui.Component.EventType);
  71. goog.log.fine(logger, 'Listening for: ' + EVENTS.join(', ') + '.');
  72. function logEvent(e) {
  73. var component = e.target;
  74. var caption = (typeof component.getCaption == 'function' &&
  75. component.getCaption()) || component.getId();
  76. goog.log.info(logger, '"' + caption + '" dispatched: ' + e.type);
  77. }
  78. var p1 = new goog.ui.DimensionPicker();
  79. p1.render(goog.dom.getElement('p1'));
  80. goog.events.listen(p1, goog.ui.Component.EventType.ACTION,
  81. function(e) {
  82. var picker = e.target;
  83. var size = picker.getValue();
  84. goog.dom.setTextContent(goog.dom.getElement('p1_value'),
  85. size.width + ' x ' + size.height);
  86. });
  87. goog.events.listen(p1, EVENTS, logEvent);
  88. // Perf and clean up
  89. goog.dom.setTextContent(goog.dom.getElement('perf'),
  90. (goog.now() - timer) + 'ms');
  91. var p2 = new goog.ui.DimensionPicker();
  92. p2.decorate(goog.dom.getElement('decorateTarget'));
  93. </script>
  94. </body>
  95. </html>