OSDN Git Service

fix:balloon edit
[pettanr/pettanr.git] / app / assets / javascripts / models / speech_balloon.js.coffee
1 class Pettanr.SpeechBalloon extends Peta.Element\r
2   url: '/speech_balloons/'\r
3   \r
4   @singular: () ->\r
5     'SpeechBalloon'\r
6   \r
7   @plural: () ->\r
8     'SpeechBalloons'\r
9   \r
10   defaults: {\r
11     id: null,\r
12     z: null,\r
13     t: null\r
14   } \r
15   \r
16   @pick_item_name: () ->\r
17     'speech_balloon_template'\r
18   \r
19   @traceable_item_names: () ->\r
20     ['speech', 'balloon']\r
21   \r
22   trace_from_speech: () ->\r
23   \r
24   trace_from_balloon: () ->\r
25   \r
26   pick: (templates) ->\r
27     # \r
28     speech_balloon_template = templates.speech_balloon_template\r
29     {\r
30       speech_balloon_template_id: speech_balloon_template.get('id'),\r
31       speech_balloon_template_module_name: speech_balloon_template.get('module_name')\r
32     }\r
33   \r
34   panel: () ->\r
35     new Pettanr.Cache.Retriever(Pettanr.Panel, @get('panel_id'))\r
36   \r
37   speech_balloon_template: () ->\r
38     new Pettanr.Cache.Retriever(Pettanr.SpeechBalloonTemplate, @get('speech_balloon_template_id'))\r
39   \r
40   @has_picture: () ->\r
41     false\r
42   \r
43   symbol_option: () ->\r
44     retriever = @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   filer_caption: () ->\r
57     retriever = @retriever()\r
58     @listenTo(retriever, 'retrieve', @retrieve_filer_caption)\r
59     retriever.retrieve()\r
60   \r
61   retrieve_filer_caption: (item) -> \r
62     caption = item.escape('caption')\r
63     @trigger('ready:caption', caption)\r
64   \r
65   plain_scenario: () ->\r
66     @get('caption')\r
67   \r
68   element_face: () ->\r
69     new Pettanr.Views.SpeechBalloon.ElementFace({element: this})\r
70   \r
71   initialize: (attr, options) ->\r
72     super(attr, options)\r
73     if @id\r
74       @url = @url + @id\r
75   \r