Files
iD/js/id/ui/zoom.js
John Firebaugh 9a2054272c Fix build
2014-10-13 16:48:59 -07:00

46 lines
1.4 KiB
JavaScript

iD.ui.Zoom = function(context) {
var zooms = [{
id: 'zoom-in',
title: t('zoom.in'),
action: context.zoomIn,
key: '+'
}, {
id: 'zoom-out',
title: t('zoom.out'),
action: context.zoomOut,
key: '-'
}];
return function(selection) {
var button = selection.selectAll('button')
.data(zooms)
.enter().append('button')
.attr('tabindex', -1)
.attr('class', function(d) { return d.id; })
.on('click.editor', function(d) { d.action(); })
.call(bootstrap.tooltip()
.placement('left')
.html(true)
.title(function(d) {
return iD.ui.tooltipHtml(d.title, d.key);
}));
button.append('span')
.attr('class', function(d) { return d.id + ' icon'; });
var keybinding = d3.keybinding('zoom');
_.each(['=','ffequals','plus','ffplus'], function(key) {
keybinding.on(key, function() { context.zoomIn(); });
keybinding.on('⇧' + key, function() { context.zoomIn(); });
});
_.each(['-','ffminus','_','dash'], function(key) {
keybinding.on(key, function() { context.zoomOut(); });
keybinding.on('⇧' + key, function() { context.zoomOut(); });
});
d3.select(document)
.call(keybinding);
};
};