OSDN Git Service

366cd0940099945e1c8e638d52f53d30ae8c54d7
[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   pick: () ->\r
19     # \r
20     speech_balloon_template = @templates.speech_balloon_template\r
21     writing_format = @templates.writing_format\r
22     {\r
23       speech_balloon_template_id: speech_balloon_template.get('id'),\r
24       speech_balloon_template_module_name: speech_balloon_template.get('module_name'),\r
25       writing_format_id: writing_format.get('id'),\r
26       writing_format_module_name: writing_format.get('module_name'),\r
27     }\r
28   \r
29   speech_balloon: () ->\r
30     new Pettanr.Cache.Retriever(Pettanr.SpeechBalloon, @get('speech_balloon_id'))\r
31   \r
32   writing_format: () ->\r
33     new Pettanr.Cache.Retriever(Pettanr.WritingFormat, @get('writing_format_id'))\r
34   \r
35   @text_align_texts: () -> \r
36     ['left', 'left', 'right', 'center']\r
37   \r
38   symbol_option: () ->\r
39     retriever = @speech_balloon()\r
40     @listenTo(retriever, 'retrieve', @retrieve_speech_balloon)\r
41     retriever.retrieve()\r
42   \r
43   retrieve_speech_balloon: (speech_balloon) -> \r
44     retriever = speech_balloon.speech_balloon_template()\r
45     @listenTo(retriever, 'retrieve', @retrieve_speech_balloon_template)\r
46     retriever.retrieve()\r
47   \r
48   retrieve_speech_balloon_template: (speech_balloon_template) -> \r
49     retriever = speech_balloon_template.system_picture()\r
50     @listenTo(retriever, 'retrieve', @retrieve_system_picture)\r
51     retriever.retrieve()\r
52   \r
53   retrieve_system_picture: (system_picture) -> \r
54     @trigger('ready:symbol', system_picture.tmb_opt_img_tag())\r
55   \r
56   text_align_text: () ->\r
57     Pettanr.Speech.text_align_texts()[@get('text_align')]\r
58   \r
59   scenario: () ->\r
60     @boosts('read')\r
61     @render(@escape('content'))\r
62     \r
63   \r
64   initialize: (attr, options) ->\r
65     super(attr, options)\r
66     if @id\r
67       @url = @url + @id\r
68   \r