1 class Balloon < Peta::Element
3 belongs_to :speech_balloon
4 belongs_to :speech_balloon_template
5 belongs_to :system_picture
7 validates :speech_balloon_id, :numericality => {:allow_blank => true}
8 validates :speech_balloon_template_id, :presence => true, :numericality => true, :existence => {:both => false}
9 validates :speech_balloon_template_module_name, :presence => true, :length => {:maximum => 50}
10 validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
11 validates :x, :presence => true, :numericality => true
12 validates :y, :presence => true, :numericality => true
13 validates :width, :presence => true, :numericality => true, :natural_number => true
14 validates :height, :presence => true, :numericality => true, :natural_number => true
15 validates :r, :presence => true, :numericality => true
16 # validates :caption, :presence => true
17 validates :speech_balloon_template_settings, :boost => {:boost_name => :speech_balloon_template}
24 '/system_pictures/' + self.system_picture.filename
33 self.system_picture_id = 1
37 self.speech_balloon.speech_balloon_template.symbol_option
40 def self.public_list_where
44 def self.by_author_list_includes
55 {:include => {:speech_balloon => {:panel => {:author => {}}, :speech => {}, :speech_balloon_template => {} }}}
60 'width' => self.width.to_s + 'px','height' => self.height.to_s + 'px',
61 'top' => self.attr_y.to_s + 'px','left' => self.x.to_s + 'px'
65 def self.panelize balloon_attributes
66 {'balloon_attributes' => balloon_attributes}