(function($) {
$.fn.KinSlideshowNew = function(settings) {
settings = jQuery.extend({
intervalTime: 5,
moveSpeedTime: 400,
moveStyle: "left",
mouseEvent: "mouseclick",
isHasTitleBar: true,
titleBar: {
titleBar_height: 40,
titleBar_bgColor: "#000000",
titleBar_alpha: 0.5
},
isHasTitleFont: true,
titleFont: {
TitleFont_size: 12,
TitleFont_color: "#FFFFFF",
TitleFont_family: "Verdana",
TitleFont_weight: "bold"
},
isHasBtn: true,
btn: {
btn_bgColor: "#666666",
btn_bgHoverColor: "#CC0000",
btn_fontColor: "#CCCCCC",
btn_fontHoverColor: "#000000",
btn_fontFamily: "Verdana",
btn_borderColor: "#999999",
btn_borderHoverColor: "#FF0000",
btn_borderWidth: 1,
btn_bgAlpha: 0.7
}
},settings);
var titleBar_Bak = {
titleBar_height: 40,
titleBar_bgColor: "#000000",
titleBar_alpha: 0.5
}
var titleFont_Bak = {
TitleFont_size: 12,
TitleFont_color: "#FFFFFF",
TitleFont_family: "Verdana",
TitleFont_weight: "bold"
}
var btn_Bak = {
btn_bgColor: "#666666",
btn_bgHoverColor: "#CC0000",
btn_fontColor: "#CCCCCC",
btn_fontHoverColor: "#000000",
btn_fontFamily: "Verdana",
btn_borderColor: "#999999",
btn_borderHoverColor: "#FF0000",
btn_borderWidth: 1,
btn_bgAlpha: 0.7
}
for (var key in titleBar_Bak) {
if (settings.titleBar[key] == undefined) {
settings.titleBar[key] = titleBar_Bak[key];
}
}
for (var key in titleFont_Bak) {
if (settings.titleFont[key] == undefined) {
settings.titleFont[key] = titleFont_Bak[key];
}
}
for (var key in btn_Bak) {
if (settings.btn[key] == undefined) {
settings.btn[key] = btn_Bak[key];
}
}
var ksthis = this;
var ksbs = $(ksthis).selector;
var KinSlideshow_DateArray = new Array();
var KinSlideshow_imgaeLength = 0;
var KinSlideshow_Size = new Array();
var KinSlideshow_changeFlag = 0;
var KinSlideshow_IntervalTime = settings.intervalTime;
var KinSlideshow_setInterval;
var KinSlideshow_firstMoveFlag = true;
if (isNaN(KinSlideshow_IntervalTime) || KinSlideshow_IntervalTime <= 1) {
KinSlideshow_IntervalTime = 5;
}
if (settings.moveSpeedTime > 1000) {
settings.moveSpeedTime = 1000;
} else if (settings.moveSpeedTime < 100) {
settings.moveSpeedTime = 100;
}
function KinSlideshow_initialize() {
$(ksthis).css({
visibility: "hidden"
});
$(ksbs + " a img").css({
border: 0
});
KinSlideshow_start();
KinSlideshow_mousehover();
};
function KinSlideshow_start() {
KinSlideshow_imgaeLength = $(ksbs + " a").length;
KinSlideshow_Size.push($(ksbs).width());
KinSlideshow_Size.push($(ksbs).height());
$(ksbs + " a div").each(function(i) {
KinSlideshow_DateArray.push($(this).attr("alt"));
});
// $(ksbs + " a div").each(function(i) {
// $(this).css({
// "z-index":15
// });
// });
$(ksbs + " a").wrapAll("
");
//$(ksbs).find("#KinSlideshow_content").clone().attr("id", "KinSlideshow_contentClone").appendTo(ksthis);
KinSlideshow_setTitleBar();
KinSlideshow_setTitleFont();
KinSlideshow_setBtn();
KinSlideshow_action();
KinSlideshow_btnEvent(settings.mouseEvent);
$(ksthis).css({
visibility: "visible"
});
};
function KinSlideshow_setTitleBar() {
$(ksthis).css({
width: KinSlideshow_Size[0],
height: KinSlideshow_Size[1],
overflow: "hidden",
position: "relative"
});
$(ksthis).append("");
var getTitleBar_Height = settings.titleBar.titleBar_height;
if (isNaN(getTitleBar_Height)) {
getTitleBar_Height = 40;
} else if (getTitleBar_Height < 25) {
getTitleBar_Height = 25;
};
$(ksbs + " .KinSlideshow_titleBar").css({
height: getTitleBar_Height,
width: KinSlideshow_Size[0],
position: "absolute",
//bottom: 0,
left: 0,
top:KinSlideshow_Size[1]-getTitleBar_Height,
"z-index":20
});
// $(ksbs + " .KinSlideshow_titleBar").css("z-index", 300);
if (settings.isHasTitleBar) {
$(ksbs + " .KinSlideshow_titleBar").css({
background: settings.titleBar.titleBar_bgColor,
opacity: settings.titleBar.titleBar_alpha
})
};
};
function KinSlideshow_setTitleFont() {
if (settings.isHasTitleFont) {
$(ksbs + " .KinSlideshow_titleBar").append("");
$(ksbs + " .KinSlideshow_titleBar .title").css({
fontSize: settings.titleFont.TitleFont_size,
color: settings.titleFont.TitleFont_color,
fontFamily: settings.titleFont.TitleFont_family,
fontWeight: settings.titleFont.TitleFont_weight
});
setTiltFontShow(0);
};
};
function KinSlideshow_setBtn() {
if (settings.btn.btn_borderWidth > 2) {
settings.btn.btn_borderWidth = 2
}
if (settings.btn.btn_borderWidth < 0 || isNaN(settings.btn.btn_borderWidth)) {
settings.btn.btn_borderWidth = 0
}
if (settings.isHasBtn && KinSlideshow_imgaeLength >= 2) {
//alert(ksbs)
//$(ksthis).append("0000000000000000000000
");
$(ksthis).append("");
$(ksbs + " .KinSlideshow_btnBox").css({
//width: KinSlideshow_Size[0],
position: "absolute",
bottom: 5,//广告按钮居下边距离
right: 20,//广告按钮居右边距离
//top:KinSlideshow_Size[1]-25,
"z-index":199
});
var KinSlideshow_btnList = "";
for (i = 1; i <= KinSlideshow_imgaeLength; i++) {
KinSlideshow_btnList += "" + i + "";
}
KinSlideshow_btnList = "" + KinSlideshow_btnList + "
";
$(ksbs + " .KinSlideshow_btnBox").append(KinSlideshow_btnList);
$(ksbs + " .KinSlideshow_btnBox #btnlistID li").css({
listStyle: "none",
float: "left",
width: 18,
height: 18,
borderWidth: settings.btn.btn_borderWidth,
borderColor: settings.btn.btn_borderColor,
borderStyle: "solid",
background: settings.btn.btn_bgColor,
textAlign: "center",
cursor: "pointer",
marginLeft: 3,
fontSize: 12,
fontFamily: settings.btn.btn_fontFamily,
lineHeight: "18px",
opacity: settings.btn.btn_bgAlpha,
color: settings.btn.btn_fontColor
});
$(ksbs + " #btnlistID li:eq(0)").css({
background: settings.btn.btn_bgHoverColor,
borderColor: settings.btn.btn_borderHoverColor,
color: settings.btn.btn_fontHoverColor
});
};
};
function KinSlideshow_action() {
switch (settings.moveStyle) {
case "left":
settings.moveStyle = "left";
break;
case "right":
settings.moveStyle = "right";
break;
case "up":
settings.moveStyle = "up";
break;
case "down":
settings.moveStyle = "down";
break;
default:
settings.moveStyle = "up";
}
KinSlideshow_moveInit();
KinSlideshow_move(settings.moveStyle)
KinSlideStartMoveHandler();
};
function KinSlideshow_moveInit() {
$(ksbs + " div:lt(2)").html(""+$(ksbs).find("#KinSlideshow_content").html()+"
");
switch(settings.moveStyle){
case "up":
case "down":
$(ksbs).find("#KinSlideshow_moveBox").css({
width: KinSlideshow_Size[0]+"px",
height: KinSlideshow_Size[1]+"px",
overflow: "hidden",
position: "absolute",
left:"0",
"z-index":10
});
break;
case "left":
case "right":
$(ksbs).find("#KinSlideshow_moveBox").css({
width: KinSlideshow_Size[0]*KinSlideshow_imgaeLength+10+"px",
height: KinSlideshow_Size[1],
overflow: "hidden",
position: "absolute",
left:"0",
"z-index":10
});
$(ksbs).find("#KinSlideshow_moveBox").find("a div").each(function(){
$(this).css({
width: KinSlideshow_Size[0]+"px",
float: "left"
});
});
break;
}
//alert(KinSlideshow_IntervalTime * 1000 + settings.moveSpeedTime)
};
function KinSlideStartMoveHandler(){
//return;
KinSlideshow_setInterval = setInterval(function() {
KinSlideshow_move(settings.moveStyle)
},
KinSlideshow_IntervalTime * 1000 + settings.moveSpeedTime);
}
function KinSlideSopMoveHandler(){
clearInterval(KinSlideshow_setInterval);
}
function KinSlideshow_move(style) {
switch (style) {
case "left":
var sp=0;
sp = (KinSlideshow_changeFlag ) * KinSlideshow_Size[0];
$(ksbs).find("#KinSlideshow_moveBox").animate({
"left": -sp
},settings.moveSpeedTime);
//背景动画
// $(ksbs).find("#KinSlideshow_moveBox").css("opacity","0.5");
// $(ksbs).find("#KinSlideshow_moveBox").animate({
// "opacity":"1.0"
// },100);
setTiltFontShow(KinSlideshow_changeFlag);
break;
case "right":
break;
case "up":
var sp=0;
sp = (KinSlideshow_changeFlag ) * KinSlideshow_Size[1];
$(ksbs).find("#KinSlideshow_moveBox").animate({
"scrollTop": sp
},settings.moveSpeedTime);
// //背景动画
// $(ksbs).find("#KinSlideshow_moveBox").css("opacity","0.5");
// $(ksbs).find("#KinSlideshow_moveBox").animate({
// "opacity":"1.0"
// },100);
setTiltFontShow(KinSlideshow_changeFlag);
break;
case "down":
break;
}
KinSlideshow_changeFlag++;
if (KinSlideshow_changeFlag >= KinSlideshow_imgaeLength) {
KinSlideshow_changeFlag=0;
}
}
function setTiltFontShow(index) {
if (settings.isHasTitleFont) {
$(ksbs + " .KinSlideshow_titleBar h2").html(KinSlideshow_DateArray[index]);
};
$(ksbs + " #btnlistID li").each(function(i) {
if (i == index) {
$(this).css({
background: settings.btn.btn_bgHoverColor,
borderColor: settings.btn.btn_borderHoverColor,
color: settings.btn.btn_fontHoverColor
});
} else {
$(this).css({
background: settings.btn.btn_bgColor,
borderColor: settings.btn.btn_borderColor,
color: settings.btn.btn_fontColor
});
}
})
};
function KinSlideshow_btnEvent(Event) {
KinSlideshow_btnMouseclick();
};
function KinSlideshow_btnMouseclick() {
$(ksbs + " #btnlistID li").click(function() {
var curLiIndex = $(ksbs + " #btnlistID li").index($(this));
KinSlideshow_changeFlag=curLiIndex;
KinSlideshow_move(settings.moveStyle);
})
};
function KinSlideshow_mousehover() {
$(ksbs + " #btnlistID li").mouseover(function() {
KinSlideSopMoveHandler();
});
$(ksbs + " #btnlistID li").mouseout(function() {
KinSlideStartMoveHandler();
});
};
return KinSlideshow_initialize();
};
})(jQuery);
$(function(){
$("#KinSlideshowNew_81030").KinSlideshowNew({
intervalTime:5, //广告位轮播间隔时间,单位秒。
moveSpeedTime:1000 ,//图片变化时间,单位毫秒。
isHasTitleBar:false,
isHasTitleFont:false,
isHasBtn:true,
moveStyle:"left",//左右滚动
//moveStyle:"up",上下滚动。
titleBar:{titleBar_height:30, titleBar_bgColor:"#08355c",titleBar_alpha:1},
titleFont:{TitleFont_size:12,TitleFont_color:"#FFFFFF",TitleFont_weight:"normal"},
btn:{btn_bgColor:"#FFFFFF",btn_bgHoverColor:"#FF9900",btn_fontColor:"#000000",btn_fontHoverColor:"#000000",btn_borderColor:"#cccccc",btn_borderHoverColor:"#000000",btn_borderWidth:1,btn_bgAlpha:1 }
});
})