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; 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) function getAuthorColorClassSelector(oneClassName)
{ {
return ".authorColors ." + oneClassName; return ".authorColors ." + oneClassName;
@ -1244,7 +1255,7 @@ function Ace2Inner(){
var curDocChar; var curDocChar;
var tokenFunc = function(tokenText, tokenClass) var tokenFunc = function(tokenText, tokenClass)
{ {
lineEntry.domInfo.appendSpan(tokenText, tokenClass); lineEntry.domInfo.appendSpan(tokenText, tokenClass, className2AuthorName(tokenClass));
}; };
if (optModFunc) if (optModFunc)
{ {
@ -1801,7 +1812,7 @@ function Ace2Inner(){
p2.mark("spans"); p2.mark("spans");
getSpansForLine(entry, function(tokenText, tokenClass) getSpansForLine(entry, function(tokenText, tokenClass)
{ {
info.appendSpan(tokenText, tokenClass); info.appendSpan(tokenText, tokenClass, className2AuthorName(tokenClass));
}, lineStartOffset, isTimeUp()); }, lineStartOffset, isTimeUp());
//else if (entry.text.length > 0) { //else if (entry.text.length > 0) {
//info.appendSpan(entry.text, 'dirty'); //info.appendSpan(entry.text, 'dirty');

View file

@ -437,10 +437,10 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
function tellAceActiveAuthorInfo(userInfo) 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") if(typeof colorId == "number")
{ {
@ -452,20 +452,22 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
{ {
editor.setAuthorInfo(userId, { editor.setAuthorInfo(userId, {
bgcolor: cssColor, bgcolor: cssColor,
fade: 0.5 fade: 0.5,
name: name
}); });
} }
else else
{ {
editor.setAuthorInfo(userId, { editor.setAuthorInfo(userId, {
bgcolor: cssColor bgcolor: cssColor,
name: name
}); });
} }
} }
function fadeAceAuthorInfo(userInfo) function fadeAceAuthorInfo(userInfo)
{ {
tellAceAuthorInfo(userInfo.userId, userInfo.colorId, true); tellAceAuthorInfo(userInfo.userId, userInfo.colorId, true, userInfo.name);
} }
function getConnectedUsers() function getConnectedUsers()
@ -480,7 +482,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
var data = hadata[author]; var data = hadata[author];
if (!userSet[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 perTextNodeProcess = (doesWrap ? identity : processSpaces);
var perHtmlLineProcess = (doesWrap ? processSpaces : identity); var perHtmlLineProcess = (doesWrap ? processSpaces : identity);
var lineClass = 'ace-line'; var lineClass = 'ace-line';
result.appendSpan = function(txt, cls) result.appendSpan = function(txt, cls, aname)
{ {
if (cls.indexOf('list') >= 0) if (cls.indexOf('list') >= 0)
{ {
@ -176,7 +176,7 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
simpleTags.reverse(); simpleTags.reverse();
extraCloseTags = '</' + simpleTags.join('></') + '>' + extraCloseTags; 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() result.clearSpans = function()

View file

@ -489,7 +489,7 @@ var pad = {
$('#options-stickychat').prop("checked", true); // set the checkbox to on $('#options-stickychat').prop("checked", true); // set the checkbox to on
} }
if(padcookie.getPref("showAuthorshipColors") == false){ if(padcookie.getPref("showAuthorshipColors") == false){
pad.changeViewOption('showAuthorColors', false); pad.changeViewOption('showAuthorColors', false);
} }
} }
}, },