Browse Source

Render frames

pull/2524/head
Artur Arseniev 7 years ago
parent
commit
bda991daff
  1. 12
      src/canvas/view/CanvasView.js
  2. 4
      src/canvas/view/FrameView.js
  3. 9
      src/canvas/view/FramesView.js
  4. 12
      src/domain_abstract/view/DomainViews.js

12
src/canvas/view/CanvasView.js

@ -9,6 +9,7 @@ import {
getElRect getElRect
} from 'utils/mixins'; } from 'utils/mixins';
import FrameView from './FrameView'; import FrameView from './FrameView';
import FramesView from './FramesView';
const $ = Backbone.$; const $ = Backbone.$;
let timerZoom; let timerZoom;
@ -474,7 +475,7 @@ export default Backbone.View.extend({
}, },
render() { render() {
const { el, $el, ppfx, model } = this; const { el, $el, ppfx, model, config } = this;
this.wrapper = model.get('wrapper'); this.wrapper = model.get('wrapper');
$el.html(this.template()); $el.html(this.template());
const $frames = $el.find('[data-frames]'); const $frames = $el.find('[data-frames]');
@ -490,6 +491,15 @@ export default Backbone.View.extend({
this.renderScripts(); // will call renderBody later this.renderScripts(); // will call renderBody later
} }
} }
// Render all frames
const frames = new FramesView({
collection: model.get('frames'),
config
});
frames.render();
$frames.append(frames.el);
$el.find('[data-tools]').append(` $el.find('[data-tools]').append(`
<div id="${ppfx}tools" style="pointer-events:none"> <div id="${ppfx}tools" style="pointer-events:none">
<div class="${ppfx}highlighter"></div> <div class="${ppfx}highlighter"></div>

4
src/canvas/view/FrameView.js

@ -24,13 +24,13 @@ export default Backbone.View.extend({
this.updatePos(); this.updatePos();
}, },
updatePos() { updatePos(md) {
const { model, el } = this; const { model, el } = this;
const { x, y } = model.attributes; const { x, y } = model.attributes;
const { style } = el; const { style } = el;
style.left = isNaN(x) ? x : `${x}px`; style.left = isNaN(x) ? x : `${x}px`;
style.top = isNaN(y) ? y : `${y}px`; style.top = isNaN(y) ? y : `${y}px`;
this.updateOffset(); md && this.updateOffset();
}, },
/** /**

9
src/canvas/view/FramesView.js

@ -4,8 +4,13 @@ import FrameView from './FrameView';
export default DomainViews.extend({ export default DomainViews.extend({
itemView: FrameView, itemView: FrameView,
initialize(opts) { init() {
this.config = { editor: opts.editor || '' };
this.listenTo(this.collection, 'reset', this.render); this.listenTo(this.collection, 'reset', this.render);
},
onRender() {
const { config, $el } = this;
const { em } = config;
em && $el.attr({ class: `${em.getConfig('stylePrefix')}frames` });
} }
}); });

12
src/domain_abstract/view/DomainViews.js

@ -9,10 +9,13 @@ export default Backbone.View.extend({
itemType: 'type', itemType: 'type',
initialize(opts, config) { initialize(opts = {}, config) {
this.config = config || {}; this.config = config || opts.config || {};
this.init();
}, },
init() {},
/** /**
* Add new model to the collection * Add new model to the collection
* @param {Model} model * @param {Model} model
@ -70,6 +73,9 @@ export default Backbone.View.extend({
}, this); }, this);
this.$el.append(frag); this.$el.append(frag);
this.onRender();
return this; return this;
} },
onRender() {}
}); });

Loading…
Cancel
Save