OSDN Git Service

fix: show's destroy button
[pettanr/pettanr.git] / app / assets / javascripts / models / speech.js.coffee
1 class Pettanr.Speech extends Peta.Element\r
2   \r
3   @singular: () ->\r
4     'Speech'\r
5   \r
6   @plural: () ->\r
7     'Speeches'\r
8   \r
9   defaults: {\r
10     id: null,\r
11     x: 0,\r
12     y: 0,\r
13     width: 100,\r
14     height: 100\r
15   } \r
16   \r
17   pick: () ->\r
18     # \r
19     speech_balloon_template = @templates.speech_balloon_template\r
20     writing_format = @templates.writing_format\r
21     {\r
22       speech_balloon_template_id: speech_balloon_template.get('id'),\r
23       speech_balloon_template_module_name: speech_balloon_template.get('module_name'),\r
24       writing_format_id: writing_format.get('id'),\r
25       writing_format_module_name: writing_format.get('module_name'),\r
26     }\r
27   \r
28   speech_balloon: () ->\r
29     new Pettanr.Cache.Retriever(Pettanr.SpeechBalloon, @get('speech_balloon_id'))\r
30   \r
31   writing_format: () ->\r
32     new Pettanr.Cache.Retriever(Pettanr.WritingFormat, @get('writing_format_id'))\r
33   \r
34   @text_align_texts: () -> \r
35     ['left', 'left', 'right', 'center']\r
36   \r
37   symbol_option: () ->\r
38     retriever = @speech_balloon()\r
39     @listenTo(retriever, 'retrieve', @retrieve_speech_balloon)\r
40     retriever.retrieve()\r
41   \r
42   retrieve_speech_balloon: (speech_balloon) -> \r
43     retriever = speech_balloon.speech_balloon_template()\r
44     @listenTo(retriever, 'retrieve', @retrieve_speech_balloon_template)\r
45     retriever.retrieve()\r
46   \r
47   retrieve_speech_balloon_template: (speech_balloon_template) -> \r
48     retriever = speech_balloon_template.system_picture()\r
49     @listenTo(retriever, 'retrieve', @retrieve_system_picture)\r
50     retriever.retrieve()\r
51   \r
52   retrieve_system_picture: (system_picture) -> \r
53     @trigger('ready:symbol', system_picture.tmb_opt_img_tag())\r
54   \r
55   text_align_text: () ->\r
56     Pettanr.Speech.text_align_texts()[@get('text_align')]\r
57   \r
58   scenario: () ->\r
59     @boosts('read')\r
60     @render(@escape('content'))\r
61     \r
62   \r
63   initialize: (attr, options) ->\r
64     super(attr, options)\r
65   \r