X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fmodels%2Fground_picture.rb;h=3ca5a11c4a8df1704f5193aeba3d176130b07863;hb=467daaf74bbf62a7ad43d7af7fd6326bfacd9010;hp=fe67caa6bffdbfdfad91b41aed083dccb11389a0;hpb=a139b5ea7fe0f0cefa75e4fc64d8aa33029dedc4;p=pettanr%2Fpettanr.git diff --git a/app/models/ground_picture.rb b/app/models/ground_picture.rb index fe67caa6..3ca5a11c 100644 --- a/app/models/ground_picture.rb +++ b/app/models/ground_picture.rb @@ -1,6 +1,5 @@ class GroundPicture < Peta::Element load_manifest - include ElementInspire belongs_to :panel belongs_to :picture @@ -14,28 +13,18 @@ class GroundPicture < Peta::Element @@repeat_texts = ['repeat', 'repeat-x', 'repeat-y', 'no-repeat'] - def self.list_opt_for_panel - { - :ground_pictures => { - :picture => {:artist => {}, :license => {}} - } - } + def attr_y + self.attributes['y'] end - def self.show_opt_for_panel + def self.by_author_list_includes { - :ground_pictures => { - :picture => {:artist => {}, :license => {}} + :panel => { + :author => {} } } end - def self.json_opt_for_panel - { - :picture => {:artist => {}, :license => {}} - } - end - def self.has_picture? true end @@ -54,17 +43,12 @@ class GroundPicture < Peta::Element self.panel_id = pid end - def visible? operators - return false unless super - self.owner_model.visible? operators - end - def style spot = nil, opacity = 20 r = { '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 @@ -83,49 +67,14 @@ class GroundPicture < Peta::Element @@repeat_texts[self.repeat] end - def self.list_where + def self.public_list_where '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? ''