advancedtooltip.html 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.AdvancedTooltip</title>
  10. <meta charset="utf-8">
  11. <script src="../base.js"></script>
  12. <script>
  13. goog.require('goog.events.EventType');
  14. goog.require('goog.html.testing');
  15. goog.require('goog.ui.AdvancedTooltip');
  16. </script>
  17. <link rel="stylesheet" href="css/demo.css">
  18. <style>
  19. .goog-tooltip {
  20. background: lightyellow;
  21. color: black;
  22. border: 1px solid black;
  23. padding: 1px;
  24. font: menu;
  25. }
  26. .tooltip {
  27. background: lightyellow;
  28. color: black;
  29. border: 1px solid black;
  30. padding: 5px;
  31. font: menu;
  32. width: 400px;
  33. }
  34. </style>
  35. </head>
  36. <body>
  37. <h1>goog.ui.AdvancedTooltip</h1>
  38. <fieldset class="goog-debug-panel" style="display:none">
  39. <legend>Event Log</legend>
  40. <div id="log"></div>
  41. </fieldset>
  42. <p>
  43. <button id="btn">Hover me</button>
  44. </p>
  45. <script>
  46. var tooltip = new goog.ui.AdvancedTooltip('btn');
  47. tooltip.className = 'tooltip';
  48. tooltip.setSafeHtml(goog.html.testing.newSafeHtmlForTest(
  49. "<h2>AdvancedTooltip</h2>" +
  50. "<ul><li>Move cursor towards the tooltip (<em>that's me!</em>) " +
  51. "and see that it remains open.</li>" +
  52. "<li>Before reaching it start moving the cursor in another " +
  53. "direction...</li>" +
  54. "<li>Once the cursor reaches the tooltip the cursor tracking is turned " +
  55. "off and a 10px 'padding' around it gets added. As long as the cursor " +
  56. "stays inside the box formed by the tooltip and the padding it remains " +
  57. "open.</li></ul><hr/><div style=\"text-align: center;\">" +
  58. "<button id=\"btn-nest\">Hover me</button>&nbsp;" +
  59. "<button id=\"btn-close\">Close</button></div>"));
  60. tooltip.setHotSpotPadding(new goog.math.Box(5, 5, 5, 5));
  61. tooltip.setCursorTracking(true);
  62. tooltip.setMargin(new goog.math.Box(100, 0, 0, 100));
  63. tooltip.setHideDelayMs(250);
  64. new goog.ui.AdvancedTooltip('btn-nest').setSafeHtml(
  65. goog.html.testing.newSafeHtmlForTest(
  66. 'Clicking<br> this<br> button<br> has no effect.'));
  67. new goog.ui.Tooltip('btn-close', 'Closes tooltip');
  68. goog.events.listen(document.getElementById('btn-close'),
  69. goog.events.EventType.CLICK, function(e) {
  70. tooltip.setVisible(false);
  71. }
  72. );
  73. </script>
  74. </body>
  75. </html>