summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEgil Moeller <egil.moller@freecode.no>2012-03-01 19:22:02 +0100
committerEgil Moeller <egil.moller@freecode.no>2012-03-01 19:22:02 +0100
commitdf531a7b2bf115f51f2a3bb41f30d2e078bbd55f (patch)
treed83c344f7d4974579620441850d8c1698afa1413 /src
parent81440cd85605c3e584cba18cf868bab1629c63ba (diff)
downloadetherpad-lite-df531a7b2bf115f51f2a3bb41f30d2e078bbd55f.zip
Made ace actually use the new hooks system, and removed remnants of old system
Diffstat (limited to 'src')
-rw-r--r--src/static/js/ace.js4
-rw-r--r--src/static/js/contentcollector.js8
-rw-r--r--src/static/js/domline.js6
-rw-r--r--src/static/js/linestylefilter.js10
-rw-r--r--src/static/js/pluginfw/hooks.js12
-rw-r--r--src/static/js/plugins.js37
6 files changed, 22 insertions, 55 deletions
diff --git a/src/static/js/ace.js b/src/static/js/ace.js
index 7022b1c5..78ff098a 100644
--- a/src/static/js/ace.js
+++ b/src/static/js/ace.js
@@ -28,7 +28,7 @@ Ace2Editor.registry = {
nextId: 1
};
-var plugins = require('ep_etherpad-lite/static/js/plugins').plugins;
+var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
function Ace2Editor()
{
@@ -300,7 +300,7 @@ function Ace2Editor()
for (var i = 0, ii = iframeHTML.length; i < ii; i++) {
iframeHTML[i] = JSON.stringify(iframeHTML[i]);
}
- plugins.callHook("aceInitInnerdocbodyHead", {
+ hooks.callAll("aceInitInnerdocbodyHead", {
iframeHTML: iframeHTML
});
for (var i = 0, ii = iframeHTML.length; i < ii; i++) {
diff --git a/src/static/js/contentcollector.js b/src/static/js/contentcollector.js
index 76b20c92..f66f01a6 100644
--- a/src/static/js/contentcollector.js
+++ b/src/static/js/contentcollector.js
@@ -26,7 +26,7 @@
var _MAX_LIST_LEVEL = 8;
var Changeset = require('ep_etherpad-lite/static/js/Changeset');
-var plugins = require('ep_etherpad-lite/static/js/plugins').plugins;
+var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
function sanitizeUnicode(s)
{
@@ -37,8 +37,6 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
{
browser = browser || {};
- var plugins_ = plugins;
-
var dom = domInterface || {
isNodeText: function(n)
{
@@ -448,7 +446,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
var oldAuthorOrNull = null;
if (collectStyles)
{
- plugins_.callHook('collectContentPre', {
+ hooks.callAll('collectContentPre', {
cc: cc,
state: state,
tname: tname,
@@ -510,7 +508,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
if (collectStyles)
{
- plugins_.callHook('collectContentPost', {
+ hooks.callAll('collectContentPost', {
cc: cc,
state: state,
tname: tname,
diff --git a/src/static/js/domline.js b/src/static/js/domline.js
index 71ad2c52..3df98dc0 100644
--- a/src/static/js/domline.js
+++ b/src/static/js/domline.js
@@ -27,7 +27,7 @@
// requires: undefined
var Security = require('ep_etherpad-lite/static/js/security');
-var plugins = require('ep_etherpad-lite/static/js/plugins').plugins;
+var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
var map = require('ep_etherpad-lite/static/js/ace2_common').map;
var domline = {};
@@ -145,9 +145,7 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
var extraOpenTags = "";
var extraCloseTags = "";
- var plugins_ = plugins;
-
- map(plugins_.callHook("aceCreateDomLine", {
+ map(hooks.callAll("aceCreateDomLine", {
domline: domline,
cls: cls
}), function(modifier)
diff --git a/src/static/js/linestylefilter.js b/src/static/js/linestylefilter.js
index b75ac200..e2fa316a 100644
--- a/src/static/js/linestylefilter.js
+++ b/src/static/js/linestylefilter.js
@@ -29,7 +29,7 @@
// requires: undefined
var Changeset = require('ep_etherpad-lite/static/js/Changeset');
-var plugins = require('ep_etherpad-lite/static/js/plugins').plugins;
+var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
var map = require('ep_etherpad-lite/static/js/ace2_common').map;
var linestylefilter = {};
@@ -55,8 +55,6 @@ linestylefilter.getAuthorClassName = function(author)
linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFunc, apool)
{
- var plugins_ = plugins;
-
if (lineLength == 0) return textAndClassFunc;
var nextAfterAuthorColors = textAndClassFunc;
@@ -97,7 +95,7 @@ linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFun
}
else
{
- classes += plugins_.callHookStr("aceAttribsToClasses", {
+ classes += hooks.callAllStr("aceAttribsToClasses", {
linestylefilter: linestylefilter,
key: key,
value: value
@@ -300,9 +298,7 @@ linestylefilter.getFilterStack = function(lineText, textAndClassFunc, browser)
{
var func = linestylefilter.getURLFilter(lineText, textAndClassFunc);
- var plugins_ = plugins;
-
- var hookFilters = plugins_.callHook("aceGetFilterStack", {
+ var hookFilters = hooks.callAll("aceGetFilterStack", {
linestylefilter: linestylefilter,
browser: browser
});
diff --git a/src/static/js/pluginfw/hooks.js b/src/static/js/pluginfw/hooks.js
index 383a2a2c..7141d75f 100644
--- a/src/static/js/pluginfw/hooks.js
+++ b/src/static/js/pluginfw/hooks.js
@@ -61,3 +61,15 @@ exports.aCallFirst = function (hook_name, args, cb) {
if (plugins.hooks[hook_name][0] === undefined) cb([]);
hookCallWrapper(plugins.hooks[hook_name][0], hook_name, args, function (res) { cb(exports.flatten(res)); });
}
+
+exports.callAllStr = function(hook_name, args, sep, pre, post) {
+ if (sep == undefined) sep = '';
+ if (pre == undefined) pre = '';
+ if (post == undefined) post = '';
+ var newCallhooks = [];
+ var callhooks = exports.callAll(hook_name, args);
+ for (var i = 0, ii = callhooks.length; i < ii; i++) {
+ newCallhooks[i] = pre + callhooks[i] + post;
+ }
+ return newCallhooks.join(sep || "");
+}
diff --git a/src/static/js/plugins.js b/src/static/js/plugins.js
deleted file mode 100644
index 3e226eba..00000000
--- a/src/static/js/plugins.js
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * This code is mostly from the old Etherpad. Please help us to comment this code.
- * This helps other people to understand this code better and helps them to improve it.
- * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED
- */
-
-var plugins = {
- callHook: function(hookName, args)
- {
- var global = (function () {return this}());
- var hook = ((global.clientVars || {}).hooks || {})[hookName];
- if (hook === undefined) return [];
- var res = [];
- for (var i = 0, N = hook.length; i < N; i++)
- {
- var plugin = hook[i];
- var pluginRes = eval(plugin.plugin)[plugin.original || hookName](args);
- if (pluginRes != undefined && pluginRes != null) res = res.concat(pluginRes);
- }
- return res;
- },
-
- callHookStr: function(hookName, args, sep, pre, post)
- {
- if (sep == undefined) sep = '';
- if (pre == undefined) pre = '';
- if (post == undefined) post = '';
- var newCallhooks = [];
- var callhooks = plugins.callHook(hookName, args);
- for (var i = 0, ii = callhooks.length; i < ii; i++) {
- newCallhooks[i] = pre + callhooks[i] + post;
- }
- return newCallhooks.join(sep || "");
- }
-};
-
-exports.plugins = plugins;