X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fpanel_picture.js.coffee;h=40e47ace37992675bb55dfea1e24da1a908c9e6a;hb=083cd052b6a10be6ddb3534307176f8c415952a8;hp=3c3003d796f041fd430c1442297574f09559b05d;hpb=f52d305f8c8857da0a38049e85ebd37e3525c8c8;p=pettanr%2Fpettanr.git diff --git a/app/assets/javascripts/models/panel_picture.js.coffee b/app/assets/javascripts/models/panel_picture.js.coffee index 3c3003d7..40e47ace 100644 --- a/app/assets/javascripts/models/panel_picture.js.coffee +++ b/app/assets/javascripts/models/panel_picture.js.coffee @@ -11,11 +11,28 @@ class Pettanr.PanelPicture extends Peta.Element id: null } + @pick_item_name: () -> + 'resource_picture' + + @traceable_item_names: () -> + ['ground_picture', 'picture'] + + trace_from_ground_picture: () -> + + trace_from_picture: () -> + + pick: (picked_item) -> + { + picture_id: picked_item.get('picture_id'), + width: picked_item.get('width'), + height: picked_item.get('height') + } + picture: () -> - new Pettanr.Picture({id: @get('picture_id')}) + new Pettanr.Cache.Retriever(Pettanr.Picture, @get('picture_id')) - panel: (options = {}) -> - new Pettanr.Panel({id: @get('panel_id')}, options) + panel: () -> + new Pettanr.Cache.Retriever(Pettanr.Panel, @get('panel_id')) @has_picture: () -> true @@ -35,7 +52,11 @@ 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) @@ -44,21 +65,27 @@ class Pettanr.PanelPicture extends Peta.Element new Pettanr.Image.SymbolPicture({ attr: { src: picture.r_url(), - alt: @get('caption') + alt: @escape('caption') }, picture: picture }) - symbol_option: (cb) -> - i = @picture() - _this = this - i.fetch({cache: true}).done -> - cb(_this.tmb_opt_img_tag(i)) + symbol_option: () -> + retriever = @picture() + @listenTo(retriever, 'retrieve', @retrieve_symbol) + retriever.retrieve() + + retrieve_symbol: (item) -> + @trigger('ready:symbol', item.tmb_opt_img_tag()) element_face: () -> new Pettanr.Views.PanelPicture.ElementFace({element: this}) - initialize: () -> + initialize: (attr, options) -> + super(attr, options) if @id @url = @url + @id + @bind('change:width', () -> + console.log('cng') + )