class Pettanr.GroundPicture extends Peta.Element url: '/ground_pictures/' @singular: () -> 'GroundPicture' @plural: () -> 'GroundPictures' defaults: { id: null, x: 0, y: 0, repeat: 0 } @repeat_texts: () -> ['repeat', 'repeat-x', 'repeat-y', 'no-repeat'] picture: () -> new Pettanr.Picture({id: @get('picture_id')}) has_picture: () -> true style: (spot = null, opacity = 20) -> r = { position: 'absolute', top: '0px', left: '0px', 'z-index': @get('z'), 'background-image': 'url(' + @picture().r_url() + ')', 'background-repeat': @repeat_text(), 'background-position': Pettanr.to_s(@get('x')) + 'px ' + Pettanr.to_s(@get('y')) + 'px' } @merge_opacity(r, opacity) if spot and spot != this r tmb_opt_img_tag: (picture) -> wh = Pettanr.Imager.thumbnail_size(picture.get('width'), picture.get('height')) new Pettanr.AppHelperImg({src: picture.r_url(), size: Math.abs(wh[0]), alt: @get('caption')}) symbol_option: (cb) -> i = @picture() _this = this i.fetch().done -> cb(_this.tmb_opt_img_tag(i)) repeat_text: () -> Pettanr.GroundPicture.repeat_texts()[@get('repeat')] initialize: () -> if @id @url = @url + @id class Pettanr.GroundPicture.Collection extends Backbone.Collection model: Pettanr.GroundPicture url: '/ground_pictures'