if item.item_name() == @target_model.item_name()\r
# Inspire\r
@listenTo(this, 'ready', @ready)\r
- balloon_list = item.has_one('balloon')\r
- speech_list = item.has_one('speech')\r
- balloon_list.open(() =>\r
- balloon = balloon_list.items()[0]\r
- speech_list.open(() =>\r
- speech = speech_list.items()[0]\r
- new_item = new @target_model(item.attributes)\r
- new_item.unset('id', {silent: true})\r
- new_item.set({panel_id: @editor().item.get('id')}, {silent: true})\r
- balloon.unset('id', {silent: true})\r
- balloon.unset('speech_balloon_id', {silent: true})\r
- speech.unset('id', {silent: true})\r
- speech.unset('speech_balloon_id', {silent: true})\r
- new_item.boosts 'post'\r
- balloon.boosts 'post'\r
- speech.boosts 'post'\r
- new_item.set({balloon: balloon, speech: speech}, {silent: true})\r
- @trigger('ready', new_item)\r
- )\r
- )\r
+ item.get_child('balloon', this, {\r
+ success: (balloon) =>\r
+ item.get_child('speech', this, {\r
+ success: (speech) =>\r
+ new_item = new @target_model(item.attributes)\r
+ new_item.unset('id', {silent: true})\r
+ new_item.set({panel_id: @editor().item.get('id')}, {silent: true})\r
+ balloon.unset('id', {silent: true})\r
+ balloon.unset('speech_balloon_id', {silent: true})\r
+ speech.unset('id', {silent: true})\r
+ speech.unset('speech_balloon_id', {silent: true})\r
+ new_item.boosts 'post'\r
+ balloon.boosts 'post'\r
+ speech.boosts 'post'\r
+ new_item.set({balloon: balloon, speech: speech}, {silent: true})\r
+ @trigger('ready', new_item)\r
+ })\r
+ })\r
else if @target_model.is_traceable(item.item_name())\r
# Trace\r
- tracer_class = @target_model['TraceFrom' + item.singular()]\r
- tracer = new tracer_class()\r
- @listenTo(tracer, 'trace', @trace)\r
- tracer.trace(item)\r
+ item.trace_to(item.my_class().pick_item_name(), this, {\r
+ success: (pick_item) => \r
+ @dialog.http_get(pick_item.show_url())\r
+ })\r
else if item.item_name() == @target_model.pick_item_name()\r
# Pick\r
@listenTo(this, 'ready', @ready)\r
writing_format_list = Locmare.ListGroup.list(\r
'writing_formats', 'index', {}\r
)\r
- writing_format_list.open(() =>\r
- writing_format = writing_format_list.items()[0]\r
- templates = {\r
- speech_balloon_template: speech_balloon_template,\r
- writing_format: writing_format\r
- }\r
- new_item = new @target_model()\r
- new_item.templates = templates\r
- new_item.set(new_item.pick(), {silent: true})\r
- new_item.boosts 'post'\r
- new_item.supply_default()\r
- # prepare balloon\r
- balloon = new Pettanr.Balloon()\r
- balloon.templates = templates\r
- balloon.set(balloon.pick(), {silent: true})\r
- balloon.boosts 'post'\r
- balloon.supply_default()\r
- # prepare speech\r
- speech = new Pettanr.Speech()\r
- speech.templates = templates\r
- speech.set(speech.pick(), {silent: true})\r
- speech.boosts 'post'\r
- speech.supply_default()\r
- # join elements\r
- new_item.set({balloon: balloon, speech: speech}, {silent: true})\r
- @trigger('ready', new_item)\r
- )\r
+ writing_format_list.open(this, {\r
+ success: (writing_formats) => \r
+ writing_format = writing_formats[0]\r
+ templates = {\r
+ speech_balloon_template: speech_balloon_template,\r
+ writing_format: writing_format\r
+ }\r
+ new_item = new @target_model()\r
+ new_item.templates = templates\r
+ new_item.set(new_item.pick(), {silent: true})\r
+ new_item.boosts 'post'\r
+ new_item.supply_default()\r
+ # prepare balloon\r
+ balloon = new Pettanr.Balloon()\r
+ balloon.templates = templates\r
+ balloon.set(balloon.pick(), {silent: true})\r
+ balloon.boosts 'post'\r
+ balloon.supply_default()\r
+ # prepare speech\r
+ speech = new Pettanr.Speech()\r
+ speech.templates = templates\r
+ speech.set(speech.pick(), {silent: true})\r
+ speech.boosts 'post'\r
+ speech.supply_default()\r
+ # join elements\r
+ new_item.set({balloon: balloon, speech: speech}, {silent: true})\r
+ @trigger('ready', new_item)\r
+ })\r
\r
ready: (new_item) ->\r
@dialog.stop()\r
@trigger('pick', new_item)\r
\r
- trace: (speech_balloon) ->\r
- @dialog.http_get(speech_balloon.show_url())\r
- \r
dock: () ->\r
@parent.dock()\r
\r