X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fground_picture.js.coffee;h=a699cce2091c137c6b1212a1c604de50653e1ff1;hb=dc5fe0b8ebfbde443317df9e2c18aa0deacd471d;hp=6817bb328af2be9a882dee7eb80721f57119fa3e;hpb=13dc1176bce676f02e571a0f3c38a272de6940a7;p=pettanr%2Fpettanr.git diff --git a/app/assets/javascripts/models/ground_picture.js.coffee b/app/assets/javascripts/models/ground_picture.js.coffee index 6817bb32..a699cce2 100644 --- a/app/assets/javascripts/models/ground_picture.js.coffee +++ b/app/assets/javascripts/models/ground_picture.js.coffee @@ -17,47 +17,36 @@ class Pettanr.GroundPicture extends Peta.Element @repeat_texts: () -> ['repeat', 'repeat-x', 'repeat-y', 'no-repeat'] + panel: (options = {}) -> + new Pettanr.Panel({id: @get('panel_id')}, options) + picture: () -> new Pettanr.Picture({id: @get('picture_id')}) - has_picture: () -> + @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) -> - new Pettanr.Picture.SymbolPicture({ + new Pettanr.Image.SymbolPicture({ attr: { src: picture.r_url(), - alt: @get('caption') + alt: @escape('caption') }, picture: picture }) - symbol_option: (cb) -> + symbol_option: () -> i = @picture() - _this = this - i.fetch().done -> - cb(_this.tmb_opt_img_tag(i)) + i.fetch({cache: true}).done => + @trigger('ready:symbol', i.tmb_opt_img_tag()) repeat_text: () -> Pettanr.GroundPicture.repeat_texts()[@get('repeat')] + element_face: () -> + new Pettanr.Views.GroundPicture.ElementFace({element: this}) + initialize: () -> if @id @url = @url + @id -class Pettanr.GroundPicture.Collection extends Backbone.Collection - model: Pettanr.GroundPicture - url: '/ground_pictures'