Fix ad_banner loading

This commit is contained in:
Christophe Vilayphiou 2012-02-27 17:48:30 +08:00
parent f13ebc6c46
commit 680b28023a
3 changed files with 7 additions and 8 deletions

View File

@ -74,7 +74,7 @@ module ParserBackEnd
ad_banner = AdBanner.find(tag.attr["id"]) rescue nil ad_banner = AdBanner.find(tag.attr["id"]) rescue nil
if ad_banner if ad_banner
res << "<script type='text/javascript'> res << "<script type='text/javascript'>
$(document).ready(function(){ $('#slideshow-#{ad_banner.title.dehumanize}').cycle({after: onAfter,timeout:1 ,fx: '#{ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx}' }); }); $(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>" </script>"
res << "<div id='slideshow-#{ad_banner.title.dehumanize}'>" res << "<div id='slideshow-#{ad_banner.title.dehumanize}'>"
ad_banner.ad_images.each do |ad_image| ad_banner.ad_images.each do |ad_image|

View File

@ -89,7 +89,7 @@ module ParserFrontEnd
ad_banner = AdBanner.find(tag.attr["id"]) rescue nil ad_banner = AdBanner.find(tag.attr["id"]) rescue nil
if ad_banner && ad_banner.display? if ad_banner && ad_banner.display?
res << "<script type='text/javascript'> res << "<script type='text/javascript'>
$(document).ready(function(){ $('#slideshow-#{ad_banner.title.dehumanize}').cycle({after: onAfter,timeout:1 ,fx: '#{ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx}' }); }); $(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>" </script>"
res << "<div id='slideshow-#{ad_banner.title.dehumanize}'>" res << "<div id='slideshow-#{ad_banner.title.dehumanize}'>"
ad_banner.ad_images.each do |ad_image| ad_banner.ad_images.each do |ad_image|

View File

@ -17,13 +17,12 @@ function ajax_load_proc(wapper,url){
wapper.html("Loading Failed"); wapper.html("Loading Failed");
}); });
} }
// Ad Banner FX code [start]
function onAfter(e) { // Ad Banner FX code [start]
var parent = $(this).parent(); function getTimeout() {
var time_to_next = $(this).attr('time_to_next'); return $(this).attr('time_to_next');
parent.cycle('pause');
setTimeout(function(){parent.cycle('resume')},time_to_next);
} }
$(document).ready(function() { $(document).ready(function() {
$('.slideshow').children('img').click(function() $('.slideshow').children('img').click(function()
{ {