Fix Ad_Banner Image loading bug
This commit is contained in:
parent
35733da7ba
commit
3b0dc9cd50
|
@ -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 %>' 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 %><%= "?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? %>'/>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -11,7 +11,9 @@
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
var banner = {"banner_name":"#slideshow-<%= @ad_banner.title.dehumanize %>",
|
var banner = {"banner_name":"#slideshow-<%= @ad_banner.title.dehumanize %>",
|
||||||
"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_loaded":0
|
||||||
};
|
};
|
||||||
banners.push(banner);
|
banners.push(banner);
|
||||||
</script>
|
</script>
|
|
@ -19,7 +19,12 @@ function ajax_load_proc(wapper,url,isBanner){
|
||||||
if (textSta == 'success') {
|
if (textSta == 'success') {
|
||||||
if(isBanner=="true"){
|
if(isBanner=="true"){
|
||||||
wapper.html(respText);
|
wapper.html(respText);
|
||||||
BannerCycle();
|
var banner = banners[banner_index];
|
||||||
|
$(banner.banner_name+" > img").each(function(){
|
||||||
|
$(this).load(function(){ banner.image_loaded++; });
|
||||||
|
});
|
||||||
|
BannerCycle(banner_index);
|
||||||
|
banner_index++;
|
||||||
}else{
|
}else{
|
||||||
wapper.html(respText);
|
wapper.html(respText);
|
||||||
}
|
}
|
||||||
|
@ -29,10 +34,9 @@ function ajax_load_proc(wapper,url,isBanner){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function BannerCycle(){
|
function BannerCycle(banner_index){
|
||||||
var banner = banners[banner_index];
|
var banner = banners[banner_index];
|
||||||
banner_index++;
|
if (!!$.prototype.cycle && (banner.image_loaded==$(banner.banner_name+" img").length)){
|
||||||
$.getScript('/static/jquery.cycle.all.latest.js', function(){
|
|
||||||
$(banner.banner_name).ready(function() {
|
$(banner.banner_name).ready(function() {
|
||||||
$(banner.banner_name).cycle({
|
$(banner.banner_name).cycle({
|
||||||
delay: -1000,
|
delay: -1000,
|
||||||
|
@ -42,7 +46,10 @@ function BannerCycle(){
|
||||||
pagerAnchorBuilder: function(idx, slide) { return "<li><a href='#'></a></li>"; }
|
pagerAnchorBuilder: function(idx, slide) { return "<li><a href='#'></a></li>"; }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}else{
|
||||||
|
if(!$.prototype.cycle) $.getScript('/static/jquery.cycle.all.latest.js');
|
||||||
|
setTimeout("BannerCycle("+banner_index+")",500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ad Banner FX code [start]
|
// Ad Banner FX code [start]
|
||||||
|
|
Loading…
Reference in New Issue