Ad_Banner fix for FGU

Conflicts:

	app/views/front/show_banner.html.erb
	public/static/kernel.js
This commit is contained in:
Manson Wang 2013-10-14 19:07:32 +08:00
parent 3999308bb4
commit 9849b5c7dd
3 changed files with 65 additions and 57 deletions

View File

@ -220,7 +220,7 @@ module ApplicationHelper
javascripts << "<script type='text/javascript' src='/assets/orbit-bar-search.js'></script>\n" javascripts << "<script type='text/javascript' src='/assets/orbit-bar-search.js'></script>\n"
end end
javascripts << "<script type='text/javascript' src='/assets/lib/jquery.preload-min.js'></script>\n" javascripts << "<script type='text/javascript' src='/assets/lib/jquery.preload-min.js'></script>\n"
javascripts << "<script type='text/javascript' src='/static/jquery.cycle.all.latest.js'></script>\n" # javascripts << "<script type='text/javascript' src='/static/jquery.cycle.all.latest.js'></script>\n"
javascripts << "<script type='text/javascript' src='/static/kernel.js'></script>\n" javascripts << "<script type='text/javascript' src='/static/kernel.js'></script>\n"
# javascripts << "<script type='text/javascript' src='/assets/social-share-button.js'></script>\n" # javascripts << "<script type='text/javascript' src='/assets/social-share-button.js'></script>\n"
javascripts << "<script type='text/javascript' src='/assets/lib/social-share-button.js'></script>\n" javascripts << "<script type='text/javascript' src='/assets/lib/social-share-button.js'></script>\n"

View File

@ -1,4 +1,3 @@
<%= javascript_include_tag "lib/jquery.cycle.all.latest.js"%>
<div style='position:relative'> <div style='position:relative'>
<ul id='banner_nav' class='clear banner_nav-<%= @ad_banner.title.dehumanize %>'></ul> <ul id='banner_nav' class='clear banner_nav-<%= @ad_banner.title.dehumanize %>'></ul>
<div id='slideshow-<%= @ad_banner.title.dehumanize %>' class='slideshow'> <div id='slideshow-<%= @ad_banner.title.dehumanize %>' class='slideshow'>
@ -12,7 +11,11 @@
<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_loaded":0,
"time_to_next":<%= @ad_banner.transition_msec %>,
"current":0,
"best_size": "<%= @ad_banner.best_size %>"
}; };
banners.push(banner); banners.push(banner);
</script> </script>

View File

@ -1,67 +1,72 @@
var banners = []; var banners = [];
var banner_index = 0; var banner_index = 0;
$q = jQuery;
$q.getScript('/static/jquery.cycle.all.latest.js');
$(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")!=''){
if($(this).attr("path").indexOf("show_banner")>0){ if($(this).attr("path").indexOf("show_banner")>0){
ajax_load_proc($(this),$(this).attr("path"),"true"); ajax_load_proc($(this),$(this).attr("path"),"true");
}else{ }else{
ajax_load_proc($(this),$(this).attr("path"),$(this).attr("path")); ajax_load_proc($(this),$(this).attr("path"),$(this).attr("path"));
} }
}}); }});
$("#main_content").addClass("module"); $("#main_content").addClass("module");
}); });
function ajax_load_proc(wapper,url,isBanner){ 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') {
if(isBanner=="true"){ if(isBanner=="true"){
wapper.html(respText); wapper.html(respText);
setTimeout("BannerCycle()", 2500); var banner = banners[banner_index];
}else{ if($(banner.banner_name+" img").length>1){
wapper.html(respText); $(banner.banner_name+" > img").each(function(){
} $(this).load(function(){ banner.image_loaded++; });
}; });
if(textSta == 'error') BannerCycle(banner_index);
wapper.html("Loading Failed<br/> <a href='"+$(this).attr('path')+"'>Go See</a>"); }
}); banner_index++;
}else{
wapper.html(respText);
}
};
if(textSta == 'error')
wapper.html("Loading Failed<br/> <a href='"+$(this).attr('path')+"'>Go See</a>");
});
} }
function BannerCycle(){ function BannerCycle(banner_index){
var banner = banners[banner_index]; var banner = banners[banner_index];
banner_index++; if (banner.image_loaded==$(banner.banner_name+" img").length){
$(banner.banner_name).ready(function() { $q(banner.banner_name).cycle({
$(banner.banner_name).cycle({ delay: -1000,
delay: -1000, fx: banner.banner_fx,
fx: banner.banner_fx, timeout: banner.time_to_next,
timeoutFn: getTimeout, pager: banner.banner_pager,
pager: banner.banner_pager, pagerAnchorBuilder: function(idx, slide) { return "<li><a href='#'></a></li>"; }
pagerAnchorBuilder: function(idx, slide) { return "<li><a href='#'></a></li>"; } });
}); }else{
}); setTimeout("BannerCycle("+banner_index+")",500);
}
} }
// Ad Banner FX code [start]
function getTimeout() {
return $(this).attr('time_to_next');
}
$(document).ready(function() { $(document).ready(function() {
$(document).on('click', '.slideshow img', function() $(document).on('click', '.slideshow img', function()
{ {
if($(this).attr('link_url')!='') if($(this).attr('link_url')!='')
{ {
if($(this).attr('link_open')=='new_window') if($(this).attr('link_open')=='new_window')
{ {
window.open($(this).attr('link_url')); window.open($(this).attr('link_url'));
} }
else else
{ {
document.location.href=$(this).attr('link_url') document.location.href=$(this).attr('link_url')
} }
} }
}) })
}); });
// Ad Banner FX code [end] // Ad Banner FX code [end]