Reformat Ace2Editor frame boot scripts.
This commit is contained in:
parent
fa65f889ec
commit
9f5946c942
|
@ -33,6 +33,14 @@ Ace2Editor.registry = {
|
||||||
var hooks = require('./pluginfw/hooks');
|
var hooks = require('./pluginfw/hooks');
|
||||||
var _ = require('./underscore');
|
var _ = require('./underscore');
|
||||||
|
|
||||||
|
function scriptTag(source) {
|
||||||
|
return (
|
||||||
|
'<script type="text/javascript">\n'
|
||||||
|
+ source.replace(/<\//g, '<\\/') +
|
||||||
|
'</script>'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function Ace2Editor()
|
function Ace2Editor()
|
||||||
{
|
{
|
||||||
var ace2 = Ace2Editor;
|
var ace2 = Ace2Editor;
|
||||||
|
@ -226,9 +234,8 @@ function Ace2Editor()
|
||||||
throw new Error("Require kernel could not be found.");
|
throw new Error("Require kernel could not be found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
iframeHTML.push('\
|
iframeHTML.push(scriptTag(
|
||||||
<script type="text/javascript">\n\
|
Ace2Editor.EMBEDED[KERNEL_SOURCE] + '\n\
|
||||||
' + Ace2Editor.EMBEDED[KERNEL_SOURCE] + '\n\
|
|
||||||
require.setRootURI("../javascripts/src");\n\
|
require.setRootURI("../javascripts/src");\n\
|
||||||
require.setLibraryURI("../javascripts/lib");\n\
|
require.setLibraryURI("../javascripts/lib");\n\
|
||||||
require.setGlobalKeyPath("require");\n\
|
require.setGlobalKeyPath("require");\n\
|
||||||
|
@ -240,9 +247,7 @@ function Ace2Editor()
|
||||||
\n\
|
\n\
|
||||||
$ = jQuery = require("ep_etherpad-lite/static/js/rjquery").jQuery; // Expose jQuery #HACK\n\
|
$ = jQuery = require("ep_etherpad-lite/static/js/rjquery").jQuery; // Expose jQuery #HACK\n\
|
||||||
require("ep_etherpad-lite/static/js/ace2_inner");\n\
|
require("ep_etherpad-lite/static/js/ace2_inner");\n\
|
||||||
</script>\n\
|
'));
|
||||||
');
|
|
||||||
iframeHTML.push('<\/script>');
|
|
||||||
|
|
||||||
iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>');
|
iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>');
|
||||||
|
|
||||||
|
@ -256,8 +261,32 @@ function Ace2Editor()
|
||||||
var thisFunctionsName = "ChildAccessibleAce2Editor";
|
var thisFunctionsName = "ChildAccessibleAce2Editor";
|
||||||
(function () {return this}())[thisFunctionsName] = Ace2Editor;
|
(function () {return this}())[thisFunctionsName] = Ace2Editor;
|
||||||
|
|
||||||
var outerScript = 'editorId = "' + info.id + '"; editorInfo = parent.' + thisFunctionsName + '.registry[editorId]; ' + 'window.onload = function() ' + '{ window.onload = null; setTimeout' + '(function() ' + '{ var iframe = document.createElement("IFRAME"); iframe.name = "ace_inner";' + 'iframe.scrolling = "no"; var outerdocbody = document.getElementById("outerdocbody"); ' + 'iframe.frameBorder = 0; iframe.allowTransparency = true; ' + // for IE
|
var outerScript = '\
|
||||||
'outerdocbody.insertBefore(iframe, outerdocbody.firstChild); ' + 'iframe.ace_outerWin = window; ' + 'readyFunc = function() { editorInfo.onEditorReady(); readyFunc = null; editorInfo = null; }; ' + 'var doc = iframe.contentWindow.document; doc.open(); var text = (' + JSON.stringify(iframeHTML.join('\n')) + ');doc.write(text); doc.close(); ' + '}, 0); }';
|
editorId = ' + JSON.stringify(info.id) + ';\n\
|
||||||
|
editorInfo = parent[' + JSON.stringify(thisFunctionsName) + '].registry[editorId];\n\
|
||||||
|
window.onload = function () {\n\
|
||||||
|
window.onload = null;\n\
|
||||||
|
setTimeout(function () {\n\
|
||||||
|
var iframe = document.createElement("IFRAME");\n\
|
||||||
|
iframe.name = "ace_inner";\n\
|
||||||
|
iframe.scrolling = "no";\n\
|
||||||
|
var outerdocbody = document.getElementById("outerdocbody");\n\
|
||||||
|
iframe.frameBorder = 0;\n\
|
||||||
|
iframe.allowTransparency = true; // for IE\n\
|
||||||
|
outerdocbody.insertBefore(iframe, outerdocbody.firstChild);\n\
|
||||||
|
iframe.ace_outerWin = window;\n\
|
||||||
|
readyFunc = function () {\n\
|
||||||
|
editorInfo.onEditorReady();\n\
|
||||||
|
readyFunc = null;\n\
|
||||||
|
editorInfo = null;\n\
|
||||||
|
};\n\
|
||||||
|
var doc = iframe.contentWindow.document;\n\
|
||||||
|
doc.open();\n\
|
||||||
|
var text = (' + JSON.stringify(iframeHTML.join('\n')) + ');\n\
|
||||||
|
doc.write(text);\n\
|
||||||
|
doc.close();\n\
|
||||||
|
}, 0);\n\
|
||||||
|
}';
|
||||||
|
|
||||||
var outerHTML = [doctype, '<html><head>']
|
var outerHTML = [doctype, '<html><head>']
|
||||||
|
|
||||||
|
@ -275,7 +304,7 @@ function Ace2Editor()
|
||||||
|
|
||||||
// bizarrely, in FF2, a file with no "external" dependencies won't finish loading properly
|
// bizarrely, in FF2, a file with no "external" dependencies won't finish loading properly
|
||||||
// (throbs busy while typing)
|
// (throbs busy while typing)
|
||||||
outerHTML.push('<link rel="stylesheet" type="text/css" href="data:text/css,"/>', '\x3cscript>\n', outerScript.replace(/<\//g, '<\\/'), '\n\x3c/script>', '</head><body id="outerdocbody"><div id="sidediv"><!-- --></div><div id="linemetricsdiv">x</div><div id="overlaysdiv"><!-- --></div></body></html>');
|
outerHTML.push('<link rel="stylesheet" type="text/css" href="data:text/css,"/>', scriptTag(outerScript), '</head><body id="outerdocbody"><div id="sidediv"><!-- --></div><div id="linemetricsdiv">x</div><div id="overlaysdiv"><!-- --></div></body></html>');
|
||||||
|
|
||||||
var outerFrame = document.createElement("IFRAME");
|
var outerFrame = document.createElement("IFRAME");
|
||||||
outerFrame.name = "ace_outer";
|
outerFrame.name = "ace_outer";
|
||||||
|
|
Loading…
Reference in New Issue