1 class GroundColor < Peta::Element
7 validates :panel_id, :numericality => {:allow_blank => true}
8 validates :code, :presence => true, :numericality => {:greater_than_or_equal_to => 0, :less_than => 0x1000000}
9 validates :orientation, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
10 validates :xy, :numericality => {:greater_than_or_equal_to => 0, :allow_blank => true}
11 validates :wh, :numericality => {:greater_than_or_equal_to => 0, :allow_blank => true}
12 validates :z, :presence => true, :numericality => {:greater_than => 0}
13 validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
15 def self.colum_structures
16 @@colum_structures ||= {
18 :helper => 'panels/color_helper'
23 def self.list_opt_for_panel
30 def self.show_opt_for_panel
37 def self.json_opt_for_panel
49 self.t = self.panel.new_t
50 self.z = self.panel.new_z
58 def visible? operators
59 return false unless super
60 self.owner_model.visible? operators
68 wh ? wh : 100 - self.div_offset
72 if self.orientation == 0
80 if self.orientation == 0
88 if self.orientation == 0
96 if self.orientation == 0
103 def opt_div_style spot = nil, opacity = 20
104 o = (spot and spot != self) ? "opacity: #{opacity.to_f/100}; filter:alpha(opacity=#{opacity});" : ''
105 "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}"
120 'ground_colors.updated_at desc'
124 {:panel => {:author => {}} }
127 def self.list_json_opt
128 {:include => {:panel => {:include => {:author => {}}} }}
132 {:include => {:panel => {:author => {}} }}
135 def self.show_json_opt
136 {:include => {:panel => {:include => {:author => {}}} }}
141 self.panel.ground_colors.build(self.attributes)
143 self.panel.ground_colors.each do |ground_color|
144 next unless ground_color == self
145 attr = self.attributes
147 ground_color.attributes = attr
151 self.panel.store({}, operators)
155 self.panel.remove_element(self, operators)
162 '<p>' + ERB::Util.html_escape(self.caption) + '</p>'