-class GroundColor < Peta::Content
- include Peta::Element
+class GroundColor < Peta::Element
+ load_manifest
include ElementInspire
belongs_to :panel
belongs_to :color
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 => {
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