| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 * @param {!Element} element | 129 * @param {!Element} element |
| 130 * @param {!Element|string} tooltipContent | 130 * @param {!Element|string} tooltipContent |
| 131 * @param {string=} actionId | 131 * @param {string=} actionId |
| 132 */ | 132 */ |
| 133 WebInspector.Tooltip.install = function(element, tooltipContent, actionId) | 133 WebInspector.Tooltip.install = function(element, tooltipContent, actionId) |
| 134 { | 134 { |
| 135 if (typeof tooltipContent === "string" && tooltipContent === "") | 135 if (typeof tooltipContent === "string" && tooltipContent === "") |
| 136 return; | 136 return; |
| 137 element[WebInspector.Tooltip._symbol] = { content: tooltipContent, actionId
: actionId }; | 137 element[WebInspector.Tooltip._symbol] = { content: tooltipContent, actionId
: actionId }; |
| 138 } | 138 } |
| OLD | NEW |