added UI to for unnamed authors

This commit is contained in:
Matthias Bartelmeß 2012-03-25 15:48:31 +02:00
parent 94a9795a04
commit e463273901
2 changed files with 28 additions and 4 deletions

View file

@ -116,6 +116,11 @@
padding-right: 0.4em; padding-right: 0.4em;
} }
#authorsList .author-anonymous {
padding-left: 0.6em;
padding-right: 0.6em;
}
#padeditor { #padeditor {
position: static; position: static;
} }

View file

@ -181,20 +181,26 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
authorsList.empty(); authorsList.empty();
var numAnonymous = 0; var numAnonymous = 0;
var numNamed = 0; var numNamed = 0;
var colorsAnonymous = [];
_.each(authors, function(author) _.each(authors, function(author)
{ {
var authorColor = clientVars.colorPalette[author.colorId] || author.colorId;
if (author.name) if (author.name)
{ {
if (numNamed !== 0) authorsList.append(', '); if (numNamed !== 0) authorsList.append(', ');
var authorColor = clientVars.colorPalette[author.colorId] || author.colorId; $('<span />')
var span = $('<span />').text(author.name || "unnamed").css('background-color', authorColor).addClass('author'); .text(author.name || "unnamed")
authorsList.append(span); .css('background-color', authorColor)
.addClass('author')
.appendTo(authorsList);
numNamed++; numNamed++;
} }
else else
{ {
numAnonymous++; numAnonymous++;
if(authorColor) colorsAnonymous.push(authorColor);
} }
}); });
if (numAnonymous > 0) if (numAnonymous > 0)
@ -205,6 +211,19 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
} else { } else {
authorsList.append(anonymousAuthorString); authorsList.append(anonymousAuthorString);
} }
if(colorsAnonymous.length > 0){
authorsList.append(' (');
_.each(colorsAnonymous, function(color, i){
if( i > 0 ) authorsList.append(' ');
$('<span /> ')
.css('background-color', color)
.addClass('author author-anonymous')
.appendTo(authorsList);
});
authorsList.append(')');
}
} }
if (authors.length == 0) if (authors.length == 0)
{ {