X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fspeech_balloon.js.coffee;h=f77322a0d82e2b1b9d4f8d82275ed5fe48a24ef1;hb=cc2dbf353c285c78423a8a29d7adf233e1651c6e;hp=e1dc8ce2aaffafc9b11adb055fbebadf594eab18;hpb=2e1fe642e8bf2e237f6bcfb605d4d26da96fe2e9;p=pettanr%2Fpettanr.git diff --git a/app/assets/javascripts/models/speech_balloon.js.coffee b/app/assets/javascripts/models/speech_balloon.js.coffee index e1dc8ce2..f77322a0 100644 --- a/app/assets/javascripts/models/speech_balloon.js.coffee +++ b/app/assets/javascripts/models/speech_balloon.js.coffee @@ -1,4 +1,6 @@ class Pettanr.SpeechBalloon extends Peta.Element + url: '/speech_balloons/' + @singular: () -> 'SpeechBalloon' @@ -11,16 +13,63 @@ class Pettanr.SpeechBalloon extends Peta.Element t: null } + @pick_item_name: () -> + 'speech_balloon_template' + + @traceable_item_names: () -> + ['speech', 'balloon'] + + trace_from_speech: () -> + + trace_from_balloon: () -> + + pick: (templates) -> + # + speech_balloon_template = templates.speech_balloon_template + { + speech_balloon_template_id: speech_balloon_template.get('id'), + speech_balloon_template_module_name: speech_balloon_template.get('module_name') + } + + panel: () -> + new Pettanr.Cache.Retriever(Pettanr.Panel, @get('panel_id')) + + speech_balloon_template: () -> + new Pettanr.Cache.Retriever(Pettanr.SpeechBalloonTemplate, @get('speech_balloon_template_id')) + @has_picture: () -> false - @symbol_option: () -> - @speech_balloon_template.symbol_option + symbol_option: () -> + retriever = @speech_balloon_template() + @listenTo(retriever, 'retrieve', @retrieve_speech_balloon_template) + retriever.retrieve() + + retrieve_speech_balloon_template: (speech_balloon_template) -> + retriever = speech_balloon_template.system_picture() + @listenTo(retriever, 'retrieve', @retrieve_system_picture) + retriever.retrieve() + + retrieve_system_picture: (system_picture) -> + @trigger('ready:symbol', system_picture.tmb_opt_img_tag()) + + filer_caption: () -> + retriever = @retriever() + @listenTo(retriever, 'retrieve', @retrieve_filer_caption) + retriever.retrieve() + + retrieve_filer_caption: (item) -> + caption = item.escape('caption') + @trigger('ready:caption', caption) + + plain_scenario: () -> + @get('caption') + + element_face: () -> + new Pettanr.Views.SpeechBalloon.ElementFace({element: this}) - initialize: () -> + initialize: (attr, options) -> + super(attr, options) if @id @url = @url + @id -class Pettanr.SpeechBalloon.Collection extends Backbone.Collection - model: Pettanr.SpeechBalloon - url: '/speech_balloons'