modalBox.js
1.76 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
// =============
// ==== 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 class="modalBox ' + $modalBoxId + '" ' + $style + '>'
+ '<div class="right"><div class="close bClose">X</div></div>'
+ '<div class="content">' + content + '</div>'
+ '</div>';
var $default = {
'id': ID,
'transition': 'slideDown',
// 'closeClass': 'bClose-' + ID,
'onOpen': function() {
$modalBoxTotal++;
$(this).html($modal)
},
'onClose': function() {
$modalBoxTotal--;
$('.' + $modalBoxId).remove();
},
'width': $width
};
var $setting = $.extend({}, $default, $option);
if ($('#duty').length == 0)
{
$('body').append('<div id="duty"></div>').promise().done(function()
{
$('#duty').bPopup($setting).reposition(1);
});
}
else
{
$('#duty').bPopup($setting).reposition(1);
}
}
function modalBoxClose ()
{
$('#duty').bPopup().close();
}
function isModalBox ()
{
return ($modalBoxTotal > 0) ? true : false;
}