Fix for banner on ie

This commit is contained in:
Christophe Vilayphiou 2012-08-13 15:10:53 +08:00
parent c2f3f45196
commit 18e18a4add
3 changed files with 27 additions and 11 deletions

View File

@ -0,0 +1,9 @@
/**
* jQuery.Preload - Multifunctional preloader
* Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com
* Dual licensed under MIT and GPL.
* Date: 3/25/2009
* @author Ariel Flesler
* @version 1.0.8
*/
;(function($){var h=$.preload=function(c,d){if(c.split)c=$(c);d=$.extend({},h.defaults,d);var f=$.map(c,function(a){if(!a)return;if(a.split)return d.base+a+d.ext;var b=a.src||a.href;if(typeof d.placeholder=='string'&&a.src)a.src=d.placeholder;if(b&&d.find)b=b.replace(d.find,d.replace);return b||null}),data={loaded:0,failed:0,next:0,done:0,total:f.length};if(!data.total)return finish();var g=$(Array(d.threshold+1).join('<img/>')).load(handler).error(handler).bind('abort',handler).each(fetch);function handler(e){data.element=this;data.found=e.type=='load';data.image=this.src;data.index=this.index;var a=data.original=c[this.index];data[data.found?'loaded':'failed']++;data.done++;if(d.enforceCache)h.cache.push($('<img/>').attr('src',data.image)[0]);if(d.placeholder&&a.src)a.src=data.found?data.image:d.notFound||a.src;if(d.onComplete)d.onComplete(data);if(data.done<data.total)fetch(0,this);else{if(g&&g.unbind)g.unbind('load').unbind('error').unbind('abort');g=null;finish()}};function fetch(i,a,b){if(a.attachEvent&&data.next&&data.next%h.gap==0&&!b){setTimeout(function(){fetch(i,a,1)},0);return!1}if(data.next==data.total)return!1;a.index=data.next;a.src=f[data.next++];if(d.onRequest){data.index=a.index;data.element=a;data.image=a.src;data.original=c[data.next-1];d.onRequest(data)}};function finish(){if(d.onFinish)d.onFinish(data)}};h.gap=14;h.cache=[];h.defaults={threshold:2,base:'',ext:'',replace:''};$.fn.preload=function(a){h(this,a);return this}})(jQuery);

View File

@ -160,6 +160,7 @@ module ApplicationHelper
javascripts << "<script type='text/javascript' src='/assets/orbit_bar.js'></script>\n" javascripts << "<script type='text/javascript' src='/assets/orbit_bar.js'></script>\n"
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='/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"

View File

@ -44,17 +44,23 @@ module ParserCommon
ad_banner = AdBanner.find(banner["id"]) rescue nil ad_banner = AdBanner.find(banner["id"]) rescue nil
if ad_banner if ad_banner
res << "<script type='text/javascript'> res << "<script type='text/javascript'>
$(document).ready(function(){ jQuery(function( $ ){
$('#slideshow-#{ad_banner.title.dehumanize}').cycle({ $.preload( '#slideshow-#{ad_banner.title.dehumanize} img', {
delay: -1000, onFinish:finish,
fx: '#{ad_banner.ad_fx.nil? ? 'fade': ad_banner.ad_fx}', threshold: 2 //'2' is the default, how many at a time, to load.
timeoutFn: getTimeout, });
pager: '#banner_nav', function finish(){
pagerAnchorBuilder: function(idx, slide) { $('#slideshow-#{ad_banner.title.dehumanize}').cycle({
return \"<li><a href='#'></a></li>\"; delay: -1000,
} fx: '#{ad_banner.ad_fx.nil? ? 'fade': ad_banner.ad_fx}',
timeoutFn: getTimeout,
pager: '#banner_nav',
pagerAnchorBuilder: function(idx, slide) {
return \"<li><a href='#'></a></li>\";
}
});
};
}); });
});
</script>" </script>"
res << "<ul id='banner_nav' class='clear'></ul>" res << "<ul id='banner_nav' class='clear'></ul>"
res << "<div id='slideshow-#{ad_banner.title.dehumanize}' class='slideshow'>" res << "<div id='slideshow-#{ad_banner.title.dehumanize}' class='slideshow'>"
@ -74,7 +80,7 @@ module ParserCommon
res << "link_open='#{ad_image.link_open}' " res << "link_open='#{ad_image.link_open}' "
# res << "link_url='#{(ad_image.direct_to_after_click?? ad_image.out_link : ad_banner.context) || ' '}' " # res << "link_url='#{(ad_image.direct_to_after_click?? ad_image.out_link : ad_banner.context) || ' '}' "
res << "link_url='#{(ad_image.out_link)}' " res << "link_url='#{(ad_image.out_link)}' "
res << "style='cursor:pointer'" if !ad_image.out_link.blank? res << "style='cursor:pointer; visibility='hidden'" if !ad_image.out_link.blank?
res << "/>" res << "/>"
end end
res << "</div>" res << "</div>"