OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @param {!Document} doc | 7 * @param {!Document} doc |
8 */ | 8 */ |
9 WebInspector.Tooltip = function(doc) | 9 WebInspector.Tooltip = function(doc) |
10 { | 10 { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 var tooltip = anchorElement[WebInspector.Tooltip._symbol]; | 59 var tooltip = anchorElement[WebInspector.Tooltip._symbol]; |
60 this._anchorElement = anchorElement; | 60 this._anchorElement = anchorElement; |
61 this._tooltipElement.removeChildren(); | 61 this._tooltipElement.removeChildren(); |
62 if (typeof tooltip.content === "string") | 62 if (typeof tooltip.content === "string") |
63 this._tooltipElement.textContent = tooltip.content; | 63 this._tooltipElement.textContent = tooltip.content; |
64 else | 64 else |
65 this._tooltipElement.appendChild(tooltip.content); | 65 this._tooltipElement.appendChild(tooltip.content); |
66 | 66 |
67 if (tooltip.actionId) { | 67 if (tooltip.actionId) { |
68 var shortcuts = WebInspector.shortcutRegistry.shortcutDescriptorsFor
Action(tooltip.actionId); | 68 var shortcuts = WebInspector.shortcutRegistry.shortcutDescriptorsFor
Action(tooltip.actionId); |
69 if (shortcuts && shortcuts.length) { | 69 for (var shortcut of shortcuts) { |
70 var shortcutElement = this._tooltipElement.createChild("div", "t
ooltip-shortcut"); | 70 var shortcutElement = this._tooltipElement.createChild("div", "t
ooltip-shortcut"); |
71 shortcutElement.textContent = shortcuts[0].name; | 71 shortcutElement.textContent = shortcut.name; |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 this._tooltipElement.classList.add("shown"); | 75 this._tooltipElement.classList.add("shown"); |
76 // Reposition to ensure text doesn't overflow unnecessarily. | 76 // Reposition to ensure text doesn't overflow unnecessarily. |
77 this._tooltipElement.positionAt(0, 0); | 77 this._tooltipElement.positionAt(0, 0); |
78 | 78 |
79 // Show tooltip instantly if a tooltip was shown recently. | 79 // Show tooltip instantly if a tooltip was shown recently. |
80 var now = Date.now(); | 80 var now = Date.now(); |
81 var instant = (this._tooltipLastClosed && now - this._tooltipLastClosed
< WebInspector.Tooltip.Timing.InstantThreshold); | 81 var instant = (this._tooltipLastClosed && now - this._tooltipLastClosed
< WebInspector.Tooltip.Timing.InstantThreshold); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 /** | 158 /** |
159 * @param {!Element|string} x | 159 * @param {!Element|string} x |
160 * @this {!Element} | 160 * @this {!Element} |
161 */ | 161 */ |
162 set: function(x) | 162 set: function(x) |
163 { | 163 { |
164 WebInspector.Tooltip.install(this, x); | 164 WebInspector.Tooltip.install(this, x); |
165 } | 165 } |
166 }); | 166 }); |
OLD | NEW |