结合Pnotify插件--app-jquery-notify.js

$.NOTIFY =
{
    showSuccess : function (title, text, context)
    {
        var opt =
        {
            title : title,
            text : text,
            type : 'success',
            hide : true,
            delay : 1500
        };
        if (context != undefined && context != null)
        {
            $.NOTIFY.show_context (context, false, opt);
            return;
        }
        new PNotify (opt);
    },
    showNotice : function (title, text, context)
    {
        var opt =
        {
            title : title,
            text : text,
            type : 'notice',
            hide : true,
            delay : 1500
        };
        if (context != undefined && context != null)
        {
            $.NOTIFY.show_context (context, false, opt);
            return;
        }
        new PNotify (opt);
    },
    showError : function (title, text, context)
    {
        var opt =
        {
            title : title,
            text : text,
            type : 'error',
            hide : true,
            delay : 1500
        };
        if (context != undefined && context != null)
        {
            $.NOTIFY.show_context (context, false, opt);
            return;
        }
        new PNotify (opt);
    },
    showLogin : function (context)
    {
        var opt =
        {
            title : "信息",
            text : "您可能已经离线,请重新刷新网页后再试!",
            type : "info",
            confirm :
            {
                confirm : true,
                buttons : [
                    {
                        text : '刷新网页',
                        click : function (notice)
                        {
                            top.location.reload ();
                        }
                    }
                ]
            },
            buttons :
            {
                closer : false,
                sticker : false
            }
        };
        if (context != undefined && context != null)
        {
            $.NOTIFY.show_context (context, false, opt);
            return;
        }
        new PNotify (opt)
    },
    showConfirm : function (title, text, buttons, context)
    {
        var opt =
        {
            title : title,
            text : text,
            type : "notice",
            confirm :
            {
                confirm : true,
                buttons : buttons
            },
            buttons :
            {
                closer : false,
                sticker : false
            }
        };
        
        if (context != undefined && context != null)
        {
            $.NOTIFY.show_context (context, false, opt);
            return;
        }
        
        new PNotify (opt);
        
    },
    show_context : function (context, modal, opt)
    {
        var opts = $.extend (
        {
            "push" : "top",
            "dir1" : "down",
            "dir2" : "left",
            "context" : context,
            "modal" : modal,
            "overlay_close" : true,
            "addclass" : "stack-modal"
        }, opt)
        new PNotify (opts);
    }
}
原文地址:https://www.cnblogs.com/cryst/p/6029150.html