OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / assets / javascripts / models / panel.js.coffee
1 class Pettanr.Panel extends Peta.Root\r
2   url: '/panels/'\r
3   \r
4   @singular: () ->\r
5     'Panel'\r
6   \r
7   @plural: () ->\r
8     'Panels'\r
9   \r
10   defaults: {\r
11     id: null,\r
12     border: 2,\r
13     publish: 0\r
14   } \r
15   \r
16   pp: () ->\r
17     new Pettanr.PanelPicture({id: @get('pp_id')})\r
18   \r
19   is_visible: (operators) ->\r
20     switch super(operators)\r
21       when null # super return\r
22         return true\r
23       when false\r
24         return false\r
25       else\r
26         return true if @isNew()\r
27         @is_publish()\r
28   \r
29   is_usable: (operators) ->\r
30     @is_visible(operators)\r
31   \r
32   is_publish: () ->\r
33     @get('publish') > 0\r
34   \r
35   initialize: (attr = {}, options = {}) ->\r
36     @set(attr)\r
37     if @get('id')\r
38       @url = @url + @get('id')\r
39     if options.with_elements\r
40       @url = @url + '?with_elements=true'\r
41   \r
42 class Pettanr.Panels extends Backbone.Collection\r
43   model: Pettanr.Panel\r
44   url: '/panels/'\r