Lots of fixes

This commit is contained in:
Egil Moeller 2015-04-25 19:56:22 +02:00
parent 0ec2592c53
commit e5abd185b5
10 changed files with 1140 additions and 1108 deletions

View file

@ -199,28 +199,7 @@ define(['ep_etherpad-lite/static/js/pluginfw/hooks', 'underscore'], function (ho
')); '));
iframeHTML.push('<script type="text/javascript" src="../static/plugins/requirejs/require.js"></script>'); iframeHTML.push('<script type="text/javascript" src="../static/plugins/requirejs/require.js"></script>');
iframeHTML.push('<script type="text/javascript" src="../static/plugins/ep_etherpad-lite/static/js/ace2_inner_main.js"></script>');
iframeHTML.push(scriptTag('\n\
var pathComponents = parent.parent.location.pathname.split("/");\n\
var baseURL = pathComponents.slice(0,pathComponents.length-2).join("/") + "/";\n\
requirejs.config({\n\
baseUrl: baseURL + "static/plugins",\n\
paths: {underscore: baseURL + "static/plugins/underscore/underscore"}\n\
});\n\
\n\
requirejs(["ep_etherpad-lite/static/js/rjquery", "ep_etherpad-lite/static/js/pluginfw/client_plugins", "ep_etherpad-lite/static/js/ace2_inner"], function (j, plugins, Ace2Inner) {\n\
jQuery = $ = window.jQuery = window.$ = j; // Expose jQuery #HACK\n\
\n\
plugins.adoptPluginsFromAncestorsOf(window, function () {\n\
var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks");\n\
hooks.plugins = plugins;\n\
\n\
plugins.ensure(function () {\n\
Ace2Inner.init();\n\
});\n\
});\n\
});\n\
'));
iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>'); iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>');

View file

@ -20,7 +20,9 @@
* limitations under the License. * limitations under the License.
*/ */
define(["ep_etherpad-lite/static/js/rjquery", "underscore", 'ep_etherpad-lite/static/js/pluginfw/hooks'], function ($, _, hooks) { define(["ep_etherpad-lite/static/js/rjquery", "underscore", 'ep_etherpad-lite/static/js/pluginfw/hooks', 'ep_etherpad-lite/static/js/linestylefilter', 'ep_etherpad-lite/static/js/domline'], function ($, _, hooks, linestylefilterMod, domlineMod) {
var linestylefilter = linestylefilterMod.linestylefilter;
var domline = domlineMod.domline;
var exports = {}; var exports = {};
var browser = require('./browser').browser; var browser = require('./browser').browser;
@ -50,11 +52,9 @@ function Ace2Inner(){
var colorutils = require('./colorutils').colorutils; var colorutils = require('./colorutils').colorutils;
var makeContentCollector = require('./contentcollector').makeContentCollector; var makeContentCollector = require('./contentcollector').makeContentCollector;
var makeCSSManager = require('./cssmanager').makeCSSManager; var makeCSSManager = require('./cssmanager').makeCSSManager;
var domline = require('./domline').domline;
var AttribPool = require('./AttributePool'); var AttribPool = require('./AttributePool');
var Changeset = require('./Changeset'); var Changeset = require('./Changeset');
var ChangesetUtils = require('./ChangesetUtils'); var ChangesetUtils = require('./ChangesetUtils');
var linestylefilter = require('./linestylefilter').linestylefilter;
var SkipList = require('./skiplist'); var SkipList = require('./skiplist');
var undoModule = require('./undomodule').undoModule; var undoModule = require('./undomodule').undoModule;
var AttributeManager = require('./AttributeManager'); var AttributeManager = require('./AttributeManager');
@ -475,6 +475,7 @@ function Ace2Inner(){
//console.log("Just did action for: "+type); //console.log("Just did action for: "+type);
cleanExit = true; cleanExit = true;
} }
/*
catch (e) catch (e)
{ {
caughtErrors.push( caughtErrors.push(
@ -485,6 +486,7 @@ function Ace2Inner(){
dmesg(e.toString()); dmesg(e.toString());
throw e; throw e;
} }
*/
finally finally
{ {
var cs = currentCallStack; var cs = currentCallStack;

View file

@ -0,0 +1,26 @@
var pathComponents = parent.parent.location.pathname.split("/");
var baseURL = pathComponents.slice(0,pathComponents.length-2).join("/") + "/";
requirejs.config({
baseUrl: baseURL + "static/plugins",
paths: {underscore: baseURL + "static/plugins/underscore/underscore"}
});
requirejs(
[
"ep_etherpad-lite/static/js/rjquery",
"ep_etherpad-lite/static/js/pluginfw/client_plugins",
"ep_etherpad-lite/static/js/pluginfw/hooks",
"ep_etherpad-lite/static/js/ace2_inner"
],
function (j, plugins, hooks, Ace2Inner) {
jQuery = $ = window.jQuery = window.$ = j; // Expose jQuery #HACK
plugins.adoptPluginsFromAncestorsOf(window, function () {
hooks.plugins = plugins;
plugins.ensure(function () {
Ace2Inner.init();
});
});
}
);

View file

@ -20,14 +20,14 @@
* limitations under the License. * limitations under the License.
*/ */
define(['ep_etherpad-lite/static/js/pluginfw/hooks', 'ep_etherpad-lite/static/js/linestylefilter', 'ep_etherpad-lite/static/js/domline', 'underscore'], function (hooks, linetyleFilterMod, domlineMod, _) {
var exports = {};
var makeCSSManager = require('./cssmanager').makeCSSManager; var makeCSSManager = require('./cssmanager').makeCSSManager;
var domline = require('./domline').domline; var domline = domlineMod.domline;
var AttribPool = require('./AttributePool'); var AttribPool = require('./AttributePool');
var Changeset = require('./Changeset'); var Changeset = require('./Changeset');
var linestylefilter = require('./linestylefilter').linestylefilter; var linestylefilter = linetyleFilterMod.linestylefilter;
var colorutils = require('./colorutils').colorutils; var colorutils = require('./colorutils').colorutils;
var _ = require('./underscore');
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
// These parameters were global, now they are injected. A reference to the // These parameters were global, now they are injected. A reference to the
// Timeslider controller would probably be more appropriate. // Timeslider controller would probably be more appropriate.
@ -594,3 +594,6 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
} }
exports.loadBroadcastJS = loadBroadcastJS; exports.loadBroadcastJS = loadBroadcastJS;
return exports;
});

View file

@ -26,10 +26,11 @@
// requires: plugins // requires: plugins
// requires: undefined // requires: undefined
define(['ep_etherpad-lite/static/js/pluginfw/hooks', 'ep_etherpad-lite/static/js/linestylefilter', 'underscore'], function(hooks, linestylefilterMod, _) {
var exports = {};
var Security = require('./security'); var Security = require('./security');
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); var lineAttributeMarker = linestylefilterMod.lineAttributeMarker;
var _ = require('./underscore');
var lineAttributeMarker = require('./linestylefilter').lineAttributeMarker;
var noop = function(){}; var noop = function(){};
@ -319,3 +320,6 @@ domline.processSpaces = function(s, doesWrap)
}; };
exports.domline = domline; exports.domline = domline;
return exports;
});

View file

@ -28,10 +28,11 @@
// requires: plugins // requires: plugins
// requires: undefined // requires: undefined
define(['ep_etherpad-lite/static/js/pluginfw/hooks', 'underscore'], function (hooks, _) {
var exports = {};
var Changeset = require('./Changeset'); var Changeset = require('./Changeset');
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
var linestylefilter = {}; var linestylefilter = {};
var _ = require('./underscore');
var AttributeManager = require('./AttributeManager'); var AttributeManager = require('./AttributeManager');
linestylefilter.ATTRIB_CLASSES = { linestylefilter.ATTRIB_CLASSES = {
@ -363,3 +364,6 @@ linestylefilter.populateDomLine = function(textLine, aline, apool, domLineObj)
}; };
exports.linestylefilter = linestylefilter; exports.linestylefilter = linestylefilter;
return exports;
});

View file

@ -53,7 +53,7 @@ define(["ep_etherpad-lite/static/js/rjquery", "underscore", './shared'], functio
var parentRequire = null; var parentRequire = null;
try { try {
while (frame = frame.parent) { while (frame = frame.parent) {
if (typeof (frame.require) !== "undefined") { if (typeof (frame.requirejs) !== "undefined") {
parentRequire = frame.requirejs; parentRequire = frame.requirejs;
break; break;
} }

View file

@ -70,18 +70,16 @@ exports.flatten = function (lst) {
exports.callAll = function (hook_name, args) { exports.callAll = function (hook_name, args) {
if (!args) args = {}; if (!args) args = {};
if (exports.plugins){ if (exports.plugins === undefined || exports.plugins.hooks[hook_name] === undefined) return [];
if (exports.plugins.hooks[hook_name] === undefined) return [];
return _.flatten(_.map(exports.plugins.hooks[hook_name], function (hook) { return _.flatten(_.map(exports.plugins.hooks[hook_name], function (hook) {
return hookCallWrapper(hook, hook_name, args); return hookCallWrapper(hook, hook_name, args);
}), true); }), true);
} }
}
exports.aCallAll = function (hook_name, args, cb) { exports.aCallAll = function (hook_name, args, cb) {
if (!args) args = {}; if (!args) args = {};
if (!cb) cb = function () {}; if (!cb) cb = function () {};
if (exports.plugins.hooks[hook_name] === undefined) return cb(null, []); if (exports.plugins === undefined || exports.plugins.hooks[hook_name] === undefined) return cb(null, []);
async.map( async.map(
exports.plugins.hooks[hook_name], exports.plugins.hooks[hook_name],
function (hook, cb) { function (hook, cb) {
@ -95,7 +93,7 @@ exports.aCallAll = function (hook_name, args, cb) {
exports.callFirst = function (hook_name, args) { exports.callFirst = function (hook_name, args) {
if (!args) args = {}; if (!args) args = {};
if (exports.plugins.hooks[hook_name] === undefined) return []; if (exports.plugins === undefined || exports.plugins.hooks[hook_name] === undefined) return [];
return exports.syncMapFirst(exports.plugins.hooks[hook_name], function (hook) { return exports.syncMapFirst(exports.plugins.hooks[hook_name], function (hook) {
return hookCallWrapper(hook, hook_name, args); return hookCallWrapper(hook, hook_name, args);
}); });
@ -104,7 +102,7 @@ exports.callFirst = function (hook_name, args) {
exports.aCallFirst = function (hook_name, args, cb) { exports.aCallFirst = function (hook_name, args, cb) {
if (!args) args = {}; if (!args) args = {};
if (!cb) cb = function () {}; if (!cb) cb = function () {};
if (exports.plugins.hooks[hook_name] === undefined) return cb(null, []); if (exports.plugins === undefined || exports.plugins.hooks[hook_name] === undefined) return cb(null, []);
exports.mapFirst( exports.mapFirst(
exports.plugins.hooks[hook_name], exports.plugins.hooks[hook_name],
function (hook, cb) { function (hook, cb) {

View file

@ -27,8 +27,9 @@ define([
'ep_etherpad-lite/static/js/rjquery', 'ep_etherpad-lite/static/js/rjquery',
'ep_etherpad-lite/static/js/pluginfw/hooks', 'ep_etherpad-lite/static/js/pluginfw/hooks',
'ep_etherpad-lite/static/js/pad_utils', 'ep_etherpad-lite/static/js/pad_utils',
'ep_etherpad-lite/static/js/broadcast_slider' 'ep_etherpad-lite/static/js/broadcast_slider',
], function($, hooks, padUtilsMod, broadcastSliderMod) { 'ep_etherpad-lite/static/js/broadcast',
], function($, hooks, padUtilsMod, broadcastSliderMod, broadcastMod) {
var exports = {}; var exports = {};
JSON = window.requireKernel('./json2'); JSON = window.requireKernel('./json2');
@ -36,6 +37,11 @@ define([
var createCookie = padUtilsMod.createCookie; var createCookie = padUtilsMod.createCookie;
var readCookie = padUtilsMod.readCookie; var readCookie = padUtilsMod.readCookie;
var randomString = padUtilsMod.randomString; var randomString = padUtilsMod.randomString;
var broadcastRevisionsMod = require('./broadcast_revisions');
var padimpexpMod = require('./pad_impexp');
//initialize export ui
require('./pad_impexp').padimpexp.init();
var token, padId, export_links; var token, padId, export_links;
@ -142,11 +148,11 @@ define([
//load all script that doesn't work without the clientVars //load all script that doesn't work without the clientVars
BroadcastSlider = broadcastSliderMod.loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded); BroadcastSlider = broadcastSliderMod.loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded);
require('./broadcast_revisions').loadBroadcastRevisionsJS(); broadcastRevisionsMod.loadBroadcastRevisionsJS();
changesetLoader = require('./broadcast').loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, BroadcastSlider); changesetLoader = broadcastMod.loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, BroadcastSlider);
//initialize export ui //initialize export ui
require('./pad_impexp').padimpexp.init(); padimpexpMod.padimpexp.init();
//change export urls when the slider moves //change export urls when the slider moves
BroadcastSlider.onSlider(function(revno) BroadcastSlider.onSlider(function(revno)

View file

@ -398,11 +398,9 @@
[ [
'ep_etherpad-lite/static/js/rjquery', 'ep_etherpad-lite/static/js/rjquery',
'ep_etherpad-lite/static/js/pluginfw/client_plugins', 'ep_etherpad-lite/static/js/pluginfw/client_plugins',
'ep_etherpad-lite/static/js/pluginfw/hooks', 'ep_etherpad-lite/static/js/pluginfw/hooks'
'ep_etherpad-lite/static/js/pad', ], function ($, plugins, hooks) {
'ep_etherpad-lite/static/js/chat', console.log("hooks & plugins modules loaded");
'ep_etherpad-lite/static/js/pad_editbar',
], function ($, plugins, hooks, padMod, chatMod, padEditbarMod) {
window.$ = $; // Expose jQuery #HACK window.$ = $; // Expose jQuery #HACK
window.jQuery = $; window.jQuery = $;
@ -415,14 +413,23 @@
plugins.update(function () { plugins.update(function () {
hooks.plugins = plugins; hooks.plugins = plugins;
console.log("hooks.plugins initialized");
// Call documentReady hook // Call documentReady hook
$(function() { $(function() {
hooks.aCallAll('documentReady'); hooks.aCallAll('documentReady');
}); });
requirejs(
[
'ep_etherpad-lite/static/js/pad',
'ep_etherpad-lite/static/js/chat',
'ep_etherpad-lite/static/js/pad_editbar',
], function (padMod, chatMod, padEditbarMod) {
console.log("pad loaded");
padMod.baseURL = baseURL; padMod.baseURL = baseURL;
padMod.init(); padMod.init();
});
/* TODO: These globals shouldn't exist. */ /* TODO: These globals shouldn't exist. */
pad = padMod.pad; pad = padMod.pad;
@ -431,6 +438,9 @@
padimpexp = window.requireKernel('ep_etherpad-lite/static/js/pad_impexp').padimpexp; padimpexp = window.requireKernel('ep_etherpad-lite/static/js/pad_impexp').padimpexp;
} }
); );
});
}
);
}()); }());
</script> </script>
<% e.end_block(); %> <% e.end_block(); %>