|
|
@ -97,27 +97,26 @@ module.exports = Backbone.Model.extend(Styleable).extend({ |
|
|
toolbar: null, |
|
|
toolbar: null, |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
initialize(o, opt) { |
|
|
initialize(props = {}, opt = {}) { |
|
|
|
|
|
const em = opt.sm || {}; |
|
|
|
|
|
|
|
|
// Check void elements
|
|
|
// Check void elements
|
|
|
if(opt && opt.config && opt.config.voidElements.indexOf(this.get('tagName')) >= 0) |
|
|
if(opt && opt.config && |
|
|
this.set('void', true); |
|
|
opt.config.voidElements.indexOf(this.get('tagName')) >= 0) { |
|
|
const em = opt ? opt.sm || {} : {}; |
|
|
this.set('void', true); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.opt = opt; |
|
|
this.opt = opt; |
|
|
this.sm = em; |
|
|
this.sm = em; |
|
|
this.config = o || {}; |
|
|
this.config = props; |
|
|
this.defaultC = this.config.components || []; |
|
|
|
|
|
this.defaultCl = this.normalizeClasses(this.get('classes') || this.config.classes || []); |
|
|
|
|
|
this.components = new Components(this.defaultC, opt); |
|
|
|
|
|
this.components.parent = this; |
|
|
|
|
|
this.set('attributes', this.get('attributes') || {}); |
|
|
this.set('attributes', this.get('attributes') || {}); |
|
|
this.listenTo(this, 'change:script', this.scriptUpdated); |
|
|
this.listenTo(this, 'change:script', this.scriptUpdated); |
|
|
this.listenTo(this, 'change:traits', this.traitsUpdated); |
|
|
this.listenTo(this, 'change:traits', this.traitsUpdated); |
|
|
this.set('components', this.components); |
|
|
//this.defaultCl = this.normalizeClasses(this.get('classes') || this.config.classes || []);
|
|
|
this.set('classes', new Selectors(this.defaultCl)); |
|
|
//this.set('classes', new Selectors(this.defaultCl));
|
|
|
var traits = new Traits(); |
|
|
this.loadTraits(this.get('traits')); |
|
|
traits.setTarget(this); |
|
|
this.initClasses(); |
|
|
traits.add(this.get('traits')); |
|
|
this.initComponents(); |
|
|
this.set('traits', traits); |
|
|
|
|
|
this.initToolbar(); |
|
|
this.initToolbar(); |
|
|
|
|
|
|
|
|
// Normalize few properties from strings to arrays
|
|
|
// Normalize few properties from strings to arrays
|
|
|
@ -135,6 +134,19 @@ module.exports = Backbone.Model.extend(Styleable).extend({ |
|
|
this.init(); |
|
|
this.init(); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
initClasses() { |
|
|
|
|
|
const classes = this.normalizeClasses(this.get('classes') || this.config.classes || []); |
|
|
|
|
|
this.set('classes', new Selectors(classes)); |
|
|
|
|
|
return this; |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
initComponents() { |
|
|
|
|
|
let comps = new Components(this.get('components'), this.opt); |
|
|
|
|
|
comps.parent = this; |
|
|
|
|
|
this.set('components', comps); |
|
|
|
|
|
return this; |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Initialize callback |
|
|
* Initialize callback |
|
|
*/ |
|
|
*/ |
|
|
@ -153,6 +165,7 @@ module.exports = Backbone.Model.extend(Styleable).extend({ |
|
|
traitsUpdated() { |
|
|
traitsUpdated() { |
|
|
let found = 0; |
|
|
let found = 0; |
|
|
const attrs = Object.assign({}, this.get('attributes')); |
|
|
const attrs = Object.assign({}, this.get('attributes')); |
|
|
|
|
|
this.loadTraits(this.get('traits'), {silent: 1}); |
|
|
|
|
|
|
|
|
this.get('traits').each((trait) => { |
|
|
this.get('traits').each((trait) => { |
|
|
found = 1; |
|
|
found = 1; |
|
|
@ -201,11 +214,11 @@ module.exports = Backbone.Model.extend(Styleable).extend({ |
|
|
* @param {Array} traits |
|
|
* @param {Array} traits |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
loadTraits(traits) { |
|
|
loadTraits(traits, opts = {}) { |
|
|
var trt = new Traits(); |
|
|
var trt = new Traits(); |
|
|
trt.setTarget(this); |
|
|
trt.setTarget(this); |
|
|
trt.add(traits); |
|
|
trt.add(traits); |
|
|
this.set('traits', trt); |
|
|
this.set('traits', trt, opts); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|