aboutsummaryrefslogtreecommitdiffstats
path: root/trunk/infrastructure/ace/www
diff options
context:
space:
mode:
authorEgil Moeller <egil.moller@freecode.no>2010-03-12 21:25:15 +0100
committerEgil Moeller <egil.moller@freecode.no>2010-03-12 21:25:15 +0100
commitfaae6d36cc92aae7c040146edb8471fa8e8c6a75 (patch)
tree40ce0e6a8c1959ba288a1a130243687b2ed98a45 /trunk/infrastructure/ace/www
parent2d8d9afeb01df0772661348321974627d42c8850 (diff)
downloadetherpad-faae6d36cc92aae7c040146edb8471fa8e8c6a75.tar.gz
etherpad-faae6d36cc92aae7c040146edb8471fa8e8c6a75.tar.xz
etherpad-faae6d36cc92aae7c040146edb8471fa8e8c6a75.zip
Tags are now shown as links
Diffstat (limited to 'trunk/infrastructure/ace/www')
-rw-r--r--trunk/infrastructure/ace/www/ace2_inner.js1
-rw-r--r--trunk/infrastructure/ace/www/domline.js6
-rw-r--r--trunk/infrastructure/ace/www/linestylefilter.js50
3 files changed, 57 insertions, 0 deletions
diff --git a/trunk/infrastructure/ace/www/ace2_inner.js b/trunk/infrastructure/ace/www/ace2_inner.js
index afd1e35..eccb53c 100644
--- a/trunk/infrastructure/ace/www/ace2_inner.js
+++ b/trunk/infrastructure/ace/www/ace2_inner.js
@@ -1140,6 +1140,7 @@ function OUTER(gscope) {
else {
var offsetIntoLine = 0;
var filteredFunc = textAndClassFunc;
+ filteredFunc = linestylefilter.getPadTagFilter(text, filteredFunc);
filteredFunc = linestylefilter.getURLFilter(text, filteredFunc);
if (browser.msie) {
// IE7+ will take an e-mail address like <foo@bar.com> and linkify it to foo@bar.com.
diff --git a/trunk/infrastructure/ace/www/domline.js b/trunk/infrastructure/ace/www/domline.js
index 70f86cc..e8a9ba7 100644
--- a/trunk/infrastructure/ace/www/domline.js
+++ b/trunk/infrastructure/ace/www/domline.js
@@ -85,6 +85,12 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument) {
return space+"url";
});
}
+ if (cls.indexOf('padtag') >= 0) {
+ cls = cls.replace(/(^| )padtag:(\S+)/g, function(x0, space, padtag) {
+ href = '/ep/tag/?query=' + padtag;
+ return space+"padtag padtag_"+padtag;
+ });
+ }
if (cls.indexOf('tag') >= 0) {
cls = cls.replace(/(^| )tag:(\S+)/g, function(x0, space, tag) {
if (! simpleTags) simpleTags = [];
diff --git a/trunk/infrastructure/ace/www/linestylefilter.js b/trunk/infrastructure/ace/www/linestylefilter.js
index 0ac578b..8c7c396 100644
--- a/trunk/infrastructure/ace/www/linestylefilter.js
+++ b/trunk/infrastructure/ace/www/linestylefilter.js
@@ -185,6 +185,55 @@ linestylefilter.getURLFilter = function(lineText, textAndClassFunc) {
splitPoints);
};
+/* Copy of getURLFilter with slight modifications, should probably merge and just use different regexps */
+linestylefilter.REGEX_PADTAG = new RegExp("#[^,#!\\s][^,#!\\s]*", "g");
+
+linestylefilter.getPadTagFilter = function(lineText, textAndClassFunc) {
+ linestylefilter.REGEX_PADTAG.lastIndex = 0;
+ var padTags = null;
+ var splitPoints = null;
+ var execResult;
+ while ((execResult = linestylefilter.REGEX_PADTAG.exec(lineText))) {
+ if (! padTags) {
+ padTags = [];
+ splitPoints = [];
+ }
+ var startIndex = execResult.index;
+ var padTag = execResult[0];
+ padTags.push([startIndex, padTag]);
+ splitPoints.push(startIndex, startIndex + padTag.length);
+ }
+
+ if (! padTags) return textAndClassFunc;
+
+ function padTagForIndex(idx) {
+ for(var k=0; k<padTags.length; k++) {
+ var u = padTags[k];
+ if (idx >= u[0] && idx < u[0]+u[1].length) {
+ return u[1];
+ }
+ }
+ return false;
+ }
+
+ var handlePadTagsAfterSplit = (function() {
+ var curIndex = 0;
+ return function(txt, cls) {
+ var txtlen = txt.length;
+ var newCls = cls;
+ var padTag = padTagForIndex(curIndex);
+ if (padTag) {
+ newCls += " padtag:"+padTag.substring(1);
+ }
+ textAndClassFunc(txt, newCls);
+ curIndex += txtlen;
+ };
+ })();
+
+ return linestylefilter.textAndClassFuncSplitter(handlePadTagsAfterSplit,
+ splitPoints);
+}
+
linestylefilter.textAndClassFuncSplitter = function(func, splitPointsOpt) {
var nextPointIndex = 0;
var idx = 0;
@@ -241,6 +290,7 @@ linestylefilter.populateDomLine = function(textLine, aline, apool,
var func = textAndClassFunc;
func = linestylefilter.getURLFilter(text, func);
+ func = linestylefilter.getPadTagFilter(text, func);
func = linestylefilter.getLineStyleFilter(text.length, aline,
func, apool);
func(text, '');