OSDN Git Service

t#31772:element lib
[pettanr/pettanr.git] / app / models / ground_picture.rb
index 5042868..3562d32 100644 (file)
@@ -75,7 +75,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.get_panel.width}px; height:#{self.get_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
@@ -83,6 +83,18 @@ class GroundPicture < ActiveRecord::Base
     {:src => self.picture.url, :width => tw, :height => th, :alt => self.caption}
   end
   
+  def new_panel
+    @new_panel
+  end
+  
+  def new_panel= v
+    @new_panel = v
+  end
+  
+  def get_panel
+    self.panel || @new_panel
+  end
+  
   def tag_id c = nil
     'panel' + tag_panel_id + 'ground_picture' + tag_element_id + c.to_s
   end
@@ -92,7 +104,7 @@ class GroundPicture < ActiveRecord::Base
   end
   
   def tag_panel_id
-    self.panel.new_record? ? '0' : self.panel.id.to_s
+    self.get_panel.new_record? ? '0' : self.get_panel.id.to_s
   end
   
   def tag_element_id