class Pettanr.Views.PanelPicture.Element extends Backbone.View tagName: 'div' className: 'pettanr-panel-picture-wrapper' initialize: (options) -> @element = options.element @root = options.root @spot = options.spot render: () -> @attr = {style: Pettanr.to_style(@opt_div_style())} this.$el.attr(@attr) @picture = @element.picture() _this = this @picture.fetch().done -> _this.img = new Tag.Img({ attr: _this.opt_img_tag(_this.spot) }) _this.$el.html(_this.img.render().el) this opt_div_style: () -> { 'top': Pettanr.to_s(@element.get('y')) + 'px', 'left': Pettanr.to_s(@element.get('x')) + 'px', 'z-index': @element.get('z'), 'position': 'absolute' } opt_img_tag: (spot = null, opacity = 20) -> style = {} if spot and spot != @element @merge_opacity(style, opacity) { vPicture: @element.get('id'), src: @element.r_url(@picture), width: Pettanr.to_s(Math.abs(@element.get('width'))) + 'px', height: Pettanr.to_s(Math.abs(@element.get('height'))) + 'px', alt: @element.get('caption'), style: Pettanr.to_style(style) }