OSDN Git Service

t#31558:
authoryasushiito <yas@pen-chan.jp>
Thu, 20 Jun 2013 23:16:44 +0000 (08:16 +0900)
committeryasushiito <yas@pen-chan.jp>
Thu, 20 Jun 2013 23:16:44 +0000 (08:16 +0900)
app/assets/javascripts/panels.js.coffee
app/models/balloon.rb
app/models/ground_picture.rb
app/models/speech.rb
app/views/speech_balloons/_form.html.erb

index 327914e..aceeecc 100644 (file)
@@ -1,4 +1,5 @@
 $ ->\r
+  repeat_texts = ['repeat', 'repeat-x', 'repeat-y', 'no-repeat']\r
   element_tag_id = (element) ->\r
     '#panel' + element.attr('panel_id') + element.attr('element_type') + element.attr('element_id')\r
   \r
@@ -68,6 +69,16 @@ $ ->
     if $(@).attr('element_type') and $(@).attr('element_type') == 'panel_picture'\r
       $(@).focusout ->\r
         switch $(@).attr('column')\r
+          when 'x'\r
+            trace = element_tag_id($(@)) + 'img'\r
+            v = parseInt($(@).val()).toString() + 'px'\r
+            $(trace).parent().css('left', v)\r
+            $(trace).css('left', v)\r
+          when 'y'\r
+            trace = element_tag_id($(@)) + 'img'\r
+            v = parseInt($(@).val()).toString() + 'px'\r
+            $(trace).parent().css('top', v)\r
+            $(trace).css('top', v)\r
           when 'width'\r
             trace = element_tag_id($(@)) + 'img'\r
             v = parseInt($(@).val())\r
@@ -121,6 +132,69 @@ $ ->
     }\r
   \r
   # sync view \r
+  $('input').map  ->\r
+    if $(@).attr('element_type') and $(@).attr('element_type') == 'speech_balloon'\r
+      $(@).focusout ->\r
+        switch $(@).attr('column')\r
+          when 'x'\r
+            trace = element_tag_id($(@))\r
+            v = parseInt($(@).val()).toString() + 'px'\r
+            $(trace).css('left', v)\r
+          when 'y'\r
+            trace = element_tag_id($(@))\r
+            v = parseInt($(@).val()).toString() + 'px'\r
+            $(trace).css('top', v)\r
+          when 'width'\r
+            trace = element_tag_id($(@))\r
+            v = parseInt($(@).val())\r
+            $(trace).width(Math.abs(v))\r
+            trace = '#panel' + $(trace).attr('panel_id') + 'speech_balloon' + $(trace).attr('element_id') + 'balloon' + $(trace).attr('balloon_id')\r
+            $(trace).parent().width(v)\r
+            $(trace).width(v)\r
+          when 'height'\r
+            trace = element_tag_id($(@))\r
+            v = parseInt($(@).val())\r
+            $(trace).height(Math.abs(v))\r
+            trace = '#panel' + $(trace).attr('panel_id') + 'speech_balloon' + $(trace).attr('element_id') + 'balloon' + $(trace).attr('balloon_id')\r
+            $(trace).parent().height(v)\r
+            $(trace).height(v)\r
+          else\r
+    else\r
+  \r
+  # ground-picture\r
+  # sync view \r
+  $('input').map  ->\r
+    if $(@).attr('element_type') and $(@).attr('element_type') == 'ground_picture'\r
+      $(@).focusout ->\r
+        switch $(@).attr('column')\r
+          when 'x', 'y'\r
+            trace = element_tag_id($(@))\r
+            x = parseInt($(@).val()).toString() + 'px'\r
+            ytrace = '#panel' + $(@).attr('panel_id') + 'ground_picture' + $(@).attr('element_id') + 'y'\r
+            y = parseInt($(ytrace).val()).toString() + 'px'\r
+            $(trace).css('background-position', y + ' ' + x)\r
+  $('select').map  ->\r
+    if $(@).attr('element_type') and $(@).attr('element_type') == 'ground_picture'\r
+      $(@).change ->\r
+        switch $(@).attr('column')\r
+          when 'repeat'\r
+            trace = element_tag_id($(@))\r
+            v = parseInt($(@).val())\r
+            $(trace).css('background-repeat', repeat_texts[v])\r
+    else\r
+  \r
+  \r
+  # ground_color\r
+  # sync view \r
+  $('input').map  ->\r
+    if $(@).attr('element_type') and $(@).attr('element_type') == 'ground_color'\r
+      $(@).focusout ->\r
+        switch $(@).attr('column')\r
+          when 'code'\r
+            trace = element_tag_id($(@))\r
+            v = '#' + parseInt($(@).val()).toString()\r
+            $(trace).css('background-color', v)\r
+  \r
   $('#t-sortable tbody').sortable {\r
       update: ( event, ui ) ->\r
         t = 0;\r
index beda944..343b61d 100644 (file)
@@ -73,7 +73,7 @@ self.system_picture_id = 1
   end
   
   def field_tree f
-    'panels-' + self.tag_panel_id + '-speech_balloons_attributes-' + self.tag_element_id + '-balloon_attributes-' + self.tag_element_part_id + '-' + f.to_s
+    'panels-' + self.tag_panel_id + '-speech_balloons_attributes-' + self.tag_element_id + '-balloon_attributes-' + f.to_s
   end
   
   def self.default_page_size
index 23b6bbc..9a13d93 100644 (file)
@@ -47,7 +47,7 @@ class GroundPicture < ActiveRecord::Base
   
   def opt_div_style full_url, spot = nil, opacity = 20
     o = (spot and spot != self) ? "opacity: #{opacity.to_f/100}; filter:alpha(opacity=#{opacity});" : ''
-    "position: absolute; width:#{self.panel.width}px; height:#{self.panel.height}px; top: 0px; left: 0px;  z-index:#{self.z}; background-image: url(#{full_url}); background-repeat: #{self.repeat_text}; background-position: #{self.x}px, #{self.y}px; #{o}"
+    "position: absolute; width:#{self.panel.width}px; height:#{self.panel.height}px; top: 0px; left: 0px;  z-index:#{self.z}; background-image: url(#{full_url}); background-repeat: #{self.repeat_text}; background-position: #{self.x}px #{self.y}px; #{o}"
   end
   
   def tmb_opt_img_tag
index 0366221..dbcbad8 100644 (file)
@@ -63,7 +63,7 @@ class Speech < ActiveRecord::Base
   end
   
   def field_tree f
-    'panels-' + self.tag_panel_id + '-speech_balloons_attributes-' + self.tag_element_id + '-' + '-speech_attributes-' + self.tag_element_part_id + '-' + f.to_s
+    'panels-' + self.tag_panel_id + '-speech_balloons_attributes-' + self.tag_element_id + '-speech_attributes-' + f.to_s
   end
   
   def self.default_page_size
index 4c0108b..6a3f3a6 100644 (file)
@@ -2,8 +2,8 @@
   <%= render 'system/error_explanation', :obj => speech_balloon %>
 
   <div class="field">
-    <%= f.label :caption, :id => speech_balloon.field_tag_id(:caption), :panel_id => speech_balloon.tag_panel_id, :element_id => speech_balloon.tag_element_id, :element_type => speech_balloon.tag_element_type, :column => :caption, :tree => speech_balloon.field_tree(:caption) %><br />
-    <%= f.number_field :caption %>
+    <%= f.label :caption %><br />
+    <%= f.number_field :caption, :id => speech_balloon.field_tag_id(:caption), :panel_id => speech_balloon.tag_panel_id, :element_id => speech_balloon.tag_element_id, :element_type => speech_balloon.tag_element_type, :column => :caption, :tree => speech_balloon.field_tree(:caption) %>
   </div>
   <div class="field">
     <%= f.label :z %><br />
@@ -22,9 +22,9 @@
     <%= render 'speeches/form', :f => sf, :speech => speech_balloon.speech %>
   <% end %>
 
-  <%= f.hidden_field :panel_id %>
-  <%= f.hidden_field :classname %>
-  <%= f.hidden_field :speech_balloon_template_id %>
+  <%= f.hidden_field :panel_id, :id => speech_balloon.field_tag_id(:panel_id), :panel_id => speech_balloon.tag_panel_id, :element_id => speech_balloon.tag_element_id, :element_type => speech_balloon.tag_element_type, :column => :panel_id, :tree => speech_balloon.field_tree(:panel_id) %>
+  <%= f.hidden_field :classname, :id => speech_balloon.field_tag_id(:classname), :panel_id => speech_balloon.tag_panel_id, :element_id => speech_balloon.tag_element_id, :element_type => speech_balloon.tag_element_type, :column => :classname, :tree => speech_balloon.field_tree(:classname) %>
+  <%= f.hidden_field :speech_balloon_template_id, :id => speech_balloon.field_tag_id(:speech_balloon_template_id), :panel_id => speech_balloon.tag_panel_id, :element_id => speech_balloon.tag_element_id, :element_type => speech_balloon.tag_element_type, :column => :speech_balloon_template_id, :tree => speech_balloon.field_tree(:speech_balloon_template_id) %>
   <% unless speech_balloon.new_record?  %>
     <%= f.hidden_field :id, :id => speech_balloon.field_tag_id(:id), :panel_id => speech_balloon.tag_panel_id, :element_id => speech_balloon.tag_element_id, :element_type => speech_balloon.tag_element_type, :column => :id, :tree => speech_balloon.field_tree(:id) %>
   <% end %>