OSDN Git Service

add credit
[pettanr/pettanr.git] / app / assets / javascripts / models / license.js.coffee
1 class Pettanr.License extends Peta.SystemResource\r
2   url: '/licenses/'\r
3   \r
4   @singular: () ->\r
5     'License'\r
6   \r
7   @plural: () ->\r
8     'Licenses'\r
9   \r
10   defaults: {\r
11     id: null\r
12   } \r
13   \r
14   license_group: () ->\r
15     r = new Pettanr.LicenseGroup({id: @get('license_group_id')})\r
16   \r
17   system_picture: () ->\r
18     new Pettanr.SystemPicture({id: @get('system_picture_id')})\r
19   \r
20   symbol_option: (cb) ->\r
21     i = @system_picture()\r
22     i.fetch().done ->\r
23       cb(i.tmb_opt_img_tag())\r
24   \r
25   caption_with_group: () ->\r
26     new Pettanr.License.Caption({license: this, license_group: @license_group()})\r
27   \r
28   initialize: () ->\r
29     if @id\r
30       @url = @url + @id\r
31   \r
32 class Pettanr.License.Collection extends Backbone.Collection\r
33   model: Pettanr.License\r
34   url: '/licenses'\r
35 \r
36 class Pettanr.License.Caption extends Backbone.View\r
37   tagName: 'span'\r
38   initialize: (options) ->\r
39     @license = options.license\r
40     @license_group = options.license_group\r
41     \r
42   render: () ->\r
43     _this = this\r
44     @license_group.fetch().done ->\r
45       _this.$el.html(_this.license_group.get('caption') + '/' + _this.license.get('caption'))\r
46     this\r
47   \r