From 13b5cc4c4d56baa353b9b72bd0c3abc953004b7c Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Sun, 17 Mar 2013 19:54:47 -0700 Subject: [PATCH] Move inspector logic to Inspector --- js/id/modes/select.js | 27 +++++---------------------- js/id/ui/inspector.js | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/js/id/modes/select.js b/js/id/modes/select.js index 31142fba4..331707f39 100644 --- a/js/id/modes/select.js +++ b/js/id/modes/select.js @@ -14,6 +14,9 @@ iD.modes.Select = function(context, selection, initial) { iD.modes.DragNode(context).behavior], radialMenu; + var wrap = context.container() + .select('.inspector-wrap'); + function changeTags(d, tags) { if (!_.isEqual(singular().tags, tags)) { context.perform( @@ -85,16 +88,7 @@ iD.modes.Select = function(context, selection, initial) { }), true)); if (entity) { - var wrap = context.container() - .select('.inspector-wrap'); - - wrap.style('display', 'block') - .call(inspector) - .style('right', '-500px') - .style('opacity', 1) - .transition() - .duration(200) - .style('right', '0px'); + wrap.call(inspector); if (d3.event) { // Pan the map if the clicked feature intersects with the position @@ -193,18 +187,7 @@ iD.modes.Select = function(context, selection, initial) { mode.exit = function() { if (timeout) window.clearTimeout(timeout); - context.container() - .select('.inspector-wrap') - .transition() - .style('right', '-500px') - .each('end', function() { - d3.select(this).style('display', 'none') - .html(''); - }); - - // Firefox incorrectly implements blur, so typeahead elements - // are not correctly removed. Remove any stragglers manually. - d3.selectAll('div.typeahead').remove(); + wrap.call(inspector.close); behaviors.forEach(function(behavior) { context.uninstall(behavior); diff --git a/js/id/ui/inspector.js b/js/id/ui/inspector.js index 83b252a99..d45de74c3 100644 --- a/js/id/ui/inspector.js +++ b/js/id/ui/inspector.js @@ -3,6 +3,14 @@ iD.ui.Inspector = function(context, entity) { tagEditor; function inspector(selection) { + selection + .style('display', 'block') + .style('right', '-500px') + .style('opacity', 1) + .transition() + .duration(200) + .style('right', '0px'); + var panewrap = selection .append('div') .classed('panewrap', true); @@ -54,6 +62,20 @@ iD.ui.Inspector = function(context, entity) { } } + inspector.close = function(selection) { + selection.transition() + .style('right', '-500px') + .each('end', function() { + d3.select(this) + .style('display', 'none') + .html(''); + }); + + // Firefox incorrectly implements blur, so typeahead elements + // are not correctly removed. Remove any stragglers manually. + d3.selectAll('div.typeahead').remove(); + }; + inspector.tags = function() { tagEditor.tags.apply(this, arguments); return inspector;