From dade9520a457a1313d9cc3d2d01a86833f8d5900 Mon Sep 17 00:00:00 2001 From: Egil Moeller Date: Sun, 12 Apr 2015 11:32:59 +0200 Subject: [PATCH] Hooks can now be loaded as AMD --- src/static/js/ace2_inner.js | 3 +-- src/static/js/pluginfw/hooks.js | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index f4af21c7a..70a867488 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -20,7 +20,7 @@ * limitations under the License. */ -define(["ep_etherpad-lite/static/js/rjquery", "underscore"], function ($, _) { +define(["ep_etherpad-lite/static/js/rjquery", "underscore", 'ep_etherpad-lite/static/js/pluginfw/hooks'], function ($, _, hooks) { var exports = {}; var browser = require('./browser').browser; @@ -43,7 +43,6 @@ var isNodeText = Ace2Common.isNodeText, binarySearchInfinite = Ace2Common.binarySearchInfinite, htmlPrettyEscape = Ace2Common.htmlPrettyEscape, noop = Ace2Common.noop; - var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); function Ace2Inner(){ diff --git a/src/static/js/pluginfw/hooks.js b/src/static/js/pluginfw/hooks.js index cf5fcc4eb..0a524eabf 100644 --- a/src/static/js/pluginfw/hooks.js +++ b/src/static/js/pluginfw/hooks.js @@ -1,5 +1,5 @@ -var async = require("async"); -var _ = require("underscore"); +function defineHooks(_, async, exports) { + if (exports == undefined) exports = {}; exports.bubbleExceptions = true @@ -125,3 +125,13 @@ exports.callAllStr = function(hook_name, args, sep, pre, post) { } return newCallhooks.join(sep || ""); } + + return exports; +} + + +if (typeof(define) != 'undefined' && define.amd != undefined && typeof(exports) == 'undefined') { + define(["underscore", "async/lib/async"], defineHooks); +} else { + defineHooks(require("underscore"), require("async"), exports); +}