1 class SpeechBalloon < Peta::Element
3 has_one :balloon, :dependent => :destroy
4 has_one :speech, :dependent => :destroy
5 belongs_to :speech_balloon_template
8 accepts_nested_attributes_for :balloon
9 accepts_nested_attributes_for :speech
11 validates :panel_id, :numericality => {:allow_blank => true}
12 validates :speech_balloon_template_id, :presence => true, :numericality => true, :existence => {:both => false}
13 validates :speech_balloon_template_classname, :presence => true, :length => {:maximum => 50}
14 validates :z, :presence => true, :numericality => {:greater_than => 0}
15 validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
16 validates :speech_balloon_template_settings, :boost => {:boost_name => :speech_balloon_template}
18 def self.by_author_list_includes
26 def self.list_opt_for_panel
28 :speech_balloons => {:balloon => {}, :speech => {}}
32 def self.show_opt_for_panel
34 :speech_balloons => {:balloon => {}, :speech => {}}
38 def self.json_opt_for_panel
40 :balloon => {}, :speech => {}
50 self.t = self.panel.new_t
51 self.z = self.panel.new_z
60 self.speech_balloon_template.symbol_option
67 def self.public_list_where
72 {:include => {:panel => {:author => {}}, :balloon => {}, :speech => {}, :speech_balloon_template => {} }}
75 def self.show_json_opt
76 {:include => {:panel => {:include => {:author => {} }}, :balloon => {}, :speech => {}, :speech_balloon_template => {} }}
80 @parts ||= [self.balloon, self.speech]
84 self.speech_balloon_template.engine_name + '/'
87 def path_name with_engine = false
88 (with_engine ? self.engine_path_name : '') +
92 def form_template with_engine = false
93 self.path_name(true) + '/form'
96 def speech_form_template with_engine = false
97 self.engine_path_name + 'speeches/form'
100 def balloon_form_template with_engine = false
101 self.engine_path_name + 'balloons/form'
104 def scenario_template with_engine = false
105 self.path_name(true) + '/scenario'
108 def element_face_template with_engine = false
109 self.path_name(false) + '/element_face'
113 ERB::Util.html_escape(self.caption.to_s) + self.balloon.scenario.to_s +
114 self.speech.scenario.to_s
118 self.caption.to_s + self.balloon.plain_scenario.to_s +
119 self.speech.plain_scenario.to_s