From 541ff96af67c8baf1bfcd680c2b114cccc977b52 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Mon, 28 Jan 2013 17:46:25 -0500 Subject: [PATCH] Close modals with esc or backspace --- js/id/ui/modal.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/id/ui/modal.js b/js/id/ui/modal.js index 498f1e241..2e58166cb 100644 --- a/js/id/ui/modal.js +++ b/js/id/ui/modal.js @@ -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; };