Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow tooltip to show as key/value list #686

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/DebugBar/Resources/debugbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ a.phpdebugbar-open-btn {
.phpdebugbar-indicator span.phpdebugbar-tooltip {
display: none;
position: absolute;
top: -30px;
bottom: 30px;
background: #efefef70;
border: 1px solid #ccc;
color: #555;
Expand All @@ -268,6 +268,20 @@ a.phpdebugbar-open-btn {
.phpdebugbar-indicator:hover span.phpdebugbar-tooltip:not(.phpdebugbar-disabled) {
display: block;
}
.phpdebugbar-indicator span.phpdebugbar-tooltip dl {
display: grid;
grid-gap: 4px 10px;
grid-template-columns: max-content;
}
.phpdebugbar-indicator span.phpdebugbar-tooltip dl dt {
font-weight: bold;
text-align: left;
}
.phpdebugbar-indicator span.phpdebugbar-tooltip dl dd {
margin: 0;
grid-column-start: 2;
text-align: left;
}

select.phpdebugbar-datasets-switcher {
float: right;
Expand Down
13 changes: 11 additions & 2 deletions src/DebugBar/Resources/debugbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,16 @@ if (typeof(PhpDebugBar) == 'undefined') {
this.$tooltip = $('<span />').addClass(csscls('tooltip disabled')).appendTo(this.$el);
this.bindAttr('tooltip', function(tooltip) {
if (tooltip) {
this.$tooltip.text(tooltip).removeClass(csscls('disabled'));
var dl = $('<dl />');
if (Array.isArray(tooltip) || typeof tooltip === 'object') {
$.each(tooltip, function(key, value) {
$('<dt />').text(key).appendTo(dl);
$('<dd />').text(value).appendTo(dl);
});
this.$tooltip.html(dl).removeClass(csscls('disabled'));
} else {
this.$tooltip.text(tooltip).removeClass(csscls('disabled'));
}
} else {
this.$tooltip.addClass(csscls('disabled'));
}
Expand Down Expand Up @@ -665,7 +674,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
* @this {DebugBar}
* @param {String} name Internal name
* @param {String} icon
* @param {String} tooltip
* @param {String|Object} tooltip
* @param {String} position "right" or "left", default is "right"
* @return {Indicator}
*/
Expand Down