From 1439b30049cd54cbbc1334ab48cb756c52fcd813 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Thu, 28 Mar 2013 18:06:12 -0400 Subject: [PATCH] Fix mixup around events so that background and geocoder close each other --- js/id/ui/background.js | 17 +++++------------ js/id/ui/geocoder.js | 17 +++++------------ 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/js/id/ui/background.js b/js/id/ui/background.js index cd8c87bea..e1226c2af 100644 --- a/js/id/ui/background.js +++ b/js/id/ui/background.js @@ -140,27 +140,20 @@ iD.ui.Background = function(context) { content.selectAll('.toggle-list li:first-child a').node().focus(); } - function blockClick() { - selection.on('mousedown.help-inside', function() { - return d3.event.stopPropagation(); - }); - selection.on('mousedown.help-inside', function() { - return d3.event.stopPropagation(); - }); - } - function setVisible(show) { if (show !== shown) { button.classed('active', show); shown = show; if (show) { + selection.on('mousedown.background-inside', function() { + return d3.event.stopPropagation(); + }); content.style('display', 'block') .style('left', '-500px') .transition() .duration(200) - .style('left', '30px') - .each('end', blockClick); + .style('left', '30px'); } else { content.style('display', 'block') .style('left', '30px') @@ -227,7 +220,7 @@ iD.ui.Background = function(context) { gpxLayerItem.call(bootstrap.tooltip() .title(t('gpx.drag_drop')) - .placement('right')) + .placement('right')); gpxLayerItem.append('span') .text(t('gpx.local_layer')); diff --git a/js/id/ui/geocoder.js b/js/id/ui/geocoder.js index 066698798..e97ceb2eb 100644 --- a/js/id/ui/geocoder.js +++ b/js/id/ui/geocoder.js @@ -94,15 +94,6 @@ iD.ui.Geocoder = function(context) { setVisible(!button.classed('active')); } - function blockClick() { - selection.on('mousedown.help-inside', function() { - return d3.event.stopPropagation(); - }); - selection.on('mousedown.help-inside', function() { - return d3.event.stopPropagation(); - }); - } - function setVisible(show) { if (show !== shown) { button.classed('active', show); @@ -117,14 +108,17 @@ iD.ui.Geocoder = function(context) { } if (show) { + selection.on('mousedown.geocoder-inside', function() { + return d3.event.stopPropagation(); + }); gcForm.style('display', 'block') .style('left', '-500px') .transition() .duration(200) - .style('left', '30px') - .each('end', blockClick); + .style('left', '30px'); inputNode.node().focus(); } else { + selection.on('mousedown.geocoder-inside', null); gcForm.style('display', 'block') .style('left', '30px') .transition() @@ -133,7 +127,6 @@ iD.ui.Geocoder = function(context) { .each('end', function() { d3.select(this).style('display', 'none'); }); - selection.on('mousedown.background-inside', null); inputNode.node().blur(); } }