Ad_Banner fix for FGU

This commit is contained in:
Manson Wang 2013-10-14 19:07:32 +08:00
parent 3b0dc9cd50
commit 56ef57cdd8
3 changed files with 48 additions and 9 deletions

View File

@ -220,7 +220,7 @@ module ApplicationHelper
javascripts << "<script type='text/javascript' src='/assets/orbit-bar-search.js'></script>\n" javascripts << "<script type='text/javascript' src='/assets/orbit-bar-search.js'></script>\n"
end end
javascripts << "<script type='text/javascript' src='/assets/lib/jquery.preload-min.js'></script>\n" javascripts << "<script type='text/javascript' src='/assets/lib/jquery.preload-min.js'></script>\n"
javascripts << "<script type='text/javascript' src='/static/jquery.cycle.all.latest.js'></script>\n" # javascripts << "<script type='text/javascript' src='/static/jquery.cycle.all.latest.js'></script>\n"
javascripts << "<script type='text/javascript' src='/static/kernel.js'></script>\n" javascripts << "<script type='text/javascript' src='/static/kernel.js'></script>\n"
# javascripts << "<script type='text/javascript' src='/assets/social-share-button.js'></script>\n" # javascripts << "<script type='text/javascript' src='/assets/social-share-button.js'></script>\n"
javascripts << "<script type='text/javascript' src='/assets/lib/social-share-button.js'></script>\n" javascripts << "<script type='text/javascript' src='/assets/lib/social-share-button.js'></script>\n"

View File

@ -3,7 +3,7 @@
<div id='slideshow-<%= @ad_banner.title.dehumanize %>' class='slideshow'> <div id='slideshow-<%= @ad_banner.title.dehumanize %>' class='slideshow'>
<% (images = @ad_banner.ad_images).shuffle.each do |ad_image| %> <% (images = @ad_banner.ad_images).shuffle.each do |ad_image| %>
<% if ad_image.display? %> <% if ad_image.display? %>
<img src='<%= ad_image.file %><%= "?update=".to_s << Time.now().to_i.to_s %>' alt='<%= ad_image.title || ' ' %>' title='<%= ad_image.title || ' ' %>' time_to_next='<%= @ad_banner.transition_msec %>' link_open='<%= ad_image.link_open %>' link_url='<%= ad_image_link(ad_image) %>' style=' <%= 'cursor:pointer;' if !ad_image_link(ad_image).blank? %>'/> <img src='<%= ad_image.file %>' alt='<%= ad_image.title || ' ' %>' title='<%= ad_image.title || ' ' %>' time_to_next='<%= @ad_banner.transition_msec %>' link_open='<%= ad_image.link_open %>' link_url='<%= ad_image_link(ad_image) %>' style=' <%= 'cursor:pointer;' if !ad_image_link(ad_image).blank? %>'/>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
@ -13,7 +13,10 @@
"banner_fx":"<%= @ad_banner.ad_fx.nil? ? 'fade': @ad_banner.ad_fx %>", "banner_fx":"<%= @ad_banner.ad_fx.nil? ? 'fade': @ad_banner.ad_fx %>",
"banner_pager":".banner_nav-<%= @ad_banner.title.dehumanize %>", "banner_pager":".banner_nav-<%= @ad_banner.title.dehumanize %>",
"image_count":"<%= @ad_banner.ad_images.length %>", "image_count":"<%= @ad_banner.ad_images.length %>",
"image_loaded":0 "image_loaded":0,
"time_to_next":<%= @ad_banner.transition_msec %>,
"current":0,
"best_size": "<%= @ad_banner.best_size %>"
}; };
banners.push(banner); banners.push(banner);
</script> </script>

View File

@ -1,5 +1,7 @@
var banners = []; var banners = [];
var banner_index = 0; var banner_index = 0;
$q = jQuery;
$q.getScript('/static/jquery.cycle.all.latest.js');
$(document).ready(function() { $(document).ready(function() {
$.each($(".dymanic_load"),function(){ $.each($(".dymanic_load"),function(){
@ -36,22 +38,56 @@ function ajax_load_proc(wapper,url,isBanner){
function BannerCycle(banner_index){ function BannerCycle(banner_index){
var banner = banners[banner_index]; var banner = banners[banner_index];
if (!!$.prototype.cycle && (banner.image_loaded==$(banner.banner_name+" img").length)){ if (banner.image_loaded==$(banner.banner_name+" img").length){
$(banner.banner_name).ready(function() { if(banner.banner_name=="#slideshow-banner"){
$(banner.banner_name).cycle({ $q(banner.banner_name).cycle({
delay: -1000, delay: -1000,
fx: banner.banner_fx, fx: banner.banner_fx,
timeoutFn: getTimeout, timeout: banner.time_to_next,
pager: banner.banner_pager, pager: banner.banner_pager,
pagerAnchorBuilder: function(idx, slide) { return "<li><a href='#'></a></li>"; } pagerAnchorBuilder: function(idx, slide) { return "<li><a href='#'></a></li>"; }
}); });
});
}else{ }else{
if(!$.prototype.cycle) $.getScript('/static/jquery.cycle.all.latest.js'); var width = banner.best_size.split(" x ")[0];
var height = banner.best_size.split(" x ")[1];
$(banner.banner_name).css( "width", width);
$(banner.banner_name).css( "height", height);
$(banner.banner_name).css( "display", "block");
$(banner.banner_name).css( "overflow", "hidden");
$(banner.banner_name+" > img").each(function(){
$( this ).css( "position", "absolute" );
$( this ).css( "top", "0" );
$( this ).css( "left", "0" );
$( this ).css( "display", "block" );
});
if($(banner.banner_name+" > img").length>1) OrbitCycle(banner_index);
}
}else{
setTimeout("BannerCycle("+banner_index+")",500); setTimeout("BannerCycle("+banner_index+")",500);
} }
} }
function OrbitCycle(banner_index){
var banner = banners[banner_index];
var index = 0;
$(banner.banner_name+" > img").each(function(){
if(index==banner.current){
$(this).fadeTo( "slow" , 1);
}else{
$(this).fadeTo( "slow" , 0);
}
index++;
});
if((banner.current+1)<$(banner.banner_name+" img").length){
banner.current++;
}else{
banner.current=0;
}
// console.log("OrbitCycle: "+banner_index);
setTimeout("OrbitCycle("+banner_index+")",banner.time_to_next);
}
// Ad Banner FX code [start] // Ad Banner FX code [start]
function getTimeout() { function getTimeout() {
return $(this).attr('time_to_next'); return $(this).attr('time_to_next');