class Pettanr.ResourcePicture extends Peta.Content url: '/resource_pictures/' @singular: () -> 'ResourcePicture' @plural: () -> 'ResourcePictures' defaults: { 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: () -> if @id @url = @url + @id