From 98e2821b38a775737e42a2479a6bc65107210859 Mon Sep 17 00:00:00 2001 From: Elliot Kroo Date: Thu, 11 Mar 2010 15:21:30 -0800 Subject: reorganizing the first level of folders (trunk/branch folders are not the git way :) --- infrastructure/ace/www/ace2_outer.js | 214 +++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 infrastructure/ace/www/ace2_outer.js (limited to 'infrastructure/ace/www/ace2_outer.js') diff --git a/infrastructure/ace/www/ace2_outer.js b/infrastructure/ace/www/ace2_outer.js new file mode 100644 index 0000000..b0fc20c --- /dev/null +++ b/infrastructure/ace/www/ace2_outer.js @@ -0,0 +1,214 @@ +/** + * Copyright 2009 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +Ace2Editor.registry = { nextId: 1 }; + +function Ace2Editor() { + var thisFunctionsName = "Ace2Editor"; + var ace2 = Ace2Editor; + + var editor = {}; + var info = { editor: editor, id: (ace2.registry.nextId++) }; + var loaded = false; + + var actionsPendingInit = []; + function pendingInit(func, optDoNow) { + return function() { + var that = this; + var args = arguments; + function action() { + func.apply(that, args); + } + if (optDoNow) { + optDoNow.apply(that, args); + } + if (loaded) { + action(); + } + else { + actionsPendingInit.push(action); + } + }; + } + function doActionsPendingInit() { + for(var i=0;i, time: +new Date()} + return info.ace_getUnhandledErrors(); + }; + editor.execCommand = pendingInit(function(cmd, arg1) { + info.ace_execCommand(cmd, arg1); + }); + + // 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) { + return ''; + }; + var $$INCLUDE_JS = function(fileName) { + return '\x3cscript type="text/javascript" src="'+fileName+'">\x3c/script>'; + }; + var $$INCLUDE_JS_DEV = $$INCLUDE_JS; + var $$INCLUDE_CSS_DEV = $$INCLUDE_CSS; + + var $$INCLUDE_CSS_Q = function(fileName) { + return '\'\''; + }; + var $$INCLUDE_JS_Q = function(fileName) { + return '\'\\x3cscript type="text/javascript" src="'+fileName+'">\\x3c/script>\''; + }; + var $$INCLUDE_JS_Q_DEV = $$INCLUDE_JS_Q; + var $$INCLUDE_CSS_Q_DEV = $$INCLUDE_CSS_Q; + + editor.destroy = pendingInit(function() { + info.ace_dispose(); + info.frame.parentNode.removeChild(info.frame); + delete ace2.registry[info.id]; + info = null; // prevent IE 6 closure memory leaks + }); + + editor.init = function(containerId, initialCode, doneFunc) { + + editor.importText(initialCode); + + info.onEditorReady = function() { + loaded = true; + doActionsPendingInit(); + doneFunc(); + }; + + (function() { + var doctype = ''; + + var iframeHTML = ["'"+doctype+"'"]; + // these lines must conform to a specific format because they are passed by the build script: + iframeHTML.push($$INCLUDE_CSS_Q("editor.css syntax.css inner.css")); + //iframeHTML.push(INCLUDE_JS_Q_DEV("ace2_common_dev.js")); + //iframeHTML.push(INCLUDE_JS_Q_DEV("profiler.js")); + iframeHTML.push($$INCLUDE_JS_Q("ace2_common.js skiplist.js virtual_lines.js easysync2.js cssmanager.js colorutils.js undomodule.js contentcollector.js changesettracker.js linestylefilter.js domline.js")); + iframeHTML.push($$INCLUDE_JS_Q("ace2_inner.js")); + iframeHTML.push('\'\\n\\n\''); + iframeHTML.push('\' \''); + + 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(); doc.write('+ + iframeHTML.join('+')+'); doc.close(); '+ + '}, 0); }'; + + var outerHTML = [doctype, '', + $$INCLUDE_CSS("editor.css"), + // bizarrely, in FF2, a file with no "external" dependencies won't finish loading properly + // (throbs busy while typing) + '', + '\x3cscript>', outerScript, '\x3c/script>', + '
x
']; + + var outerFrame = document.createElement("IFRAME"); + outerFrame.frameBorder = 0; // for IE + info.frame = outerFrame; + document.getElementById(containerId).appendChild(outerFrame); + + var editorDocument = outerFrame.contentWindow.document; + + editorDocument.open(); + editorDocument.write(outerHTML.join('')); + editorDocument.close(); + + editor.adjustSize(); + })(); + }; + + return editor; +} -- cgit v1.2.3-1-g7c22 From ba468fedd61f36c842531129977590d86a763c20 Mon Sep 17 00:00:00 2001 From: Egil Moeller Date: Sat, 27 Mar 2010 16:23:39 +0100 Subject: Added the aceInitInnerdocbodyHead hook --- infrastructure/ace/www/ace2_outer.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'infrastructure/ace/www/ace2_outer.js') diff --git a/infrastructure/ace/www/ace2_outer.js b/infrastructure/ace/www/ace2_outer.js index b0fc20c..e6d430d 100644 --- a/infrastructure/ace/www/ace2_outer.js +++ b/infrastructure/ace/www/ace2_outer.js @@ -14,6 +14,10 @@ * limitations under the License. */ +// requires: top +// requires: plugins +// requires: undefined + Ace2Editor.registry = { nextId: 1 }; @@ -163,6 +167,10 @@ function Ace2Editor() { '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; var iframeHTML = ["'"+doctype+"'"]; + + top.plugins.callHook( + "aceInitInnerdocbodyHead", {iframeHTML:iframeHTML}); + // these lines must conform to a specific format because they are passed by the build script: iframeHTML.push($$INCLUDE_CSS_Q("editor.css syntax.css inner.css")); //iframeHTML.push(INCLUDE_JS_Q_DEV("ace2_common_dev.js")); -- cgit v1.2.3-1-g7c22 From e794aa43d7977aa58a7ef8704ac212008e0280e9 Mon Sep 17 00:00:00 2001 From: "Simon B @piratpartiet" Date: Wed, 21 Apr 2010 10:55:30 +0200 Subject: Fix IFRAME bug. Closes #70 --- infrastructure/ace/www/ace2_outer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'infrastructure/ace/www/ace2_outer.js') diff --git a/infrastructure/ace/www/ace2_outer.js b/infrastructure/ace/www/ace2_outer.js index e6d430d..212c159 100644 --- a/infrastructure/ace/www/ace2_outer.js +++ b/infrastructure/ace/www/ace2_outer.js @@ -168,7 +168,7 @@ function Ace2Editor() { var iframeHTML = ["'"+doctype+"'"]; - top.plugins.callHook( + plugins.callHook( "aceInitInnerdocbodyHead", {iframeHTML:iframeHTML}); // these lines must conform to a specific format because they are passed by the build script: @@ -203,6 +203,7 @@ function Ace2Editor() { '\x3cscript>', outerScript, '\x3c/script>', '
x
']; + var outerFrame = document.createElement("IFRAME"); outerFrame.frameBorder = 0; // for IE info.frame = outerFrame; -- cgit v1.2.3-1-g7c22 From a234be69475a98fca3234a73ab70018124ced5cb Mon Sep 17 00:00:00 2001 From: "Simon B @piratpartiet" Date: Wed, 21 Apr 2010 10:57:14 +0200 Subject: Fix IE lacking Array#map. Closes #70 --- infrastructure/ace/www/ace2_outer.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'infrastructure/ace/www/ace2_outer.js') diff --git a/infrastructure/ace/www/ace2_outer.js b/infrastructure/ace/www/ace2_outer.js index 212c159..f947534 100644 --- a/infrastructure/ace/www/ace2_outer.js +++ b/infrastructure/ace/www/ace2_outer.js @@ -204,6 +204,17 @@ function Ace2Editor() { '
x
']; + if (!Array.prototype.map) Array.prototype.map = function(fun) { //needed for IE + if (typeof fun != "function") throw new TypeError(); + var len = this.length; + var res = new Array(len); + var thisp = arguments[1]; + for (var i = 0; i < len; i++) { + if (i in this) res[i] = fun.call(thisp, this[i], i, this); + } + return res; + }; + var outerFrame = document.createElement("IFRAME"); outerFrame.frameBorder = 0; // for IE info.frame = outerFrame; -- cgit v1.2.3-1-g7c22