Move modules from Marionette to AMD modules, fix tests

This commit is contained in:
Tautvidas Sipavičius
2015-09-09 14:05:34 +03:00
parent a25a8f2560
commit 8ac9799df6
42 changed files with 3573 additions and 3534 deletions

View File

@ -1,37 +1,37 @@
define([
'newsletter_editor/App',
'backbone',
], function(EditorApplication, Backbone) {
'backbone.supermodel',
], function(App, SuperModel) {
EditorApplication.module("components.config", function(Module, App, Backbone, Marionette, $, _) {
"use strict";
var Module = {};
Module.ConfigModel = Backbone.SuperModel.extend({
defaults: {
availableStyles: {},
socialIcons: {},
blockDefaults: {},
translations: {},
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(options) {
// Expose config methods globally
App.getConfig = Module.getConfig;
App.setConfig = Module.setConfig;
App.setConfig(options.config);
});
Module.ConfigModel = SuperModel.extend({
defaults: {
availableStyles: {},
socialIcons: {},
blockDefaults: {},
translations: {},
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(options) {
// Expose config methods globally
App.getConfig = Module.getConfig;
App.setConfig = Module.setConfig;
App.setConfig(options.config);
});
return Module;
});