+ '/pictures/' + self.filename
+ end
+
+ def opt_div_style
+ "top:#{self.y}px; left:#{self.x}px; z-index:#{self.z}; position: absolute;"
+ end
+
+ def opt_img_tag spot = nil, opacity = 20
+ o = (spot and spot != self) ? "opacity: #{opacity.to_f/100}; filter:alpha(opacity=#{opacity});" : ''
+ self.tag_attributes(:img, {
+ :class => "panel-picture", :vPicture => self.id,
+ :src => self.url, :width => self.width.abs, :height => self.height.abs, :picture_id => self.picture_id, :ext => self.picture.ext, :alt => self.caption,
+ :style => "#{o}"
+ })
+ end
+
+ def tmb_opt_img_tag
+ tw, th = PettanImager.thumbnail_size(self.width.abs, self.height.abs)
+ {:src => self.url, :width => tw, :height => th, :alt => self.caption}
+ end
+
+ def symbol_option
+ self.picture.symbol_option
+ end
+
+ def self.public_list_where
+ 'panels.publish > 0'
+ end
+
+ def self.list_order
+ 'panel_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.panel_pictures.build(self.attributes)
+ else
+ self.panel.panel_pictures.each do |panel_picture|
+ next unless panel_picture == self
+ attr = self.attributes
+ attr.delete 'id'
+ panel_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?
+ ''
+ else
+ '<p>' + ERB::Util.html_escape(self.caption) + '</p>'
+ end
+ end
+
+ def plain_scenario
+ if caption.blank?
+ ''
+ else
+ self.caption + "\n"
+ end