Orbit/public/static/kernel.js

114 lines
3.1 KiB
JavaScript
Raw Permalink Normal View History

var banners = [];
var banner_index = 0;
2013-10-14 11:07:32 +00:00
$q = jQuery;
$q.getScript('/static/jquery.cycle.all.latest.js');
$(document).ready(function() {
$.each($(".dymanic_load"),function(){
2011-12-23 10:34:21 +00:00
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"));
2011-12-23 10:34:21 +00:00
}
}});
2011-11-19 17:26:24 +00:00
$("#main_content").addClass("module");
});
2011-12-23 10:34:21 +00:00
function ajax_load_proc(wapper,url,isBanner){
2012-12-24 07:22:26 +00:00
$.get(encodeURI(url), {}, function(respText,textSta,XML){
if (textSta == 'success') {
if(isBanner=="true"){
wapper.html(respText);
2013-10-14 01:52:14 +00:00
var banner = banners[banner_index];
$(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<br/> <a href='"+$(this).attr('path')+"'>Go See</a>");
});
}
2013-10-14 01:52:14 +00:00
function BannerCycle(banner_index){
var banner = banners[banner_index];
2013-10-14 11:07:32 +00:00
if (banner.image_loaded==$(banner.banner_name+" img").length){
if(banner.banner_name=="#slideshow-banner"){
$q(banner.banner_name).cycle({
2013-10-02 07:51:22 +00:00
delay: -1000,
fx: banner.banner_fx,
2013-10-14 11:07:32 +00:00
timeout: banner.time_to_next,
2013-10-02 07:51:22 +00:00
pager: banner.banner_pager,
pagerAnchorBuilder: function(idx, slide) { return "<li><a href='#'></a></li>"; }
});
2013-10-14 11:07:32 +00:00
}else{
var width = banner.best_size.split(" x ")[0];
var height = banner.best_size.split(" x ")[1];
$(banner.banner_name).css( "width", width);
$(banner.banner_name).css( "height", height);
$(banner.banner_name).css( "display", "block");
$(banner.banner_name).css( "overflow", "hidden");
$(banner.banner_name+" > img").each(function(){
$( this ).css( "position", "absolute" );
$( this ).css( "top", "0" );
$( this ).css( "left", "0" );
$( this ).css( "display", "block" );
});
if($(banner.banner_name+" > img").length>1) OrbitCycle(banner_index);
}
2013-10-14 01:52:14 +00:00
}else{
setTimeout("BannerCycle("+banner_index+")",500);
}
}
2012-02-27 09:48:30 +00:00
2013-10-14 11:07:32 +00:00
function OrbitCycle(banner_index){
var banner = banners[banner_index];
var index = 0;
$(banner.banner_name+" > img").each(function(){
if(index==banner.current){
2013-10-18 07:54:50 +00:00
$( this ).css( "z-index", $(banner.banner_name+" img").length+1);
2013-10-14 11:07:32 +00:00
$(this).fadeTo( "slow" , 1);
}else{
2013-10-18 07:54:50 +00:00
$( this ).css( "z-index", index);
2013-10-14 11:07:32 +00:00
$(this).fadeTo( "slow" , 0);
}
index++;
});
if((banner.current+1)<$(banner.banner_name+" img").length){
banner.current++;
}else{
banner.current=0;
}
// console.log("OrbitCycle: "+banner_index);
setTimeout("OrbitCycle("+banner_index+")",banner.time_to_next);
}
2012-02-27 09:48:30 +00:00
// Ad Banner FX code [start]
function getTimeout() {
return $(this).attr('time_to_next');
}
2012-02-27 09:48:30 +00:00
$(document).ready(function() {
$(document).on('click', '.slideshow img', function()
{
2012-08-13 03:03:11 +00:00
if($(this).attr('link_url')!='')
{
2012-08-13 03:03:11 +00:00
if($(this).attr('link_open')=='new_window')
{
window.open($(this).attr('link_url'));
}
2012-08-13 03:03:11 +00:00
else
{
document.location.href=$(this).attr('link_url')
}
2012-08-13 03:03:11 +00:00
}
})
});
2013-10-14 01:52:14 +00:00
// Ad Banner FX code [end]