1 class GroundColor < Peta::Content
8 validates :panel_id, :numericality => {:allow_blank => true}
9 validates :code, :presence => true, :numericality => {:greater_than_or_equal_to => 0, :less_than => 0x1000000}
10 validates :orientation, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
11 validates :xy, :numericality => {:greater_than_or_equal_to => 0, :allow_blank => true}
12 validates :wh, :numericality => {:greater_than_or_equal_to => 0, :allow_blank => true}
13 validates :z, :presence => true, :numericality => {:greater_than => 0}
14 validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
16 def self.colum_structures
17 @@colum_structures ||= {
19 :helper => 'panels/color_helper'
24 def self.list_opt_for_panel
31 def self.show_opt_for_panel
38 def self.json_opt_for_panel
50 self.t = self.panel.new_t
51 self.z = self.panel.new_z
59 def visible? operators
60 return false unless super
61 self.owner_model.visible? operators
69 wh ? wh : 100 - self.div_offset
73 if self.orientation == 0
81 if self.orientation == 0
89 if self.orientation == 0
97 if self.orientation == 0
104 def opt_div_style spot = nil, opacity = 20
105 o = (spot and spot != self) ? "opacity: #{opacity.to_f/100}; filter:alpha(opacity=#{opacity});" : ''
106 "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}"
121 'ground_colors.updated_at desc'
125 {:panel => {:author => {}} }
128 def self.list_json_opt
129 {:include => {:panel => {:include => {:author => {}}} }}
133 {:include => {:panel => {:author => {}} }}
136 def self.show_json_opt
137 {:include => {:panel => {:include => {:author => {}}} }}
142 self.panel.ground_colors.build(self.attributes)
144 self.panel.ground_colors.each do |ground_color|
145 next unless ground_color == self
146 attr = self.attributes
148 ground_color.attributes = attr
152 self.panel.store({}, operators)
156 self.panel.remove_element(self, operators)
163 '<p>' + ERB::Util.html_escape(self.caption) + '</p>'