2 class Element < ElementNestableContent
3 self.abstract_class = true
10 pm = Manifest.manifest.models[self.my_peta.parent_model_name].classify
11 define_singleton_method("parent_model") do
23 if self.parent_model.element?
24 self.parent_model.root_model
36 self.__send__ self.class.root_model.item_name
39 def visible? operators
40 return false unless super
41 self.root.visible? operators
44 def self.list_opt_for_panel
48 def self.show_opt_for_panel
52 def self.json_opt_for_panel
56 def self.panelize elements_attributes
57 elements_attributes = [elements_attributes] unless elements_attributes.is_a?(Array)
60 elements_attributes.each do |element_attributes|
61 hash[self.to_s.tableize + '_attributes'] ||= {}
62 n = if element_attributes['id']
63 element_attributes['id'].to_s
68 hash[self.to_s.tableize + '_attributes'][n] = element_attributes
89 def extend_element_name
90 self.extend_column ? self.attributes[extend_column] : self.element_name
93 def scenario_template with_engine = false
94 self.path_name(with_engine) + '/scenario'
97 def element_face_template with_engine = false
98 self.path_name(with_engine) + '/element_face'
101 def tag_attributes column = nil, opt = {}
103 r.merge({'data-parent_dom_id' => self.parent.dom_item_id}) if self.editize?
107 def merge_opacity s, opacity
109 'opacity' => opacity.to_f/100,
110 'filter' => "alpha(opacity=#{opacity})"
114 def copy_attributes opt = {}
118 r.delete 't' unless opt[:all]
119 r.delete 'z' unless opt[:all]
120 r.delete 'created_at'
121 r.delete 'updated_at'