1 class Balloon < Peta::Element
3 belongs_to :speech_balloon
4 belongs_to :system_picture
6 validates :speech_balloon_id, :numericality => {:allow_blank => true}
7 validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
8 validates :x, :presence => true, :numericality => true
9 validates :y, :presence => true, :numericality => true
10 validates :width, :presence => true, :numericality => true, :natural_number => true
11 validates :height, :presence => true, :numericality => true, :natural_number => true
12 validates :r, :presence => true, :numericality => true
13 # validates :caption, :presence => true
14 validates :settings, :extend_balloon => true
17 '/system_pictures/' + self.system_picture.filename
20 def visible? operators
21 return false unless super
22 self.owner_model.visible? operators
31 self.system_picture_id = 1
35 self.speech_balloon.speech_balloon_template.symbol_option
43 'balloons.updated_at desc'
46 def self.by_author_list_includes
57 {:speech_balloon => {:panel => {:author => {}}, :speech => {}, :speech_balloon_template => {} }}
60 def self.list_json_opt
61 {:include => {:speech_balloon => {:include => {:panel => {:include => {:author => {} }}, :speech => {}, :speech_balloon_template => {} }}}}
65 {:include => {:speech_balloon => {:panel => {:author => {}}, :speech => {}, :speech_balloon_template => {} }}}
68 def self.show_json_opt
69 {:include => {:speech_balloon => {:include => {:panel => {:include => {:author => {} }}, :speech => {}, :speech_balloon_template => {} }}}}
74 'width' => self.width.to_s + 'px','height' => self.height.to_s + 'px',
75 'top' => self.y.to_s + 'px','left' => self.x.to_s + 'px'
82 r.delete 'speech_balloon_id'
88 def self.panelize balloon_attributes
89 {'balloon_attributes' => balloon_attributes}