Browse Source

Update ComponentTextView

pull/415/head
Artur Arseniev 9 years ago
parent
commit
f065479ee1
  1. 4
      dist/grapes.min.js
  2. 13
      src/dom_components/view/ComponentTextView.js
  3. 6
      src/dom_components/view/ComponentView.js

4
dist/grapes.min.js

File diff suppressed because one or more lines are too long

13
src/dom_components/view/ComponentTextView.js

@ -60,13 +60,15 @@ module.exports = ComponentView.extend({
const content = this.getChildrenContainer().innerHTML;
const comps = model.get('components');
comps.length && comps.reset();
// If there is a custom RTE the content is just baked staticly
// inside 'content'
if (rte.customRte) {
// Avoid double content by removing its children components
comps.reset();
model.set('content', content);
// and force to trigger change
model.set('content', '')
.set('content', content);
} else {
const clean = model => {
model.set({
@ -76,19 +78,14 @@ module.exports = ComponentView.extend({
draggable: 0,
copyable: 0,
toolbar: '',
});
})
model.get('components').each(model => clean(model));
}
// Avoid re-render on reset with silent option
model.set('content', '');
comps.reset();
comps.add(content);
comps.each(model => clean(model));
// With rerender it's possible to see changes applied
// after clean method
this.render();
comps.trigger('resetNavigator');
}
}

6
src/dom_components/view/ComponentView.js

@ -23,7 +23,7 @@ module.exports = Backbone.View.extend({
const classes = model.get('classes');
this.listenTo(model, 'destroy remove', this.remove);
this.listenTo(model, 'change:style', this.updateStyle);
this.listenTo(model, 'change:attributes', this.updateAttributes);
this.listenTo(model, 'change:attributes change:highlightable', this.updateAttributes);
this.listenTo(model, 'change:status', this.updateStatus);
this.listenTo(model, 'change:state', this.updateState);
this.listenTo(model, 'change:script', this.render);
@ -153,7 +153,7 @@ module.exports = Backbone.View.extend({
updateAttributes() {
var model = this.model;
var attributes = {},
attr = model.get("attributes");
attr = model.get('attributes');
for(var key in attr) {
if (key && attr.hasOwnProperty(key)) {
attributes[key] = attr[key];
@ -171,7 +171,7 @@ module.exports = Backbone.View.extend({
if(styleStr)
attributes.style = styleStr;
console.log(attributes);
this.$el.attr(attributes);
},

Loading…
Cancel
Save