OSDN Git Service

merge:
[pettanr/pettanr.git] / app / models / ground_picture.rb
index d0e9833..b1f13f0 100644 (file)
@@ -13,33 +13,28 @@ class GroundPicture < Peta::Element
   
   @@repeat_texts = ['repeat', 'repeat-x', 'repeat-y', 'no-repeat']
   
-  def self.by_author_list_includes
-    {
-      :panel => {
-        :author => {}
-      }
-    }
+  def self.pickup_item_name
+    Picture.item_name
   end
   
-  def self.list_opt_for_panel
-    {
-      :ground_pictures => {
-        :picture => {:artist => {}, :license => {}}
-      }
-    }
+  def self.pickup_column_name
+    self.pickup_item_name + '_id'
   end
   
-  def self.show_opt_for_panel
-    {
-      :ground_pictures => {
-        :picture => {:artist => {}, :license => {}}
-      }
-    }
+  def pickup_id
+    # get :picture_id if head revision
+    self.attributes[self.pickup_column_name]
   end
   
-  def self.json_opt_for_panel
+  def y
+    self.attributes['y']
+  end
+  
+  def self.by_author_list_includes
     {
-      :picture => {:artist => {}, :license => {}}
+      :panel => {
+        :author => {}
+      }
     }
   end
   
@@ -66,7 +61,7 @@ class GroundPicture < Peta::Element
       'position' => 'absolute', 'top' => '0px', 'left' => '0px', 'z-index' => self.z, 
       'background-image' => "url(#{self.picture.url})", 
       'background-repeat' => self.repeat_text, 
-      'background-position' => "#{self.x}px #{self.y}px"
+      'background-position' => "#{self.x}px #{self.attr_y}px"
     }
     self.merge_opacity(r, opacity) if spot and spot != self
     r
@@ -85,49 +80,14 @@ class GroundPicture < Peta::Element
     @@repeat_texts[self.repeat]
   end
   
-  def self.public_list_where
+  def self.public_list_where list
     'panels.publish > 0'
   end
   
-  def self.list_order
-    'ground_pictures.updated_at desc'
-  end
-  
-  def self.list_opt
-    {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}} }
-  end
-  
-  def self.list_json_opt
-    {:include => {:panel => {:include => {:author => {}}}, :picture => {:include => {:artist => {}, :license => {}}} }}
-  end
-  
   def self.show_opt
     {:include => {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}}}}
   end
   
-  def self.show_json_opt
-    {:include => {:panel => {:include => {:author => {}}}, :picture => {:include => {:artist => {}, :license => {}}} }}
-  end
-  
-  def store operators
-    if self.new_record?
-      self.panel.ground_pictures.build(self.attributes)
-    else
-      self.panel.ground_pictures.each do |ground_picture|
-        next unless ground_picture == self
-        attr = self.attributes
-        attr.delete 'id'
-        ground_picture.attributes = attr
-        break
-      end
-    end
-    self.panel.store({}, operators)
-  end
-  
-  def remove operators
-    self.panel.remove_element(self, operators)
-  end
-  
   def scenario
     if caption.blank?
       ''