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=86d964215d67c889c2c5ac7527fc2f7f64404da3;hb=d7c8065be895b67dc453b0e11ad0f259f1ca6706;hpb=70027b80e56b5fbea8d63d520fbbf92050959f28 diff --git a/app/assets/javascripts/models/panel_picture.js.coffee b/app/assets/javascripts/models/panel_picture.js.coffee index 86d96421..962f2f58 100644 --- a/app/assets/javascripts/models/panel_picture.js.coffee +++ b/app/assets/javascripts/models/panel_picture.js.coffee @@ -1,18 +1,64 @@ class Pettanr.PanelPicture extends Peta.Element - @single: () -> + + @singular: () -> 'PanelPicture' @plural: () -> 'PanelPictures' - @colum_structures: -> - {} - defaults: { - x: 11 + id: null } - initialize: () -> - confirm("Welcome to this world") + @pick_item_name: () -> + 'resource_picture' + + @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 + + flip: () -> + v = if @get('height') > 0 + '' + else + 'v' + h = if @get('width') > 0 + '' + else + 'h' + res = v + h + res = res # format of /1.png?subdir=v + # res += '/' unless res.empty? # format of /v/1.png + res + + filename: (picture) -> + q = if _.isEmpty(@flip()) + '' + else + '?subdir=' + @flip() + picture.filename() + q + + r_url: (picture) -> + '/pictures/' + @filename(picture) + + element_face: () -> + new Pettanr.Views.PanelPicture.ElementFace({element: this}) + + initialize: (attr, options) -> + super(attr, options) -