OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / assets / javascripts / models / picture.js.coffee
1 class Pettanr.Picture extends Peta.Content\r
2   \r
3   @singular: () ->\r
4     'Picture'\r
5   \r
6   @plural: () ->\r
7     'Pictures'\r
8   \r
9   defaults: {\r
10     id: null\r
11   } \r
12   \r
13   @trace_routes: () ->\r
14     {\r
15       resource_picture: ['resource_picture_picture', 'resource_picture']\r
16     }\r
17   \r
18   is_visible: (operators = Pettanr.cache.operators) ->\r
19     return true\r
20   \r
21   filename: () ->\r
22     @get('id') + '.' + @get('ext')\r
23   \r
24   gifname: () ->\r
25     @get('id') + '.gif'\r
26   \r
27   mime_type: () ->\r
28     'image/' + @get('ext')\r
29   \r
30   r_url: (subdir = null) ->\r
31     q = if subdir\r
32       '?subdir=' + subdir\r
33     else\r
34       ''\r
35     '/pictures/' + @filename() + q\r
36   \r
37   alt_name: () ->\r
38     lgn = Pettanr.to_s(@license().license_group().get('caption'))\r
39     ln = Pettanr.to_s(@license().get('caption'))\r
40     lgn + '[' + ln + ']'\r
41   \r
42   symbol_option: (context, options) ->\r
43     @retrieve(this, {\r
44       success: (symbol_item) => \r
45         options.success.call(context, symbol_item.to_symbol())\r
46     })\r
47   \r
48   is_enable: () ->\r
49     if @head().resource_picture()\r
50       true\r
51     else\r
52       false\r
53   \r
54   @head: (opid) ->\r
55     #Picture.find( conditions => ['original_picture_id = ?', opid], :order => 'pictures.revision desc')\r
56   \r
57   head: () ->\r
58     Picture.head(@get('original_picture_id'))\r
59   \r
60   is_head: () ->\r
61     #this == @head()\r
62   \r
63   subdirs: () ->\r
64     if @license_extend().reverse < 0\r
65       ['']\r
66     else\r
67       ['', 'v', 'h', 'vh']\r
68   \r
69   is_showable: (operators = Pettanr.cache.operators) ->\r
70     return false if not @original_picture()\r
71     return true if @is_own(operators)\r
72     #@is_enable() and @is_head()\r
73   \r
74   initialize: (attr = {}, options = {}) ->\r
75     super(attr, options)\r
76   \r