Tooltip for author colors

This commit is contained in:
Mehmet Ali Elicin 2012-04-16 00:38:39 -07:00
parent 3c8674ebde
commit 45456c2a4c
4 changed files with 24 additions and 11 deletions

View file

@ -291,6 +291,17 @@ function Ace2Inner(){
return null;
}
function className2AuthorName(className)
{
var a = className2Author(className);
var aname = null;
if (a) {
var ainfo = authorInfos[a];
aname = (ainfo) ? ainfo.name : null;
}
return aname;
}
function getAuthorColorClassSelector(oneClassName)
{
return ".authorColors ." + oneClassName;
@ -1244,7 +1255,7 @@ function Ace2Inner(){
var curDocChar;
var tokenFunc = function(tokenText, tokenClass)
{
lineEntry.domInfo.appendSpan(tokenText, tokenClass);
lineEntry.domInfo.appendSpan(tokenText, tokenClass, className2AuthorName(tokenClass));
};
if (optModFunc)
{
@ -1801,7 +1812,7 @@ function Ace2Inner(){
p2.mark("spans");
getSpansForLine(entry, function(tokenText, tokenClass)
{
info.appendSpan(tokenText, tokenClass);
info.appendSpan(tokenText, tokenClass, className2AuthorName(tokenClass));
}, lineStartOffset, isTimeUp());
//else if (entry.text.length > 0) {
//info.appendSpan(entry.text, 'dirty');

View file

@ -437,10 +437,10 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
function tellAceActiveAuthorInfo(userInfo)
{
tellAceAuthorInfo(userInfo.userId, userInfo.colorId);
tellAceAuthorInfo(userInfo.userId, userInfo.colorId, false, userInfo.name);
}
function tellAceAuthorInfo(userId, colorId, inactive)
function tellAceAuthorInfo(userId, colorId, inactive, name)
{
if(typeof colorId == "number")
{
@ -452,20 +452,22 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
{
editor.setAuthorInfo(userId, {
bgcolor: cssColor,
fade: 0.5
fade: 0.5,
name: name
});
}
else
{
editor.setAuthorInfo(userId, {
bgcolor: cssColor
bgcolor: cssColor,
name: name
});
}
}
function fadeAceAuthorInfo(userInfo)
{
tellAceAuthorInfo(userInfo.userId, userInfo.colorId, true);
tellAceAuthorInfo(userInfo.userId, userInfo.colorId, true, userInfo.name);
}
function getConnectedUsers()
@ -480,7 +482,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
var data = hadata[author];
if (!userSet[author])
{
tellAceAuthorInfo(author, data.colorId, true);
tellAceAuthorInfo(author, data.colorId, true, data.name);
}
}
}

View file

@ -92,7 +92,7 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
var perTextNodeProcess = (doesWrap ? identity : processSpaces);
var perHtmlLineProcess = (doesWrap ? processSpaces : identity);
var lineClass = 'ace-line';
result.appendSpan = function(txt, cls)
result.appendSpan = function(txt, cls, aname)
{
if (cls.indexOf('list') >= 0)
{
@ -176,7 +176,7 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
simpleTags.reverse();
extraCloseTags = '</' + simpleTags.join('></') + '>' + extraCloseTags;
}
html.push('<span class="', Security.escapeHTMLAttribute(cls || ''), '">', extraOpenTags, perTextNodeProcess(Security.escapeHTML(txt)), extraCloseTags, '</span>');
html.push('<span title="', Security.escapeHTMLAttribute(aname || ''),'" class="', Security.escapeHTMLAttribute(cls || ''), '">', extraOpenTags, perTextNodeProcess(Security.escapeHTML(txt)), extraCloseTags, '</span>');
}
};
result.clearSpans = function()