From f0c45034bd8f692ea71a14b5f97ede5055ac6257 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Wed, 5 Dec 2012 17:19:48 -0500 Subject: [PATCH] Improve, move geocoder --- css/app.css | 31 +++++++++++++++++-------------- js/id/id.js | 38 +++++++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/css/app.css b/css/app.css index 438218e6c..f20848162 100644 --- a/css/app.css +++ b/css/app.css @@ -102,12 +102,21 @@ table th { right:0; } -input#geocode-location { +div.geocode-control { position:absolute; - background:#f4f4ff; + top:130px; + left:10px; color:#222; } +#bar div.geocode-control button { + width:40px; +} + +div.geocode-control input { + display:none; +} + #bar button { width:80px; white-space:nowrap; @@ -145,19 +154,15 @@ div.buttons-joined { } #bar .messages { - position:absolute; - right:200px; - top:0; padding:10px; overflow:hidden; width:100px; + display:inline-block; } #bar .user { - width:200px; - position:absolute; - right:300px; - top:0; + width:150px; + display:inline-block; padding:10px; } @@ -176,9 +181,7 @@ div.buttons-joined { } #bar button.save { - position:absolute; - top:0; - right:100px; + display:inline-block; } #bar button.mini, @@ -188,8 +191,8 @@ div.buttons-joined { #bar input[type=text] { width:150px; - height:30px; - border:0; + height:20px; + border:1px solid #ccc; padding:5px; margin:0; } diff --git a/js/id/id.js b/js/id/id.js index 84280568f..453536636 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -60,24 +60,11 @@ window.iD = function(container) { .call(bootstrap.tooltip() .placement('bottom')); - bar.append('input') - .attr({ type: 'text', placeholder: 'find a place', id: 'geocode-location' }) - .on('keydown', function () { - if (d3.event.keyCode !== 13) return; - d3.event.preventDefault(); - var val = d3.select('#geocode-location').node().value; - d3.select(document.body).append('script') - .attr('src', 'http://api.tiles.mapbox.com/v3/mapbox/geocode/' + - encodeURIComponent(val) + '.jsonp?callback=grid'); - }); window.grid = function(resp) { map.center([resp.results[0][0].lon, resp.results[0][0].lat]); }; - bar.append('div') - .attr('class', 'messages'); - bar.append('div') .attr('class', 'user') .append('div') @@ -119,6 +106,9 @@ window.iD = function(container) { } }); + bar.append('div') + .attr('class', 'messages'); + var zoom = bar.append('div') .attr('class', 'zoombuttons') .selectAll('button') @@ -127,6 +117,28 @@ window.iD = function(container) { .text(function(d) { return d[1]; }) .on('click', function(d) { return d[2](); }); + var gc = bar.append('div').attr('class', 'geocode-control'); + gc.append('button').text('?'); + gc.on('mouseover', function() { + d3.select('.geocode-control input').style('display', 'inline-block'); + }); + gc.on('mouseout', function() { + d3.select('.geocode-control input').style('display', 'none'); + }); + gc.append('input') + .attr({ + type: 'text', + placeholder: 'find a place' + }) + .on('keydown', function () { + if (d3.event.keyCode !== 13) return; + d3.event.preventDefault(); + var val = this.value; + d3.select(document.body).append('script') + .attr('src', 'http://api.tiles.mapbox.com/v3/mapbox/geocode/' + + encodeURIComponent(val) + '.jsonp?callback=grid'); + }); + this.append('div') .attr('class', 'inspector-wrap') .style('display', 'none');