Browse Source

Minor update in `loadModule`

pull/540/head
Artur Arseniev 9 years ago
parent
commit
6c77d85c76
  1. 22
      src/editor/model/Editor.js

22
src/editor/model/Editor.js

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

Loading…
Cancel
Save