tooltip.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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.Tooltip</title>
  10. <meta charset="utf-8">
  11. <script src="../base.js"></script>
  12. <script>
  13. goog.require('goog.html.testing');
  14. goog.require('goog.ui.Tooltip');
  15. </script>
  16. <link rel="stylesheet" href="css/demo.css">
  17. <style>
  18. .goog-tooltip {
  19. background: infobackground;
  20. color: infotext;
  21. border: 1px solid infotext;
  22. padding: 1px;
  23. font: menu;
  24. }
  25. .tooltip2 {
  26. background: #C0C0FF;
  27. color: infotext;
  28. border: 1px solid infotext;
  29. padding: 1px;
  30. font: menu;
  31. width: 120px;
  32. }
  33. span {
  34. border-bottom: 1px dotted black;
  35. }
  36. </style>
  37. </head>
  38. <body>
  39. <h1>goog.ui.Tooltip</h1>
  40. <p>
  41. <button id="btn1">Hover me</button>
  42. <button id="btn2">and me</button>
  43. <button id="btn3">and me</button>
  44. <button id="btnNoTooltip">but not me</button>
  45. </p>
  46. <p>
  47. Demo <span id="txt1">tooltips</span> in text and and of <span id="txt2">nested
  48. <span id="txt3">tooltips</span>, where an element triggers
  49. one tooltip and an element inside the first element triggers another
  50. one.</span>
  51. </p>
  52. <div style="overflow: auto; height: 100px; border: 1px solid black;">
  53. <div style="margin: 5px; padding: 5px; height: 200px;">
  54. <button id="btn4">and me too!</button>
  55. </div>
  56. </div>
  57. <button id="btn5" style="position: absolute; bottom: 5px;">near bottom</button>
  58. <script>
  59. var msg1 = "Tooltip widget. Appears next to the cursor when over an " +
  60. "attached element or next to the element if it's active.";
  61. var tooltip1 = new goog.ui.Tooltip('btn1', msg1);
  62. var tooltip2 = new goog.ui.Tooltip('btn2');
  63. tooltip2.className = 'tooltip2';
  64. tooltip2.setSafeHtml(goog.html.testing.newSafeHtmlForTest(
  65. "This is message two, using a different class name for the tooltip and " +
  66. "<strong>HTML</strong> <em>markup</em>.<br>" +
  67. "<button id=\"btn-nest\">Hover me</button>"));
  68. tooltip2.attach('btn5');
  69. var tooltip3 = new goog.ui.Tooltip('btn3', 'Tooltip for button 3');
  70. var msg4 = "Tooltip for button 4, demonstrating that it's positioned " +
  71. "correctly even when inside a scrolling container.";
  72. var tooltip4 = new goog.ui.Tooltip('btn4', msg4);
  73. var msg5 = "tooltip for the word 'tooltips'."
  74. var tooltip5 = new goog.ui.Tooltip('txt1', msg5);
  75. tooltip5.attach('txt3');
  76. var tooltip6 = new goog.ui.Tooltip('txt2', 'outer tooltip');
  77. var tooltip7 = new goog.ui.Tooltip('btn-nest');
  78. tooltip7.setSafeHtml(goog.html.testing.newSafeHtmlForTest(
  79. "Even nested<br>tooltips!"));
  80. </script>
  81. </body>
  82. </html>