Debian Codegraph @

closure-library/closure/goog/demos/advancedtooltip.html

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