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>
<script type='text/javascript'>
$(document).ready(function(){
jQuery(function( $ ){
$('#slideshow-<%= @ad_banner.title.dehumanize %>').cycle({
delay: -1000,
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>";
}
});
});
});
var banner = {"banner_name":"#slideshow-<%= @ad_banner.title.dehumanize %>",
"banner_fx":"<%= @ad_banner.ad_fx.nil? ? 'fade': @ad_banner.ad_fx %>",
"banner_pager":".banner_nav-<%= @ad_banner.title.dehumanize %>"
};
banners.push(banner);
</script>

View File

@ -1,26 +1,48 @@
$(document).ready(function() {
var banners = [];
var banner_index = 0;
$(document).ready(function() {
$.each($(".dymanic_load"),function(){
if($(this).attr("path")==''){$(this).html("App setting Failed");}
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");
});
});
function ajax_load_proc(wapper,url){
function ajax_load_proc(wapper,url,isBanner){
$.get(encodeURI(url), {}, function(respText,textSta,XML){
if (textSta == 'success') {
if(isBanner=="true"){
wapper.html(respText);
setTimeout("BannerCycle()", 2500);
}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>"; }
});
});
}
// Ad Banner FX code [start]
function getTimeout() {
return $(this).attr('time_to_next');