mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 17:23:02 +00:00
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
32 lines
966 B
JavaScript
32 lines
966 B
JavaScript
import { select as d3_select } from 'd3-selection';
|
|
import { t, textDirection } from '../../util/locale';
|
|
import { svgIcon } from '../../svg';
|
|
import { uiTooltipHtml } from '../tooltipHtml';
|
|
import { tooltip } from '../../util/tooltip';
|
|
|
|
export function uiToolSidebarToggle(context) {
|
|
|
|
var tool = {
|
|
id: 'sidebar_toggle',
|
|
label: t('toolbar.inspect')
|
|
};
|
|
|
|
tool.render = function(selection) {
|
|
selection
|
|
.append('button')
|
|
.attr('class', 'bar-button')
|
|
.on('click', function() {
|
|
context.ui().sidebar.toggle();
|
|
})
|
|
.call(tooltip()
|
|
.placement('bottom')
|
|
.html(true)
|
|
.title(uiTooltipHtml(t('sidebar.tooltip'), t('sidebar.key')))
|
|
.scrollContainer(d3_select('#bar'))
|
|
)
|
|
.call(svgIcon('#iD-icon-sidebar-' + (textDirection === 'rtl' ? 'right' : 'left')));
|
|
};
|
|
|
|
return tool;
|
|
}
|