Some amd loading of hooks

This commit is contained in:
Egil Moeller 2015-04-12 13:33:33 +02:00
parent 77449760f6
commit 027d9e3a70
2 changed files with 35 additions and 28 deletions

View file

@ -48,8 +48,6 @@ var readCookie = require('./pad_utils').readCookie;
var randomString = require('./pad_utils').randomString; var randomString = require('./pad_utils').randomString;
var gritter = require('./gritter').gritter; var gritter = require('./gritter').gritter;
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
var receivedClientVars = false; var receivedClientVars = false;
function createCookie(name, value, days, path){ /* Warning Internet Explorer doesn't use this it uses the one from pad_utils.js */ 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; return self;
}()); }());
var hooks = undefined;
function init() { function init() {
return pad.init(); requirejs(['ep_etherpad-lite/static/js/pluginfw/hooks'], function (h) {
hooks = h;
return pad.init();
});
} }
var settings = { var settings = {

View file

@ -398,37 +398,41 @@
paths: {'underscore': baseURL + "static/plugins/underscore/underscore"}, paths: {'underscore': baseURL + "static/plugins/underscore/underscore"},
}); });
requirejs(["ep_etherpad-lite/static/js/rjquery", 'ep_etherpad-lite/static/js/pluginfw/client_plugins'], function ($, plugins) { requirejs(
window.$ = $; // Expose jQuery #HACK [
window.jQuery = $; '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; browser = require('ep_etherpad-lite/static/js/browser').browser;
if ((!browser.msie) && (!(browser.mozilla && browser.version.indexOf("1.8.") == 0))) { if ((!browser.msie) && (!(browser.mozilla && browser.version.indexOf("1.8.") == 0))) {
document.domain = document.domain; // for comet 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; // Call documentReady hook
plugins.update(function () { $(function() {
hooks.plugins = plugins; hooks.aCallAll('documentReady');
});
// Call documentReady hook var pad = require('ep_etherpad-lite/static/js/pad');
$(function() { pad.baseURL = baseURL;
hooks.aCallAll('documentReady'); pad.init();
}); });
var pad = require('ep_etherpad-lite/static/js/pad'); /* TODO: These globals shouldn't exist. */
pad.baseURL = baseURL; pad = require('ep_etherpad-lite/static/js/pad').pad;
pad.init(); 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;
});
}()); }());
</script> </script>
<% e.end_block(); %> <% e.end_block(); %>