OSDN Git Service

t#31558:
[pettanr/pettanr.git] / app / views / panels / _form.html.erb
index 82bec46..a62ba27 100644 (file)
         <%= f.submit t('panels.submit'), :class => "submit" %>
       </div>
     <% end %>
-    <h2><%= t 'panels.create_from_json' -%></h2>
-    <%= form_for(@panel) do |f| %>
-      <%= render 'system/error_explanation', :obj => @panel %>
-
-      <div>
-        <label for="json">json data</label>
-      </div>
-      <%= text_field_tag "json", '', :id => 'pettanr-panel-json' %>
-      <div>
-        <%= submit_tag t('panels.create_from_json'), :id => 'pettanr-panel-submit' -%>
-      </div>
-    <% end %>
   </div>
   <div id="tabs-2">
     <div id="elements-tabs">
@@ -87,7 +75,7 @@
     <table id="t-sortable">
       <tbody >
       <% @panel.panel_elements.each do |elm| %>
-        <tr classname="<%= elm.class.to_s -%>" oid="<%= elm.id -%>">
+        <tr 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' %>
             <td>
     <table id="z-sortable">
       <tbody >
       <% @panel.zorderd_elements.each do |elm| %>
-        <tr classname="<%= elm.class.to_s -%>" oid="<%= elm.id -%>">
+        <tr 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' %>
             <td>
     </table>
   </div>
 </div>
+<%= form_for(@panel, :html => {:jqform => 'pettanr-panel-form'}) do |f| %>
+  <%= render 'system/error_explanation', :obj => @panel %>
+
+  <%= text_field_tag "json", '', :id => 'pettanr-panel-json' %>
+  <div>
+    <%= submit_tag t('panels.create_from_json'), :id => 'pettanr-panel-submit' -%>
+  </div>
+<% end %>
 
 <style>
 <!--
@@ -186,82 +182,5 @@ function set_tree_value(keys, last_attr, value) {
     set_tree_value(keys, last_attr[key], value);
   }
 };
-jQuery( function() {
-    jQuery( '#t-sortable tbody' ) . sortable( {
-        update: function( event, ui ) {
-          var panel_pictures_attributes = {};
-          var speech_balloons_attributes = {};
-          var ground_colors_attributes = {};
-          var ground_pictures_attributes = {};
-          var i = 0;
-          jQuery( '#t-sortable tr' ) . map( function() {
-            switch ( this.getAttribute("classname") ){
-            case 'PanelPicture':
-              panel_pictures_attributes[this.getAttribute("oid")] = {id: this.getAttribute("oid"), t: i};
-              break;
-            case 'SpeechBalloon':
-              speech_balloons_attributes[this.getAttribute("oid")] = {id: this.getAttribute("oid"), t: i};
-              break;
-            case 'GroundPicture':
-              ground_pictures_attributes[this.getAttribute("oid")] = {id: this.getAttribute("oid"), t: i};
-              break;
-            case 'GroundColor':
-              ground_colors_attributes[this.getAttribute("oid")] = {id: this.getAttribute("oid"), t: i};
-              break;
-            }
-            i++;
-          } );
-          var panel = {
-            panel_pictures_attributes: panel_pictures_attributes, 
-            speech_balloons_attributes: speech_balloons_attributes,
-            ground_pictures_attributes: ground_pictures_attributes,
-            ground_colors_attributes: ground_colors_attributes
-          };
-          if ( $("#panel-id-elm") ) 
-            panel['id'] = $( "#panel-id-elm").attr("oid") ;
-          $("#t-reorder").val(JSON.stringify(panel));
-          
-        }
-    } );
-    jQuery( '#t-sortable tbody' ) . disableSelection();
-    
-    jQuery( '#z-sortable tbody' ) . sortable( {
-        update: function( event, ui ) {
-          var panel_pictures_attributes = {};
-          var speech_balloons_attributes = {};
-          var ground_colors_attributes = {};
-          var ground_pictures_attributes = {};
-          var i = 1;
-          jQuery( '#z-sortable tr' ) . map( function() {
-            switch ( this.getAttribute("classname") ){
-            case 'PanelPicture':
-              panel_pictures_attributes[this.getAttribute("oid")] = {id: this.getAttribute("oid"), z: i};
-              break;
-            case 'SpeechBalloon':
-              speech_balloons_attributes[this.getAttribute("oid")] = {id: this.getAttribute("oid"), z: i};
-              break;
-            case 'GroundPicture':
-              ground_pictures_attributes[this.getAttribute("oid")] = {id: this.getAttribute("oid"), z: i};
-              break;
-            case 'GroundColor':
-              ground_colors_attributes[this.getAttribute("oid")] = {id: this.getAttribute("oid"), z: i};
-              break;
-            }
-            i++;
-          } );
-          var panel = {
-            panel_pictures_attributes: panel_pictures_attributes, 
-            speech_balloons_attributes: speech_balloons_attributes,
-            ground_pictures_attributes: ground_pictures_attributes,
-            ground_colors_attributes: ground_colors_attributes
-          };
-          if ( $("#panel-id-zorderd") ) 
-            panel['id'] = $( "#panel-id-zorderd").attr("oid") ;
-          $("#z-reorder").val(JSON.stringify(panel));
-          
-        }
-    } );
-    jQuery( '#t-sortable tbody' ) . disableSelection();
-} );
 // -->
 </script>