OSDN Git Service

t#31524:fix spotting on panel
authoryasushiito <yas@pen-chan.jp>
Fri, 7 Jun 2013 10:05:06 +0000 (19:05 +0900)
committeryasushiito <yas@pen-chan.jp>
Fri, 7 Jun 2013 10:05:06 +0000 (19:05 +0900)
12 files changed:
app/controllers/comics_controller.rb
app/controllers/panels_controller.rb
app/models/ground_picture.rb
app/models/panel.rb
app/models/panel_picture.rb
app/views/ground_colors/_body.html.erb [deleted file]
app/views/ground_colors/_standard.html.erb
app/views/ground_pictures/_body.html.erb [deleted file]
app/views/ground_pictures/_standard.html.erb
app/views/panel_pictures/_body.html.erb [deleted file]
app/views/panel_pictures/_standard.html.erb
app/views/panels/_body.html.erb

index c42bbe9..848e4b2 100644 (file)
@@ -117,7 +117,7 @@ class ComicsController < ApplicationController
     respond_to do |format|
       if @comic.destroy_with_story
         flash[:notice] = I18n.t('flash.notice.destroyed', :model => Comic.model_name.human)
-        format.html { redirect_to '/home/comic' }
+        format.html { redirect_to '/home/comics' }
         format.json { head :ok }
       else
         flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Comic.model_name.human)
index e664820..7ebd6c6 100644 (file)
@@ -132,7 +132,7 @@ class PanelsController < ApplicationController
       Panel.transaction do
         if @panel.destroy_with_elements
           flash[:notice] = I18n.t('flash.notice.destroyed', :model => Panel.model_name.human)
-          format.html { redirect_to '/home/panel' }
+          format.html { redirect_to '/home/panels' }
           format.json { head :ok }
         else
           flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Panel.model_name.human)
index 086e5dd..6ed5f98 100644 (file)
@@ -31,8 +31,8 @@ class GroundPicture < ActiveRecord::Base
   end
   
   def opt_div_style full_url, spot = nil, opacity = 20
-    o = spot and spot != self ? "opacity: #{opacity.to_f/100}; filter:alpha(opacity=#{opacity});" : ''
-    "width:#{self.panel.width}px; height:#{self.panel.height}px; z-index:#{self.z}; background-image: url(#{full_url}); background-repeat: #{self.repeat_text}; background-position: #{self.x}px, #{self.y}px; #{o}"
+    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}"
   end
   
   def tmb_opt_img_tag
index dc8948a..09479d2 100644 (file)
@@ -184,7 +184,7 @@ class Panel < ActiveRecord::Base
   end
   
   def panel_elements
-    parts + grounds
+    (parts + grounds).compact
   end
   
   @@elm_json_opt = {
index e960e3e..b459e6f 100644 (file)
@@ -58,7 +58,7 @@ class PanelPicture < ActiveRecord::Base
   end
   
   def opt_img_tag spot = nil, opacity = 20
-    o = spot and spot != self ? "opacity: #{opacity.to_f/100}; filter:alpha(opacity=#{opacity});" : ''
+    o = (spot and spot != self) ? "opacity: #{opacity.to_f/100}; filter:alpha(opacity=#{opacity});" : ''
     {:src => self.url, :vPicture => self.id, :width => self.width.abs, :height => self.height.abs, :alt => self.caption, :style => "top:#{self.y}px; left:#{self.x}px; z-index:#{self.z}; #{o}"}
   end
   
diff --git a/app/views/ground_colors/_body.html.erb b/app/views/ground_colors/_body.html.erb
deleted file mode 100644 (file)
index 41b4048..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<div class="pettanr-comic-panel" style="width:<%= panel.width %>px;height:<%= panel.height %>px;border-style: solid;border-width: <%= panel.border %>px;border-color:black; background-color:white;">
-  <% panel.panel_elements.each do |elm| %>
-    <% case elm.class.to_s %>
-    <% when 'PanelPicture' %>
-      <%= link_to_unless(elm.link.blank?, tag(:img, elm.opt_img_tag(elm == spot ? nil : 33)), elm.link) %>
-    <% when 'SpeechBalloon' %>
-      <% balloon = elm.balloons.first %>
-      <div id="vballoon<%= elm.id -%>" class="pettanr-comic-balloon" style="width:<%= balloon.width -%>px; height:<%= balloon.height -%>px; top:<%= balloon.y -%>px; left:<%= balloon.x -%>px; z-index:<%= elm.z -%>; ">
-        <img src="<%= balloon.system_picture.url -%>" alt="<%= balloon.caption -%>">
-        <% elm.speeches.each do |speech| %>
-          <p style="top:<%= speech.y -%>px; left:<%= speech.x -%>px;width:<%= speech.width -%>px; height:<%= speech.height -%>px;">
-            <span><%= h speech.content -%></span>
-          </p>
-        <% end %>
-      </div>
-    <% when 'GroundColor' %>
-      <div id="ground-color<%= elm.id -%>" class="pettanr-comic-ground-color" style="width:<%= panel.width -%>px; height:<%= panel.height -%>px; z-index:<%= elm.z -%>; background-color:#<%= format("%06x", elm.code) -%>;">
-      
-      </div>
-    <% when 'GroundPicture' %>
-      <div id="ground-picture<%= elm.id -%>" class="pettanr-comic-ground-picture" style="width:<%= panel.width -%>px; height:<%= panel.height -%>px; z-index:<%= elm.z -%>; background-image: url(<%= full_url elm.picture.url -%>); background-repeat: <%= elm.repeat_text -%>; background-position: <%= elm.x -%>px, <%= elm.y -%>px;">
-        
-      </div>
-    <% end %>
-  <% end %>
-</div>
index 47dee5d..35f438f 100644 (file)
@@ -1,6 +1,6 @@
 <b><%= t_m 'Panel.caption' -%>:</b>
 <%= h(panel.caption) %>
-<%= render 'panel_pictures/body', :panel => panel, :author => author, :spot => spot %>
+<%= render 'panels/body', :panel => panel, :author => author, :spot => spot %>
 <%= render 'panels/footer', :panel => panel, :author => author %>
 <%= render 'panels/licensed_pictures', :licensed_pictures => panel.licensed_pictures %>
 
diff --git a/app/views/ground_pictures/_body.html.erb b/app/views/ground_pictures/_body.html.erb
deleted file mode 100644 (file)
index 41b4048..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<div class="pettanr-comic-panel" style="width:<%= panel.width %>px;height:<%= panel.height %>px;border-style: solid;border-width: <%= panel.border %>px;border-color:black; background-color:white;">
-  <% panel.panel_elements.each do |elm| %>
-    <% case elm.class.to_s %>
-    <% when 'PanelPicture' %>
-      <%= link_to_unless(elm.link.blank?, tag(:img, elm.opt_img_tag(elm == spot ? nil : 33)), elm.link) %>
-    <% when 'SpeechBalloon' %>
-      <% balloon = elm.balloons.first %>
-      <div id="vballoon<%= elm.id -%>" class="pettanr-comic-balloon" style="width:<%= balloon.width -%>px; height:<%= balloon.height -%>px; top:<%= balloon.y -%>px; left:<%= balloon.x -%>px; z-index:<%= elm.z -%>; ">
-        <img src="<%= balloon.system_picture.url -%>" alt="<%= balloon.caption -%>">
-        <% elm.speeches.each do |speech| %>
-          <p style="top:<%= speech.y -%>px; left:<%= speech.x -%>px;width:<%= speech.width -%>px; height:<%= speech.height -%>px;">
-            <span><%= h speech.content -%></span>
-          </p>
-        <% end %>
-      </div>
-    <% when 'GroundColor' %>
-      <div id="ground-color<%= elm.id -%>" class="pettanr-comic-ground-color" style="width:<%= panel.width -%>px; height:<%= panel.height -%>px; z-index:<%= elm.z -%>; background-color:#<%= format("%06x", elm.code) -%>;">
-      
-      </div>
-    <% when 'GroundPicture' %>
-      <div id="ground-picture<%= elm.id -%>" class="pettanr-comic-ground-picture" style="width:<%= panel.width -%>px; height:<%= panel.height -%>px; z-index:<%= elm.z -%>; background-image: url(<%= full_url elm.picture.url -%>); background-repeat: <%= elm.repeat_text -%>; background-position: <%= elm.x -%>px, <%= elm.y -%>px;">
-        
-      </div>
-    <% end %>
-  <% end %>
-</div>
index 47dee5d..35f438f 100644 (file)
@@ -1,6 +1,6 @@
 <b><%= t_m 'Panel.caption' -%>:</b>
 <%= h(panel.caption) %>
-<%= render 'panel_pictures/body', :panel => panel, :author => author, :spot => spot %>
+<%= render 'panels/body', :panel => panel, :author => author, :spot => spot %>
 <%= render 'panels/footer', :panel => panel, :author => author %>
 <%= render 'panels/licensed_pictures', :licensed_pictures => panel.licensed_pictures %>
 
diff --git a/app/views/panel_pictures/_body.html.erb b/app/views/panel_pictures/_body.html.erb
deleted file mode 100644 (file)
index 41b4048..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<div class="pettanr-comic-panel" style="width:<%= panel.width %>px;height:<%= panel.height %>px;border-style: solid;border-width: <%= panel.border %>px;border-color:black; background-color:white;">
-  <% panel.panel_elements.each do |elm| %>
-    <% case elm.class.to_s %>
-    <% when 'PanelPicture' %>
-      <%= link_to_unless(elm.link.blank?, tag(:img, elm.opt_img_tag(elm == spot ? nil : 33)), elm.link) %>
-    <% when 'SpeechBalloon' %>
-      <% balloon = elm.balloons.first %>
-      <div id="vballoon<%= elm.id -%>" class="pettanr-comic-balloon" style="width:<%= balloon.width -%>px; height:<%= balloon.height -%>px; top:<%= balloon.y -%>px; left:<%= balloon.x -%>px; z-index:<%= elm.z -%>; ">
-        <img src="<%= balloon.system_picture.url -%>" alt="<%= balloon.caption -%>">
-        <% elm.speeches.each do |speech| %>
-          <p style="top:<%= speech.y -%>px; left:<%= speech.x -%>px;width:<%= speech.width -%>px; height:<%= speech.height -%>px;">
-            <span><%= h speech.content -%></span>
-          </p>
-        <% end %>
-      </div>
-    <% when 'GroundColor' %>
-      <div id="ground-color<%= elm.id -%>" class="pettanr-comic-ground-color" style="width:<%= panel.width -%>px; height:<%= panel.height -%>px; z-index:<%= elm.z -%>; background-color:#<%= format("%06x", elm.code) -%>;">
-      
-      </div>
-    <% when 'GroundPicture' %>
-      <div id="ground-picture<%= elm.id -%>" class="pettanr-comic-ground-picture" style="width:<%= panel.width -%>px; height:<%= panel.height -%>px; z-index:<%= elm.z -%>; background-image: url(<%= full_url elm.picture.url -%>); background-repeat: <%= elm.repeat_text -%>; background-position: <%= elm.x -%>px, <%= elm.y -%>px;">
-        
-      </div>
-    <% end %>
-  <% end %>
-</div>
index 47dee5d..35f438f 100644 (file)
@@ -1,6 +1,6 @@
 <b><%= t_m 'Panel.caption' -%>:</b>
 <%= h(panel.caption) %>
-<%= render 'panel_pictures/body', :panel => panel, :author => author, :spot => spot %>
+<%= render 'panels/body', :panel => panel, :author => author, :spot => spot %>
 <%= render 'panels/footer', :panel => panel, :author => author %>
 <%= render 'panels/licensed_pictures', :licensed_pictures => panel.licensed_pictures %>
 
index a73039e..4827570 100644 (file)
@@ -2,7 +2,7 @@
   <% panel.panel_elements.each do |elm| %>
     <% case elm.class.to_s %>
     <% when 'PanelPicture' %>
-      <%= link_to_unless(elm.link.blank?, tag(:img, elm.opt_img_tag(elm == spot ? nil : 20)), elm.link) %>
+      <%= link_to_unless(elm.link.blank?, tag(:img, elm.opt_img_tag(spot)), elm.link) %>
     <% when 'SpeechBalloon' %>
       <% balloon = elm.balloons.first %>
       <div id="vballoon<%= elm.id -%>" class="pettanr-comic-balloon" style="width:<%= balloon.width -%>px; height:<%= balloon.height -%>px; top:<%= balloon.y -%>px; left:<%= balloon.x -%>px; z-index:<%= elm.z -%>; ">
@@ -14,7 +14,7 @@
         <% end %>
       </div>
     <% when 'GroundPicture' %>
-      <div id="ground-picture<%= elm.id -%>" class="pettanr-comic-ground-picture" style="<%= elm.opt_div_style(full_url(elm.picture.url)) -%>">
+      <div id="ground-picture<%= elm.id -%>" class="pettanr-comic-ground-picture" style="<%= elm.opt_div_style(full_url(elm.picture.url), spot) -%>">
         
       </div>
     <% when 'GroundColor' %>