X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fresource_picture.js.coffee;h=141b66c29572164a28808867dea1c4cdffb2b49c;hb=091b085aa054691dfe37d6f55f699dcb80f63ee5;hp=1853af3069ef89e8862e83625a7c490a96e1049f;hpb=10d7d403b74c06dcbf42a132b9712c3817547284;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..141b66c2 100644 --- a/app/assets/javascripts/models/resource_picture.js.coffee +++ b/app/assets/javascripts/models/resource_picture.js.coffee @@ -1,25 +1,66 @@ -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 => + @symbol_picture = @tmb_opt_img_tag() + @trigger('ready:symbol') + + 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 +