内建对话框-CarlZeng

用法 var a=new NLAlertDialog(‘“NLAlertDialog”‘); a.show(‘title’,’sMessage’,3) ———————————————————————- function hideAlertBox(elemId) { document.getElement…

用法 var a=new NLAlertDialog(‘“NLAlertDialog”‘);

a.show(‘title’,’sMessage’,3)

-———————————————————————

function hideAlertBox(elemId)
{
document.getElementById(elemId).style.display=’none’;
}

function getAlertBoxHtml(sTitle, sMessage, iType, width, helpUrl, helpText)
{
if (iType != NLAlertDialog.TYPE_LOWEST_PRIORITY &&
iType != NLAlertDialog.TYPE_LOW_PRIORITY &&
iType != NLAlertDialog.TYPE_MEDIUM_PRIORITY &&
iType != NLAlertDialog.TYPE_HIGH_PRIORITY)
iType = NLAlertDialog.TYPE_LOW_PRIORITY;
if(!width)
width = 600;
if (!sTitle)
{
switch (iType)
{
case NLAlertDialog.TYPE_LOWEST_PRIORITY:
sTitle = “Confirmation”;
break;
case NLAlertDialog.TYPE_LOW_PRIORITY:
sTitle = “Information”;
break;
case NLAlertDialog.TYPE_MEDIUM_PRIORITY:
sTitle = “WARNING”;
break;
case NLAlertDialog.TYPE_HIGH_PRIORITY:
default:
sTitle = “Error”;
break;
}
}

var bHelpLink = false;
if (helpUrl && helpUrl.length > 0)
{
bHelpLink = true;
if (!helpText)
helpText = “Visit this Help Topic”;
}
return “

“+
““+
““+
““+
““+
““+
““+
““+
““+
““+
““+
““+
““+
““+
““+
““+
““+
““+
““+
““+
““+
““+
““+
““+
“+sTitle+”
“+sMessage +
( (bHelpLink) ?
(“

<a href=\“” + helpUrl.replace(/“/g, “&#34”) + “\“>” + helpText + “

“) :””) +
“;
}

NLAlertDialog = Class.create();

NLAlertDialog.TYPE_LOWEST_PRIORITY = 0;
NLAlertDialog.TYPE_LOW_PRIORITY = 1;
NLAlertDialog.TYPE_MEDIUM_PRIORITY = 2;
NLAlertDialog.TYPE_HIGH_PRIORITY = 3;

NLAlertDialog.prototype =
{
initialize: function(sId)
{
this.sId = sId || “NLAlertDialog”;
},

show: function(sTitle, sMessage, iType, sTargetDivId)
{
var posX = document.body.clientWidth / 2;
var posY = document.body.clientHeight / 2;

var sTitleId = this.sId + ‘_title’;
var sMessageId = this.sId + ‘_message’;

if(!iType) iType = NLAlertDialog.TYPE_LOW_PRIORITY;

if (!this.hndDialogDiv)
{
this.hndDialogDiv = document.createElement(“div”);
this.hndDialogDiv.innerHTML = getAlertBoxHtml(sTitle, sMessage, iType);
this.hndDialogDiv.style.display = “none”;
this.hndDialogDiv.style.position = “absolute”;
document.body.appendChild(this.hndDialogDiv);
}
if (sTargetDivId != null)
{
$(sTargetDivId).innerHTML = this.hndDialogDiv.innerHTML;
return;
}
if (this.hndDialogDiv.style.display == “block”)
return;
this.hndDialogDiv.style.display = “block”;
this.hndDialogDiv.style.top = posY - (this.hndDialogDiv.clientHeight / 2);
this.hndDialogDiv.style.left = posX - (this.hndDialogDiv.clientWidth / 2);
},

hide: function( sTargetDivId )
{
if (sTargetDivId != null)
$(sTargetDivId).innerHTML = “”;
else if (this.hndDialogDiv != null)
this.hndDialogDiv.style.display = “none”;
}
}

个性化需求沟通 扫客服加V加群: