/**
* 弹出窗口
* 用于提示错误、成功信息、警告等
* 创建日期 2007-4-9
* @author Harold.HH
* @version 1.0
*/
function $(_sId){return document.getElementById(_sId)}
function dialog(){
window.ebDialog = null;
this.elt = null;
var titile = '';
var width = 300;
var height = 180;
var src = "";
var path = _contextPath+"/eb/template/OsaccBlog/images/face1/";
var sFunc = ' ';
var sClose = '';
var sBody = '\
\
|
\
\
| \
 | \
| \
| \
\
|
\
| ' + sFunc + ' |
\
|
\
\
';
var sBox = '\
\
|
\
\
\
\
\
| \
| \
\
' + sClose + '\
| \
| \
\
\
| \
\
|
\
\
| ' + sBody + ' | \
\
\
\
\
';
var sBG = '\
\
';
this.show = function(){
this.middle('dialogBox');
this.shadow();
//$('adframe').src = '/lm/iframe/20/20070406/16.html';
$("dialogBoxBG").style.width = document.body.scrollWidth;
$("dialogBoxBG").style.height = document.body.scrollHeight;
}
this.reset = function(){
$('dialogBox').style.display='none';
$('dialogBoxBG').style.display='none';
$('dialogBoxShadow').style.display = "none";
$('dialogBoxIframe').style.display = "none";
$('dialogBody').innerHTML = sBody;
changeShow();
//document.body.removeChild($('_dgc'));
//alert($('_dgc').outerHTML);//.outerHYML='';
// var elt=$('pDiv');
// if (elt)
// {
// elt.style.display = "none";
// elt.parentNode.removeChild(elt);
// window.clearInterval(timer)
// }
window.neatDialog = null;
}
this.html = function(_sHtml){$("dialogBody").innerHTML = _sHtml;this.show();}
this.init = function(){
$('dialogCase') ? $('dialogCase').parentNode.removeChild($('dialogCase')) : function(){};
var oDiv = document.createElement('div');
oDiv.id = "dialogCase";
oDiv.style.zIndex="100";
oDiv.innerHTML = sBG + sBox;
var bgDiv = document.createElement('div');
if(!document.getElementById('pDiv')){
bgDiv.id="pDiv";
bgDiv.style.position = 'absolute';
bgDiv.style.top="0px";
bgDiv.style.left="0px";
bgDiv.style.zIndex="7";
bgDiv.style.display="none";
document.body.appendChild(bgDiv);
}
bgDiv.style.width = getWinSize().width+"px";
bgDiv.style.height = getBodySize().height+"px";//document.body.clientHeight;//getBodyHeight()
this.button = function(_sId, _sFuc){
if($(_sId)){
$(_sId).style.display = '';
if($(_sId).addEventListener){
if($(_sId).act){$(_sId).removeEventListener('click', function(){eval($(_sId).act)}, false);}
$(_sId).act = _sFuc;
$(_sId).addEventListener('click', function(){check(_sFuc);}, false);
}else{
if($(_sId).act){$(_sId).detachEvent('onclick', function(){eval($(_sId).act)});}
$(_sId).act = _sFuc;
$(_sId).attachEvent('onclick', function(){check(_sFuc);});
}
}
}
this.shadow = function(){
var oShadow = $('dialogBoxShadow');
var oDialog = $('dialogBox');
var oIframe = $('dialogBoxIframe');
oShadow.style.position = "absolute";
oIframe.style.position = "absolute";
oShadow.style.background = "#000000";
oShadow.style.display = "";
oIframe.style.display = "";
oShadow.style.opacity = "0.2";
oShadow.style.filter = "alpha(opacity=20)";
oShadow.style.top = (oDialog.offsetTop + 6)+"px";
oShadow.style.left = (oDialog.offsetLeft + 6)+"px";
oShadow.style.width = oDialog.offsetWidth;
oShadow.style.height = oDialog.offsetHeight;
oIframe.style.top = oDialog.offsetTop+"px";
oIframe.style.left = oDialog.offsetLeft+"px";
oIframe.style.width = oDialog.offsetWidth+"px";
oIframe.style.height = oDialog.offsetHeight+"px";
}
this.open = function(_sUrl, _sMode){
this.show();
if(!_sMode || _sMode == "no" || _sMode == "yes"){
$("dialogBody").innerHTML = "";
}
}
this.showWindow = function(_sUrl, _iWidth, _iHeight, _sMode, _sTitle){
var oWindow;
var sLeft = (screen.width) ? (screen.width - _iWidth)/2 : 0;
var iTop = -80 + (screen.height - _iHeight)/2;
iTop = iTop > 0 ? iTop : (screen.height - _iHeight)/2;
var sTop = (screen.height) ? iTop : 0;
if(window.showModalDialog && _sMode == "m"){
oWindow = window.showModalDialog(_sUrl,_sTitle,"dialogWidth:" + _iWidth + "px;dialogheight:" + _iHeight + "px");
} else {
oWindow = window.open(_sUrl, _sTitle, 'height=' + _iHeight + ', width=' + _iWidth + ', top=' + sTop + ', left=' + sLeft + ', toolbar=no, menubar=no, scrollbars=' + _sMode + ', resizable=no,location=no, status=no');
this.reset();
}
}
this.event = function(_sMsg, _sOk, _sCancel, _sClose){
$('dialogFunc').innerHTML = sFunc;
$('dialogClose').innerHTML = sClose;
$('dialogBodyBox') == null ? $('dialogBody').innerHTML = sBody : function(){};
$('dialogMsg') ? $('dialogMsg').innerHTML = _sMsg : function(){};
_sOk && _sOk != "" ? this.button('dialogOk', _sOk)| $('dialogOk').focus() : $('dialogOk').style.display = 'none';
_sCancel && _sCancel != "" ? this.button('dialogCancel', _sCancel) : $('dialogCancel').style.display = 'none';
//_sOk ? this.button('dialogOk', _sOk) : _sOk == "" ? function(){} : $('dialogCancel').style.display = 'none';
//_sCancel ? this.button('dialogCancel', _sCancel) : _sCancel == "" ? function(){} : $('dialogCancel').style.display = 'none';
_sClose ? this.button('dialogBoxClose', _sClose) : function(){};
this.show();
this.middle('dialogBox');
}
this.set = function(_oAttr, _sVal){
var oShadow = $('dialogBoxShadow');
var oDialog = $('dialogBox');
var oHeight = $('dialogHeight');
var oIframe = $('dialogBoxIframe');
if(_sVal != ''){
switch(_oAttr){
case 'title':
$('dialogBoxTitle').innerHTML = _sVal;
title = _sVal;
break;
case 'width':
oDialog.style.width = _sVal+"px";
width = _sVal;
break;
case 'height':
oHeight.style.height = _sVal+"px";
height = _sVal;
break;
case 'src':
if(parseInt(_sVal) > 0){
$('dialogBoxFace') ? $('dialogBoxFace').src = path + _sVal + '.gif' : function(){};
}else{
$('dialogBoxFace') ? $('dialogBoxFace').src = _sVal : function(){};
}
src = _sVal;
break;
}
}
this.middle('dialogBox');
oShadow.style.top = (oDialog.offsetTop + 6)+"px";
oShadow.style.left = (oDialog.offsetLeft + 6)+"px";
oShadow.style.width = oDialog.offsetWidth+"px";
oShadow.style.height = oDialog.offsetHeight+"px";
oIframe.style.top = oDialog.offsetTop+"px";
oIframe.style.left = oDialog.offsetLeft+"px";
oIframe.style.width = oDialog.offsetWidth+"px";
oIframe.style.height = oDialog.offsetHeight+"px";
}
this.moveStart = function (e, _sId){
function fixE(e) {
if (typeof e == 'undefined') e = window.event;
if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
return e;
}
function getX(e){ return fixE(e).clientX; };
function getY(e){ return fixE(e).clientY; };
function drag(e){
v = document.getElementById(_sId);
var nX = getX(e);
var nY = getY(e);
var ll = v.rL + nX - v.oX;
var tt = v.rT + nY - v.oY;
v.style.left = ll + 'px';
v.style.top = tt + 'px';
$('dialogBoxShadow').style.left = ll + 6 +'px';
$('dialogBoxShadow').style.top = tt + 6 + 'px';
$('dialogBoxIframe').style.left = ll + 'px';
$('dialogBoxIframe').style.top = tt + 'px';
return false;
}
function end() {
document.onmousemove = null;
document.onmouseup = null;
}
v = $(_sId);
v.oX = getX(e);
v.oY = getY(e);
v.rL = parseInt(v.style.left ? v.style.left : 0);
v.rT = parseInt(v.style.top ? v.style.top : 0);
document.onmousemove = drag;
document.onmouseup = end;
return false;
}
/**
* 隐藏或显示模块,将某类型的元素设置为显示或隐藏
* @param _sType tagName
* @param _sDisplay showModel
*/
this.hideModule = function(_sType, _sDisplay){
var aIframe = parent.document.getElementsByTagName("iframe");aIframe=0;
var aType = document.getElementsByTagName(_sType);
var iChildObj, iChildLen;
for (var i = 0; i < aType.length; i++){
aType[i].style.display = _sDisplay;
}
for (var j = 0; j < aIframe.length; j++){
iChildObj = document.frames ? document.frames[j] : aIframe[j].contentWindow;
iChildLen = iChildObj.document.body.getElementsByTagName(_sType).length;
for (var k = 0; k < iChildLen; k++){
iChildObj.document.body.getElementsByTagName(_sType)[k].style.display = _sDisplay;
}
}
}
/**
* 将对象在其容器中居中显示,目前用于摆正按钮body的位置
* @param _sId 对象名称
*/
this.middle = function(_sId){
var obj = document.getElementById(_sId);
var sClientWidth = getWinSize().width;
var sClientHeight = parent ? getWinSize(parent).height - 200 : getWinSize().height ;
var sScrollTop ;//= parent ? parent.document.body.scrollTop : document.body.scrollTop;
if (document.documentElement && document.documentElement.scrollTop)
sScrollTop = document.documentElement.scrollTop;
else if (document.body) sScrollTop = document.body.scrollTop;
obj.style.display = "block";
obj.style.position = "absolute";
obj.style.left = (sClientWidth - obj.offsetWidth)<0?0:(sClientWidth - obj.offsetWidth)/2 + 'px';
obj.style.top = (sClientHeight - obj.offsetHeight)<0?0:(sClientHeight - obj.offsetHeight)/2+sScrollTop + 'px';
}
}
/**
* 得到当前窗口的body的高度
* @return body的长度 一般用于计算scroll
*/
function getBodyHeight(){
if (document.documentElement && document.documentElement.scrollTop){
return document.documentElement.scrollTop;
}
else if (document.body) {
return document.body.scrollHeight;
}
}
/**
* 得到当前窗口的大小
* @param _target window 对象
*/
function getWinSize(_target) {
var windowWidth, windowHeight;
if(_target) target = _target.document;
else target = document;
if (self.innerHeight) { //all except Explorer IE支持
if(_target) target = _target.self;
else target = self;
windowWidth = target.innerWidth;
windowHeight = target.innerHeight;
} else if (target.documentElement && target.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = target.documentElement.clientWidth;
windowHeight = target.documentElement.clientHeight;
} else if (target.body) { // other Explorers
windowWidth = target.body.clientWidth;
windowHeight = target.body.clientHeight;
}
return {width:parseInt(windowWidth),height:parseInt(windowHeight)};
}
/**
* 得到当前窗口的body的size
* getBodySize()
*/
function getBodySize(_target) {
var windowWidth, windowHeight;
if(_target) target = _target.document;
else target = document;
if(browser.isIE){
windowWidth = target.body.clientWidth;
windowHeight =target.body.clientHeight;
}else if(browser.isNS){
windowWidth = target.documentElement.scrollWidth;
windowHeight = target.documentElement.scrollHeight;//.clientHeight;
}else{
windowWidth = target.body.clientWidth;
windowHeight = target.body.clientHeight;
}
return {width:parseInt(windowWidth),height:parseInt(windowHeight)};
}
/**
* 弹出窗口的入口程序-一般用于错误显示
* @param msg 将要在弹出窗口显示的消息
* @param click ok按钮的innerHTML
* @param icon 要显示图标的名称
* @param title 窗口上方标题的显示
*/
function _error_msg_show(msg, click, icon, title)
{
click = click ? click : ' ';
icon = icon ? icon : '';
title = title ? title : '系统提示信息';
switch (icon)
{
case 'forbid':
icon = 1;
break;
case 'succ':
icon = 2;
break;
case 'smile':
icon = 3;
break;
case 'forget':
icon = 4;
break;
case 'sorry':
icon = 5;
break;
case 'care':
icon = 6;
break;
case '':
icon = 3;
break;
}
dg=new dialog();
dg.init();
dg.set('src', icon);
dg.set('title', title);
msg = ""+msg+"";//为提示信息统一加上默认的字体颜色(临时解决黑色模版下,提示信息显示不出来的问题)
dg.event(msg, click, '', click);
}
/**
* 弹出窗口的入口程序-一般用于错误信息
* @param msg 将要在弹出窗口显示的消息
* @param click ok按钮的innerHTML
* @param icon 按钮的名称
* @param top 离窗口上方的距离
* @param left 离窗口左方的距离
* @param width 宽度
* @param height 高度
*/
function _win_error_msg_show(msg, click, icon, top, left, width, height)
{
click = click ? click : ' ';
icon = icon ? icon : '';
title = '系统提示信息';
top = top ? top : 80;
switch (icon)
{
case 'forbid':
icon = 1;
break;
case 'succ':
icon = 2;
break;
case 'smile':
icon = 3;
break;
case 'forget':
icon = 4;
break;
case 'sorry':
icon = 5;
break;
case 'care':
icon = 6;
break;
case '':
icon = 5;
break;
}
dg=new dialog();
dg.init();
dg.set('src', icon);
dg.set('title', title);
if (width)
{
dg.set('width', width);
}
if (height)
{
dg.set('height', height);
}
if (left)
{
document.getElementById('dialogBox').style.left = left+"px";
document.getElementById('dialogBoxShadow').style.left = left+"px";
}
if (top)
{
document.getElementById('dialogBox').style.top = top+"px";
document.getElementById('dialogBoxShadow').style.top = top+"px";
}
dg.event(msg, click, '', click);
}
/**
* 弹出窗口的入口程序-一般用于确认
* @param msg 将要在弹出窗口显示的消息
* @param click_ok ok按钮的innerHTML
* @param clcik_no 取消按钮的innerHTML
* @param title 窗口上方标题的显示
*/
function _confirm_msg_show(msg, click_ok, click_no, title)
{
//_disabled_bg();
click_ok = click_ok ? click_ok : ' ';
click_no = click_no ? click_no : ' ';
title = title ? title : '系统提示信息';
dg=new dialog();
dg.init();
dg.set('src', 3); // smile
dg.set('title', title);
dg.event(msg, click_ok, click_no, click_no);
}
/**
* 弹出窗口的入口程序-一般用于确认
* @param msg 将要在弹出窗口显示的消息
* @param click_ok ok按钮的innerHTML
* @param clcik_no 取消按钮的innerHTML
* @param top 离窗口上方的距离
* @param left 离窗口左方的距离
* @param width 宽度
* @param height 高度
*/
function _win_confirm_msg_show(msg, click_ok, click_no, top, left, width, height)
{
click_ok = click_ok ? click_ok : ' ';
click_no = click_no ? click_no : ' ';
title = '系统提示信息';
top = top ? top : 80;
dg=new dialog();
dg.init();
dg.set('src', 3); // smile
dg.set('title', title);
if (width)
{
dg.set('width', width);
}
if (height)
{
dg.set('height', height);
}
dg.event(msg, click_ok, click_no, click_no);
if (left)
{
document.getElementById('dialogBox').style.left = left+"px";
document.getElementById('dialogBoxShadow').style.left = left+"px";
}
if (top)
{
document.getElementById('dialogBox').style.top = top+"px";
document.getElementById('dialogBoxShadow').style.top = top+"px";
}
}
var timer
var Opacity = 0
function hide() {
document.getElementById('pDiv').style.display = "block"
Opacity = 0
//changeHidden();
timer = window.setInterval("changeHidden()", 5);
}
function changeHidden()
{
/** if (Opacity == 50)
{
window.clearInterval(timer)
return
}
*/
//Opacity = 50;// ( Opacity + 50 ) > 50 ? 50 : Opacity + 3
// document.getElementById('pDiv').style.filter = "Alpha(Opacity=" + Opacity + ")"
if (Opacity >= 0.5)
{
window.clearInterval(timer)
return
}
Opacity+=0.06;
if(browser.isIE){
document.getElementById('pDiv').style.filter ="progid:DXImageTransform.Microsoft.Alpha(opacity=0,finishOpacity=50,style=0)"
//document.getElementById('pDiv').style.opacity =Opacity;
document.getElementById('pDiv').filters.item('DXImageTransform.Microsoft.Alpha').opacity=Opacity*100;
}else if(browser.isNS){
document.getElementById('pDiv').style.filter ="progid:DXImageTransform.Microsoft.Alpha(opacity=0,finishOpacity=50,style=0)"
document.getElementById('pDiv').style.opacity =Opacity;
}
document.getElementById('pDiv').style.backgroundColor="green";
}
function changeShow()
{
document.getElementById('pDiv').style.backgroundColor="";
Opacity=0;
if(browser.isIE){
document.getElementById('pDiv').filters.item('DXImageTransform.Microsoft.Alpha').opacity=Opacity*100;
}else if(browser.isNS){
document.getElementById('pDiv').style.opacity =Opacity;
}
document.getElementById('pDiv').style.display="none";
window.clearInterval(timer)
return
}
function cc()
{
timer = window.setInterval('changeShow()', 5);
}
function showWindow(_sUrl, _sWidth, _sHeight, _sTitle, _sScroll,_login)
{
var oEdit = new dialog();
oEdit.init();
if(!_login && _needlogin){
oEdit.set('title', _sTitle ? _sTitle : "系统提示信息" );
oEdit.set('width', 300);oEdit.set('height', 220);
oEdit.open(_contextPath+"/Base?tf=loginshow", _sScroll ? 'no' : 'yes');
}else{
oEdit.set('title', _sTitle ? _sTitle : "系统提示信息" );
oEdit.set('width', _sWidth);oEdit.set('height', _sHeight);
oEdit.open(_sUrl, _sScroll ? 'no' : 'yes');
window.ebDialog = oEdit;
}
return ;
}
function closWindow(){
new dialog().reset();
}