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