Files
iD/modules/util/tooltip.js
Quincy Morgan 523a467836 2.x: Make toolbar horizontally scrollable when it overflows (re: #6755, re: 7545f67063b5e7007ef2d8367e3181e59c04a487)
Generalize tooltip into popover control
Use the same popover control for tooltip as the preset browser and tools list popovers
Smartly position the preset browser popover and menu bar tooltips to stay fully onscreen
Position most tooltips closer to their controls
Fix small gap that could appear between a tooltip and its arrow
Allow wider toolbar tooltips
2019-12-16 13:30:07 -05:00

53 lines
1.2 KiB
JavaScript

import { utilFunctor } from './util';
import { popover } from './popover';
export function tooltip(klass) {
var tooltip = popover((klass || '') + ' tooltip')
.displayType('hover');
var _title = function() {
var title = this.getAttribute('data-original-title');
if (title) {
return title;
} else {
title = this.getAttribute('title');
this.removeAttribute('title');
this.setAttribute('data-original-title', title);
}
return title;
};
var _html = utilFunctor(false);
tooltip.title = function(val) {
if (arguments.length) {
_title = utilFunctor(val);
return tooltip;
} else {
return _title;
}
};
tooltip.html = function(val) {
if (arguments.length) {
_html = utilFunctor(val);
return tooltip;
} else {
return _html;
}
};
tooltip.content(function() {
var content = _title.apply(this, arguments);
var markup = _html.apply(this, arguments);
return function(selection) {
selection[markup ? 'html' : 'text'](content);
};
});
return tooltip;
}