OSDN Git Service

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