OSDN Git Service

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