OSDN Git Service

fix:balloon r
[pettanr/pettanr.git] / app / assets / javascripts / views / speech_balloons / new_element.js.coffee
index 0fa2e8b..d10c67c 100644 (file)
@@ -55,29 +55,36 @@ class Pettanr.Views.SpeechBalloon.NewElement extends Backbone.View
       # Pick\r
       @listenTo(this, 'ready', @ready)\r
       speech_balloon_template = item\r
-      writing_format = new Pettanr.WritingFormat({id: 1})\r
-      writing_format.fetch({cache: true}).done =>\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.set(new_item.pick(templates), {silent: true})\r
+        new_item.templates = templates\r
+        new_item.set(new_item.pick(), {silent: true})\r
         new_item.boosts 'post'\r
-        new_item.supply_default(templates)\r
+        new_item.supply_default()\r
         # prepare balloon\r
         balloon = new Pettanr.Balloon()\r
-        balloon.set(balloon.pick(templates), {silent: true})\r
+        balloon.templates = templates\r
+        balloon.set(balloon.pick(), {silent: true})\r
         balloon.boosts 'post'\r
-        balloon.supply_default(templates)\r
+        balloon.supply_default()\r
         # prepare speech\r
         speech = new Pettanr.Speech()\r
-        speech.set(speech.pick(templates), {silent: true})\r
+        speech.templates = templates\r
+        speech.set(speech.pick(), {silent: true})\r
         speech.boosts 'post'\r
-        speech.supply_default(templates)\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