From 9849b5c7ddaa7281dd15e5cf6aae7de1a5bc8e3d Mon Sep 17 00:00:00 2001 From: Manson Wang Date: Mon, 14 Oct 2013 19:07:32 +0800 Subject: [PATCH] Ad_Banner fix for FGU Conflicts: app/views/front/show_banner.html.erb public/static/kernel.js --- app/helpers/application_helper.rb | 2 +- app/views/front/show_banner.html.erb | 7 +- public/static/kernel.js | 113 ++++++++++++++------------- 3 files changed, 65 insertions(+), 57 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4f52935fa..94e560a13 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -220,7 +220,7 @@ module ApplicationHelper javascripts << "\n" end javascripts << "\n" - javascripts << "\n" + # javascripts << "\n" javascripts << "\n" # javascripts << "\n" javascripts << "\n" diff --git a/app/views/front/show_banner.html.erb b/app/views/front/show_banner.html.erb index ffbcb064a..987511e4e 100644 --- a/app/views/front/show_banner.html.erb +++ b/app/views/front/show_banner.html.erb @@ -1,4 +1,3 @@ -<%= javascript_include_tag "lib/jquery.cycle.all.latest.js"%>
@@ -12,7 +11,11 @@ diff --git a/public/static/kernel.js b/public/static/kernel.js index ec2d5dc0b..802bef70a 100644 --- a/public/static/kernel.js +++ b/public/static/kernel.js @@ -1,67 +1,72 @@ var banners = []; var banner_index = 0; +$q = jQuery; +$q.getScript('/static/jquery.cycle.all.latest.js'); $(document).ready(function() { - $.each($(".dymanic_load"),function(){ - if($(this).attr("path")==''){$(this).html("App setting Failed");} - if($(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"); + $.each($(".dymanic_load"),function(){ + if($(this).attr("path")==''){$(this).html("App setting Failed");} + if($(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,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
Go See"); - }); + $.get(encodeURI(url), {}, function(respText,textSta,XML){ + if (textSta == 'success') { + if(isBanner=="true"){ + wapper.html(respText); + var banner = banners[banner_index]; + if($(banner.banner_name+" img").length>1){ + $(banner.banner_name+" > img").each(function(){ + $(this).load(function(){ banner.image_loaded++; }); + }); + BannerCycle(banner_index); + } + banner_index++; + }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 "
  • "; } - }); - }); +function BannerCycle(banner_index){ + var banner = banners[banner_index]; + if (banner.image_loaded==$(banner.banner_name+" img").length){ + $q(banner.banner_name).cycle({ + delay: -1000, + fx: banner.banner_fx, + timeout: banner.time_to_next, + pager: banner.banner_pager, + pagerAnchorBuilder: function(idx, slide) { return "
  • "; } + }); + }else{ + setTimeout("BannerCycle("+banner_index+")",500); + } } -// Ad Banner FX code [start] -function getTimeout() { - return $(this).attr('time_to_next'); -} - $(document).ready(function() { - $(document).on('click', '.slideshow img', function() - { - if($(this).attr('link_url')!='') - { - if($(this).attr('link_open')=='new_window') - { - window.open($(this).attr('link_url')); - } - else - { - document.location.href=$(this).attr('link_url') - } - } - }) + $(document).on('click', '.slideshow img', function() + { + if($(this).attr('link_url')!='') + { + if($(this).attr('link_open')=='new_window') + { + window.open($(this).attr('link_url')); + } + else + { + document.location.href=$(this).attr('link_url') + } + } + }) }); -// Ad Banner FX code [end] +// Ad Banner FX code [end] \ No newline at end of file