2012-01-31 10:31:31 +00:00
|
|
|
module Admin::AdBannerHelper
|
2012-04-01 15:39:49 +00:00
|
|
|
def preview_block(ad_banner)
|
|
|
|
res =''
|
|
|
|
#same code as in frontend backend parser
|
|
|
|
if ad_banner
|
|
|
|
res << "<script type='text/javascript'>
|
|
|
|
$(document).ready(function(){ $('#slideshow-#{ad_banner.title.dehumanize}').cycle({delay: -1000, fx: '#{ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx}', timeoutFn: getTimeout }); });
|
|
|
|
</script>"
|
|
|
|
res << "<div id='slideshow-#{ad_banner.title.dehumanize}'>"
|
|
|
|
printable_ad_images = []
|
|
|
|
ad_banner.ad_images.each do |ad_image|
|
|
|
|
if ad_image.display?
|
|
|
|
ad_image.weight.times do
|
|
|
|
printable_ad_images << ad_image
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
printable_ad_images.shuffle!
|
|
|
|
printable_ad_images.each do |ad_image| #TODO Need Reflact
|
|
|
|
res << "<img src='#{ad_image.file}' "
|
|
|
|
res << "alt='#{ad_image.title || ' '}' "
|
|
|
|
res << "time_to_next='#{ad_banner.transition_sec}' "
|
|
|
|
res << "link_open='#{ad_image.link_open}' "
|
|
|
|
# res << "link_url='#{(ad_image.direct_to_after_click?? ad_image.out_link : ad_banner.context) || ' '}' "
|
|
|
|
res << "link_url='#{(ad_image.out_link || ad_banner.context || ' ')}' "
|
|
|
|
res << "/>"
|
|
|
|
end
|
|
|
|
res << "</div>"
|
|
|
|
res.html_safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-01-31 10:31:31 +00:00
|
|
|
end
|