mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-25 23:13:42 +00:00
Smarter contributors box, links to history when truncated. Fixes #306
This commit is contained in:
@@ -156,8 +156,12 @@ window.iD = function(container) {
|
||||
.attr('class','about-block fillD pad1');
|
||||
contributors.append('span')
|
||||
.attr('class', 'icon nearby icon-pre-text');
|
||||
contributors.append('pan')
|
||||
contributors.append('span')
|
||||
.text('Viewing contributions by ');
|
||||
contributors.append('span')
|
||||
.attr('class', 'contributor-list');
|
||||
contributors.append('span')
|
||||
.attr('class', 'contributor-count');
|
||||
|
||||
history.on('change.buttons', function() {
|
||||
var undo = history.undoAnnotation(),
|
||||
|
||||
@@ -3,22 +3,48 @@ iD.ui.contributors = function(map) {
|
||||
function contributors(selection) {
|
||||
|
||||
var users = {},
|
||||
limit = 3,
|
||||
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;
|
||||
}
|
||||
if (entities[i].user) users[entities[i].user] = true;
|
||||
}
|
||||
var u = Object.keys(users);
|
||||
var l = selection.selectAll('a.user-link').data(u);
|
||||
|
||||
var u = Object.keys(users),
|
||||
subset = u.slice(0, limit);
|
||||
|
||||
var l = selection
|
||||
.select('.contributor-list')
|
||||
.selectAll('a.user-link')
|
||||
.data(subset);
|
||||
|
||||
|
||||
l.enter().append('a')
|
||||
.attr('class', 'user-link')
|
||||
.attr('href', function(d) { return map.connection().userUrl(d); })
|
||||
.attr('href', function(d) { console.log(d); return map.connection().userUrl(d); })
|
||||
.attr('target', '_blank')
|
||||
.text(String);
|
||||
|
||||
l.exit().remove();
|
||||
|
||||
selection
|
||||
.select('.contributor-count')
|
||||
.html('');
|
||||
|
||||
if (u.length > limit) {
|
||||
selection
|
||||
.select('.contributor-count')
|
||||
.append('a')
|
||||
.attr('target', '_blank')
|
||||
.attr('href', function() {
|
||||
var ext = map.extent();
|
||||
return 'http://www.openstreetmap.org/browse/changesets?bbox=' + [
|
||||
ext[0][0], ext[1][1],
|
||||
ext[1][0], ext[0][1]];
|
||||
})
|
||||
.text(' and ' + (u.length - limit) + ' others');
|
||||
}
|
||||
|
||||
if (!u.length) {
|
||||
selection.transition().style('opacity', 0);
|
||||
} else if (selection.style('opacity') === '0') {
|
||||
|
||||
Reference in New Issue
Block a user