yoho_dialog_common.js
2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// 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=\"dialogBoxBg\" style=\"height:"+$(document).height()+"px;filter:alpha(opacity=0);opacity:0;\"></div>";
temp_float+="<div id=\"dialogBox\" class=\"dialogBox\">";
temp_float+="<div class=\"dialogtitle\"><h4></h4><span class=\"dialogclose\"></span></div>";
temp_float+="<div class=\"dialogcontent\"></div>";
temp_float+="</div>";
$("body").append(temp_float);
dialogFirst=false;
}
$("#dialogBox .dialogclose").click(function(){
$("#dialogBoxBg").animate({opacity:"0"},"normal",function(){$(this).hide();});
$("#dialogBox").animate({top:($(document).scrollTop()-(height=="auto"?300:parseInt(height)))+"px"},"normal",function(){$(this).hide();});
});
function closeDialog() {
$("#dialogBoxBg").animate({opacity:"0"},"normal",function(){$(this).hide();});
$("#dialogBox").animate({top:($(document).scrollTop()-(height=="auto"?300:parseInt(height)))+"px"},"normal",function(){$(this).hide();});
}
$("#dialogBox .dialogtitle h4").html(title);
contentType=content.substring(0,content.indexOf(":"));
content=content.substring(content.indexOf(":")+1,content.length);
switch(contentType){
case "url":
var content_array=content.split("?");
$("#dialogBox .dialogcontent").ajaxStart(function(){
$(this).html("loading...");
});
$.ajax({
type:content_array[0],
url:content_array[1],
data:content_array[2],
error:function(){
$("#dialogBox .dialogcontent").html("error...");
},
success:function(html){
$("#dialogBox .dialogcontent").html(html);
}
});
break;
case "text":
$("#dialogBox .dialogcontent").html(content);
break;
case "id":
$("#dialogBox .dialogcontent").html($("#"+content+"").html());
break;
case "iframe":
$("#dialogBox .dialogcontent").html("<iframe src=\""+content+"\" width=\"100%\" height=\""+(parseInt(height)-30)+"px"+"\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");
}
$("#dialogBoxBg").show();
$("#dialogBoxBg").animate({opacity:"0.9"},"normal");
$("#dialogBox").attr("class","dialogBox "+cssName);
$("#dialogBox").css({display:"block",left:(($(document).width())/2-(parseInt(width)/2))+"px",top:($(document).scrollTop()-(height=="auto"?300:parseInt(height)))+"px",width:width,height:height});
$("#dialogBox").animate({top:($(document).scrollTop()+50)+"px"},"normal");
}