class GroundColor < ActiveRecord::Base
+ include Element
+ include ElementInspire
belongs_to :panel
belongs_to :color
end
end
+ def self.colum_structures
+ @@colum_structures ||= {
+ :code => {
+ :helper => 'panels/color_helper'
+ }
+ }
+ end
+
+ def self.list_opt_for_panel
+ {
+ :ground_colors => {
+ }
+ }
+ end
+
+ def self.show_opt_for_panel
+ {
+ :ground_colors => {
+ }
+ }
+ end
+
+ def self.json_opt_for_panel
+ {
+ }
+ end
+
+ def self.has_picture?
+ false
+ end
+
def supply_default
- self.code = 0
+ self.code ||= 0
if self.panel
self.t = self.panel.new_t
self.z = self.panel.new_z
self.panel.visible? roles
end
- def tag_id c = nil
- 'panel' + tag_panel_id + 'ground_color' + tag_element_id + c.to_s
+ def opt_div_style spot = nil, opacity = 20
+ o = (spot and spot != self) ? "opacity: #{opacity.to_f/100}; filter:alpha(opacity=#{opacity});" : ''
+ "position: absolute; width:#{self.get_panel.width}px; height:#{self.get_panel.height}px; z-index:#{self.z}; background-color:##{format("%06x", self.code)}; #{o}"
end
- def field_tag_id f
- self.tag_id + f.to_s
- end
-
- def tag_panel_id
- self.panel.new_record? ? '0' : self.panel.id.to_s
- end
-
- def tag_element_id
- self.new_record? ? '0' : self.id.to_s
+ def boost
end
def tag_element_type
'ground_color'
end
- def field_tree f
- 'panels-' + self.tag_panel_id + '-ground_colors_attributes_-' + self.tag_element_id + '-' + f.to_s
- end
-
def self.default_page_size
25
end
end
def remove au
- d = false
- ground_colors_attributes = {}
- self.panel.ground_colors.each do |ground_color|
- attr = ground_color.attributes
- if ground_color == self
- attr['_destroy'] = true
- d = true
- else
- if d
- attr['t'] -= 1
- end
- end
- ground_colors_attributes[ground_color.id] = attr
- end
- self.panel.attributes = {:ground_colors_attributes => ground_colors_attributes}
- self.panel.store({}, au)
+ self.panel.remove_element(self, au)
end
def scenario
- ''
+ if caption.blank?
+ ''
+ else
+ '<p>' + ERB::Util.html_escape(self.caption) + '</p>'
+ end
+ end
+
+ def plain_scenario
+ if caption.blank?
+ ''
+ else
+ self.caption + "\n"
+ end
end
end