From 2f8454e50e72e1c2a67eab7797462e7d08610909 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Tue, 8 Jan 2013 15:33:22 -0500 Subject: [PATCH] Add close button to modal --- js/id/ui/modal.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/js/id/ui/modal.js b/js/id/ui/modal.js index 236102987..3b90f63e3 100644 --- a/js/id/ui/modal.js +++ b/js/id/ui/modal.js @@ -5,15 +5,23 @@ iD.modal = function() { .style('opacity', 0).remove(); var shaded = d3.select(document.body) - .append('div').attr('class', 'shaded') + .append('div') + .attr('class', 'shaded') .style('opacity', 0) .on('click.remove-modal', function() { if (d3.event.target == this) d3.select(this).remove(); }); - shaded.append('div') - .attr('class', 'modal') - .append('div') + var modal = shaded.append('div') + .attr('class', 'modal'); + + modal.append('button') + .attr('class', 'icon remove close-modal') + .on('click', function() { + shaded.remove(); + }); + + modal.append('div') .attr('class', 'content'); if (animate) {