Plugins are injected and no longer exist in the global scope.

This commit is contained in:
Chad Weider 2012-02-05 11:13:43 -08:00
parent 8ade4c89d5
commit 3fb62956b9
7 changed files with 22 additions and 94 deletions

View File

@ -337,6 +337,15 @@ function Ace2Editor()
$$INCLUDE_JS("../static/js/domline.js"); $$INCLUDE_JS("../static/js/domline.js");
$$INCLUDE_JS("../static/js/ace2_inner.js"); $$INCLUDE_JS("../static/js/ace2_inner.js");
pushRequireScriptTo(iframeHTML); pushRequireScriptTo(iframeHTML);
// Inject my plugins into my child.
iframeHTML.push('\
<script type="text/javascript">\
require.define("/plugins", null);\n\
require.define("/plugins.js", function (require, exports, module) {\
module.exports = parent.parent.require("/plugins");\
});\
</script>\
');
pushScriptTagsFor(iframeHTML, includedJS); pushScriptTagsFor(iframeHTML, includedJS);
iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>'); iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>');

View File

@ -26,12 +26,7 @@
var _MAX_LIST_LEVEL = 8; var _MAX_LIST_LEVEL = 8;
var Changeset = require('/easysync2').Changeset var Changeset = require('/easysync2').Changeset
var plugins = undefined; var plugins = require('/plugins').plugins;
try {
plugins = require('/plugins').plugins;
} catch (e) {
// silence
}
function sanitizeUnicode(s) function sanitizeUnicode(s)
{ {
@ -42,15 +37,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
{ {
browser = browser || {}; browser = browser || {};
var plugins_; var plugins_ = plugins;
if (typeof(plugins) != 'undefined')
{
plugins_ = plugins;
}
else
{
plugins_ = parent.parent.plugins;
}
var dom = domInterface || { var dom = domInterface || {
isNodeText: function(n) isNodeText: function(n)

View File

@ -26,12 +26,7 @@
// requires: plugins // requires: plugins
// requires: undefined // requires: undefined
var plugins = undefined; var plugins = require('/plugins').plugins;
try {
plugins = require('/plugins').plugins;
} catch (e) {
// silence
}
var domline = {}; var domline = {};
domline.noop = function() domline.noop = function()
@ -148,15 +143,7 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
var extraOpenTags = ""; var extraOpenTags = "";
var extraCloseTags = ""; var extraCloseTags = "";
var plugins_; var plugins_ = plugins;
if (typeof(plugins) != 'undefined')
{
plugins_ = plugins;
}
else
{
plugins_ = parent.parent.plugins;
}
plugins_.callHook("aceCreateDomLine", { plugins_.callHook("aceCreateDomLine", {
domline: domline, domline: domline,

View File

@ -25,12 +25,7 @@
// requires: plugins // requires: plugins
// requires: undefined // requires: undefined
var plugins = undefined; var plugins = require('/plugins').plugins;
try {
plugins = require('/plugins').plugins;
} catch (e) {
// silence
}
var domline = {}; var domline = {};
domline.noop = function() domline.noop = function()
@ -147,15 +142,7 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
var extraOpenTags = ""; var extraOpenTags = "";
var extraCloseTags = ""; var extraCloseTags = "";
var plugins_; var plugins_ = plugins;
if (typeof(plugins) != 'undefined')
{
plugins_ = plugins;
}
else
{
plugins_ = parent.parent.plugins;
}
plugins_.callHook("aceCreateDomLine", { plugins_.callHook("aceCreateDomLine", {
domline: domline, domline: domline,

View File

@ -29,12 +29,7 @@
// requires: undefined // requires: undefined
var Changeset = require('/easysync2').Changeset var Changeset = require('/easysync2').Changeset
var plugins = undefined; var plugins = require('/plugins').plugins;
try {
plugins = require('/plugins').plugins;
} catch (e) {
// silence
}
var linestylefilter = {}; var linestylefilter = {};
@ -59,15 +54,7 @@ linestylefilter.getAuthorClassName = function(author)
linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFunc, apool) linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFunc, apool)
{ {
var plugins_; var plugins_ = plugins;
if (typeof(plugins) != 'undefined')
{
plugins_ = plugins;
}
else
{
plugins_ = parent.parent.plugins;
}
if (lineLength == 0) return textAndClassFunc; if (lineLength == 0) return textAndClassFunc;
@ -312,15 +299,7 @@ linestylefilter.getFilterStack = function(lineText, textAndClassFunc, browser)
{ {
var func = linestylefilter.getURLFilter(lineText, textAndClassFunc); var func = linestylefilter.getURLFilter(lineText, textAndClassFunc);
var plugins_; var plugins_ = plugins;
if (typeof(plugins) != 'undefined')
{
plugins_ = plugins;
}
else
{
plugins_ = parent.parent.plugins;
}
var hookFilters = plugins_.callHook("aceGetFilterStack", { var hookFilters = plugins_.callHook("aceGetFilterStack", {
linestylefilter: linestylefilter, linestylefilter: linestylefilter,

View File

@ -27,12 +27,7 @@
// requires: undefined // requires: undefined
var Changeset = require('/easysync2_client').Changeset var Changeset = require('/easysync2_client').Changeset
var plugins = undefined; var plugins = require('/plugins').plugins;
try {
plugins = require('/plugins').plugins;
} catch (e) {
// silence
}
var linestylefilter = {}; var linestylefilter = {};
@ -57,15 +52,7 @@ linestylefilter.getAuthorClassName = function(author)
linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFunc, apool) linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFunc, apool)
{ {
var plugins_; var plugins_ = plugins;
if (typeof(plugins) != 'undefined')
{
plugins_ = plugins;
}
else
{
plugins_ = parent.parent.plugins;
}
if (lineLength == 0) return textAndClassFunc; if (lineLength == 0) return textAndClassFunc;
@ -310,15 +297,7 @@ linestylefilter.getFilterStack = function(lineText, textAndClassFunc, browser)
{ {
var func = linestylefilter.getURLFilter(lineText, textAndClassFunc); var func = linestylefilter.getURLFilter(lineText, textAndClassFunc);
var plugins_; var plugins_ = plugins;
if (typeof(plugins) != 'undefined')
{
plugins_ = plugins;
}
else
{
plugins_ = parent.parent.plugins;
}
var hookFilters = plugins_.callHook("aceGetFilterStack", { var hookFilters = plugins_.callHook("aceGetFilterStack", {
linestylefilter: linestylefilter, linestylefilter: linestylefilter,

View File

@ -4,7 +4,7 @@
* TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED
*/ */
plugins = { var plugins = {
callHook: function(hookName, args) callHook: function(hookName, args)
{ {
var global = (function () {return this}()); var global = (function () {return this}());