Skip to content

Commit

Permalink
Now possible to reregister tooltips for a specific container
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Mar 28, 2022
1 parent d5608a1 commit 32d790a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<l:icon class="icon-lock icon-sm" tooltip="${%Keep this build forever}:&lt;br/&gt;${h.xmlEscape(build.whyKeepLog)}" xmlns:l="/lib/layout"/>
<l:icon class="icon-lock icon-sm" tooltip="${%Keep this build forever}:\n${h.xmlEscape(build.whyKeepLog)}" xmlns:l="/lib/layout"/>
13 changes: 9 additions & 4 deletions war/src/main/js/tooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,28 @@ registerTooltips()
/**
* Registers tooltips for the page
* If called again, destroys existing tooltips and registers them again (useful for progressive rendering)
* @param {HTMLElement} container - Registers the tooltips for the given container
*/
function registerTooltips() {
function registerTooltips(container = document) {
tooltipInstances.forEach(instance => {
instance.destroy()
if (instance.props.container === container) {
instance.destroy()
}
})

tippy("[tooltip]:not([tooltip=\"\"])", {
tippy(container.querySelectorAll("[tooltip]:not([tooltip=\"\"])"), {
content: element => element.getAttribute("tooltip")
.replace("<br>", "\n")
.replace("<br/>", "\n")
.replace("\\n", "\n"),
container: container,
...TOOLTIP_BASE
})

tippy("[html-tooltip]", {
tippy(container.querySelectorAll("[html-tooltip]"), {
content: element => element.getAttribute("html-tooltip"),
allowHTML: true,
container: container,
...TOOLTIP_BASE
})
}
Expand Down
1 change: 1 addition & 0 deletions war/src/main/webapp/scripts/hudson-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -1736,6 +1736,7 @@ function refreshPart(id,url) {

Behaviour.applySubtree(node);
layoutUpdateCallback.call();
registerTooltips(node)
}
});
}
Expand Down

0 comments on commit 32d790a

Please sign in to comment.