Bootbox 封装 拿过去直接用不谢

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
(function ($) {
    $.systemBootBox = function (options) {
        var opts = $.extend({}, $.systemBootBox.defaults, options);
        var tokenTime = new Date().getTime();
        $.cookie('hf_token', tokenTime); //设置cookie
        if (opts.boxType == 'alert') {
            bootbox.alert({
                size: opts.size,
                title: opts.title,
                message: opts.message,
                callback: function (data) { opts.boxCallback(data); },
                //buttons: {
                // OK: {
                // label: '<i class="fa fa-check"></i> 确定',
                // className: 'btn-info', //按钮颜色
                // }
                //}
            });
        }
        if (opts.boxType == 'confirm') {
            bootbox.confirm({
                size: opts.size,
                message: opts.message,
                buttons: {
                    cancel: {
                        label: '<i class="fa fa-times"></i> 取消',
                        className: 'btn-danger',
                    },
                    confirm: {
                        label: '<i class="fa fa-check"></i> 确定',
                        className: 'btn-info', //按钮颜色
 
                    }
                },
                callback: function (data) { opts.boxCallback(data); }
            })
        }
        if (opts.boxType == 'dialog') {
            bootbox.dialog({
                size: opts.size,
                title: opts.title,
                message: '<form id="DataForm" action="" class="form-style">' + opts.message + '<input name="token" type="hidden" value="' + tokenTime + '"/></form>',
                complete: function () {
                    opts.onComplete();
                },
                buttons: {
                    cancel: {
                        label: '<i class="fa fa-times"></i> 取消',
                        className: 'btn-danger',
                        callback: function () {
                            // Example.show('Custom cancel clicked');
                        }
                    },
                    ok: {
                        label: '<i class="fa fa-check"></i> 确定',
                        className: 'btn-info', //按钮颜色
                        callback: function (data) {
                            opts.boxCallback(data);
                            if (opts.closeOrShow == false) {
                                return false;
                            }
                        }
                    }
                }
            });
        }
    }
    $.hideModel = function () {
        $('.bootbox').modal('hide');
    }
    $.systemBootBox.defaults = {
        boxType: '',//alert ,confirm,diolog 弹出框 ,警告框,自定义对话框
        size: null, // large ,small
        title: "标题演示",
        message: "标题信息演示",
        onComplete: function () { },
        onEscape: true, //Esc 关闭对话框
        show: false,//立即显示对话框
        closeButton: false, //关闭按钮
        boxCallback: function (data) { alert(data); }, //回调函数
        closeOrShow: false, //true 关闭 false 不关
        dialogInt: function () { }, //初始化执行函数
    };
})(jQuery);
 
//调用
 
$.systemBootBox({
    title: titleMsg,
    boxType: 'dialog',
    message: $('#hf_window').html(),
    boxCallback: function (data) {
        edit();
    }
});
 
//关闭模态框; $.hideModel(); 默认点击确定不关闭模态框,可修改封装里面为True
 
//修改源码 bootbox.js
 
var defaults = {
    // default language
    locale: "en",
    // show backdrop or not. Default to static so user has to interact with dialog
    backdrop: "static",
    // animate the modal in/out
    animate: true,
    // additional class string applied to the top level dialog
    className: null,
    // whether or not to include a close button
    closeButton: true,
    // show the dialog immediately by default
    show: true,
    complete: function () { },
    // dialog container
    container: "body"
};

  

posted @   wolfsocket  阅读(374)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示