Close modals with esc or backspace

This commit is contained in:
Ansis Brammanis
2013-01-28 17:46:25 -05:00
parent 8fe9da4710
commit 541ff96af6

View File

@@ -1,6 +1,13 @@
iD.ui.modal = function(blocking) {
var animate = d3.select('div.modal').empty();
var keybinding = d3.keybinding('modal')
.on('⌫', close)
.on('⎋', close);
d3.select(document).call(keybinding);
d3.select('div.modal').transition()
.style('opacity', 0).remove();
@@ -30,5 +37,10 @@ iD.ui.modal = function(blocking) {
shaded.style('opacity', 1);
}
function close() {
shaded.remove();
keybinding.off();
}
return shaded;
};