/**
* Created by Administrator on 2016/5/4.
*/
/**
* 模态窗口
*/
window.Modal = {
tpls:{
alert:'<div class="modal fade" tabindex="-1" role="dialog"><div class="modal-dialog modal-sm" role="document" style="margin-top: 20%;"><div class="modal-content"><div class="modal-header" style="padding: 8px 15px;"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button><h4 class="modal-title">系统提示</h4></div><div class="modal-body"><p class="message-box text-center"></p></div></div></div></div>',
confirm:'<div class="modal fade"><div class="modal-dialog modal-sm" role="document" style="margin-top: 20%;"><div class="modal-content"><div class="modal-header" style="padding: 8px 15px;"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button><h4 class="modal-title">系统提示</h4></div><div class="modal-body"><p class="message-box text-center"></p></div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">取消</button><button type="button" class="btn btn-primary">确定</button></div></div></div></div>',
loading:'<div class="modal fade"><div class="modal-dialog modal-sm" role="document" style="margin-top: 20%;"><div class="modal-content" style="box-shadow: none;border: none;background: rgba(0,0,0,0.5); color: #FFFFFF;"><div class="modal-body"><div class="text-center"><i class="fa fa-spinner fa-spin fa-2x"></i></div> <div class="message-box text-center form-control-static">正在载入...</div></div></div></div></div>'
},
register:function(events){
events = events || [];
if(events.length == 0){
events = ['alert', 'confirm', 'loading'];
}
var body = $(document.body);
this.modal = {};
for(var i=0; i<events.length; i++){
var event = events[i];
var tpl = this.tpls[event];
if(tpl){
this.modal[event] = $(tpl);
body.append(this.modal[event]);
}
}
},
alert:function(message, config){
config = config || {};
var confirmText = config.confirmText || "确定";
this.modal.alert.find(".btn-primary").text(confirmText);
this.modal.alert.find(".message-box").html(message);
this.modal.alert.modal("show");
},
confirm:function(message, config){
config = config || {};
var confirmText = config.confirmText || "确定";
var cancelText = config.cancelText || "取消";
this.modal.confirm.find(".btn-primary").text(confirmText);
this.modal.confirm.find(".btn-default").text(cancelText);
this.modal.confirm.find(".message-box").html(message);
this.modal.confirm.modal("show");
var _this = this;
this.modal.confirm.find(".btn-primary").on("click", function(){
if(typeof config.confirm == "function"){
config.confirm();
}
_this.modal.confirm.modal("hide");
});
},
loading:function(message){
this.modal.loading.find(".message-box").html(message);
this.modal.loading.modal({backdrop:'static'});
},
dismissLoading:function(){
this.modal.loading.find(".message-box").html("");
this.modal.loading.modal("hide");
}
};
Modal.register();

Bootstrap Modal 框 alert confirm loading的更多相关文章

  1. Bootstrap 警告框(Alert)插件

    警告消息大多来是用来向终端用户提示警告或确认的消息,使用警告框插件,您可以向所有的警告框消息添加取消功能. 用法 您有以下两种方式启用警告框的可取消功能. 1.通过data属性:通过数据添加可取消功能 ...

  2. js 重写 bootstrap 样式 alert/confirm 消息窗口

    相信很多人都受够了 alert.confirm 的样子,最近正在用 bootstrap 做项目,顺便封装了一个 bootstrap 样式的消息框. 实现起来很简单,bootstrap 本身就自带了 m ...

  3. Bootstrap 模态框(Modal)插件

    原文链接:http://www.runoob.com/bootstrap/bootstrap-modal-plugin.html Bootstrap 模态框(Modal)插件 模态框(Modal)是覆 ...

  4. js控制Bootstrap 模态框(Modal)插件

    js控制Bootstrap 模态框(Modal)插件 http://www.cnblogs.com/zzjeny/p/5564400.html

  5. bootstrap模态框modal使用remote第二次加载显示相同内容解决办法

    bootstrap模态框modal使用remote动态加载内容,第二次加载显示相同内容解决办法 bootstrap的modal中,使用remote可以动态加载页面到modal-body中,并弹窗显示 ...

  6. selenium python (十一)alert/confirm/prompt的处理(js中的弹出框)

    webdriver中处理js所生成的alert.confirm以及prompt,采用switch_to_alert()方法定位到alert/confirm/prompt.然后使用text/accept ...

  7. JS 提示框 alert()、confirm()、prompt()的三者的区别

    使用消息框 使用警告.提示和确认 可以使用警告.确认和提示消息框来获得用户的输入.这些消息框是 window 对象的接口方法.由于 window 对象位于对象层次的顶层,因此实际应用中不必使用这些消息 ...

  8. jquery仿alert提示框、confirm确认对话框、prompt带输入的提示框插件[附实例演示]

    jquery仿alert提示框.confirm确认对话框.prompt带输入的提示框插件实例演示 第一步:引入所需要的jquery插件文件: http://www.angelweb.cn/Inc/eg ...

  9. Bootstrap modal模态框关闭时,combobox input下拉框仍然保留在页面上

    问题描述: 当点击模态框的关闭按钮时,下拉框中的内容没有消失,而是移动到了页面左上角 分析:这个问题的定位在于是用的哪种模态框,bootstrap和easyui都可以实现模态框,但是两个方法实现的模态 ...

随机推荐

  1. bzoj1233: [Usaco2009Open]干草堆tower

    Description 奶牛们讨厌黑暗. 为了调整牛棚顶的电灯的亮度,Bessie必须建一座干草堆使得她能够爬上去够到灯泡 .一共有N大包的干草(1<=N<=100000)(从1到N编号) ...

  2. bzoj1662: [Usaco2006 Nov]Round Numbers 圆环数

    Description 正如你所知,奶牛们没有手指以至于不能玩“石头剪刀布”来任意地决定例如谁先挤奶的顺序.她们甚至也不能通过仍硬币的方式. 所以她们通过"round number" ...

  3. map和lambda

    同事问我python里,比如一个列表: a = ['1', '2', '3'] 如何变成: b = ['1x', '2x', '3x'] 好吧,果断不知道-原来pthon中有map函数,查看帮助文档: ...

  4. Unity问答——请问一下动画状态机怎么判断动画是否播完了?

    这篇博客源自我在泰课在线的回答.链接:http://www.taikr.com/group/1/thread/233 问:请问一下动画状态机怎么判断动画是否播完了? 答: 1. 脚本参考 Animat ...

  5. 【转】nodejs

    Node.JS + MongoDB技术讲座            云计算 + 大数据 = 未来. 在中国的云计算上基本上是一个概念,个人感觉与当初的SOA没有太大的区别,空泛的理论. 中小型开发的未来 ...

  6. github 托管代码两分钟教程【转载,亲测可行】

    http://blog.csdn.net/duxinfeng2010/article/details/8654690 出自以上地址 本篇文章介绍的是如何将工程代码托管到上面:如果你还没注册GitHub ...

  7. C++ Primer 随笔 Chapter 9 顺序容器

     参考:http://www.cnblogs.com/kurtwang/archive/2010/08/19/1802912.html 1..顺序容器:vector(快速随机访问):list(快速插入 ...

  8. ♫【JS基础】壹零零壹

    如何面试一个前端开发者? function spacify(str) { return str.split('').join(' ') } console.log(spacify('hello wor ...

  9. CodeForces 591A

    题目链接: http://codeforces.com/problemset/problem/591/A 题意: a,b两个相距L距离,两个分别以p,q速度从左右两个端点出发,每次相遇后,又以原来的速 ...

  10. (转)【C++ STL】细数C++ STL 的那些事 -- priority_queue(优先队列)

    装载自http://blog.csdn.net/tianshuai1111/article/details/7652553 一,概述 priority_queue是拥有权值观念的queue,它允许加入 ...