Browse Source

Clean canvas view render

pull/3411/head
Artur Arseniev 6 years ago
parent
commit
feed1a5103
  1. 18
      src/canvas/model/Frame.js
  2. 11
      src/canvas/view/CanvasView.js

18
src/canvas/model/Frame.js

@ -4,29 +4,25 @@ import CssRules from 'css_composer/model/CssRules';
import { isString } from 'underscore'; import { isString } from 'underscore';
export default Backbone.Model.extend({ export default Backbone.Model.extend({
defaults: { defaults: () => ({
width: null, width: null,
height: null, height: null,
head: '', head: [],
x: 0, x: 0,
y: 0, y: 0,
root: 0, root: 0,
components: 0, components: 0,
styles: 0, styles: 0,
attributes: {} attributes: {}
}, }),
initialize(props, opts = {}) { initialize(props, opts = {}) {
const { config } = opts; const { config } = opts;
const { em } = config; const { em } = config;
const { root, styles, components } = this.attributes; const { root, styles, components } = this.attributes;
this.set('head', []); const conf = em.get('DomComponents').getConfig();
this.em = em; this.em = em;
const modOpts = { const modOpts = { em, config: conf, frame: this };
em,
config: em.get('DomComponents').getConfig(),
frame: this
};
!root && !root &&
this.set( this.set(
@ -44,6 +40,10 @@ export default Backbone.Model.extend({
this.set('styles', new CssRules(styles, modOpts)); this.set('styles', new CssRules(styles, modOpts));
}, },
getComponent() {},
getStyle() {},
remove() { remove() {
this.view = 0; this.view = 0;
const coll = this.collection; const coll = this.collection;

11
src/canvas/view/CanvasView.js

@ -330,20 +330,9 @@ export default Backbone.View.extend({
render() { render() {
const { el, $el, ppfx, model, em, frames } = this; const { el, $el, ppfx, model, em, frames } = this;
const cssc = em.get('CssComposer');
const wrapper = model.get('wrapper');
$el.html(this.template()); $el.html(this.template());
const $frames = $el.find('[data-frames]'); const $frames = $el.find('[data-frames]');
this.framesArea = $frames.get(0); this.framesArea = $frames.get(0);
this.wrapper = wrapper;
if (wrapper && typeof wrapper.render == 'function') {
model.get('frame').set({
wrapper,
root: wrapper.getWrapper(),
styles: cssc.getAll()
});
}
const toolsWrp = $el.find('[data-tools]'); const toolsWrp = $el.find('[data-tools]');
this.toolsWrapper = toolsWrp.get(0); this.toolsWrapper = toolsWrp.get(0);

Loading…
Cancel
Save