You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.7 KiB
JavaScript
88 lines
2.7 KiB
JavaScript
// JavaScript Document
|
|
|
|
var gearFlash_CJ = function(DivWidth,DivHeight)
|
|
{
|
|
var arrStrImgSrc = new Array();arrStrTxt = new Array();
|
|
var StrMenu = "";
|
|
this.MaxCount = 3;
|
|
this.DivWidth = DivWidth;
|
|
this.DivHeight = DivHeight;
|
|
this.StrImgSrc = "";
|
|
this.StrTxt = "";
|
|
this.intSpeed = "300,2000";
|
|
|
|
this.DivConfig = function(DivWidth,DivHeight)
|
|
{
|
|
/*==================================================================*/
|
|
if(DivWidth==undefined || !DivHeight==undefined)
|
|
{
|
|
// 未设置轮播大小
|
|
return "Flash error 1";
|
|
}
|
|
$("#gearFlashDiv").css({width:DivWidth,height:DivHeight});
|
|
/*==================================================================*/
|
|
arrStrImgSrc = this.StrImgSrc.split("|");
|
|
arrStrTxt = this.StrTxt.split("|");
|
|
|
|
if(arrStrImgSrc.length != this.MaxCount)
|
|
{
|
|
// 设置轮播数与实际存放路径数不符
|
|
return "Flash error 2";
|
|
}
|
|
for(m=1;m<=this.MaxCount;m++)
|
|
{
|
|
if(m==1){var tmpActive = "class='active'";}else{tmpActive = "";}
|
|
StrMenu += "<span id=\"gearFlashMenu_"+m+"\" "+tmpActive+">"+m+"</span>";
|
|
}
|
|
$("#gearFlashMenu").html(StrMenu);
|
|
/*==================================================================*/
|
|
if(arrStrTxt.length != this.MaxCount)
|
|
{
|
|
// 设置轮播数与实际标题文字数不符
|
|
return "Flash error 3";
|
|
}
|
|
else return true;
|
|
/*==================================================================*/
|
|
}
|
|
this.PlaySwf = function()
|
|
{
|
|
var tmp = this.DivConfig(this.DivWidth,this.Height);
|
|
if(tmp != true)
|
|
{
|
|
//alert(tmp);
|
|
return false;
|
|
}
|
|
|
|
$("#gearFlashImg img").attr("src",arrStrImgSrc[0]).css({width:DivWidth,height:DivHeight});
|
|
$("#gearFlashWords").html(arrStrTxt[0]);
|
|
|
|
var arrintSpeed = this.intSpeed.split(",");
|
|
|
|
$("#gearFlashMenu span").click(function(){
|
|
$("#gearFlashMenu span").removeClass("active");
|
|
$(this).addClass("active");
|
|
var id = $(this).attr("id").split("_")[1];
|
|
$("#gearFlashImg img").fadeOut(arrintSpeed[0],function(){$(this).attr("src",arrStrImgSrc[id-1])}).fadeIn(arrintSpeed[0]);
|
|
$("#gearFlashWords").slideUp(arrintSpeed[0],function()
|
|
{
|
|
document.getElementById("gearFlashWords").innerHTML = arrStrTxt[id-1];
|
|
}).slideDown(arrintSpeed[0]);
|
|
});
|
|
//链接点击停止播放
|
|
$("a").click(function(){_clearInterval = clearInterval(_interval);});
|
|
$("#gearFlashDiv").mouseover(function(){
|
|
_clearInterval = clearInterval(_interval);
|
|
}).mouseout(function(){
|
|
_interval = setInterval("gearFlashPlay("+this.MaxCount+")",arrintSpeed[1]);
|
|
})
|
|
_interval = setInterval("gearFlashPlay("+this.MaxCount+")",arrintSpeed[1]);
|
|
}
|
|
}
|
|
|
|
function gearFlashPlay(int){
|
|
var maxid = int;
|
|
var id = parseInt($("#gearFlashMenu").find(".active").attr("id").split("_")[1]) + 1;
|
|
if(id > maxid){id = 1};
|
|
$("#gearFlashMenu_"+(id)).click();
|
|
}
|