-
Notifications
You must be signed in to change notification settings - Fork 1
/
alert.js
41 lines (39 loc) · 1.37 KB
/
alert.js
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
/*
* User: Alaa Badran
* Date: 2013-12-01
* Time: 15:34:37
* Contact: me@alaabadran.com
* URL: http://www.alaabadran.com/
*/
$(function (){
// First, storing default alert()
var $alert = window.alert;
// now overriding.
window.alert = function (msg, title){
if(!title){
title = $(document).prop('title');
}
$('#jsalert_modal h4').html(title);
$('#jsalert_modal .modal-body').html(msg);
$('#jsalert_modal').modal('show');
};
// preparing HTML layout for new alert()
// Adding Modal HTML.
var html = '<div class="modal fade" role="dialog" id="jsalert_modal" aria-hidden="true"><div class="modal-dialog"><div class="modal-content">'+
'<div class="modal-header">'+
'<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'+
'<h4 class="modal-title">{{TITLE}}</h4>'+
'</div>'+
'<div class="modal-body">'+
'{{ALERT}}'+
'</div>'+
'<div class="modal-footer"><button type="button" class="btn btn-primary" data-dismiss="modal"> Ok </button></div>'+
'</div></div></div>';
var alertObj = $('body').append(html);
$('#jsalert_modal').modal('hide');
// Showing your message
$('#jsalert').on('click', function (e){
e.preventDefault();
alert($('#alert_message').val());
});
});