OSDN Git Service

fix: js models
[pettanr/pettanr.git] / app / assets / javascripts / models / speech.js.coffee
1 class Pettanr.Speech extends Peta.Element\r
2   @singular: () ->\r
3     'Speech'\r
4   \r
5   @plural: () ->\r
6     'Speeches'\r
7   \r
8   defaults: {\r
9     id: null,\r
10     x: 0,\r
11     y: 0,\r
12     width: 100,\r
13     height: 100\r
14   } \r
15   \r
16   @text_align_texts: () -> \r
17     ['left', 'left', 'right', 'center']\r
18   \r
19   symbol_option: () ->\r
20     @speech_balloon().speech_balloon_template().symbol_option()\r
21   \r
22   outer_style: () ->\r
23     {\r
24       top: @get('y'), left: @get('x'), \r
25       width: @get('width'), height: @get('height')\r
26     }\r
27   \r
28   inner_style: () ->\r
29     {\r
30       'font-size': Pettanr.to_s(@get('font_size')) + 'em',\r
31       'text-align': @text_align_text(), \r
32       color: '#' + ('000000' + Pettanr.to_s(@get('fore_color'))).slice(-6)\r
33     }\r
34   \r
35   text_align_text: () ->\r
36     Pettanr.Speech.text_align_texts()[@get('text_align')]\r
37   \r
38   initialize: () ->\r
39     if @id\r
40       @url = @url + @id\r
41   \r
42 class Pettanr.Speech.Collection extends Backbone.Collection\r
43   model: Pettanr.Speech\r
44   url: '/Speeches'\r