Class: TaggedImageSlideshow

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/tagged_image_slideshow.rb

Constant Summary collapse

IMAGE_ZOOM_OPTIONS =
[
  ['Full Width','width'],['Height','height'],['Either','either']
]
IMAGE_ORDER_OPTIONS =
[
  ['Image Name','name'],['Image Creation Date','created_at']
]
SPEED_OPTIONS =
[
  ['1 second',1000],['1/2 second',500],['1.5 seconds',1500],['2 seconds',2000],['3 seconds',3000],['4 seconds',4000]
]
TIMEOUT_OPTIONS =
[
  ['4 seconds',4000],['1 second',1000],['2 seconds',2000],['3 seconds',3000],['5 seconds',5000],['6 seconds',6000],['7 seconds',7000],['8 seconds',8000],['9 seconds',9000],['10 seconds',10000],['15 seconds',15000],['20 seconds',20000],['30 seconds',30000],['1 minute',60000]
]
EFFECT_OPTIONS =
[
  'blindX','blindY','blindZ','cover','curtainX','curtainY','fade','fadeZoom','growX','growY','none','scrollUp','scrollDown','scrollLeft','scrollRight','scrollHorz','scrollVert','shuffle','slideX','slideY','toss','turnUp','turnDown','turnLeft','turnRight','uncover','wipe','zoom'
]

Instance Method Summary collapse

Instance Method Details

#geometryObject



32
33
34
35
36
37
38
39
40
# File 'app/models/tagged_image_slideshow.rb', line 32

def geometry
  if self.image_zoom == 'width'
    "#{width}"
  elsif self.image_zoom == 'height'
    "x#{height}"
  else
    "#{width}x#{height}"
  end
end

#imagesObject



42
43
44
45
46
47
48
49
50
# File 'app/models/tagged_image_slideshow.rb', line 42

def images
  tag_ids_to_find = self.tags.collect{|t| t.id}
  taggings = Tagging.find(:all, :conditions => {:taggable_type => 'AbstractFileBlock', :tag_id => tag_ids_to_find})
  if taggings.blank?
    nil
  else 
    taggings.collect{|t| t.taggable}.reject{|i| i.class != ImageBlock}.uniq.compact.sort_by{|im| im.send(self.image_order)}
  end
end