From 45456c2a4cd5bb5a799e88883a6ef03339abae15 Mon Sep 17 00:00:00 2001 From: Mehmet Ali Elicin Date: Mon, 16 Apr 2012 00:38:39 -0700 Subject: [PATCH] Tooltip for author colors --- static/js/ace2_inner.js | 15 +++++++++++++-- static/js/collab_client.js | 14 ++++++++------ static/js/domline.js | 4 ++-- static/js/pad.js | 2 +- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/static/js/ace2_inner.js b/static/js/ace2_inner.js index 17d02036f..749520e8f 100644 --- a/static/js/ace2_inner.js +++ b/static/js/ace2_inner.js @@ -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'); diff --git a/static/js/collab_client.js b/static/js/collab_client.js index bb68f6040..ef4af0520 100644 --- a/static/js/collab_client.js +++ b/static/js/collab_client.js @@ -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); } } } diff --git a/static/js/domline.js b/static/js/domline.js index 3074c9e93..8364ac999 100644 --- a/static/js/domline.js +++ b/static/js/domline.js @@ -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 = '' + extraCloseTags; } - html.push('', extraOpenTags, perTextNodeProcess(Security.escapeHTML(txt)), extraCloseTags, ''); + html.push('', extraOpenTags, perTextNodeProcess(Security.escapeHTML(txt)), extraCloseTags, ''); } }; result.clearSpans = function() diff --git a/static/js/pad.js b/static/js/pad.js index bda68956e..bb083a3a0 100644 --- a/static/js/pad.js +++ b/static/js/pad.js @@ -489,7 +489,7 @@ var pad = { $('#options-stickychat').prop("checked", true); // set the checkbox to on } if(padcookie.getPref("showAuthorshipColors") == false){ - pad.changeViewOption('showAuthorColors', false); + pad.changeViewOption('showAuthorColors', false); } } },