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 style spot = nil, opacity = 20
105 'position' => 'absolute', 'z-index' => self.z,
106 'top' => self.div_y.to_s + '%', 'left' => self.div_x.to_s + '%',
107 'width' => self.div_width.to_s + '%', 'height' => self.div_height.to_s + '%',
108 'background-color' => '#' + format("%06x", self.code)
110 self.merge_opacity(r, opacity) if spot and spot != self
126 'ground_colors.updated_at desc'
130 {:panel => {:author => {}} }
133 def self.list_json_opt
134 {:include => {:panel => {:include => {:author => {}}} }}
138 {:include => {:panel => {:author => {}} }}
141 def self.show_json_opt
142 {:include => {:panel => {:include => {:author => {}}} }}
147 self.panel.ground_colors.build(self.attributes)
149 self.panel.ground_colors.each do |ground_color|
150 next unless ground_color == self
151 attr = self.attributes
153 ground_color.attributes = attr
157 self.panel.store({}, operators)
161 self.panel.remove_element(self, operators)
168 '<p>' + ERB::Util.html_escape(self.caption) + '</p>'