/*---------- Show Dialogue Function ZHIYING on Oct. 1st, 2008
add dialog box width,height parameter on March 10, 2009
dialog(w,h);showDialog(...,w,h)
Confirmation parameter added:
example:
showDialog(' Are you sure you want to delete selected document(s)?',3,7,this,355,150); in CSA My Draft view
need to set a doAction() function in current form's header
---------------------------------------------------------------*/
var closeYN = true; //to validate the dropdown list before click ok button
var boxTitle = "";
function dialog(w,h)
{
var dbw = "i-sight/dcjis.nsf";
var boxTitleBgImg = "images/table_top_bg.gif";
var blankBgImg = "images/blank.gif";
var closeImg_0 = "images/dialog_Close_0.gif";
var closeImg_1 = "images/dialog_Close_1.gif";
var shadowPx = 2;
var boxWidth = w; //default 450;
var boxHeight =h; //default 260;
var divBg = '\
\
';
var divShadow = '\
\
';
var divTitle = '\
\
' + boxTitle + ' \
\
\
';
var divContent = '\
\
\
\
\
';
var divButton = '\
\
\
\
\
';
var divBox = '\
\
' + divTitle + '\
' + divContent + '\
' + divButton + '\
\
';
function $(_sId)
{
return window.top.document.getElementById(_sId);
}
//Show Dialogue box
this.showBox = function(_sMsg, _sImg, _sOk, _sCancel)
{
this.init();
$('dialogBoxMsg').innerHTML = _sMsg;
$('dialogBoxMsgImg') ? $('dialogBoxMsgImg').src = '/'+dbw+'/images/' + _sImg + '.gif' : function(){};
_sOk && _sOk != "" ? this.button('buttonOk', _sOk) : $('buttonOk').style.display = 'none';
_sCancel && _sCancel != "" ? this.button('buttonCancel', _sCancel) : $('buttonCancel').style.display = 'none';
//$('buttonOk').focus();
}
//Dialogue Box Appearing Setup
this.boxSet = function()
{
var obj = $('dialogBox');
obj['style']['background'] = "#ffffff";
obj['style']['z-index'] = 10;
obj['style']['border'] = "1px solid #336699";
obj['style']['width'] = boxWidth + "px";
obj['style']['height'] = boxHeight + "px";
obj['style']['display'] = "";
}
//Dialogue Box Title Appearing Setup
this.titleSet = function()
{
var obj = $('dialogBoxTitle');
obj['style']['color'] = "#ffffff";
obj['style']['background']= "url(/" +dbw + '/'+ boxTitleBgImg +")";
obj['style']['height'] = "12px";
obj['style']['width'] = boxWidth + "px";
obj['style']['padding'] = "6px 8px";
obj['style']['cursor'] = "move";
obj['style']['display'] = "";
}
//Dialogue Box Close Button Appearing Setup
this.closeSet = function()
{
var obj = $('dialogBoxClose');
obj['style']['width']= "14px";
obj['style']['height'] = "14px";
obj['style']['cursor'] = "pointer";
obj['style']['display'] = "";
}
//Dialogue Box Ok Button Appearing Setup
this.okSet = function()
{
var obj = $('buttonOk');
obj['style']['cursor'] = "pointer";
obj['style']['width'] = "50px";
obj['style']['margin'] = "auto";
obj['style']['padding'] = "2px 2px 2px 2px";
obj['style']['font'] = "normal 10px Verdana";
obj['style']['color'] = "#001037";
obj['style']['border'] = "1px solid #245487";
obj['style']['background'] = "#F7FCFF";
}
//Dialogue Box Cancel Button Appearing Setup
this.cancelSet = function()
{
var obj = $('buttonCancel');
obj['style']['cursor'] = "pointer";
obj['style']['width']= "50px";
obj['style']['padding'] = "2px 2px 2px 2px";
obj['style']['font'] = "normal 10px Verdana";
obj['style']['color'] = "#001037";
obj['style']['border'] = "1px solid #245487";
obj['style']['background'] = "#F7FCFF";
}
//Dialogue Box Content Appearing Setup
this.contentSet = function()
{
var obj = $('dialogBoxContent');
obj['style']['width'] = boxWidth + "px";
obj['style']['height'] = "75%";
obj['style']['overflow'] = "auto";
obj['style']['display'] = "";
}
//Dialogue Box Image Appearing Setup
this.msgImgSet = function()
{
var obj = $('dialogBoxMsgImg');
obj['style']['position'] = "relative";
obj['style']['left'] = "2px";
obj['style']['top'] = "2px";
obj['style']['display'] = "";
}
//Dialogue Box Text Message Appearing Setup
this.msgSet = function()
{
var obj = $('dialogBoxMsg');
obj['style']['width'] = boxWidth - 30 + "px";
obj['style']['padding'] = "2px 5px 5px 5px";
obj['style']['font'] = "normal 10px Verdana";
obj['style']['color'] = "#001037";
obj['style']['display'] = "";
}
//Dialogue Box Shadow Appearing Setup
this.shadowSet = function()
{
var obj = $('dialogBoxShadow');
var objDialog = $('dialogBox');
obj['style']['position'] = "absolute";
obj['style']['background']= "#000000";
obj['style']['z-index']= 9;
obj['style']['opacity']= "0.2";
obj['style']['filter'] = "alpha(opacity=30)";
obj['style']['top'] = objDialog.offsetTop + shadowPx +"px";
obj['style']['left'] = objDialog.offsetLeft + shadowPx + "px";
obj['style']['width'] = boxWidth + "px";
obj['style']['height'] = boxHeight + "px";
obj['style']['display'] = "";
}
//Main Window (Opener) Background Appearing Setup
this.bgSet = function()
{
var obj = $('dialogBoxBg');
obj['style']['position'] = "absolute";
obj['style']['background'] = "#000000 url(/"+ dbw + '/' + blankBgImg + ")";
obj['style']['z-index'] = 8;
obj['style']['top'] = "0px";
obj['style']['left'] = "0px";
obj['style']['width'] = "100%";
obj['style']['height'] = window.top.document.body.scrollHeight + "px";
obj['style']['height'] = "100%";
obj['style']['display'] = "";
obj['style']['filter'] = "alpha(opacity=30)";
}
//Initialize Dialogue Box
this.init = function()
{
$('dialogCase') ? $('dialogCase').parentNode.removeChild($('dialogCase')) : function(){};
var oDiv = window.top.document.createElement('span');
oDiv.id = "dialogCase";
oDiv.innerHTML = divBg + divShadow + divBox;
window.top.document.body.appendChild(oDiv);
this.boxSet();
this.titleSet();
this.closeSet();
this.okSet();
this.cancelSet();
this.contentSet();
this.msgImgSet();
this.msgSet();
this.middle('dialogBox');
this.shadowSet();
this.bgSet();
}
//Close Dialogue Box
this.close = function()
{
$('dialogBoxBg')['style']['display'] = 'none';
$('dialogBox')['style']['display'] = 'none';
$('dialogBoxTitle')['style']['display'] = 'none';
$('dialogBoxClose')['style']['display'] = 'none';
$('dialogBoxContent')['style']['display'] = 'none';
$('dialogBoxMsgImg')['style']['display'] = 'none';
$('dialogBoxMsg')['style']['display'] = 'none';
$('divBoxBotton')['style']['display'] = 'none';
$('dialogBoxShadow')['style']['display'] = 'none';
}
//Action of Buttons
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(){eval(_sFuc)}, false);
}
else
{
if($(_sId).act){$(_sId).detachEvent('onclick', function(){eval($(_sId).act)});}
$(_sId).act = _sFuc;
$(_sId).attachEvent('onclick', function(){eval(_sFuc)});
}
}
}
//Centralize Dialogue Box
this.middle = function(_sId)
{
var sClientWidth = window.top.document.body.clientWidth;
var sClientHeight = window.top.document.body.clientHeight;
var sScrollTop = window.top.document.documentElement.scrollTop;
var obj = $(_sId);
var left = (sClientWidth / 2) - (obj.offsetWidth / 2) - (shadowPx / 2) + "px";
var top = sScrollTop + 180 + "px";//×¢Òâ
obj['style']['display'] = '';
obj['style']['position'] = "absolute";
obj['style']['left'] = left;
obj['style']['top'] = top;
}
//Move Dialogue Box
this.moveStart = function (event, _sId)
{
var oObj = $(_sId);
oObj.onmousemove = mousemove;
oObj.onmouseup = mouseup;
oObj.setCapture ? oObj.setCapture() : function(){};
oEvent = window.event ? window.event : event;
var dragData = {x : oEvent.clientX, y : oEvent.clientY};
var backData = {x : parseInt(oObj.style.top), y : parseInt(oObj.style.left)};
function mousemove()
{
var oEvent = window.event ? window.event : event;
var iLeft = oEvent.clientX - dragData["x"] + parseInt(oObj.style.left);
var iTop = oEvent.clientY - dragData["y"] + parseInt(oObj.style.top);
oObj.style.left = iLeft + "px";
oObj.style.top = iTop + "px";
$('dialogBoxShadow').style.left = iLeft + shadowPx + "px";
$('dialogBoxShadow').style.top = iTop + shadowPx + "px";
dragData = {x: oEvent.clientX, y: oEvent.clientY};
}
function mouseup()
{
var oEvent = window.event ? window.event : event;
oObj.onmousemove = null;
oObj.onmouseup = null;
if(oEvent.clientX < 1 || oEvent.clientY < 1 || oEvent.clientX > window.top.document.body.clientWidth || oEvent.clientY > window.top.document.body.clientHeight)
{
oObj.style.left = backData.y + "px";
oObj.style.top = backData.x + "px";
$('dialogBoxShadow').style.left = backData.y + shadowPx + "px";
$('dialogBoxShadow').style.top = backData.x + shadowPx + "px";
}
oObj.releaseCapture ? oObj.releaseCapture() : function(){};
}
}
}
//------------------------------------------------------
//Function£ºShow Dialog Box
//Paremeter£º
// msgStr£º Text Message
// infoType£º Info(Image) Type: 0 Validate Message,1 Close/Cancel/Decline/Reopen Case Msg Yes/No(with Cancel button), 2 Success, 3 Failure, 4 Warning
// actType£º Action Return from Ok Button:
// 0 None
// 1 Close
// 2 Cancel //Previous
// 3 Switch URL
// 4 Open URL in New Window
// 5 Open URL in Self window
// 6 Open URL in Self window(Del)
// 7 Switch to Cutomized URL
// 8 Switch Main Window to Customized URL
// 9 Switch to Customized URL in Self Window
// 10 Switch Child Window to Customized URL
// 11 Refresh Current Window
// 12 Refresh Main (Parent) WindowΪˢи¸´°¿Ú
// 13 Submit Form
// Other or add customized function
// obj: Object returned from the Form, use 'this', If Object is not Link Use URL Address
//------------------------------------------------------
var objPage
function showDialog(msgStr, infoType, actType, obj, w, h)
{
var iconImg, cancelBtn, okBtn;
msgStr = msgStr ? msgStr : "System Message";
infoType = infoType ? infoType : 0;
actType = actType ? actType : 0;
obj = obj ? obj : "";
objPage = obj;
w=w?w:450;
h=h?h:260;
switch (infoType)
{
case 0:
iconImg = 0;
cancelBtn = "";
break;
case 1:
iconImg = 1;
switch (actType)
{
case 1:
cancelBtn = "parent.clearCloseReason();";
break;
case 2:
cancelBtn = "parent.clearCancelReason();";
break;
case 3:
cancelBtn = "parent.clearDeclineReason();";
break;
case 4:
cancelBtn = "parent.clearReopenReason();";
break;
case 5:
cancelBtn = "parent.clearCompleteReason();";
break;
default:
cancelBtn = " ";
break;
}
break;
case 2:
iconImg = 2;
cancelBtn = "";
break;
case 3: //Confirmation
iconImg = 3;
cancelBtn = " ";
break;
case 4:
iconImg = 4;
cancelBtn = "";
break;
default:
iconImg = 0;
cancelBtn = "";
break;
}
switch (actType)
{
case 0:
boxTitle = "I-Sight Validation";
okBtn = " ";
break;
case 1:
boxTitle = "I-Sight Case Close";
okBtn = "parent.getCloseReason();"; //window.top.opener = null;window.top.close();
break;
case 2:
boxTitle = "I-Sight Case Cancel";
okBtn = "parent.getCancelReason();"; //history.go(-1);
break;
case 3:
boxTitle = "I-Sight Case Decline"
okBtn = "parent.getDeclineReason();"; //"document.location.href = '" + obj.href + "';";
break;
case 4:
boxTitle = "I-Sight Case Reopen";
okBtn = "parent.getReopenReason();"; //"window.open('" + obj.href + "');";
break;
case 5:
boxTitle = "I-Sight Case Complete";
okBtn = "parent.getCompleteReason();"; //"frameSrc('" + obj.href + "');"
break;
case 6:
boxTitle = "I-Sight View Skip to record";
//var goUrl ="parent.document.location.href ='"+view+"?OpenView&Startkey="+document.getElementById('JumpToVal').value+"';";
//alert(goUrl);
//okBtn = goUrl; //"frameSrcDel('" + obj.href + "');";
okBtn = "parent.goJumptoUrl();";
break;
case 7:
boxTitle = "I-Sight Confirmation";
okBtn = "parent.doAction();" //"frameSrc('" + obj + "');" //"window.top.document.location.href = '" + obj + "';";
break;
case 8:
okBtn = "parent.document.location.href = '" + obj + "';";
break;
case 9:
okBtn = "document.location.href = '" + obj + "';";
break;
case 10:
okBtn = "frameSrc('" + obj + "');"
break;
case 11:
okBtn = "document.location.reload();";
break;
case 12:
okBtn = "parent.document.location.reload();";
break;
case 13:
okBtn = "formSubmit(document.getElementById('" + obj.id + "'));";
break;
default:
okBtn = actType;
break;
}
var dg = new dialog(w, h);
dg.showBox(msgStr, iconImg, okBtn, cancelBtn);
return false;
}
//Create a hidden Frame
function createFrame()
{
var oFrame = document.createElement("iframe");
oFrame.id = "OptionFrame";
oFrame.name = "OptionFrame";
oFrame.width = "0";
oFrame.height = "0";
oFrame.src = "";
document.body.appendChild(oFrame);
document.getElementById('OptionFrame')['style']['display'] = 'none';
}
//Firing URL in Hidden Frame
function frameSrc(hrefSrc)
{
document.getElementById('OptionFrame') ? function(){} : createFrame();
document.getElementById('OptionFrame').src = hrefSrc;
}
//Delete Table tag ,Firing URL in Hidden Frame
function frameSrcDel(hrefSrc)
{
if (objPage.parentNode.parentNode.tagName == 'TR')
{
objPage.parentNode.parentNode.parentNode.removeChild(objPage.parentNode.parentNode);
}
frameSrc(hrefSrc);
}
//Submit Form
function formSubmit(obj)
{
var objForm
objForm = document.getElementById(obj.form.id);
var objInput = document.createElement("input");
objInput.id = "SubmitType";
objInput.name = "SubmitType";
objInput.value = obj.value;
objInput.type = "hidden";
objForm.appendChild(objInput);
objForm.submit();
objForm.removeChild(objInput);
}