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) {
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;
},

Loading…
Cancel
Save