From e2d09c737984bfdfda47e3b671e4ab0d6131fdb3 Mon Sep 17 00:00:00 2001 From: Manson Wang Date: Mon, 30 Sep 2013 21:03:38 +0800 Subject: [PATCH] Fix Ad_Banner Loading Problem (Not complete) --- app/views/front/show_banner.html.erb | 19 +++--------- public/static/kernel.js | 46 ++++++++++++++++++++-------- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/app/views/front/show_banner.html.erb b/app/views/front/show_banner.html.erb index f06e505b6..ffbcb064a 100644 --- a/app/views/front/show_banner.html.erb +++ b/app/views/front/show_banner.html.erb @@ -10,18 +10,9 @@ diff --git a/public/static/kernel.js b/public/static/kernel.js index cef6f0661..ec2d5dc0b 100644 --- a/public/static/kernel.js +++ b/public/static/kernel.js @@ -1,23 +1,45 @@ +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') { - wapper.html(respText); - }; - if(textSta == 'error') - wapper.html("Loading Failed
Go See"); + if (textSta == 'success') { + if(isBanner=="true"){ + wapper.html(respText); + setTimeout("BannerCycle()", 2500); + }else{ + wapper.html(respText); + } + }; + if(textSta == 'error') + wapper.html("Loading Failed
Go See"); + }); +} + +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 "
  • "; } + }); }); }