diff --git a/src/static/js/pad.js b/src/static/js/pad.js index 557a9cd91..362a4b1ad 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -48,8 +48,6 @@ var readCookie = require('./pad_utils').readCookie; var randomString = require('./pad_utils').randomString; var gritter = require('./gritter').gritter; -var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); - var receivedClientVars = false; function createCookie(name, value, days, path){ /* Warning Internet Explorer doesn't use this it uses the one from pad_utils.js */ @@ -947,8 +945,13 @@ var alertBar = (function() return self; }()); +var hooks = undefined; + function init() { - return pad.init(); + requirejs(['ep_etherpad-lite/static/js/pluginfw/hooks'], function (h) { + hooks = h; + return pad.init(); + }); } var settings = { diff --git a/src/templates/pad.html b/src/templates/pad.html index 96dcd8f27..6eaf75b1a 100644 --- a/src/templates/pad.html +++ b/src/templates/pad.html @@ -398,37 +398,41 @@ paths: {'underscore': baseURL + "static/plugins/underscore/underscore"}, }); - requirejs(["ep_etherpad-lite/static/js/rjquery", 'ep_etherpad-lite/static/js/pluginfw/client_plugins'], function ($, plugins) { - window.$ = $; // Expose jQuery #HACK - window.jQuery = $; + requirejs( + [ + 'ep_etherpad-lite/static/js/rjquery', + 'ep_etherpad-lite/static/js/pluginfw/client_plugins', + 'ep_etherpad-lite/static/js/pluginfw/hooks' + ], function ($, plugins, hooks) { + window.$ = $; // Expose jQuery #HACK + window.jQuery = $; - browser = require('ep_etherpad-lite/static/js/browser').browser; - if ((!browser.msie) && (!(browser.mozilla && browser.version.indexOf("1.8.") == 0))) { - document.domain = document.domain; // for comet - } + browser = require('ep_etherpad-lite/static/js/browser').browser; + if ((!browser.msie) && (!(browser.mozilla && browser.version.indexOf("1.8.") == 0))) { + document.domain = document.domain; // for comet + } - var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); + plugins.baseURL = baseURL; + plugins.update(function () { + hooks.plugins = plugins; - plugins.baseURL = baseURL; - plugins.update(function () { - hooks.plugins = plugins; + // Call documentReady hook + $(function() { + hooks.aCallAll('documentReady'); + }); - // Call documentReady hook - $(function() { - hooks.aCallAll('documentReady'); + var pad = require('ep_etherpad-lite/static/js/pad'); + pad.baseURL = baseURL; + pad.init(); }); - var pad = require('ep_etherpad-lite/static/js/pad'); - pad.baseURL = baseURL; - pad.init(); - }); - - /* TODO: These globals shouldn't exist. */ - pad = require('ep_etherpad-lite/static/js/pad').pad; - chat = require('ep_etherpad-lite/static/js/chat').chat; - padeditbar = require('ep_etherpad-lite/static/js/pad_editbar').padeditbar; - padimpexp = require('ep_etherpad-lite/static/js/pad_impexp').padimpexp; - }); + /* TODO: These globals shouldn't exist. */ + pad = require('ep_etherpad-lite/static/js/pad').pad; + chat = require('ep_etherpad-lite/static/js/chat').chat; + padeditbar = require('ep_etherpad-lite/static/js/pad_editbar').padeditbar; + padimpexp = require('ep_etherpad-lite/static/js/pad_impexp').padimpexp; + } + ); }()); <% e.end_block(); %>