OSDN Git Service

t#31896:refact elm
[pettanr/pettanr.git] / app / models / speech.rb
index d47fd5f..68b8562 100644 (file)
@@ -1,4 +1,5 @@
 class Speech < ActiveRecord::Base
+  include ElementPart
   belongs_to :speech_balloon
   belongs_to :writing_format
   
@@ -42,67 +43,14 @@ class Speech < ActiveRecord::Base
     self.speech_balloon.panel.visible? roles
   end
   
-  def new_speech_balloon
-    @new_speech_balloon
-  end
-  
-  def new_speech_balloon= v
-    @new_speech_balloon = v
-  end
-  
-  def get_speech_balloon
-    self.speech_balloon || @new_speech_balloon
-  end
-  
-  def get_panel_id
-    if self.get_speech_balloon == nil or self.get_speech_balloon.panel == nil or self.get_speech_balloon.panel.new_record?
-      0
-    else
-      self.get_speech_balloon.panel.id
-    end
-  end
-  
-  def tag_id c = nil
-    'panel' + tag_panel_id + tag_element_type + tag_element_id + tag_element_part_type + tag_element_part_id + c.to_s
-  end
-  
-  def field_tag_id f
-    self.tag_id + f.to_s
-  end
-  
-  def tag_panel_id
-    self.get_panel_id.to_s
-  end
-  
-  def tag_element_id
-    r = if self.get_speech_balloon == nil or self.get_speech_balloon.new_record?
-      0
-    else
-      self.get_speech_balloon.id
-    end
-    r.to_s
-  end
-  
-  def tag_element_type
-    'speech_balloon'
-  end
-  
-  def tag_element_part_id
-    self.new_record? ? '0' : self.id.to_s
+  def get_parent
+    self.speech_balloon || @new_parent
   end
   
   def tag_element_part_type
     'speech'
   end
   
-  def tag_new_index
-    if self.get_speech_balloon == nil
-      nil
-    else
-      self.get_speech_balloon.tag_new_index
-    end
-  end
-  
   def text_align_text
     @@text_align_texts[self.text_align]
   end