Files
piratepoet/assets/js/src/newsletter_editor/components/config.js
2017-09-21 08:35:12 +00:00

38 lines
911 B
JavaScript

define([
'newsletter_editor/App',
'backbone.supermodel'
], function (App, SuperModel) {
var Module = {};
Module.ConfigModel = SuperModel.extend({
defaults: {
availableStyles: {},
socialIcons: {},
blockDefaults: {},
sidepanelWidth: '331px',
validation: {},
urls: {}
}
});
// Global and available styles for access in blocks and their settings
Module._config = {};
Module.getConfig = function () { return Module._config; };
Module.setConfig = function (options) {
Module._config = new Module.ConfigModel(options, { parse: true });
return Module._config;
};
App.on('before:start', function (App, options) {
var Application = App;
// Expose config methods globally
Application.getConfig = Module.getConfig;
Application.setConfig = Module.setConfig;
Application.setConfig(options.config);
});
return Module;
});