Fix Ad_Banner Loading Problem (Not complete)

This commit is contained in:
Manson Wang 2013-09-30 21:03:38 +08:00
parent c5935f7104
commit 27db216d0c
2 changed files with 39 additions and 26 deletions

View File

@ -10,18 +10,9 @@
</div> </div>
</div> </div>
<script type='text/javascript'> <script type='text/javascript'>
$(document).ready(function(){ var banner = {"banner_name":"#slideshow-<%= @ad_banner.title.dehumanize %>",
jQuery(function( $ ){ "banner_fx":"<%= @ad_banner.ad_fx.nil? ? 'fade': @ad_banner.ad_fx %>",
"banner_pager":".banner_nav-<%= @ad_banner.title.dehumanize %>"
$('#slideshow-<%= @ad_banner.title.dehumanize %>').cycle({ };
delay: -1000, banners.push(banner);
fx: "<%= @ad_banner.ad_fx.nil? ? 'fade': @ad_banner.ad_fx %>",
timeoutFn: getTimeout,
pager: '.banner_nav-<%= @ad_banner.title.dehumanize %>',
pagerAnchorBuilder: function(idx, slide) {
return "<li><a href='#'></a></li>";
}
});
});
});
</script> </script>

View File

@ -1,23 +1,45 @@
var banners = [];
var banner_index = 0;
$(document).ready(function() { $(document).ready(function() {
$.each($(".dymanic_load"),function(){ $.each($(".dymanic_load"),function(){
if($(this).attr("path")==''){$(this).html("App setting Failed");} if($(this).attr("path")==''){$(this).html("App setting Failed");}
if($(this).attr("path")!=''){ if($(this).attr("path")!=''){
ajax_load_proc($(this),$(this).attr("path")); if($(this).attr("path").indexOf("show_banner")>0){
} ajax_load_proc($(this),$(this).attr("path"),"true");
}else{
ajax_load_proc($(this),$(this).attr("path"),$(this).attr("path"));
} }
); }});
$("#main_content").addClass("module"); $("#main_content").addClass("module");
}); });
function ajax_load_proc(wapper,url){ function ajax_load_proc(wapper,url,isBanner){
$.get(encodeURI(url), {}, function(respText,textSta,XML){ $.get(encodeURI(url), {}, function(respText,textSta,XML){
if (textSta == 'success') { if (textSta == 'success') {
wapper.html(respText); if(isBanner=="true"){
}; wapper.html(respText);
if(textSta == 'error') setTimeout("BannerCycle()", 2500);
wapper.html("Loading Failed<br/> <a href='"+$(this).attr('path')+"'>Go See</a>"); }else{
wapper.html(respText);
}
};
if(textSta == 'error')
wapper.html("Loading Failed<br/> <a href='"+$(this).attr('path')+"'>Go See</a>");
});
}
function BannerCycle(){
var banner = banners[banner_index];
banner_index++;
$(banner.banner_name).ready(function() {
$(banner.banner_name).cycle({
delay: -1000,
fx: banner.banner_fx,
timeoutFn: getTimeout,
pager: banner.banner_pager,
pagerAnchorBuilder: function(idx, slide) { return "<li><a href='#'></a></li>"; }
});
}); });
} }