mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
Split client and server plugin functionality.
There is virtually no shared code for the client, extract it into its own module and do away with the switches.
This commit is contained in:
parent
9394495364
commit
1258ed3a0d
9 changed files with 117 additions and 108 deletions
36
src/static/js/pluginfw/client_plugins.js
Normal file
36
src/static/js/pluginfw/client_plugins.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
var $, jQuery;
|
||||
$ = jQuery = require("ep_etherpad-lite/static/js/rjquery").$;
|
||||
var _ = require("underscore");
|
||||
|
||||
var pluginUtils = require('./shared');
|
||||
|
||||
exports.loaded = false;
|
||||
exports.plugins = {};
|
||||
exports.parts = [];
|
||||
exports.hooks = {};
|
||||
exports.baseURL = '';
|
||||
|
||||
exports.ensure = function (cb) {
|
||||
if (!exports.loaded)
|
||||
exports.update(cb);
|
||||
else
|
||||
cb();
|
||||
};
|
||||
|
||||
exports.update = function (cb) {
|
||||
// It appears that this response (see #620) may interrupt the current thread
|
||||
// of execution on Firefox. This schedules the response in the run-loop,
|
||||
// which appears to fix the issue.
|
||||
var callback = function () {setTimeout(cb, 0);};
|
||||
|
||||
jQuery.getJSON(exports.baseURL + 'pluginfw/plugin-definitions.json', function(data) {
|
||||
exports.plugins = data.plugins;
|
||||
exports.parts = data.parts;
|
||||
exports.hooks = pluginUtils.extractHooks(exports.parts, "client_hooks");
|
||||
exports.loaded = true;
|
||||
callback();
|
||||
}).error(function(xhr, s, err){
|
||||
console.error("Failed to load plugin-definitions: " + err);
|
||||
callback();
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue