OSDN Git Service

t#31945:separate js
[pettanr/pettanr.git] / app / views / panels / _form.html.erb
index a260168..1ac7361 100644 (file)
@@ -1,4 +1,4 @@
-<div id="tabs">
+<div id="tabs" class="panel-editor" panel_id="<%= @panel.tag_panel_id -%>" current="1">
   <ul>
     <li><a href="#tabs-1">panel</a></li>
     <li><a href="#tabs-2">elements</a></li>
     <div id="elements-tabs">
       <ul>
         <% @panel.panel_elements.each do |elm| %>
-          <li id="<%= elm.field_tag_id(:element_tab) -%>" panel_id="<%= elm.tag_panel_id -%>" element_id="<%= elm.tag_element_id -%>" element_type="<%= elm.tag_element_type -%>">
-            <a href="#elements-tabs-<%= elm.t -%>">
-              <div class="elements-tab">
-                <%= render elm.class.to_s.tableize + '/element_face', :elm => elm %>
-              </div>
-            </a>
-            <button class="ui-icon-destroy" id="<%= elm.field_tag_id(:_destroy_button) -%>" panel_id="<%= elm.tag_panel_id -%>" element_id="<%= elm.tag_element_id -%>" element_type="<%= elm.tag_element_type -%>"></button>
-          </li>
+          <%= render 'element_tab', :elm => elm %>
         <% end %>
       </ul>
       <% @panel.panel_elements.each do |elm| %>
         <div id="<%= elm.field_tag_id(:tab_panel) -%>" panel_id="<%= elm.tag_panel_id -%>" element_id="<%= elm.tag_element_id -%>" element_type="<%= elm.tag_element_type -%>">
           <div id="elements-tabs-<%= elm.t -%>">
-            <% case elm.class.to_s %>
-            <% when 'PanelPicture' %>
-              <%= render 'panel_pictures/form', :panel_picture => elm, :no_attr => 0 %>
-            <% when 'SpeechBalloon' %>
-              <% 
-                speech_balloon = elm
-                speech_balloon_template = speech_balloon.speech_balloon_template
-                balloon = speech_balloon.balloon 
-                speech = speech_balloon.speech 
-                
-                speech_balloon_extend = speech_balloon.extend_speech_balloon
-                balloon_extend = balloon.extend_balloon
-                speech_extend = speech.extend_speech
-              %>
-              <%= render elm.speech_balloon_template.engine_name + '/speech_balloons/form', :speech_balloon => speech_balloon, :balloon => balloon, :speech => speech, :speech_balloon_extend => speech_balloon_extend, :balloon_extend => balloon_extend, :speech_extend => speech_extend, :no_attr => 0 %>
-            <% when 'GroundPicture' %>
-              <%= render 'ground_pictures/form', :ground_picture => elm, :no_attr => 0 %>
-            <% when 'GroundColor' %>
-              <%= render 'ground_colors/form', :ground_color => elm, :no_attr => 0 %>
-            <% end %>
+            <%= render elm.form_template, :elm => elm, :no_attr => 0 %>
             <%= hidden_field_tag '_destroy', '', :id => elm.field_tag_id(:_destroy), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :_destroy %>
           </div>
         </div>
@@ -85,7 +59,7 @@
         <% @panel.panel_elements.each do |elm| %>
           <li id="<%= elm.field_tag_id(:tsort) -%>" panel_id="<%= elm.tag_panel_id -%>" element_id="<%= elm.tag_element_id -%>" element_type="<%= elm.tag_element_type -%>">
             <div class="elements-tab">
-              <%= render elm.class.to_s.tableize + '/element_face', :elm => elm %>
+              <%= render elm.path_name + '/element_face', :elm => elm %>
             </div>
           </li>
         <% end %>
     <div id="<%= @panel.tag_id -%>scenario" class="scenario" panel_id="<%= @panel.tag_panel_id -%>">
       <% @panel.panel_elements.each do |elm| %>
         <div panel_id="<%= elm.tag_panel_id -%>" element_id="<%= elm.tag_element_id -%>" element_type="<%= elm.tag_element_type -%>">
-          <% case elm.class.to_s %>
-          <% when 'PanelPicture' %>
-            <%= render 'panel_pictures/scenario', :panel_picture => elm %>
-          <% when 'SpeechBalloon' %>
-            <%= render elm.speech_balloon_template.engine_name + '/speech_balloons/scenario', :speech_balloon => elm %>
-          <% when 'GroundPicture' %>
-            <%= render 'ground_pictures/scenario', :ground_picture => elm %>
-          <% when 'GroundColor' %>
-            <%= render 'ground_colors/scenario', :ground_color => elm %>
-          <% end %>
+          <%= render elm.scenario_template, :elm => elm, :no_attr => 0 %>
         </div>
       <% end %>
     </div>
                     </li>
                   <% end %>
                 </ul>
-                <% SpeechBalloonTemplate.list().each_with_index do |sbt, index| %>
+                <% SpeechBalloonTemplate.enable_list().each_with_index do |sbt, index| %>
                   <div id="new-speech_balloon-tabs-<%= index -%>">
                     <% elm = SpeechBalloon.new :panel_id => @panel.id, :speech_balloon_template_id => sbt.id %>
                     <% 
-                      speech_balloon = elm
-                      speech_balloon_template = speech_balloon.speech_balloon_template
-                      speech_balloon.extend speech_balloon_template.engine_speech_balloon_module
-                      speech_balloon.supply_default
-                      balloon = speech_balloon.build_balloon 
-                      speech = speech_balloon.build_speech 
-                      balloon.extend speech_balloon_template.engine_balloon_module
-                      speech.extend speech_balloon_template.engine_speech_module
-                      
-                      speech_balloon_extend = speech_balloon.extend_speech_balloon
-                      balloon_extend = balloon.extend_balloon
-                      speech_extend = speech.extend_speech
-                      
-                      balloon.new_speech_balloon = speech_balloon
-                      speech.new_speech_balloon = speech_balloon
-                      balloon.supply_default 
-                      speech.supply_default 
+                      elm.new_panel = @panel
+                      elm.boost
+                      elm.supply_default
+                      elm.get_balloon.supply_default 
+                      elm.get_speech.supply_default 
                     %>
-                    <%= render elm.speech_balloon_template.engine_name + '/speech_balloons/form', :speech_balloon => speech_balloon, :balloon => balloon, :speech => speech, :speech_balloon_extend => speech_balloon_extend, :balloon_extend => balloon_extend, :speech_extend => speech_extend, :no_attr => 1 %>
+                    <%= render elm.form_template, :elm => elm, :no_attr => 1 %>
                   </div>
                 <% end %>
             <% when 'GroundPicture' %>
             <% when 'GroundColor' %>
               <% elm = GroundColor.new :panel_id => @panel.id %>
-              <% elm.supply_default %>
-              <%= render k.to_s.tableize + '/form', :ground_color => elm, :no_attr => 1 %>
+              <% elm.new_panel = @panel ; elm.boost ; elm.supply_default %>
+              <%= render elm.form_template, :elm => elm, :no_attr => 1 %>
             <% end %>
           </div>
         </div>
     </div>
     <script>
     <!--
-      <% SpeechBalloonTemplate.list().each do |sbt| %>
+      <% SpeechBalloonTemplate.enable_list().each do |sbt| %>
         var <%= h(sbt.engine_name) %>_settings = <%= raw sbt.parsed_settings.to_json -%>;
       <% end %>
     // -->
     </script>
-    <% SpeechBalloonTemplate.list().each do |sbt| %>
+    <% SpeechBalloonTemplate.enable_list().each do |sbt| %>
       <%= stylesheet_link_tag sbt.engine_name + "/application" %>
       <%= javascript_include_tag sbt.engine_name + "/application" %>
     <% end %>
 <% end %>
 <script>
 <!--
-var pettanr_current_panel_id = <%= @panel.tag_panel_id -%>;
 var writing_formats = {};
+var writing_format_functions = {};
 <% WritingFormat.list().each do |wf| %>
   writing_formats[<%= wf.id -%>] = '<%= wf.engine_name -%>';
 <% end %>