运用于特定项目环境。暂未改成普遍使用。
var imgGallary=function(){
var imgList=new Array();
var imgId=new Array();
var imgInfo=new Array();
this.push=function(id,element){
imgList.push(element);
imgId.push(id);
imgInfo.push(0);
};
this.preview=function(id){
var index=$.inArray(id,imgId);
if(index!=-1){
if(imgInfo[index]!=1){
for(var i=0;i<imgInfo.length;i++){
if(imgInfo[i]==1){
imgInfo[i]=0;
imgList[i].css("display","none");
}
}
imgInfo[index]=1;
imgList[index].css("display","block");
}
}
};
this.next=function(){
var index=$.inArray(1,imgInfo);
if(index<(imgInfo.length/2-1)){
imgInfo[index]=0;
imgList[index].css("display","none");
imgInfo[index+1]=1;
imgList[index+1].css("display","block");
}
};
this.previous=function(){
var index=$.inArray(1,imgInfo);
if(index>0){
imgInfo[index]=0;
imgList[index].css("display","none");
imgInfo[index-1]=1;
imgList[index-1].css("display","block");
}
};
};
var imgGal=new imgGallary();
$(function(){
$("#previewDialog").dialog({
title:"Image Preview",
autoOpen:false,
modal:true,
width:520,
height:520,
buttons:[
{
text:"OK",
click:function(){
$("#previewDialog").dialog("close");
}
},
{
text:"Next",
click:function(){
imgGal.next();
}
},
{
text:"Previous",
click:function(){
imgGal.previous();
}
}
]
});
});