Files
iD/js/id/ui/source_switch.js
T
2013-04-17 16:24:12 -07:00

31 lines
813 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()
.switch(live ? iD.data.keys[1] : iD.data.keys[0]);
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);
};
};