Files
iD/js/id/ui/source_switch.js
Tom MacWright 3b09c186b6 Be specific about retina as not to break the glue-generated sprite.
* Warn before switching sources. Fixes #779.
* Inline docs keep their place. Fixes #1109
2013-03-22 17:56:22 -04:00

30 lines
833 B
JavaScript

iD.ui.SourceSwitch = function(context) {
function click() {
d3.event.preventDefault();
if (context.history().hasChanges() &&
!window.confirm(t('source_switch.lose_changes'))) return;
var live = d3.select(this).classed('live');
context.connection()
.url(live ? 'http://api06.dev.openstreetmap.org' : 'http://www.openstreetmap.org');
context.map()
.flush();
d3.select(this)
.text(live ? t('source_switch.dev') : t('source_switch.live'))
.classed('live', !live);
}
return function(selection) {
selection.append('a')
.attr('href', '#')
.text(t('source_switch.live'))
.classed('live', true)
.attr('tabindex', -1)
.on('click', click);
};
};