1 class Balloon < Peta::Content
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.get_parent.speech_balloon_template.symbol_option
43 'balloons.updated_at desc'
47 {:speech_balloon => {:panel => {:author => {}}, :speech => {}, :speech_balloon_template => {} }}
50 def self.list_json_opt
51 {:include => {:speech_balloon => {:include => {:panel => {:include => {:author => {} }}, :speech => {}, :speech_balloon_template => {} }}}}
55 {:include => {:speech_balloon => {:panel => {:author => {}}, :speech => {}, :speech_balloon_template => {} }}}
58 def self.show_json_opt
59 {:include => {:speech_balloon => {:include => {:panel => {:include => {:author => {} }}, :speech => {}, :speech_balloon_template => {} }}}}
64 'width' => self.width.to_s + 'px','height' => self.height.to_s + 'px',
65 'top' => self.y.to_s + 'px','left' => self.x.to_s + 'px'
72 r.delete 'speech_balloon_id'
78 def self.panelize balloon_attributes
79 {'balloon_attributes' => balloon_attributes}