Browse Source

Put FramesView creation in CanvasView init

pull/2524/head
Artur Arseniev 7 years ago
parent
commit
fb6d9dbca7
  1. 20
      src/canvas/view/CanvasView.js
  2. 1
      src/canvas/view/FrameWrapView.js
  3. 4
      src/editor/view/EditorView.js

20
src/canvas/view/CanvasView.js

@ -36,7 +36,15 @@ export default Backbone.View.extend({
this.pfx = this.config.stylePrefix || ''; this.pfx = this.config.stylePrefix || '';
this.ppfx = this.config.pStylePrefix || ''; this.ppfx = this.config.pStylePrefix || '';
this.className = this.config.stylePrefix + 'canvas'; this.className = this.config.stylePrefix + 'canvas';
const { em } = this; const { em, config } = this;
this.frames = new FramesView({
collection: model.get('frames'),
config: {
...config,
canvasView: this,
renderContent: 1
}
});
this.listenTo(em, 'change:canvasOffset', this.clearOff); this.listenTo(em, 'change:canvasOffset', this.clearOff);
this.listenTo(em, 'component:selected', this.checkSelected); this.listenTo(em, 'component:selected', this.checkSelected);
this.listenTo(model, 'change:zoom change:x change:y', this.updateFrames); this.listenTo(model, 'change:zoom change:x change:y', this.updateFrames);
@ -492,7 +500,7 @@ export default Backbone.View.extend({
}, },
render() { render() {
const { el, $el, ppfx, model, config, em } = this; const { el, $el, ppfx, model, em, frames } = this;
const cssc = em.get('CssComposer'); const cssc = em.get('CssComposer');
const wrapper = model.get('wrapper'); const wrapper = model.get('wrapper');
$el.html(this.template()); $el.html(this.template());
@ -548,14 +556,6 @@ export default Backbone.View.extend({
// Render all frames // Render all frames
const frms = model.get('frames'); const frms = model.get('frames');
const frames = new FramesView({
collection: frms,
config: {
...config,
renderContent: 1,
canvasView: this
}
});
frms.listenToLoad(); frms.listenToLoad();
frms.on('loaded:all', () => em.trigger('loaded')); frms.on('loaded:all', () => em.trigger('loaded'));
frames.render(); frames.render();

1
src/canvas/view/FrameWrapView.js

@ -87,6 +87,7 @@ export default Backbone.View.extend({
* @private * @private
*/ */
updateDim() { updateDim() {
console.log('updateDim');
const { em, el, $el, model } = this; const { em, el, $el, model } = this;
const { width, height } = model.attributes; const { width, height } = model.attributes;
const { style } = el; const { style } = el;

4
src/editor/view/EditorView.js

@ -9,9 +9,11 @@ export default Backbone.View.extend({
model.view = this; model.view = this;
this.conf = model.config; this.conf = model.config;
this.pn = model.get('Panels'); this.pn = model.get('Panels');
this.cv = model.get('Canvas');
model.on('loaded', () => { model.on('loaded', () => {
this.pn.active(); this.pn.active();
this.pn.disableButtons(); this.pn.disableButtons();
console.log('editorView runDefault');
model.runDefault(); model.runDefault();
setTimeout(() => model.trigger('load', model.get('Editor'))); setTimeout(() => model.trigger('load', model.get('Editor')));
}); });
@ -27,7 +29,7 @@ export default Backbone.View.extend({
if (conf.width) contEl.css('width', conf.width); if (conf.width) contEl.css('width', conf.width);
if (conf.height) contEl.css('height', conf.height); if (conf.height) contEl.css('height', conf.height);
$el.append(model.get('Canvas').render()); $el.append(this.cv.render());
$el.append(this.pn.render()); $el.append(this.pn.render());
$el.attr('class', `${pfx}editor ${pfx}one-bg ${pfx}two-color`); $el.attr('class', `${pfx}editor ${pfx}one-bg ${pfx}two-color`);
contEl contEl

Loading…
Cancel
Save