X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fpanel_picture.js.coffee;h=962f2f58980e38d3842507d3b0f20f1451f872ef;hp=1a86e4a018eaa7a2ab0a2d07affc86a2bebeadb2;hb=d7c8065be895b67dc453b0e11ad0f259f1ca6706;hpb=eec19634998fd448e4bb1be831260537199d8271 diff --git a/app/assets/javascripts/models/panel_picture.js.coffee b/app/assets/javascripts/models/panel_picture.js.coffee index 1a86e4a0..962f2f58 100644 --- a/app/assets/javascripts/models/panel_picture.js.coffee +++ b/app/assets/javascripts/models/panel_picture.js.coffee @@ -1,5 +1,4 @@ class Pettanr.PanelPicture extends Peta.Element - url: '/panel_pictures/' @singular: () -> 'PanelPicture' @@ -11,11 +10,24 @@ class Pettanr.PanelPicture extends Peta.Element id: null } - picture: () -> - new Pettanr.Picture({id: @get('picture_id')}) + @pick_item_name: () -> + 'resource_picture' - panel: () -> - new Pettanr.Panel({id: @get('panel_id')}) + @traceable_item_names: () -> + ['ground_picture', 'picture'] + + pick: (picked_item) -> + { + picture_id: picked_item.get('picture_id'), + width: picked_item.get('width'), + height: picked_item.get('height') + } + + @trace_routes: () -> + { + resource_picture: ['picture', 'resource_picture_picture', 'resource_picture'] + symbol: 'picture' + } @has_picture: () -> true @@ -35,31 +47,18 @@ class Pettanr.PanelPicture extends Peta.Element res filename: (picture) -> - picture.filename() + '?subdir=' + @flip() + q = if _.isEmpty(@flip()) + '' + else + '?subdir=' + @flip() + picture.filename() + q r_url: (picture) -> '/pictures/' + @filename(picture) - tmb_opt_img_tag: (picture) -> - new Pettanr.Image.SymbolPicture({ - attr: { - src: picture.r_url(), - alt: @get('caption') - }, - picture: picture - }) - - symbol_option: (cb) -> - i = @picture() - _this = this - i.fetch().done -> - cb(_this.tmb_opt_img_tag(i)) - - initialize: () -> - if @id - @url = @url + @id + element_face: () -> + new Pettanr.Views.PanelPicture.ElementFace({element: this}) -class Pettanr.PanelPictures extends Backbone.Collection - model: Pettanr.PanelPicture - url: '/panel_pictures/' + initialize: (attr, options) -> + super(attr, options)