mirror of https://github.com/artf/grapesjs.git
10 changed files with 139 additions and 59 deletions
@ -1,12 +1,18 @@ |
|||||
define(['backbone'], |
define(['backbone', './Frame'], |
||||
function(Backbone){ |
function(Backbone, Frame){ |
||||
|
|
||||
return Backbone.Model.extend({ |
return Backbone.Model.extend({ |
||||
|
|
||||
defaults :{ |
defaults :{ |
||||
|
frame: '', |
||||
wrapper: '', |
wrapper: '', |
||||
rulers: false, |
rulers: false, |
||||
}, |
}, |
||||
|
|
||||
|
initialize: function(config) { |
||||
|
var conf = this.conf || {}; |
||||
|
this.set('frame', new Frame(conf.frame)); |
||||
|
}, |
||||
|
|
||||
}); |
}); |
||||
}); |
}); |
||||
|
|||||
@ -0,0 +1,14 @@ |
|||||
|
define(['backbone'], |
||||
|
function(Backbone){ |
||||
|
|
||||
|
return Backbone.Model.extend({ |
||||
|
|
||||
|
defaults :{ |
||||
|
wrapper: '', |
||||
|
width: '', |
||||
|
height: '', |
||||
|
attributes: {}, |
||||
|
}, |
||||
|
|
||||
|
}); |
||||
|
}); |
||||
@ -1,25 +1,32 @@ |
|||||
define(['backbone'], |
define(['backbone','./FrameView'], |
||||
function(Backbone) { |
function(Backbone, FrameView) { |
||||
/** |
/** |
||||
* @class CanvasView |
* @class CanvasView |
||||
* */ |
* */ |
||||
return Backbone.View.extend({ |
return Backbone.View.extend({ |
||||
|
|
||||
//id: 'canvas',
|
|
||||
|
|
||||
initialize: function(o) { |
initialize: function(o) { |
||||
this.config = o.config; |
this.config = o.config; |
||||
this.className = this.config.stylePrefix + 'canvas'; |
this.className = this.config.stylePrefix + 'canvas'; |
||||
|
this.frame = new FrameView({ |
||||
|
model: this.model.get('frame') |
||||
|
}); |
||||
}, |
}, |
||||
|
|
||||
render: function() { |
render: function() { |
||||
this.wrapper = this.model.get('wrapper'); |
this.wrapper = this.model.get('wrapper'); |
||||
|
|
||||
if(this.wrapper && typeof this.wrapper.render == 'function'){ |
if(this.wrapper && typeof this.wrapper.render == 'function'){ |
||||
this.$el.append( this.wrapper.render() ); |
this.model.get('frame').set('wrapper', this.wrapper); |
||||
|
var wrap = this.wrapper.render(); |
||||
|
this.$el.append(this.frame.render().el); |
||||
|
var frame = this.frame; |
||||
|
frame.el.onload = function(){ frame.renderWrapper(); }; |
||||
} |
} |
||||
|
|
||||
this.$el.attr({class: this.className, id: this.config.canvasId}); |
this.$el.attr({class: this.className, id: this.config.canvasId}); |
||||
return this; |
return this; |
||||
}, |
}, |
||||
|
|
||||
}); |
}); |
||||
}); |
}); |
||||
@ -0,0 +1,40 @@ |
|||||
|
define(['backbone'], |
||||
|
function(Backbone) { |
||||
|
/** |
||||
|
* @class CanvasView |
||||
|
* */ |
||||
|
return Backbone.View.extend({ |
||||
|
|
||||
|
tagName: 'iframe', |
||||
|
|
||||
|
attributes: { |
||||
|
src: 'about:blank' |
||||
|
}, |
||||
|
|
||||
|
getBody: function(){ |
||||
|
this.$el.contents().find('body'); |
||||
|
}, |
||||
|
|
||||
|
getWrapper: function(){ |
||||
|
return this.$el.contents().find('body div'); |
||||
|
}, |
||||
|
|
||||
|
renderWrapper: function(){ |
||||
|
var wrap = this.model.get('wrapper'); |
||||
|
|
||||
|
if(wrap){ |
||||
|
var body = this.$el.contents().find('body'); |
||||
|
body.append(wrap.render()); |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
render: function() { |
||||
|
this.$el.attr({ |
||||
|
class: 'testframe', |
||||
|
style: 'width: 50%; display: block; height: 80%; border: medium none; margin: 50px auto 0; background-color: white', |
||||
|
}); |
||||
|
return this; |
||||
|
}, |
||||
|
|
||||
|
}); |
||||
|
}); |
||||
Loading…
Reference in new issue