diff options
-rw-r--r-- | src/static/js/pluginfw/hooks.js | 17 | ||||
-rw-r--r-- | src/templates/pad.html | 2 | ||||
-rw-r--r-- | src/templates/timeslider.html | 3 |
3 files changed, 13 insertions, 9 deletions
diff --git a/src/static/js/pluginfw/hooks.js b/src/static/js/pluginfw/hooks.js index 44f5fc3f..d9a14d85 100644 --- a/src/static/js/pluginfw/hooks.js +++ b/src/static/js/pluginfw/hooks.js @@ -1,4 +1,3 @@ -var plugins = require("./plugins"); var async = require("async"); var _ = require("underscore"); @@ -71,8 +70,8 @@ exports.flatten = function (lst) { exports.callAll = function (hook_name, args) { if (!args) args = {}; - if (plugins.hooks[hook_name] === undefined) return []; - return _.flatten(_.map(plugins.hooks[hook_name], function (hook) { + if (exports.plugins.hooks[hook_name] === undefined) return []; + return _.flatten(_.map(exports.plugins.hooks[hook_name], function (hook) { return hookCallWrapper(hook, hook_name, args); }), true); } @@ -80,9 +79,9 @@ exports.callAll = function (hook_name, args) { exports.aCallAll = function (hook_name, args, cb) { if (!args) args = {}; if (!cb) cb = function () {}; - if (plugins.hooks[hook_name] === undefined) return cb(null, []); + if (exports.plugins.hooks[hook_name] === undefined) return cb(null, []); async.map( - plugins.hooks[hook_name], + exports.plugins.hooks[hook_name], function (hook, cb) { hookCallWrapper(hook, hook_name, args, function (res) { cb(null, res); }); }, @@ -94,8 +93,8 @@ exports.aCallAll = function (hook_name, args, cb) { exports.callFirst = function (hook_name, args) { if (!args) args = {}; - if (plugins.hooks[hook_name] === undefined) return []; - return exports.syncMapFirst(plugins.hooks[hook_name], function (hook) { + if (exports.plugins.hooks[hook_name] === undefined) return []; + return exports.syncMapFirst(exports.plugins.hooks[hook_name], function (hook) { return hookCallWrapper(hook, hook_name, args); }); } @@ -103,9 +102,9 @@ exports.callFirst = function (hook_name, args) { exports.aCallFirst = function (hook_name, args, cb) { if (!args) args = {}; if (!cb) cb = function () {}; - if (plugins.hooks[hook_name] === undefined) return cb(null, []); + if (exports.plugins.hooks[hook_name] === undefined) return cb(null, []); exports.mapFirst( - plugins.hooks[hook_name], + exports.plugins.hooks[hook_name], function (hook, cb) { hookCallWrapper(hook, hook_name, args, function (res) { cb(null, res); }); }, diff --git a/src/templates/pad.html b/src/templates/pad.html index 1f179785..c1264783 100644 --- a/src/templates/pad.html +++ b/src/templates/pad.html @@ -374,6 +374,8 @@ plugins.baseURL = baseURL; plugins.update(function () { + hooks.plugins = plugins; + // Call documentReady hook $(function() { hooks.aCallAll('documentReady'); diff --git a/src/templates/timeslider.html b/src/templates/timeslider.html index 02af9f6c..d02a5f64 100644 --- a/src/templates/timeslider.html +++ b/src/templates/timeslider.html @@ -179,6 +179,9 @@ plugins.baseURL = baseURL; plugins.update(function () { + var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); + hooks.plugins = plugins; + var timeslider = require('ep_etherpad-lite/static/js/timeslider') timeslider.baseURL = baseURL; timeslider.init(); |