modalBox.js
2.05 KB
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
// =============
// ==== VAR ====
// =============
var $modalBoxTotal = 0;
// ===============
// ==== METOD ====
// ===============
function percentToPix ($value)
{
return $value == null ? 0 : parseInt (screen.width * $value / 100);
}
function modalBoxLoad (content, $option)
{
var ID = $modalBoxTotal;
$width = 80;
$modalBoxId = 'modalBoxId-' + ID;
$style = 'style="max-width:' + percentToPix ($width) + 'px;"';
var $modal =
'<div id="' + $modalBoxId + '" class="modal fade" tabindex="-1" role="dialog">'
+ '<div class="modal-dialog">'
+ '<div class="modal-content">'
+ '<div class="modal-header">'
+ '<button aria-label="Close" data-dismiss="modal" class="close" type="button">'
+ '<span aria-hidden="true">x</span>'
+ '</button>'
+ '</div>'
+ '<div class="modal-body">'
+ content
+ '</div>'
/*
+ '<div class="modal-footer">'
+ '<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>'
+ '<button type="button" class="btn btn-primary">Save changes</button>'
+ '</div>'
*/
+ '</div>'
+ '</div>'
+ '</div>';
$modalBoxTotal++;
if ($('#duty').length == 0) {
$('body').append('<div id="duty"></div>');
}
$('#duty').html($modal).promise().done(function()
{
$('#' + $modalBoxId)
.modal('show')
.on('hidden.bs.modal', function (e)
{
$(this).data('bs.modal', null);
$('#' + $modalBoxId).remove();
window.modalBoxTotal--;
});
});
}
function modalBoxClose ()
{
$('#modal').hide();
}
function isModalBox ()
{
return ($modalBoxTotal > 0) ? true : false;
}