From 20014050bf91266757b2c1ba82ab333638fe570d Mon Sep 17 00:00:00 2001 From: Egil Moeller Date: Thu, 25 Mar 2010 19:14:53 +0100 Subject: Added aceCreateDomline hook plus some code cleanup in the ace --- infrastructure/ace/www/domline.js | 19 +++++++++++++++++-- infrastructure/ace/www/linestylefilter.js | 13 +++++-------- 2 files changed, 22 insertions(+), 10 deletions(-) (limited to 'infrastructure') diff --git a/infrastructure/ace/www/domline.js b/infrastructure/ace/www/domline.js index 70f86cc..38cddf5 100644 --- a/infrastructure/ace/www/domline.js +++ b/infrastructure/ace/www/domline.js @@ -1,4 +1,5 @@ // THIS FILE IS ALSO AN APPJET MODULE: etherpad.collab.ace.domline +// %APPJET%: import("etherpad.admin.plugins"); /** * Copyright 2009 Google Inc. @@ -16,6 +17,10 @@ * limitations under the License. */ +// requires: top +// requires: plugins +// requires: undefined + var domline = {}; domline.noop = function() {}; domline.identity = function(x) { return x; }; @@ -92,12 +97,22 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument) { return space+tag; }); } + + var extraOpenTags = ""; + var extraCloseTags = ""; + + ((top == undefined) ? plugins : top.plugins).callHook( + "aceCreateDomLine", {domline:domline, cls:cls} + ).map(function (modifier) { + cls = modifier.cls; + extraOpenTags = extraOpenTags+modifier.extraOpenTags; + extraCloseTags = modifier.extraCloseTags+extraCloseTags; + }); + if ((! txt) && cls) { lineClass = domline.addToLineClass(lineClass, cls); } else if (txt) { - var extraOpenTags = ""; - var extraCloseTags = ""; if (href) { extraOpenTags = extraOpenTags+''; diff --git a/infrastructure/ace/www/linestylefilter.js b/infrastructure/ace/www/linestylefilter.js index 71bc30d..d69376a 100644 --- a/infrastructure/ace/www/linestylefilter.js +++ b/infrastructure/ace/www/linestylefilter.js @@ -21,7 +21,6 @@ // requires: easysync2.Changeset // requires: top // requires: plugins -// requires: plugins // requires: undefined var linestylefilter = {}; @@ -239,13 +238,11 @@ linestylefilter.textAndClassFuncSplitter = function(func, splitPointsOpt) { linestylefilter.getFilterStack = function(lineText, textAndClassFunc, browser) { var func = linestylefilter.getURLFilter(lineText, textAndClassFunc); - /* Handle both client and server side situation */ - - var pluginModule = (top == undefined) ? plugins : top.plugins; - - var hookFilters = pluginModule.callHook("aceGetFilterStack", {linestylefilter:linestylefilter, browser:browser}); - for (var i = 0; i < hookFilters.length; i++) - func = hookFilters[i](lineText, func); + var hookFilters = ((top == undefined) ? plugins : top.plugins).callHook( + "aceGetFilterStack", {linestylefilter:linestylefilter, browser:browser}); + hookFilters.map(function (hookFilter) { + func = hookFilter(lineText, func); + }); if (browser !== undefined && browser.msie) { // IE7+ will take an e-mail address like and linkify it to foo@bar.com. -- cgit v1.2.3-1-g7c22