class Pettanr.ResourcePicture extends Peta.Content url: '/resource_pictures/' @singular: () -> 'ResourcePicture' @plural: () -> 'ResourcePictures' defaults: { id: null } 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: () -> wh = Pettanr.Imager.thumbnail_size(@get('width'), @get('height')) new Pettanr.AppHelperImg({src: @r_url(), size: wh[0], alt: @get('caption')}) 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: (cb) -> _this = this this.fetch().done -> cb(_this.tmb_opt_img_tag()) initialize: () -> if @id @url = @url + @id class Pettanr.ResourcePicture.Collection extends Backbone.Collection model: Pettanr.ResourcePicture url: '/resource_pictures/'