From 71a7c00abcac82795938c90fd369c82223ddaf47 Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Sun, 15 Jan 2012 00:05:26 -0800 Subject: [PATCH] Merge adjacent scripts. --- static/js/ace.js | 118 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 86 insertions(+), 32 deletions(-) diff --git a/static/js/ace.js b/static/js/ace.js index 8b0f9c73..2bcf1241 100644 --- a/static/js/ace.js +++ b/static/js/ace.js @@ -196,26 +196,62 @@ function Ace2Editor() info.ace_replaceRange(start, end, text); }); + function sortFilesByEmbeded(files) { + var embededFiles = []; + var remoteFiles = []; - // calls to these functions ($$INCLUDE_...) are replaced when this file is processed - // and compressed, putting the compressed code from the named file directly into the - // source here. - var $$INCLUDE_CSS = function(fileName) { - if (Ace2Editor.EMBEDED && Ace2Editor.EMBEDED[fileName]) { - return ''); iframeHTML.push(' '); @@ -280,10 +326,18 @@ function 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.scrolling = "no"; var outerdocbody = document.getElementById("outerdocbody"); ' + 'iframe.frameBorder = 0; iframe.allowTransparency = true; ' + // for IE '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); }'; - var outerHTML = [doctype, '', $$INCLUDE_CSS("../static/css/iframe_editor.css"), $$INCLUDE_CSS("../static/css/pad.css"), $$INCLUDE_CSS("../static/custom/pad.css"), + var outerHTML = [doctype, ''] + + var includedCSS = []; + var $$INCLUDE_CSS = function(filename) {includedCSS.push(filename)}; + $$INCLUDE_CSS("../static/css/iframe_editor.css"); + $$INCLUDE_CSS("../static/css/pad.css"); + $$INCLUDE_CSS("../static/custom/pad.css"); + pushStyleTagsFor(outerHTML, includedCSS); + // bizarrely, in FF2, a file with no "external" dependencies won't finish loading properly // (throbs busy while typing) - '', '\x3cscript>\n', outerScript.replace(/<\//g, '<\\/'), '\n\x3c/script>', '
x
']; + outerHTML.push('', '\x3cscript>\n', outerScript.replace(/<\//g, '<\\/'), '\n\x3c/script>', '
x
'); if (!Array.prototype.map) Array.prototype.map = function(fun) { //needed for IE