OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / assets / javascripts / models / original_picture.js.coffee
1 class Pettanr.OriginalPicture extends Peta.Content\r
2   @singular: () ->\r
3     'OriginalPicture'\r
4   \r
5   @plural: () ->\r
6     'OriginalPictures'\r
7   \r
8   defaults: {\r
9     id: null,\r
10     artist_id: null\r
11   } \r
12   \r
13   is_visible: (operators) ->\r
14     @is_own(operators)\r
15   \r
16   filename: () ->\r
17     @get('id') + '.' + @get('ext')\r
18   \r
19   mime_type: () ->\r
20     'image/' + @get('ext')\r
21   \r
22   r_url: () ->\r
23     '/original_pictures/' + @filename()\r
24   \r
25   opt_img_tag: () ->\r
26     {src: @r_url(), width: @get('width'), height: @get('height')}\r
27   \r
28   tmb_opt_img_tag: () ->\r
29     wh = Pettanr.Imager.thumbnail_size(@get('width'), @get('height'))\r
30     {src: @r_url(), width: wh[0], height: wh[1]}\r
31   \r
32   symbol_option: () ->\r
33     @tmb_opt_img_tag()\r
34   \r
35   revision: () ->\r
36     head = @history()[0]\r
37     if head\r
38       head.revision()\r
39     else\r
40       'unpublished'\r
41   \r
42   is_unpublished: () ->\r
43     @get('published_at') == null and @get('stopped_at') == null\r
44   \r
45   is_stopped: () ->\r
46     @get('stopped_at') != null\r
47   \r
48   is_unlicensed: () ->\r
49     dt = @get('published_at') || @get('stopped_at')\r
50     return false if not dt\r
51     @get('uploaded_at') > dt\r
52   \r
53   is_published: () ->\r
54     @get('published_at') != null\r
55   \r
56   initialize: () ->\r
57     if @id\r
58       @url = @url + @id\r
59   \r
60 class Pettanr.OriginalPicture.Collection extends Backbone.Collection\r
61   model: Pettanr.OriginalPicture\r
62   url: '/original_pictures'\r