yoho_dialog.js
1.34 KB
// Lee dialog 1.0 http://www.xij.cn/blog/?p=68
var dialogFirst=true;
function dialog(title,content,width,height,cssName){
if(dialogFirst==true){
var temp_float=new String;
temp_float="<div id=\"floatBoxBg\" style=\"height:"+$(document).height()+"px;filter:alpha(opacity=0);opacity:0;\"></div>";
temp_float+="<div id=\"floatBox\" class=\"floatBox\">";
temp_float+="<div class=\"title\"><h4></h4><span class=\"dialogclose\"></span></div>";
temp_float+="<div class=\"content\"></div>";
temp_float+="</div>";
$("body").append(temp_float);
dialogFirst=false;
}
$("#floatBox .dialogclose").click(function(){
$("#floatBoxBg").animate({opacity:"0"},"normal",function(){$(this).hide();});
$("#floatBox").animate({"top":($(document).scrollTop()-(height=="auto"?300:parseInt(height)))+"px"},"normal",function(){$(this).hide();});
});
$("#floatBox .title h4").html(title);
$("#floatBox .content").html($("#"+content+"").html());
$("#floatBoxBg").show();
$("#floatBoxBg").animate({opacity:"0.9"},"normal");
$("#floatBox").attr("class","floatBox "+cssName);
$("#floatBox").css({"display":"block","left":(($(document).width())/2-(parseInt(width)/2))+"px","top":($(document).scrollTop()-(height=="auto"?300:parseInt(height)))+"px","width":width,"height":height});
$("#floatBox").animate({top:($(document).scrollTop()+50)+"px"},"normal");
}