X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fpanel_picture.js.coffee;h=52b1fd030dc624f2d13d4e2c5373940db95280cc;hb=7cc9010daab46f2f6ae0b0314904ad9704022e7f;hp=23f9d4589ea42e2b7059d94e7707e460dce5ef39;hpb=6cbe57ca7a9cac83fad2f3c66fa097055c1fe803;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 23f9d458..52b1fd03 100644 --- a/app/assets/javascripts/models/panel_picture.js.coffee +++ b/app/assets/javascripts/models/panel_picture.js.coffee @@ -11,9 +11,35 @@ class Pettanr.PanelPicture extends Peta.Element id: null } + @pick_item_name: () -> + 'resource_picture' + + @pick_model: () -> + Manifest.item_name_to_model(@pick_item_name()) + + @traceable_item_names: () -> + ['ground_picture', 'picture'] + + @is_traceable: (item_name) -> + _.contains(@traceable_item_names(), item_name) + + 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')}) + panel: (options = {}) -> + new Pettanr.Panel({id: @get('panel_id')}, options) + @has_picture: () -> true @@ -31,51 +57,38 @@ class Pettanr.PanelPicture extends Peta.Element # res += '/' unless res.empty? # format of /v/1.png res - filename: () -> - @picture().filename() + '?subdir=' + @flip() - - r_url: () -> - '/pictures/' + @filename() - - opt_div_style: () -> - "top:#{@get('y')}px; left:#{@get('x')}px; z-index:#{@get('z')}; position: absolute;" - - opt_img_tag: (spot = null, opacity = 20) -> - o = if spot and spot != this - "opacity: #{opacity.to_f/100}; filter:alpha(opacity=#{opacity});" - else + filename: (picture) -> + q = if _.isEmpty(@flip()) '' - @tag_attributes('img', { - class: "panel-picture", - vPicture: @get('id'), - src: @r_url(), - width: Math.abs(@get('width')), - height: Math.abs(@get('height')), - picture_id: @get('picture_id'), - ext: @picture.ext, - alt: @get('caption'), - style: "#{o}" - }) + 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') + 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()) + + 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') + ) -class Pettanr.PanelPicture.Collection extends Backbone.Collection - model: Pettanr.PanelPicture - url: '/panel_pictures'