X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fresource_picture.js.coffee;h=86024e361cab4d543c08a557988841e1655ebd45;hb=65bdc3b4bcb14970651ddc9ca55148e3b0cded04;hp=1853af3069ef89e8862e83625a7c490a96e1049f;hpb=01bd644358713f599c11908152f12b911593b190;p=pettanr%2Fpettanr.git diff --git a/app/assets/javascripts/models/resource_picture.js.coffee b/app/assets/javascripts/models/resource_picture.js.coffee index 1853af30..86024e36 100644 --- a/app/assets/javascripts/models/resource_picture.js.coffee +++ b/app/assets/javascripts/models/resource_picture.js.coffee @@ -1,25 +1,65 @@ -class ResourcePicture extends Item - @single: () -> +class Pettanr.ResourcePicture extends Peta.Content + url: '/resource_pictures/' + + @singular: () -> 'ResourcePicture' @plural: () -> 'ResourcePictures' defaults: { - id: 11 + id: null } + picture: () -> + new Pettanr.Picture({id: @get('picture_id')}) + + is_visible: (operators) -> + @is_user_visible(operators) + + filename: () -> + @get('id') + '.' + @get('ext') + + gifname: () -> + @get('id') + '.gif' + + mime_type: () -> + 'image/' + @get('ext') + + r_url: (subdir = null) -> + opt = if Pettanr.to_s(@subdir).empty + '' + else + '?subdir=' + Pettanr.to_s(subdir) + '/resource_pictures/' + @filename() + opt + + tmb_opt_img_tag: () -> + new Pettanr.Image.SymbolPicture({ + attr: { + src: @r_url() + }, + picture: this + }) + + opt_img_tag: () -> + {src: @url('full'), width: @get('width'), height: @get('height')} + + alt_name: () -> + lgn = Pettanr.to_s(@license().license_group().get('caption')) + ln = Pettanr.to_s(@license().get('caption')) + lgn + '[' + ln + ']' + + symbol_option: () -> + @fetch({cache: true}).done => + @trigger('ready:symbol', @tmb_opt_img_tag()) + + credit_icon_view: () -> + new Pettanr.Views.ResourcePicture.CreditIcon({item: this}) + + credit_view: (with_icon = true) -> + new Pettanr.Views.ResourcePicture.Credit({item: this, with_icon: with_icon}) + initialize: () -> - confirm("Welcome to Panel") - - @test: () -> - confirm( @single()) - confirm( @plural() ) - confirm( @class_name() ) - confirm( @element_name() ) - confirm( @table_name() ) - - - test: () -> - -@Panel = Panel + if @id + @url = @url + @id +