diff --git a/index.html b/index.html index 782d4b32f..fa957b991 100644 --- a/index.html +++ b/index.html @@ -44,6 +44,7 @@ + diff --git a/js/id/id.js b/js/id/id.js index ac48d7878..8ee5a0e4a 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -44,28 +44,10 @@ window.iD = function(container) { } } - var showUsers = _.debounce(function() { - var users = {}, - entities = map.history().graph().intersects(map.extent()); - for (var i in entities) { - if (entities[i].user) { - users[entities[i].user] = true; - if (Object.keys(users).length > 10) break; - } - } - var u = Object.keys(users); - var l = d3.select('#user-list') - .selectAll('a.user-link').data(u); - l.enter().append('a') - .attr('class', 'user-link') - .attr('href', function(d) { return connection.userUrl(d); }) - .attr('target', '_blank') - .text(String); - l.exit().remove(); - }, 1000); - map.on('move.disable-buttons', disableTooHigh) - .on('move.show-users', showUsers); + .on('move.contributors', _.debounce(function() { + contributors.call(iD.contributors(map)); + }, 1000)); buttons.append('span') .attr('class', function(d) { @@ -191,8 +173,11 @@ window.iD = function(container) { var zoom = container.append('div') .attr('class', 'zoombuttons map-control') .selectAll('button') - .data([['zoom-in', '+', map.zoomIn], ['zoom-out', '-', map.zoomOut]]) - .enter().append('button').attr('class', function(d) { return d[0] + ' narrow'; }) + .data([['zoom-in', '+', map.zoomIn, 'Zoom In'], ['zoom-out', '-', map.zoomOut, 'Zoom Out']]) + .enter() + .append('button') + .attr('class', function(d) { return d[0] + ' narrow'; }) + .attr('title', function(d) { return d[3]; }) .on('click', function(d) { return d[2](); }) .append('span') .attr('class', function(d) { @@ -208,6 +193,7 @@ window.iD = function(container) { .attr('class', 'geolocate-control map-control') .append('button') .attr('class', 'narrow') + .attr('title', 'Show My Location') .text('G') .on('click', function() { navigator.geolocation.getCurrentPosition(geolocateSuccess, geolocateError); @@ -236,10 +222,10 @@ window.iD = function(container) { var contributors = about.append('div') .attr('id', 'user-list') .attr('class','about-block fillD pad1'); - contributors.append('span') - .attr('class', 'icon nearby icon-pre-text'); - contributors.append('pan') - .text('Viewing contributions by '); + contributors.append('span') + .attr('class', 'icon nearby icon-pre-text'); + contributors.append('pan') + .text('Viewing contributions by '); history.on('change.buttons', function() { var undo = history.undoAnnotation(), diff --git a/js/id/taginfo.js b/js/id/taginfo.js index 051339d27..77e9b3f0d 100644 --- a/js/id/taginfo.js +++ b/js/id/taginfo.js @@ -1,8 +1,40 @@ iD.taginfo = function() { var taginfo = {}, - endpoint = 'http://taginfo.openstreetmap.org/api/2/'; + endpoint = 'http://taginfo.openstreetmap.org/api/2/', + tag_sorts = { + point: 'count_nodes', + vertex: 'count_nodes', + area: 'count_ways', + line: 'count_ways' + }, + tag_filters = { + point: 'nodes', + vertex: 'nodes', + area: 'ways', + line: 'ways' + }; + + function sets(parameters, n, o) { + if (parameters.geometry && o[parameters.geometry]) { + parameters[n] = o[parameters.geometry]; + } + return parameters; + } + + function setFilter(parameters) { + return sets(parameters, 'filter', tag_filters); + } + + function setSort(parameters) { + return sets(parameters, 'sortname', tag_sorts); + } + + function clean(parameters) { + return _.omit(parameters, 'geometry'); + } taginfo.keys = function(parameters, callback) { + parameters = clean(setSort(setFilter(parameters))); d3.json(endpoint + 'db/keys?' + iD.util.qsString(_.extend({ rp: 6, @@ -13,6 +45,7 @@ iD.taginfo = function() { }; taginfo.values = function(parameters, callback) { + parameters = clean(setSort(setFilter(parameters))); d3.json(endpoint + 'db/keys/values?' + iD.util.qsString(_.extend({ rp: 20, @@ -23,6 +56,7 @@ iD.taginfo = function() { }; taginfo.docs = function(parameters, callback) { + parameters = clean(setSort(parameters)); d3.json(endpoint + 'wiki/tags?' + iD.util.qsString(parameters), callback); }; diff --git a/js/id/ui/contributors.js b/js/id/ui/contributors.js new file mode 100644 index 000000000..6ac0e9d36 --- /dev/null +++ b/js/id/ui/contributors.js @@ -0,0 +1,32 @@ +iD.contributors = function(map) { + + function contributors(selection) { + + var users = {}, + entities = map.history().graph().intersects(map.extent()); + for (var i in entities) { + if (entities[i].user) { + users[entities[i].user] = true; + if (Object.keys(users).length > 10) break; + } + } + var u = Object.keys(users); + var l = selection.selectAll('a.user-link').data(u); + l.enter().append('a') + .attr('class', 'user-link') + .attr('href', function(d) { return map.connection().userUrl(d); }) + .attr('target', '_blank') + .text(String); + l.exit().remove(); + + if (!u.length) { + selection.transition().style('opacity', 0); + } else if (selection.style('opacity') === '0') { + selection.transition().style('opacity', 1); + } + + } + + return contributors; + +}; diff --git a/js/id/ui/geocoder.js b/js/id/ui/geocoder.js index 1f11f3e11..a744f92b2 100644 --- a/js/id/ui/geocoder.js +++ b/js/id/ui/geocoder.js @@ -35,7 +35,8 @@ iD.geocoder = function() { } var button = selection.append('button') - .attr('class','narrow') + .attr('class', 'narrow') + .attr('title', 'Find A Location') .html('') .on('click', toggle); diff --git a/js/id/ui/inspector.js b/js/id/ui/inspector.js index 40bea7889..6ad48acc5 100644 --- a/js/id/ui/inspector.js +++ b/js/id/ui/inspector.js @@ -7,7 +7,7 @@ iD.Inspector = function() { function inspector(selection) { var entity = selection.datum(); - selection.html("").append('button') + selection.html('').append('button') .attr('class', 'narrow close') .html("") .on('click', function() { @@ -29,13 +29,16 @@ iD.Inspector = function() { tagList = inspectorwrap.append('ul'); - inspectorwrap.append('div').attr('class', 'add-tag-row').append('button') - .attr('class', 'add-tag') - .text('+ Add New Tag') - .on('click', function() { - addTag(); - focusNewKey(); - }); + inspectorwrap + .append('div') + .attr('class', 'add-tag-row') + .append('button') + .attr('class', 'add-tag') + .text('+ Add New Tag') + .on('click', function() { + addTag(); + focusNewKey(); + }); drawTags(entity.tags); @@ -87,6 +90,8 @@ iD.Inspector = function() { } function drawTags(tags) { + var entity = tagList.datum(); + tags = d3.entries(tags); if (!tags.length) { @@ -134,7 +139,9 @@ iD.Inspector = function() { .attr('tabindex', -1) .attr('target', '_blank') .on('click', function(d) { - taginfo.docs(d, function(err, docs) { + taginfo.docs(_.extend({}, d, { + geometry: entity.geometry() + }), function(err, docs) { var en = _.find(docs, function(d) { return d.lang == 'en'; }); @@ -174,13 +181,18 @@ iD.Inspector = function() { } function bindTypeahead() { - var row = d3.select(this), + var entity = tagList.datum(), + geometry = entity.geometry(), + row = d3.select(this), key = row.selectAll('.key'), value = row.selectAll('.value'); key.call(d3.typeahead() .data(function(_, callback) { - taginfo.keys({query: key.property('value')}, function(err, data) { + taginfo.keys({ + geometry: geometry, + query: key.property('value') + }, function(err, data) { callback(data.data.map(function (d) { return {value: d.key}; })); @@ -191,6 +203,7 @@ iD.Inspector = function() { .data(function(_, callback) { taginfo.values({ key: key.property('value'), + geometry: geometry, query: value.property('value') }, function(err, data) { callback(data.data.map(function (d) { diff --git a/js/id/ui/layerswitcher.js b/js/id/ui/layerswitcher.js index 94d4956d9..fd0a78485 100644 --- a/js/id/ui/layerswitcher.js +++ b/js/id/ui/layerswitcher.js @@ -31,6 +31,7 @@ iD.layerswitcher = function(map) { var button = selection .append('button') .attr('class', 'narrow') + .attr('title', 'Layer Settings') .html("") .on('click.layerswitcher-toggle', toggle);