更换 alert 为 bootstrap 的 modal

This commit is contained in:
virusdefender 2015-08-01 22:23:18 +08:00
parent 26dab5bd91
commit 999d03b8f7
6 changed files with 38 additions and 7 deletions

View File

@ -1,4 +1,4 @@
define("login", ["jquery", "validation"], function($){
define("login", ["jquery", "bs_alert", "validation"], function($, bs_alert){
$("#login-form")
.formValidation({
framework: "bootstrap",
@ -33,12 +33,10 @@ define("login", ["jquery", "validation"], function($){
window.location.href="/";
}
else{
alert(data.data);
bs_alert(data.data);
}
}
})
});
});

View File

@ -1,4 +1,4 @@
require(["../config"], function(){
require(["login"])
require(["bootstrap", "login"])
});

View File

@ -13,6 +13,8 @@ require.config({
code_mirror: "../utils/code_mirror",
login: "../app/account/login",
oj: "../app/oj",
"bs_alert": "../utils/bs_alert",
//formValidation 不要在代码中单独使用而是使用和修改utils/validation
base: "formValidation/base",
@ -33,7 +35,13 @@ require.config({
//code mirroe 代码编辑器
_code_mirror: "codeMirror/codemirror",
code_mirror_clang: "codeMirror/language/clike"
code_mirror_clang: "codeMirror/language/clike",
//bootstrap
bootstrap: "bootstrap/bootstrap"
},
shim: {
"bootstrap": {"deps": ['jquery']}
}
});

View File

@ -0,0 +1,7 @@
define("bs_alert", ["jquery", "bootstrap"], function($){
function bs_alert(content){
$("#modal-text").html(content);
$("#modal").modal();
}
return bs_alert;
});

View File

@ -18,7 +18,7 @@
<!-- custom css end -->
<!-- global css begin -->
<link href="/static/css/app.css" rel="stylesheet">
<link href="/static/css/oj.css" rel="stylesheet">
<!-- global css end -->
</head>
@ -75,6 +75,24 @@
<!-- custom body begin -->
{% block body %}{% endblock %}
<div class="modal fade" id="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<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 id="modal-text"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
</div>
</div>
</div>
</div>
<!-- custom body end -->
<script src="/static/js/require.js" data-main="/static/js/app/oj.js"></script>
<!-- footer begin -->