mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-27 18:32:25 +02:00
Merge branch 'master' of github.com:ansis/iD into tooltip-fix
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
<script src='js/id/ui/loading.js'></script>
|
||||
<script src='js/id/ui/userpanel.js'></script>
|
||||
<script src='js/id/ui/layerswitcher.js'></script>
|
||||
<script src='js/id/ui/contributors.js'></script>
|
||||
<script src='js/id/ui/geocoder.js'></script>
|
||||
<script src='js/id/ui/notice.js'></script>
|
||||
<script src='js/id/ui/tag_reference.js'></script>
|
||||
|
||||
+13
-27
@@ -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(),
|
||||
|
||||
+35
-1
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
};
|
||||
@@ -35,7 +35,8 @@ iD.geocoder = function() {
|
||||
}
|
||||
|
||||
var button = selection.append('button')
|
||||
.attr('class','narrow')
|
||||
.attr('class', 'narrow')
|
||||
.attr('title', 'Find A Location')
|
||||
.html('<span class=\'geocode icon\'></span>')
|
||||
.on('click', toggle);
|
||||
|
||||
|
||||
+24
-11
@@ -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("<span class='icon close'></span>")
|
||||
.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) {
|
||||
|
||||
@@ -31,6 +31,7 @@ iD.layerswitcher = function(map) {
|
||||
var button = selection
|
||||
.append('button')
|
||||
.attr('class', 'narrow')
|
||||
.attr('title', 'Layer Settings')
|
||||
.html("<span class='layers icon'></span>")
|
||||
.on('click.layerswitcher-toggle', toggle);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user