///-------------------------------------------------------------------------
//jQuery弹出窗口 By Await [2009-11-22]
//--------------------------------------------------------------------------
/*参数:[可选参数在调用时可写可不写,其他为必写]
----------------------------------------------------------------------------
title: 窗口标题
content: 内容(可选内容为){ text | id | img | url | iframe }
width: 内容宽度
height: 内容高度
drag: 是否可以拖动(ture为是,false为否)
time: 自动关闭等待的时间,为空是则不自动关闭
showbg: [可选参数]设置是否显示遮罩层(0为不显示,1为显示)
cssName: [可选参数]附加class名称
------------------------------------------------------------------------*/
//示例:
//------------------------------------------------------------------------
//simpleWindown("例子","text:例子","500","400","true","3000","0","exa")
//------------------------------------------------------------------------
var showWindown = true;
var templateSrc = ""; //设置loading.gif路径
if (top.location.host == "localhost:54447")
templateSrc = "http://localhost:1976/Resources/Resources/images/tipsWindown";
else
templateSrc = "http://oa.yafco.com/Resources/Resources/images/tipsWindown";
//function tipsWindown(title, content, width, height, drag, time, showbg, cssName) {
// self.parent.parentTisWin(title, content, width, height, drag, time, showbg, cssName);
//}
function tipsWindown(title, content, width, height, drag, time, showbg, cssName) {
$("#windown-box").remove(); //请除内容
//var width = width >= 950 ? this.width = 950 : this.width = width; //设置最大窗口宽度
//var height = height >= 527 ? this.height = 527 : this.height = height; //设置最大窗口高度
this.width = width;
this.height = height;
if (showWindown == true) {
var simpleWindown_html = new String;
simpleWindown_html = "<div id=/"windownbg/" style=/"height:" + $(self.parent.document).height() + "px;filter:alpha(opacity=0);opacity:0;z-index: 100;/"></div>";
//simpleWindown_html = "<div id=/"windownbg/" style=/"height:" + $(window.parent.document).height() + "px;filter:alpha(opacity=0);opacity:0;z-index: 999901/"></div>";
simpleWindown_html += "<div class='fixedSelect'><iframe></iframe></div>";
simpleWindown_html += "<div id=/"windown-box/" style='width:"+this.width+"px;'>";
simpleWindown_html += "<table cellpadding=/"0/" cellspacing=/"0/" width='100%'>";
simpleWindown_html += "<tr><td id=/"windown-title/"><h2></h2><span id=/"windown-close/">关闭</span></td></tr>";
simpleWindown_html += "<tr><td id=/"windown-content-border/"><div id=/"windown-content/"></div></td></tr>";
simpleWindown_html += "</table>";
//simpleWindown_html += "<div id=/"windown-title/"><h2></h2><span id=/"windown-close/">关闭</span></div>";
//simpleWindown_html += "<div id=/"windown-content-border/"><div id=/"windown-content/"></div></div>";
simpleWindown_html += "</div>";
$("body", self.parent.document).append(simpleWindown_html);
show = false;
}
contentType = content.substring(0, content.indexOf(":"));
content = content.substring(content.indexOf(":") + 1, content.length);
//content = "http://www.baidu.com";
switch (contentType) {
case "text":
$(window.parent.document).find("#windown-content").html(content);
break;
case "id":
$(window.parent.document).find("#windown-content").html($("#" + content + "").html());
break;
case "img":
$(window.parent.document).find("#windown-content").ajaxStart(function () {
$(window.parent.document).find(this).html("<img src='" + templateSrc + "/loading.gif' class='loading' />");
});
$.ajax({
error: function() {
$(window.parent.document).find("#windown-content").html("<p class='windown-error'>加载数据出错0...</p>");
},
success: function(html) {
$(window.parent.document).find("#windown-content").html("<img src=" + content + " alt='' />");
}
});
break;
case "url":
var content_array = content.split("?");
$(window.parent.document).find("#windown-content").ajaxStart(function () {
$(window.parent.document).find(this).html("<img src='" + templateSrc + "/loading.gif' class='loading' />");
});
$.ajax({
type: content_array[0],
url: content_array[1],
data: content_array[2],
error: function() {
$(window.parent.document).find("#windown-content").html("<p class='windown-error'>加载数据出错1...</p>");
},
success: function(html) {
$(window.parent.document).find("#windown-content").html(html);
}
});
break;
case "iframe":
$(window.parent.document).find("#windown-content").ajaxStart(function () {
$(this).html("<img src='" + templateSrc + "/loading.gif' class='loading' />");
});
$.ajax({
error: function() {
$(window.parent.document).find("#windown-content").html("<p class='windown-error'>加载数据出错2...</p>");
},
success: function(html) {
$(window.parent.document).find("#windown-content").html("<iframe id=/"windown-box_iframe/" name=/"windown-box_iframe/" src=/"" + content + "/" width=/"100%/" height=/"" + parseInt(height) + "px" + "/" scrolling=/"auto/" frameborder=/"0/" marginheight=/"0/" marginwidth=/"0/"></iframe>");
}
});
default:
break;
}
$(window.parent.document).find("#windown-title h2").html(title);
if (showbg == "true") {
$(window.parent.document).find("#windownbg").show();
$(window.parent.document).find("#windownbg").css("width", $(self.parent.window).width()).css("height", Math.max(parent.document.body.scrollHeight, $(self.parent.window).height()));
$(window.parent.document).find(".fixedSelect iframe").css("width", $(window).width()).css("height", $(window).height());
}
else {
$(window.parent.document).find("#windownbg").remove();
};
$(window.parent.document).find("#windown-box").show();
$(window.parent.document).find("#windownbg").animate({ opacity: "0.5" }, 0); //设置透明度
/*if (height >= 527) {
$("#windown-title").css({
width: (parseInt(width) + 22) + "px"
});
$("#windown-content").css({
width: (parseInt(width) + 10) + "px",
//width: "100%",
height: height + "px"
});
}
else {
$("#windown-title").css({
width: (parseInt(width) + 10) + "px"
});
$("#windown-content").css({
width: width + "px",
//width: "100%",
height: height + "px"
});
}*/
//var cw = document.documentElement.clientWidth, ch = document.documentElement.clientHeight, est = document.documentElement.scrollTop;
/*var _version = $.browser.version;
if (_version == 6.0) {
$("#windown-box").css({
left: "50%",
top: "50%",
//top: (parseInt((ch) / 2) + est) + "px",
marginTop: -((parseInt(height) + 53) / 2) + "px",
marginLeft: -((parseInt(width) + 32) / 2) + "px",
zIndex: "999"
});
}
else {*/
$(window.parent.document).find("#windown-box").css({
left: "50%",
top: "50%",
marginTop: -((parseInt(height) + 53) / 2) + "px",
marginLeft: -((parseInt(width) + 32) / 2) + "px",
zIndex: "999"
});
//};
//var Drag_ID = document.getElementById("windown-box"), DragHead = document.getElementById("windown-title");
$(window.parent.document).find("#windown-box").draggable({ handle: '#windown-box', delay: 0 }); //#windown-title
$(window.parent.document).find("#windown-content").attr("class", "windown-" + cssName);
var closeWindown = function() {
$(window.parent.document).find("#windownbg").remove();
$(window.parent.document).find(".fixedSelect").remove();
$(window.parent.document).find("#windown-box").fadeOut("slow", function () {
$(this).remove();
});
}
if (time == "" || typeof (time) == "undefined") {
$(window.parent.document).find("#windown-close").click(function () {
var frmWindow = getFrameWindow("windown-box_iframe");
if (frmWindow) {
if (!frmWindow.Dlg_Close()) return;
}
$(window.parent.document).find("#windownbg").remove();
$(window.parent.document).find(".fixedSelect").remove();
$(window.parent.document).find("#windown-box").fadeOut("slow", function () {
$(this).remove();
});
});
}
else {
setTimeout(closeWindown, time);
}
}