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 pm = self.__send__ self.class.parent_model.item_name
45 self.root.own? operators
48 def visible? operators
49 return false unless self.user_visible? operators
50 self.root.visible? operators
53 def self.list_opt_for_panel
57 def self.show_opt_for_panel
61 def self.json_opt_for_panel
65 def self.panelize elements_attributes
66 elements_attributes = [elements_attributes] unless elements_attributes.is_a?(Array)
69 elements_attributes.each do |element_attributes|
70 hash[self.to_s.tableize + '_attributes'] ||= {}
71 n = if element_attributes['id']
72 element_attributes['id'].to_s
77 hash[self.to_s.tableize + '_attributes'][n] = element_attributes
98 def extend_element_name
99 self.extend_column ? self.attributes[extend_column] : self.element_name
102 def scenario_template with_engine = false
103 self.path_name(with_engine) + '/scenario'
106 def element_face_template with_engine = false
107 self.path_name(with_engine) + '/element_face'
110 def tag_attributes column = nil, opt = {}
112 r.merge({'data-parent_dom_id' => self.parent.dom_item_id}) if self.editize?
116 def merge_opacity s, opacity
118 'opacity' => opacity.to_f/100,
119 'filter' => "alpha(opacity=#{opacity})"
123 def copy_attributes opt = {}
127 r.delete 't' unless opt[:all]
128 r.delete 'z' unless opt[:all]
129 r.delete 'created_at'
130 r.delete 'updated_at'