X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/efe36f4f1b5df351eeb4d40a54c3900cf9a7079b..fb23a597811c4c60dd1b9bddeab4335a33bee8c1:/src/fnpjs/runner.js diff --git a/src/fnpjs/runner.js b/src/fnpjs/runner.js index 66e0b68..7797e24 100644 --- a/src/fnpjs/runner.js +++ b/src/fnpjs/runner.js @@ -1,5 +1,7 @@ define(['libs/jquery', 'libs/underscore'], function($, _) { +'use strict'; + var Runner = function(app, modules) { function getModuleInstance(moduleName) { @@ -8,9 +10,10 @@ var Runner = function(app, modules) { } var bootstrappedData = {}, - options = {}, moduleInstances = {}, - eventListeners = []; + eventListeners = [], + plugins = [], + config; _.each(_.keys(modules || {}), function(moduleName) { if(_.contains(app.permissions[moduleName] || [], 'handleEvents')) { @@ -33,7 +36,6 @@ var Runner = function(app, modules) { }; this.publish = function(eventName) { - console.log(moduleName + ': ' + eventName); var eventArgs = Array.prototype.slice.call(arguments, 1); _.each(eventListeners, function(listenerModuleName) { var listener = moduleInstances[listenerModuleName]; @@ -50,20 +52,31 @@ var Runner = function(app, modules) { } : undefined; this.getDOM = _.contains(permissions, 'getDOM') ? function() { - return $(options.rootSelector); + return $(config.rootSelector); } : undefined; - + + this.getPlugins = function() { + return plugins; + }; + + this.getConfig = function() { + return config; + }; }; this.setBootstrappedData = function(moduleName, data) { bootstrappedData[moduleName] = data; }; + + this.registerPlugin = function(plugin) { + plugins.push(plugin); + }; - this.start = function(_options) { - options = _.extend({ + this.start = function(_config) { + config = _.extend({ rootSelector: 'body' - }, _options); + }, _config); app.initModules.forEach(function(moduleName) { getModuleInstance(moduleName).start(); });