X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fground_picture.js.coffee;h=07dd815ed5c462f7fc6d8baefd0ed0440046e463;hp=2f112d43e5a3c57569d5e7092bc4e19b69f6d9d5;hb=d7c8065be895b67dc453b0e11ad0f259f1ca6706;hpb=9529441f04dd2c502077a051b866eac838e5849e diff --git a/app/assets/javascripts/models/ground_picture.js.coffee b/app/assets/javascripts/models/ground_picture.js.coffee index 2f112d43..07dd815e 100644 --- a/app/assets/javascripts/models/ground_picture.js.coffee +++ b/app/assets/javascripts/models/ground_picture.js.coffee @@ -1,5 +1,4 @@ class Pettanr.GroundPicture extends Peta.Element - url: '/ground_pictures/' @singular: () -> 'GroundPicture' @@ -17,42 +16,30 @@ class Pettanr.GroundPicture extends Peta.Element @repeat_texts: () -> ['repeat', 'repeat-x', 'repeat-y', 'no-repeat'] - picture: () -> - new Pettanr.Picture({id: @get('picture_id')}) + @pick_item_name: () -> + 'resource_picture' - has_picture: () -> - true + @traceable_item_names: () -> + ['panel_picture', 'picture'] - 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 + pick: (picked_item) -> + {picture_id: picked_item.get('picture_id')} - 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')}) + @trace_routes: () -> + { + resource_picture: ['picture', 'resource_picture_picture', 'resource_picture'], + symbol: 'picture' + } - symbol_option: (cb) -> - i = @picture() - _this = this - i.fetch().done -> - cb(_this.tmb_opt_img_tag(i)) + @has_picture: () -> + true repeat_text: () -> Pettanr.GroundPicture.repeat_texts()[@get('repeat')] - initialize: () -> - if @id - @url = @url + @id + element_face: () -> + new Pettanr.Views.GroundPicture.ElementFace({element: this}) + + initialize: (attr, options) -> + super(attr, options) -class Pettanr.GroundPicture.Collection extends Backbone.Collection - model: Pettanr.GroundPicture - url: '/ground_pictures'