自己用JQueryUI封装了几个系统常用对话框

/*
 * @功能描述:各种系统消息框
 * @前置插件:JQueryUI
 * @开 发 者:魏巍
 * @开发日期:2015-04-15
 * @version 1.0
 */
var SF = {};
SF.Msg = function () {
    var $msgbox, offTimer;

    var popup = function (_msg) {//自动关闭
        $msgbox = $("<div>" + _msg + "</div>");
        $msgbox.dialog({
            title: "系统提示",
            width: 300,
            height: 150,
            resizable: false,
            close: function () {
                $(this).dialog("destroy");
            }
        });
        $msgbox.prev('.ui-dialog-titlebar').remove();

        clearTimeout(offTimer);
        offTimer = setTimeout(function () {
            $msgbox.dialog("close");
        }, 1000);
    }

    var succeed = function () {//操作成功
        popup("操作成功");
    }

    var alert = function (_msg) {
        $msgbox = $("<div>" + _msg + "</div>");
        $msgbox.dialog({
            title: "系统提示",
            width: 300,
            height: 200,
            modal: true,
            resizable: false,
            buttons: { "确定": function () { $(this).dialog("close"); } },
            close: function () {
                $(this).dialog("destroy");
            }
        });
    }

    var confirm = function (_msg, _callback) {
        $msgbox = $("<div>" + _msg + "</div>");
        $msgbox.dialog({
            title: "系统提示",
            width: 300,
            height: 200,
            modal: true,
            resizable: false,
            buttons: {
                "确定": function () {
                    $(this).dialog("close");
                    _callback();
                },
                "取消": function () {
                    $(this).dialog("close");
                }
            },
            close: function () {
                $(this).dialog("destroy");
            }
        });
    }

    return {
        popup: popup,
        succeed: succeed,
        alert: alert,
        confirm: confirm
    }
}();

 

posted @ 2015-04-20 10:36  魏巍(QQ:68235081)  阅读(258)  评论(0编辑  收藏  举报