1 class Speech < Pettanr::Content
3 belongs_to :speech_balloon
4 belongs_to :writing_format
6 validates :speech_balloon_id, :numericality => {:allow_blank => true}
7 validates :writing_format_id, :presence => true, :numericality => true, :existence => {:both => false}
8 validates :font_size, :presence => true, :numericality => {:only_integer => false}
9 validates :text_align, :presence => true, :numericality => true, :inclusion => { :in => 0..3 }
10 validates :fore_color, :presence => true, :numericality => {:greater_than_or_equal_to => 0, :less_than => 0x1000000}
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 :quotes, :length => {:maximum => 15}, :quotes_even => true
16 validates :settings, :extend_speech => true
18 @@text_align_texts = ['left', 'left', 'right', 'center']
21 self.speech_balloon.panel
24 def self.valid_encode_columns
25 super + ['content', 'quotes', 'settings']
28 def self.colum_structures
29 @@colum_structures ||= {
31 :helper => 'panels/color_helper'
43 def visible? operators
44 return false unless super
45 self.owner_model.visible? operators
49 self.get_parent.speech_balloon_template.symbol_option
53 self.speech_balloon || @new_parent
56 def tag_element_part_type
61 @@text_align_texts[self.text_align]
69 'speeches.updated_at desc'
73 {:speech_balloon => {:panel => {:author => {}}, :balloon => {}, :speech_balloon_template => {}} }
76 def self.list_json_opt
77 {:include => {:speech_balloon => {:include => {:panel => {:include => {:author => {} }}, :balloon => {}, :speech_balloon_template => {} }}}}
81 {:include => {:speech_balloon => {:panel => {:author => {}}, :balloon => {}, :speech_balloon_template => {} }}}
84 def self.show_json_opt
85 {:include => {:speech_balloon => {:include => {:panel => {:include => {:author => {} }}, :balloon => {}, :speech_balloon_template => {} }}}}
91 r.delete 'speech_balloon_id'
97 def self.panelize speech_attributes
98 {'speech_attributes' => speech_attributes}
101 def writing_format_engine_model
102 self.writing_format.engine_model
106 self.writing_format_engine_model.render self.content
114 ERB::Util.html_escape(self.content)