X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/f7b9f2577c412532fb29bad0cc9de27351d7daaf..becdfc02dc816d594bcad03cbcbab7aac550da5f:/src/fnpjs/runner.js?ds=sidebyside diff --git a/src/fnpjs/runner.js b/src/fnpjs/runner.js index 0da2916..2f00170 100644 --- a/src/fnpjs/runner.js +++ b/src/fnpjs/runner.js @@ -1,4 +1,4 @@ -define(['libs/jquery', 'libs/underscore'], function($, _) { +define(['libs/jquery', 'libs/underscore', 'fnpjs/logging/logging'], function($, _, logging) { 'use strict'; @@ -10,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')) { @@ -51,20 +52,37 @@ 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); + + + if(config.logging) { + logging.setConfig(config.logging); + } + app.initModules.forEach(function(moduleName) { getModuleInstance(moduleName).start(); });