class Pettanr.Picture extends Peta.Content url: '/pictures/' @singular: () -> 'Picture' @plural: () -> 'Pictures' defaults: { id: null } is_visible: (operators) -> return true filename: () -> @get('id') + '.' + @get('ext') gifname: () -> @get('id') + '.gif' mime_type: () -> 'image/' + @get('ext') r_url: () -> '/pictures/' + @filename() opt_img_tag: () -> {src: @r_url(), width: @get('width'), height: @get('height')} tmb_opt_img_tag: () -> new Pettanr.Image.SymbolPicture({ attr: { src: @r_url() }, picture: this }) tail_opt_img_tag: (img) -> {src: img, width: @get('width'), height: @get('height')} tail_tmb_opt_img_tag: (img) -> wh = Pettanr.Imager.thumbnail_size(@get('width'), @get('height')) {src: img, width: wh[0], height: wh[1]} alt_name: () -> lgn = Pettanr.to_s(@license().license_group().get('caption')) ln = Pettanr.to_s(@license().get('caption')) lgn + '[' + ln + ']' symbol_option: () -> @tmb_opt_img_tag() is_enable: () -> if @head().resource_picture() true else false @head: (opid) -> #Picture.find( conditions => ['original_picture_id = ?', opid], :order => 'pictures.revision desc') head: () -> Picture.head(@get('original_picture_id')) is_head: () -> #this == @head() subdirs: () -> if @license_extend().reverse < 0 [''] else ['', 'v', 'h', 'vh'] is_showable: (operators = null) -> return false if not @original_picture() return true if @is_own(operators) #@is_enable() and @is_head() credit_icon_view: () -> new Pettanr.Views.Picture.CreditIcon({item: this}) credit_view: (with_icon = true) -> new Pettanr.Views.Picture.Credit({item: this, with_icon: with_icon}) fetch: (options) -> if @id @credit_icon = @credit_icon_view() @credit = null f = (data, status) => @credit = data @trigger('ready') $.get(@url + '/credit', null, f, 'html') super(options) initialize: () -> if @id @url = @url + @id