OSDN Git Service

e
[pettanr/pettanr.git] / app / models / ground_picture.rb
index f356aa2..779848d 100644 (file)
@@ -1,5 +1,5 @@
-class GroundPicture < Peta::Content
-  include Peta::Element
+class GroundPicture < Peta::Element
+  load_manifest
   include ElementInspire
   belongs_to :panel
   belongs_to :picture
@@ -14,14 +14,6 @@ class GroundPicture < Peta::Content
   
   @@repeat_texts = ['repeat', 'repeat-x', 'repeat-y', 'no-repeat']
   
-  def self.owner_model
-    Panel
-  end
-  
-  def self.valid_encode_columns
-    super + ['caption']
-  end
-  
   def self.list_opt_for_panel
     {
       :ground_pictures => {
@@ -67,9 +59,15 @@ class GroundPicture < Peta::Content
     self.owner_model.visible? operators
   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});" : ''
-    "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}"
+  def style spot = nil, opacity = 20
+    r = {
+      'position' => 'absolute', 'top' => '0px', 'left' => '0px', 'z-index' => self.z, 
+      'background-image' => "url(#{self.picture.url})", 
+      'background-repeat' => self.repeat_text, 
+      'background-position' => "#{self.x}px #{self.y}px"
+    }
+    self.merge_opacity(r, opacity) if spot and spot != self
+    r
   end
   
   def tmb_opt_img_tag