ace.js AMDification

This commit is contained in:
Egil Moeller 2015-04-12 18:10:17 +02:00
parent 2f12fc0229
commit 2472cd365e
3 changed files with 296 additions and 298 deletions

View file

@ -24,13 +24,11 @@
// requires: plugins // requires: plugins
// requires: undefined // requires: undefined
define(['ep_etherpad-lite/static/js/pluginfw/hooks', 'underscore'], function (hooks, _) {
Ace2Editor.registry = { Ace2Editor.registry = {
nextId: 1 nextId: 1
}; };
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
var _ = require('./underscore');
function scriptTag(source) { function scriptTag(source) {
return ( return (
'<script type="text/javascript">\n' '<script type="text/javascript">\n'
@ -298,4 +296,5 @@ window.onload = function () {\n\
return editor; return editor;
} }
exports.Ace2Editor = Ace2Editor; return {Ace2Editor: Ace2Editor};
});

View file

@ -474,7 +474,10 @@ var pad = {
// start the custom js // start the custom js
if (typeof customStart == "function") customStart(); if (typeof customStart == "function") customStart();
getParams(); getParams();
padeditor.init(function () {
handshake(); handshake();
}, pad.padOptions.view || {}, pad);
// To use etherpad you have to allow cookies. // To use etherpad you have to allow cookies.
// This will check if the creation of a test-cookie has success. // This will check if the creation of a test-cookie has success.
@ -525,12 +528,9 @@ var pad = {
padimpexp.init(this); padimpexp.init(this);
padsavedrevs.init(this); padsavedrevs.init(this);
padeditor.init(postAceInit, pad.padOptions.view || {}, this);
paduserlist.init(pad.myUserInfo, this); paduserlist.init(pad.myUserInfo, this);
padconnectionstatus.init(); padconnectionstatus.init();
padmodals.init(this); padmodals.init(this);
pad.collabClient = getCollabClient(padeditor.ace, clientVars.collab_client_vars, pad.myUserInfo, { pad.collabClient = getCollabClient(padeditor.ace, clientVars.collab_client_vars, pad.myUserInfo, {
colorPalette: pad.getColorPalette() colorPalette: pad.getColorPalette()
}, pad); }, pad);
@ -554,8 +554,6 @@ var pad = {
$("#chatloadmessagesbutton").css("display", "none"); $("#chatloadmessagesbutton").css("display", "none");
} }
function postAceInit()
{
padeditbar.init(); padeditbar.init();
setTimeout(function() setTimeout(function()
{ {
@ -591,7 +589,6 @@ var pad = {
}) })
hooks.aCallAll("postAceInit", {ace: padeditor.ace, pad: pad}); hooks.aCallAll("postAceInit", {ace: padeditor.ace, pad: pad});
}
}, },
dispose: function() dispose: function()
{ {

View file

@ -39,9 +39,10 @@ var padeditor = (function()
ace: null, ace: null,
// this is accessed directly from other files // this is accessed directly from other files
viewZoom: 100, viewZoom: 100,
init: function(readyFunc, initialViewOptions, _pad) init: function(readyFunc, initialViewOptions, _pad) {
{ requirejs(['ep_etherpad-lite/static/js/ace'], function (ace) {
Ace2Editor = require('./ace').Ace2Editor;
Ace2Editor = ace.Ace2Editor;
pad = _pad; pad = _pad;
settings = pad.settings; settings = pad.settings;
@ -66,6 +67,7 @@ var padeditor = (function()
// view bar // view bar
$("#viewbarcontents").show(); $("#viewbarcontents").show();
});
}, },
initViewOptions: function() initViewOptions: function()
{ {