1 class Balloon < Peta::Content
3 include Peta::ElementPart
4 belongs_to :speech_balloon
5 belongs_to :system_picture
7 validates :speech_balloon_id, :numericality => {:allow_blank => true}
8 validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
9 validates :x, :presence => true, :numericality => true
10 validates :y, :presence => true, :numericality => true
11 validates :width, :presence => true, :numericality => true, :natural_number => true
12 validates :height, :presence => true, :numericality => true, :natural_number => true
13 validates :r, :presence => true, :numericality => true
14 # validates :caption, :presence => true
15 validates :settings, :extend_balloon => true
17 def self.colum_structures
18 @@colum_structures ||= {
20 :helper => 'panels/tail_angle_helper'
26 '/system_pictures/' + self.system_picture.filename
29 def visible? operators
30 return false unless super
31 self.owner_model.visible? operators
40 self.system_picture_id = 1
44 self.get_parent.speech_balloon_template.symbol_option
48 self.speech_balloon || @new_parent
51 def tag_element_part_type
60 'balloons.updated_at desc'
64 {:speech_balloon => {:panel => {:author => {}}, :speech => {}, :speech_balloon_template => {} }}
67 def self.list_json_opt
68 {:include => {:speech_balloon => {:include => {:panel => {:include => {:author => {} }}, :speech => {}, :speech_balloon_template => {} }}}}
72 {:include => {:speech_balloon => {:panel => {:author => {}}, :speech => {}, :speech_balloon_template => {} }}}
75 def self.show_json_opt
76 {:include => {:speech_balloon => {:include => {:panel => {:include => {:author => {} }}, :speech => {}, :speech_balloon_template => {} }}}}
81 'width' => self.width.to_s + 'px','height' => self.height.to_s + 'px',
82 'top' => self.y.to_s + 'px','left' => self.x.to_s + 'px'
89 r.delete 'speech_balloon_id'
95 def self.panelize balloon_attributes
96 {'balloon_attributes' => balloon_attributes}