OSDN Git Service

change: cache system
[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       speech_balloon_template_settings: speech_balloon_template.get('settings')\r
33     }\r
34   \r
35   panel: () ->\r
36     new Pettanr.Cache.Retriever(Pettanr.Panel, @get('panel_id'))\r
37   \r
38   speech_balloon_template: () ->\r
39     new Pettanr.Cache.Retriever(Pettanr.SpeechBalloonTemplate, @get('speech_balloon_template_id'))\r
40   \r
41   @has_picture: () ->\r
42     false\r
43   \r
44   symbol_option: () ->\r
45     retriever = @speech_balloon_template()\r
46     @listenTo(retriever, 'retrieve', @retrieve_speech_balloon_template)\r
47     retriever.retrieve()\r
48   \r
49   retrieve_speech_balloon_template: (speech_balloon_template) -> \r
50     retriever = speech_balloon_template.system_picture()\r
51     @listenTo(retriever, 'retrieve', @retrieve_system_picture)\r
52     retriever.retrieve()\r
53   \r
54   retrieve_system_picture: (system_picture) -> \r
55     @trigger('ready:symbol', system_picture.tmb_opt_img_tag())\r
56   \r
57   filer_caption: () ->\r
58     retriever = @retriever()\r
59     @listenTo(retriever, 'retrieve', @retrieve_filer_caption)\r
60     retriever.retrieve()\r
61   \r
62   retrieve_filer_caption: (item) -> \r
63     caption = item.escape('caption')\r
64     @trigger('ready:caption', caption)\r
65   \r
66   plain_scenario: () ->\r
67     @get('caption')\r
68   \r
69   element_face: () ->\r
70     new Pettanr.Views.SpeechBalloon.ElementFace({element: this})\r
71   \r
72   initialize: (attr, options) ->\r
73     super(attr, options)\r
74     if @id\r
75       @url = @url + @id\r
76   \r