|
|
|
@ -144,30 +144,30 @@ module.exports = Backbone.Model.extend({ |
|
|
|
*/ |
|
|
|
loadModule(moduleName) { |
|
|
|
var c = this.config; |
|
|
|
var M = new moduleName(); |
|
|
|
var name = M.name.charAt(0).toLowerCase() + M.name.slice(1); |
|
|
|
var cfg = c[name] || c[M.name] || {}; |
|
|
|
var Mod = new moduleName(); |
|
|
|
var name = Mod.name.charAt(0).toLowerCase() + Mod.name.slice(1); |
|
|
|
var cfg = c[name] || c[Mod.name] || {}; |
|
|
|
cfg.pStylePrefix = c.pStylePrefix || ''; |
|
|
|
|
|
|
|
// Check if module is storable
|
|
|
|
var sm = this.get('StorageManager'); |
|
|
|
if(M.storageKey && M.store && M.load && sm){ |
|
|
|
if(Mod.storageKey && Mod.store && Mod.load && sm){ |
|
|
|
cfg.stm = sm; |
|
|
|
var storables = this.get('storables'); |
|
|
|
storables.push(M); |
|
|
|
storables.push(Mod); |
|
|
|
this.set('storables', storables); |
|
|
|
} |
|
|
|
cfg.em = this; |
|
|
|
M.init(Object.create(cfg)); |
|
|
|
Mod.init({ ...cfg }); |
|
|
|
|
|
|
|
// Bind the module to the editor model if public
|
|
|
|
if(!M.private) |
|
|
|
this.set(M.name, M); |
|
|
|
if(!Mod.private) |
|
|
|
this.set(Mod.name, Mod); |
|
|
|
|
|
|
|
if(M.onLoad) |
|
|
|
this.get('toLoad').push(M); |
|
|
|
if(Mod.onLoad) |
|
|
|
this.get('toLoad').push(Mod); |
|
|
|
|
|
|
|
this.get('modules').push(M); |
|
|
|
this.get('modules').push(Mod); |
|
|
|
return this; |
|
|
|
}, |
|
|
|
|
|
|
|
|