1 class GroundPicture < Peta::Element
6 validates :panel_id, :numericality => {:allow_blank => true}
7 validates :repeat, :numericality => true, :inclusion => { :in => 0..3 }
8 validates :x, :numericality => true
9 validates :y, :numericality => true
10 validates :picture_id, :numericality => true, :existence => {:both => false}
11 validates :z, :presence => true, :numericality => {:greater_than => 0}
12 validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
14 @@repeat_texts = ['repeat', 'repeat-x', 'repeat-y', 'no-repeat']
20 def self.by_author_list_includes
37 self.t = self.panel.new_t
38 self.z = self.panel.new_z
46 def style spot = nil, opacity = 20
48 'position' => 'absolute', 'top' => '0px', 'left' => '0px', 'z-index' => self.z,
49 'background-image' => "url(#{self.picture.url})",
50 'background-repeat' => self.repeat_text,
51 'background-position' => "#{self.x}px #{self._y}px"
53 self.merge_opacity(r, opacity) if spot and spot != self
58 tw, th = PettanImager.thumbnail_size(self.picture.width, self.picture.height)
59 {:src => self.picture.url, :width => tw, :height => th, :alt => self.caption}
67 @@repeat_texts[self.repeat]
70 def self.public_list_where
75 {:include => {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}}}}
82 '<p>' + ERB::Util.html_escape(self.caption) + '</p>'