zoukankan      html  css  js  c++  java
  • 内建对话框

    用法 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 "<table cellpadding=8><tr><td><table cellpadding=0 cellspacing=0 border=0 width=" + width + " style='font-family: Verdana,Helvetica,sans-serif; font-size: 11px; " + width + ";'>"+
    "<tr>"+
    "<td valign=top rowspan=3 style='background-image: url(/images/icons/reporting/mbx2_box_l.gif)'><img src='/images/icons/reporting/mbx2_box_ul_type" + iType + ".gif' width=8 height=8 border=0></td>"+
    "<td valign=top rowspan=3><img src='/images/icons/reporting/mbx2_icontop_type" + iType + ".gif' width=45 height=22 border=0></td>"+
    "<td style='background-color: #E2E2E2' height='1' width='100%'><img src='/images/icons/reporting/x.gif' width=1 height=1></td>"+
    "<td bgcolor='" + ((iType <= NLAlertDialog.TYPE_MEDIUM_PRIORITY) ? "#E5E5E5" : "#F6BFBF") + "' valign=top rowspan=3><img src='/images/icons/reporting/mbx2_box_ur_type" + iType + ".gif' width=8 height=8 border=0></td>"+
    "</tr>"+
    "<tr>"+
    "<td bgcolor='" + ((iType <= NLAlertDialog.TYPE_MEDIUM_PRIORITY) ? "#F6F6F6" : "#FAD9D9") + "' height=1><img src='/images/icons/reporting/x.gif' width=1 height=1></td>"+
    "</tr>"+
    "<tr>"+
    "<td bgcolor='" + ((iType <= NLAlertDialog.TYPE_MEDIUM_PRIORITY) ? "#E5E5E5" : "#F6BFBF") + "' height=16><b>"+sTitle+"</b></td>"+
    "</tr>"+
    "<tr>"+
    "<td style='background-image: url(/images/icons/reporting/mbx2_box_l.gif)'></td>"+
    "<td valign=top bgcolor='#FFFFFF'><img src='/images/icons/reporting/mbx2_iconbot_type" + iType + ".gif' width=45 height=18 border=0></td>"+
    "<td style='background-color:#FFFFFF; font-weight:normal; padding-top:3px;'>"+sMessage +
    ( (bHelpLink) ?
    ("<p align='right'> <img height='17' src='/images/icons/help/icon_help_green.gif' width='17' style='vertical-align:middle' /> <a href=\"" + helpUrl.replace(/"/g, "&#34") + "\">" + helpText + "</a></p>") :"") +
    "</td>"+
    "<td style='background-image: url(/images/icons/reporting/mbx2_box_r.gif)'></td>"+
    "</tr>"+
    "<tr>"+
    "<td valign=top><img src='/images/icons/reporting/mbx2_box_ll.gif' width=8 height=8 border=0></td>"+
    "<td style='background-image: url(/images/icons/reporting/mbx2_box_b.gif)' colspan=2><img src='/images/icons/reporting/x.gif' width=1 height=8></td>"+
    "<td valign=bottom><img src='/images/icons/reporting/mbx2_box_lr.gif' width=8 height=8 border=0></td>"+
    "</tr>"+
    "</table></td></tr></table>";
    }


    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";
    }
    }


    纠正错误,欢迎探讨:
    打开微信-发现-扫一扫
  • 相关阅读:
    CentOS配置epel源
    找到占用CPU最高的Java线程
    awk内建函数
    GIT速查手册
    MySQL闪回工具之binlog2sql
    CentOS设置时区
    CentOS下Python管理
    MySQL主从复制
    内省、JavaBean、PropertyDescriptor类、Introspector类、BeanUtils工具包、注解、Rentention、Target、注解的基本属性和高级属性
    jdbctemplate
  • 原文地址:https://www.cnblogs.com/backuper/p/1524838.html
Copyright © 2011-2022 走看看