OSDN Git Service

e
[pettanr/pettanr.git] / app / models / ground_color.rb
index 85f0dc2..cf78ded 100644 (file)
@@ -1,5 +1,5 @@
-class GroundColor < Peta::Content
-  include Peta::Element
+class GroundColor < Peta::Element
+  load_manifest
   include ElementInspire
   belongs_to :panel
   belongs_to :color
@@ -12,14 +12,6 @@ class GroundColor < Peta::Content
   validates :z, :presence => true, :numericality => {:greater_than => 0}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
-  def self.owner_model
-    Panel
-  end
-  
-  def self.valid_encode_columns
-    super + ['caption']
-  end
-  
   def self.colum_structures
     @@colum_structures ||= {
       :code => {
@@ -108,9 +100,15 @@ class GroundColor < Peta::Content
     end
   end
   
-  def opt_div_style spot = nil, opacity = 20
-    o = (spot and spot != self) ? "opacity: #{opacity.to_f/100}; filter:alpha(opacity=#{opacity});" : ''
-    "position: absolute; left:#{self.div_x}%; top:#{self.div_y}%; width:#{self.div_width}%; height:#{self.div_height}%; z-index:#{self.z}; background-color:##{format("%06x", self.code)}; #{o}"
+  def style spot = nil, opacity = 20
+    r = {
+      'position' => 'absolute', 'z-index' => self.z, 
+      'top' => self.div_y.to_s + '%', 'left' => self.div_x.to_s + '%', 
+      'width' => self.div_width.to_s + '%', 'height' => self.div_height.to_s + '%', 
+      'background-color' => '#' + format("%06x", self.code)
+    }
+    self.merge_opacity(r, opacity) if spot and spot != self
+    r
   end
   
   def boost