dimensionpicker_rtl.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. goog.require('goog.ui.Menu');
  21. goog.require('goog.ui.PopupMenu');
  22. goog.require('goog.ui.SubMenu');
  23. </script>
  24. <link rel="stylesheet" href="css/demo.css">
  25. <link rel="stylesheet" href="../css/dimensionpicker.css">
  26. <link rel="stylesheet" href="../css/menu.css">
  27. <link rel="stylesheet" href="../css/menuitem.css">
  28. <link rel="stylesheet" href="../css/menuseparator.css">
  29. </head>
  30. <body dir="rtl">
  31. <h1>goog.ui.DimensionPicker</h1>
  32. <table border="0" cellpadding="0" cellspacing="4" width="100%">
  33. <tbody>
  34. <tr valign="top">
  35. <td width="33%">
  36. <!-- Event log. -->
  37. <fieldset class="goog-debug-panel">
  38. <legend>Event Log</legend>
  39. <div id="log"></div>
  40. </fieldset>
  41. </td>
  42. <td width="67%">
  43. <fieldset>
  44. <legend>Demo of the <strong>goog.ui.DimensionPicker</strong>
  45. component:
  46. </legend>
  47. <br/>
  48. <p ><button id="button">Open menu</button></p>
  49. <label id="p1">This is a 10x8 picker:</label>
  50. <label>You selected <span id="p1_value">nothing</span></label><br/>
  51. <label>The below picker is a decorated DIV:</label>
  52. <div id="decorateTarget" class="goog-dimension-picker"></div>
  53. </fieldset>
  54. <br/>
  55. <br/>
  56. </td>
  57. </tr>
  58. </tbody>
  59. </table>
  60. <br/>
  61. <div id="perf"></div>
  62. <script>
  63. var timer = goog.now();
  64. // Set up a logger.
  65. goog.debug.LogManager.getRoot().setLevel(goog.log.Level.ALL);
  66. var logger = goog.log.getLogger('demo');
  67. var logconsole = new goog.debug.DivConsole(goog.dom.getElement('log'));
  68. logconsole.setCapturing(true);
  69. var EVENTS = goog.object.getValues(goog.ui.Component.EventType);
  70. goog.log.fine(logger, 'Listening for: ' + EVENTS.join(', ') + '.');
  71. function logEvent(e) {
  72. var component = e.target;
  73. var caption = (typeof component.getCaption == 'function' &&
  74. component.getCaption()) || component.getId();
  75. goog.log.info(logger, '"' + caption + '" dispatched: ' + e.type);
  76. }
  77. // Popup menu with sub menus
  78. var menu = new goog.ui.PopupMenu();
  79. menu.attach(document.getElementById('button'),
  80. goog.positioning.Corner.BOTTOM_START);
  81. var subMenu = new goog.ui.SubMenu('Zero');
  82. var dimensionPicker = new goog.ui.DimensionPicker();
  83. dimensionPicker.setRightToLeft(true);
  84. var pickerMenu = new goog.ui.Menu();
  85. pickerMenu.addChild(dimensionPicker, true);
  86. subMenu.setMenu(pickerMenu);
  87. menu.addItem(subMenu);
  88. menu.render();
  89. var p1 = new goog.ui.DimensionPicker();
  90. p1.setRightToLeft(true);
  91. p1.render(goog.dom.getElement('p1'));
  92. goog.events.listen(p1, goog.ui.Component.EventType.ACTION,
  93. function(e) {
  94. var picker = e.target;
  95. var size = picker.getValue();
  96. goog.dom.setTextContent(goog.dom.getElement('p1_value'),
  97. size.width + ' x ' + size.height);
  98. });
  99. goog.events.listen(p1, EVENTS, logEvent);
  100. // Perf and clean up
  101. goog.dom.setTextContent(goog.dom.getElement('perf'),
  102. (goog.now() - timer) + 'ms');
  103. var p2 = new goog.ui.DimensionPicker();
  104. p2.setRightToLeft(true);
  105. p2.decorate(goog.dom.getElement('decorateTarget'));
  106. </script>
  107. </body>
  108. </html>