Browse Source

Update traits loading

pull/261/head
Artur Arseniev 9 years ago
parent
commit
1651afb7d3
  1. 6
      dist/grapes.min.js
  2. 2
      package.json
  3. 1
      src/dom_components/config/config.js
  4. 3
      src/dom_components/index.js
  5. 19
      src/dom_components/model/Component.js

6
dist/grapes.min.js

File diff suppressed because one or more lines are too long

2
package.json

@ -1,7 +1,7 @@
{ {
"name": "grapesjs", "name": "grapesjs",
"description": "Free and Open Source Web Builder Framework", "description": "Free and Open Source Web Builder Framework",
"version": "0.9.21", "version": "0.9.22",
"author": "Artur Arseniev", "author": "Artur Arseniev",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"homepage": "http://grapesjs.com", "homepage": "http://grapesjs.com",

1
src/dom_components/config/config.js

@ -14,6 +14,7 @@ module.exports = {
copyable: false, copyable: false,
draggable: false, draggable: false,
components: [], components: [],
traits: [],
stylable: ['background','background-color','background-image', stylable: ['background','background-color','background-image',
'background-repeat','background-attachment','background-position'], 'background-repeat','background-attachment','background-position'],
}, },

3
src/dom_components/index.js

@ -234,7 +234,8 @@ module.exports = () => {
// If the result is an object I consider it the wrapper // If the result is an object I consider it the wrapper
if (isObj) { if (isObj) {
this.getWrapper().set(result).initComponents().initClasses(); this.getWrapper().set(result)
.initComponents().initClasses().loadTraits();
} else { } else {
this.getComponents().add(result); this.getComponents().add(result);
} }

19
src/dom_components/model/Component.js

@ -114,7 +114,7 @@ module.exports = Backbone.Model.extend(Styleable).extend({
this.listenTo(this, 'change:traits', this.traitsUpdated); this.listenTo(this, 'change:traits', this.traitsUpdated);
//this.defaultCl = this.normalizeClasses(this.get('classes') || this.config.classes || []); //this.defaultCl = this.normalizeClasses(this.get('classes') || this.config.classes || []);
//this.set('classes', new Selectors(this.defaultCl)); //this.set('classes', new Selectors(this.defaultCl));
this.loadTraits(this.get('traits')); this.loadTraits();
this.initClasses(); this.initClasses();
this.initComponents(); this.initComponents();
this.initToolbar(); this.initToolbar();
@ -165,9 +165,14 @@ 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}); const traits = this.get('traits');
this.get('traits').each((trait) => { if (!(traits instanceof Traits)) {
this.loadTraits();
return;
}
traits.each((trait) => {
found = 1; found = 1;
if (!trait.get('changeProp')) { if (!trait.get('changeProp')) {
const value = trait.getInitValue(); const value = trait.getInitValue();
@ -217,8 +222,14 @@ module.exports = Backbone.Model.extend(Styleable).extend({
loadTraits(traits, opts = {}) { loadTraits(traits, opts = {}) {
var trt = new Traits(); var trt = new Traits();
trt.setTarget(this); trt.setTarget(this);
trt.add(traits); traits = traits || this.get('traits');
if (traits.length) {
trt.add(traits);
}
this.set('traits', trt, opts); this.set('traits', trt, opts);
return this;
}, },
/** /**

Loading…
Cancel
Save