2 class Element < ElementNestableContent
3 self.abstract_class = true
9 return nil if self._skip_load?
11 pm = Manifest.manifest.models[self.my_peta.parent_model_name].classify
12 define_singleton_method("parent_model") do
24 if self.parent_model.element?
25 self.parent_model.root_model
37 pm = self.__send__ self.class.parent_model.item_name
46 self.root.own? operators
49 def visible? operators
50 return false unless self.user_visible? operators
51 self.root.visible? operators
54 def self.list_opt_for_panel
58 def self.show_opt_for_panel
62 def self.json_opt_for_panel
66 def self.panelize elements_attributes
67 elements_attributes = [elements_attributes] unless elements_attributes.is_a?(Array)
70 elements_attributes.each do |element_attributes|
71 hash[self.to_s.tableize + '_attributes'] ||= {}
72 n = if element_attributes['id']
73 element_attributes['id'].to_s
78 hash[self.to_s.tableize + '_attributes'][n] = element_attributes
99 def extend_element_name
100 self.extend_column ? self.attributes[extend_column] : self.element_name
103 def scenario_template with_engine = false
104 self.path_name(with_engine) + '/scenario'
107 def element_face_template with_engine = false
108 self.path_name(with_engine) + '/element_face'
111 def tag_attributes column = nil, opt = {}
113 r.merge({'data-parent_dom_id' => self.parent.dom_item_id}) if self.editize?
117 def merge_opacity s, opacity
119 'opacity' => opacity.to_f/100,
120 'filter' => "alpha(opacity=#{opacity})"
124 def copy_attributes opt = {}
128 r.delete 't' unless opt[:all]
129 r.delete 'z' unless opt[:all]
130 r.delete 'created_at'
131 r.delete 'updated_at'