bootstrap模态框二次封装

方便工作需要,对于模态框二次封装,可拖动;15种动画效果,先看效果图;
Demo请看留言第一条;





 <div class="panel panel-default">
    <div class="panel-body">
        <button class="btn btn-info" type="button">提示信息</button>
        <button class="btn btn-warning" type="button">警告信息</button>
        <button class="btn btn-success" type="button">成功信息</button>
        <button class="btn btn-danger" type="button">错误信息</button>
        <button class="btn btn-primary" type="button">询问信息</button>
        <button class="btn btn-default" type="button">自动关闭</button>
    </div>
</div>
<div class="panel panel-default">
    <div class="panel-body">
        <button class="btn btn-success btn-sm" id="test1">
            FlipVertical
        </button>
        <button class="btn btn-default btn-sm" id="test3">
            SlideBottomContainer
        </button>
        <button class="btn btn-default btn-sm" id="test4">
            SlipTopContainer
        </button>
        <button class="btn btn-default btn-sm" id="test5">
            SlideRightContainer
        </button>
        <button class="btn btn-default btn-sm" id="test6">
            RotateBottom
        </button>

        <button class="btn btn-default btn-sm" id="test7">
            Blur
        </button>
        <button class="btn btn-default btn-sm" id="test8">
            RotateLeft
        </button>
        <button class="btn btn-default btn-sm" id="test9">
            Sign
        </button>
        <button class="btn btn-default btn-sm" id="test10">
            Fall
        </button>
        <button class="btn btn-default btn-sm" id="test11">
            Slit
        </button>
        <button class="btn btn-default btn-sm" id="test12">
            Newspaper
        </button>
        <button class="btn btn-default btn-sm" id="test13">
            SuperScaled
        </button>
        <button class="btn btn-default btn-sm" id="test14">
            SideFall
        </button>
        <button class="btn btn-warning btn-sm dialog" id="test15" data-title="外部页面" data-animation="ShowModalAnimation.FlipVertical"
                data-external=true
                data- data-size="modal-full" data-content="http://blog.51cto.com/317057112">
            iframe页面
        </button>

        <button class="btn default btn-sm" id="test16">
            SideFall
        </button>
    </div>
</div>

<script>
$(".dialog").dailog();
$("#test1").dailog({
id: "test222",//ID
title: ‘测试1‘,//窗体标题
animation: ShowModalAnimation.FlipVertical,
content: ‘<button class="btn btn-primary btn-lg" id="test2">开始演示模态框</button><script>$("#test2").dailog({id: "test1111",title:"测试2",animation: ShowModalAnimation.FlipHorizontal,content: "<p>我是测试窗口2</p>",size: ModalSize.sm,});‘,
size: ModalSize.lg,
});
$("#test3").dailog({
id: "test111",//ID
title: ‘测试2‘,//窗体标题
ico: ‘<i class="fa fa-fw fa-commenting-o"></i> ‘,
animation: ShowModalAnimation.SlideBottomContainer,
content: ‘<p>测试2</p>‘,
size: ModalSize.sm,
openEvent: function () {
alert("打开窗口");
},
closeEvent: function () {
alert("关闭窗口")
}
})
$("#test4").dailog({
title: ‘测试4‘,//窗体标题
animation: ShowModalAnimation.SlipTopContainer,
content: "<p>我是测试窗口2</p>",
size: ModalSize.sm,

})
$("#test5").dailog({
    title: ‘测试5‘,//窗体标题
    animation: ShowModalAnimation.SlideRightContainer,
    content: "<p>我是测试窗口2</p>",
    size: ModalSize.sm,
})
$("#test6").dailog({
    title: ‘测试6‘,//窗体标题
    animation: ShowModalAnimation.RotateBottom,
    content: "<p>我是测试窗口2</p>",
    size: ModalSize.sm,
})
$("#test7").dailog({
    title: ‘测试7‘,//窗体标题
    animation: ShowModalAnimation.Blur,
    content: "<p>我是测试窗口2</p>",
    size: ModalSize.sm,
})
$("#test8").dailog({
    title: ‘测试8‘,//窗体标题
    animation: ShowModalAnimation.RotateLeft,
    content: "<p>我是测试窗口2</p>",
    size: ModalSize.sm,
})
$("#test9").dailog({
    title: ‘测试9‘,//窗体标题:
    animation: ShowModalAnimation.Sign,
    content: "<p>我是测试窗口</p>",
    size: ModalSize.sm,
})
$("#test10").dailog({
    title: ‘测试10‘,//窗体标题
    animation: ShowModalAnimation.Fall,
    content: "<p>我是测试窗口</p>",
    size: ModalSize.sm,
})
$("#test11").dailog({
    title: ‘测试11‘,//窗体标题
    animation: ShowModalAnimation.Slit,
    content: "<p>我是测试窗口</p>",
    size: ModalSize.sm,
})
$("#test12").dailog({
    title: ‘测试12‘,//窗体标题
    animation: ShowModalAnimation.Newspaper,
    content: "<p>我是测试窗口</p>",
    size: ModalSize.sm,
});
$("#test13").dailog({
    title: ‘测试13‘,//窗体标题
    animation: ShowModalAnimation.SuperScaled,
    content: "<p>我是测试窗口</p>",
    size: ModalSize.sm,
});
$("#test14").dailog({
    title: ‘测试14‘,//窗体标题
    animation: ShowModalAnimation.SideFall,
    content: "<p>我是测试窗口</p>",
    size: ModalSize.sm,
    buttons: [{
        text: "OK",
        style: "btn btn-info btn-sm",
        clickEvent: function () {
            alert($(this).text());
        }
    }, {
        text: "取消",
        style: "btn btn-info btn-sm",
        clickEvent: function () {
            alert($(this).text());
        }
    }]
});

$("#test16").dailog({
    title: ‘测试16‘,//窗体标题
    animation: ShowModalAnimation.SideFall,
    content: "https://www.baidu.com/",
    size: ModalSize.lg,
    external: true,
});

$("button:contains(‘提示信息‘)").on("click", function () {
    Controls.Alert("温馨提示", messageType.info, "提示信息!");
});

$("button:contains(‘警告信息‘)").on("click", function () {
    Controls.Alert("警告", messageType.warn, "警告信息!");
});
$("button:contains(‘成功‘)").on("click", function () {
    Controls.Alert("成功", messageType.success, "成功信息!");
});
$("button:contains(‘错误信息‘)").on("click", function () {
    Controls.Alert("错误", messageType.error, "错误信息!");
});
$("button:contains(‘询问信息‘)").on("click", function () {

    Controls.Confirm("询问", "确定删除此项?", function () {
        alert("点击了确定按钮");
    },
    function () {
        alert("点击了取消按钮");
    });

});
$("button:contains(‘自动关闭‘)").on("click", function () {
    Controls.Alert("自动关闭", messageType.info, "我会自动关闭!", true, 3000);
});

</script>

原文地址:http://blog.51cto.com/317057112/2341184

时间: 2024-08-29 00:46:54

bootstrap模态框二次封装的相关文章

JavaScript:bootstrap 模态框的简单应用

最近用上了bootstrap这个强大的前端框架,有空来总结一下.这里记录下模态框的简单应用. 首先,要在页面中引入相应的js.css文件 1 <link href="css/bootstrap.css" rel="stylesheet" type="text/css" /> 2 <script type="text/javascript" src="js/jquery.min.js">

Bootstrap模态框按钮

1.触发模态框弹窗的代码 这里复制了一段Bootstrap模态框的代码 <h2>创建模态框(Modal)</h2> <!-- 按钮触发模态框 --> <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">开始演示模态框</button> <!-- 模态框(Modal) --

Bootstrap 模态框(也可以说的弹出层)

最近在尝试使用bootstrap的模态框 使用模态框主要要引入一下几个js和css: bootstrap.css jquery.1.9.1.js(这个可以灵活选择) bootstrap.js html页面的写法如下: <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css"> <script src="bootstrap/js/j

去除BOOTSTRAP模态框半透明阴影

当使用bootstrap模态框默认自带半透明阴影,如果想要去除阴影,需要怎么做呢? 今天在项目中我遇到了这个问题,想要去除模态框的阴影,试了好久都没解决.后来问同事的时候才知道,当模态框弹出后,会加上这样一句代码: <div class="modal-backdrop  in"></div> 案例:自带半透明阴影的模态框 1 <!DOCTYPE html> 2 <html> 3 4 <head> 5 <meta char

关于手动关闭BootStrap模态框

在网上找手动关闭BootStrap模态框的解决方法,说是(需要引用bootstrap.js等): $("#myModal").modal('hide'); 但是我发现我的只能关闭 , 不能关闭下面那半透明层.找了下发现是出现这两行代码的缘故. <div class="modal-backdrop fade in"></div> <div class="modal-backdrop fade in"></d

bootstrap模态框远程加载网页的正确处理方式

bootstrap模态框远程加载网页的方法 在bootsrap模态框文档里给出了这个方法: 使用链接模式 <a data-toggle="modal" href="tieniu.php" data-target="#modal">Click me</a> 使用脚本模式: $("#modal").modal({ remote: "tieniu.php" }); 没有给出任何实例,这种用

使用bootstrap模态框实现浮动层

authour: 陈博益 updatetime: 2015-04-22 06:52:15 friendly link: http://v3.bootcss.com/javascript/#modals 目录: 1,bootstrap模态框的使用示例 2,注意点 1,下面是一个简单的例子说明bootstrap模态框的使用: 1 <!DOCTYPE html> //modal.html 2 <html xmlns="http://www.w3.org/1999/xhtml"

第二百四十三节,Bootstrap模态框插件

Bootstrap模态框插件 学习要点: 1.基本使用 2.用法说明 本节课我们主要学习一下 Bootstrap 中的模态框插件,这是一款交互式网站非常常见的 弹窗功能插件. 一.基本使用 使用模态框的弹窗组件需要三层 div 容器元素: 1分别为 modal(模态声明层). 2dialog(窗口声明层). 3content(内容层). 在内容层里面,还有三层: 1分别为 header(头 部). 2body(主体). 3footer(注脚). modal样式class类,写在声明模态框<div

Bootstrap 模态框、轮播 结合使用

Bootstrap 模态框和轮播分开使用的教程网上很多.但是两者结合使用的例子和资料很少.两者结合使用时,开始我遇到了不少bug,现在分享给大家. 我的这个例子是把图片轮播嵌入到模态框里. 最后的效果如下图:点击页面上按钮,弹出模态框,模态框里的图片开始轮播,点击旁边空白位置,模态框消失. 代码如下: <!DOCTYPE html> <html> <head> <title>Bootstrap 实例 轮播.模态框</title> <link