mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
ace.js AMDification
This commit is contained in:
parent
2f12fc0229
commit
2472cd365e
3 changed files with 296 additions and 298 deletions
|
@ -24,23 +24,21 @@
|
||||||
// requires: plugins
|
// requires: plugins
|
||||||
// requires: undefined
|
// requires: undefined
|
||||||
|
|
||||||
Ace2Editor.registry = {
|
define(['ep_etherpad-lite/static/js/pluginfw/hooks', 'underscore'], function (hooks, _) {
|
||||||
|
Ace2Editor.registry = {
|
||||||
nextId: 1
|
nextId: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
function scriptTag(source) {
|
||||||
var _ = require('./underscore');
|
|
||||||
|
|
||||||
function scriptTag(source) {
|
|
||||||
return (
|
return (
|
||||||
'<script type="text/javascript">\n'
|
'<script type="text/javascript">\n'
|
||||||
+ source.replace(/<\//g, '<\\/') +
|
+ source.replace(/<\//g, '<\\/') +
|
||||||
'</script>'
|
'</script>'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Ace2Editor()
|
function Ace2Editor()
|
||||||
{
|
{
|
||||||
var ace2 = Ace2Editor;
|
var ace2 = Ace2Editor;
|
||||||
|
|
||||||
var editor = {};
|
var editor = {};
|
||||||
|
@ -237,9 +235,9 @@ function Ace2Editor()
|
||||||
(function () {return this}())[thisFunctionsName] = Ace2Editor;
|
(function () {return this}())[thisFunctionsName] = Ace2Editor;
|
||||||
|
|
||||||
var outerScript = '\
|
var outerScript = '\
|
||||||
editorId = ' + JSON.stringify(info.id) + ';\n\
|
editorId = ' + JSON.stringify(info.id) + ';\n\
|
||||||
editorInfo = parent[' + JSON.stringify(thisFunctionsName) + '].registry[editorId];\n\
|
editorInfo = parent[' + JSON.stringify(thisFunctionsName) + '].registry[editorId];\n\
|
||||||
window.onload = function () {\n\
|
window.onload = function () {\n\
|
||||||
window.onload = null;\n\
|
window.onload = null;\n\
|
||||||
setTimeout(function () {\n\
|
setTimeout(function () {\n\
|
||||||
var iframe = document.createElement("IFRAME");\n\
|
var iframe = document.createElement("IFRAME");\n\
|
||||||
|
@ -262,7 +260,7 @@ window.onload = function () {\n\
|
||||||
doc.write(text);\n\
|
doc.write(text);\n\
|
||||||
doc.close();\n\
|
doc.close();\n\
|
||||||
}, 0);\n\
|
}, 0);\n\
|
||||||
}';
|
}';
|
||||||
|
|
||||||
var outerHTML = [doctype, '<html><head>']
|
var outerHTML = [doctype, '<html><head>']
|
||||||
|
|
||||||
|
@ -296,6 +294,7 @@ window.onload = function () {\n\
|
||||||
};
|
};
|
||||||
|
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.Ace2Editor = Ace2Editor;
|
return {Ace2Editor: Ace2Editor};
|
||||||
|
});
|
||||||
|
|
|
@ -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()
|
||||||
{
|
{
|
||||||
|
|
|
@ -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()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue