X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fspeech.js.coffee;h=a91413d03d7a1ef0cd028a3f12f83e4e27ecbb72;hb=cc2dbf353c285c78423a8a29d7adf233e1651c6e;hp=7c158fd9d0140e4494591f0a9f141a01c14cb2fc;hpb=2e1fe642e8bf2e237f6bcfb605d4d26da96fe2e9;p=pettanr%2Fpettanr.git diff --git a/app/assets/javascripts/models/speech.js.coffee b/app/assets/javascripts/models/speech.js.coffee index 7c158fd9..a91413d0 100644 --- a/app/assets/javascripts/models/speech.js.coffee +++ b/app/assets/javascripts/models/speech.js.coffee @@ -1,4 +1,6 @@ class Pettanr.Speech extends Peta.Element + url: '/speeches/' + @singular: () -> 'Speech' @@ -13,32 +15,54 @@ class Pettanr.Speech extends Peta.Element height: 100 } + pick: (templates) -> + # + speech_balloon_template = templates.speech_balloon_template + writing_format = templates.writing_format + { + speech_balloon_template_id: speech_balloon_template.get('id'), + speech_balloon_template_module_name: speech_balloon_template.get('module_name'), + writing_format_id: writing_format.get('id'), + writing_format_module_name: writing_format.get('module_name'), + } + + speech_balloon: () -> + new Pettanr.Cache.Retriever(Pettanr.SpeechBalloon, @get('speech_balloon_id')) + + writing_format: () -> + new Pettanr.Cache.Retriever(Pettanr.WritingFormat, @get('writing_format_id')) + @text_align_texts: () -> ['left', 'left', 'right', 'center'] symbol_option: () -> - @speech_balloon().speech_balloon_template().symbol_option() + retriever = @speech_balloon() + @listenTo(retriever, 'retrieve', @retrieve_speech_balloon) + retriever.retrieve() - outer_style: () -> - { - top: @get('y'), left: @get('x'), - width: @get('width'), height: @get('height') - } + retrieve_speech_balloon: (speech_balloon) -> + retriever = speech_balloon.speech_balloon_template() + @listenTo(retriever, 'retrieve', @retrieve_speech_balloon_template) + retriever.retrieve() - inner_style: () -> - { - 'font-size': Pettanr.to_s(@get('font_size')) + 'em', - 'text-align': @text_align_text(), - color: '#' + ('000000' + Pettanr.to_s(@get('fore_color'))).slice(-6) - } + 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()) text_align_text: () -> Pettanr.Speech.text_align_texts()[@get('text_align')] - initialize: () -> + scenario: () -> + @boosts('read') + @render(@escape('content')) + + + initialize: (attr, options) -> + super(attr, options) if @id @url = @url + @id -class Pettanr.Speech.Collection extends Backbone.Collection - model: Pettanr.Speech - url: '/Speeches'