1 class GroundColor < Peta::Element
6 validates :panel_id, :numericality => {:allow_blank => true}
7 validates :code, :presence => true, :numericality => {:greater_than_or_equal_to => 0, :less_than => 0x1000000}
8 validates :orientation, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
9 validates :xy, :numericality => {:greater_than_or_equal_to => 0, :allow_blank => true}
10 validates :wh, :numericality => {:greater_than_or_equal_to => 0, :allow_blank => true}
11 validates :z, :presence => true, :numericality => {:greater_than => 0}
12 validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
14 def self.by_author_list_includes
29 self.t = self.panel.new_t
30 self.z = self.panel.new_z
43 wh ? wh : 100 - self.div_offset
47 if self.orientation == 0
55 if self.orientation == 0
63 if self.orientation == 0
71 if self.orientation == 0
78 def style spot = nil, opacity = 20
80 'position' => 'absolute', 'z-index' => self.z,
81 'top' => self.div_y.to_s + '%', 'left' => self.div_x.to_s + '%',
82 'width' => self.div_width.to_s + '%', 'height' => self.div_height.to_s + '%',
83 'background-color' => '#' + format("%06x", self.code)
85 self.merge_opacity(r, opacity) if spot and spot != self
89 def self.public_list_where
94 {:include => {:panel => {:author => {}} }}
101 '<p>' + ERB::Util.html_escape(self.caption) + '</p>'