OSDN Git Service

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