-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.leanModal.min.js
54 lines (53 loc) · 1.36 KB
/
jquery.leanModal.min.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
42
43
44
45
46
47
48
49
50
51
52
53
54
// leanModal v1.1 by Ray Stone - http://finelysliced.com.au
// Dual licensed under the MIT and GPL
(function($) {
$.fn.extend({
leanModal : function(options) {
var defaults = {
top : 100,
overlay : 0.5,
closeButton : null
};
var overlay = $("<div id='lean_overlay'></div>");
$("body").append(overlay);
options = $.extend(defaults, options);
return this.each(function() {
var o = options;
$(this).click(function(e) {
var modal_id = $(this).attr("href");
var position = $(this).attr("pos");
$("#lean_overlay").click(function() {
close_modal(modal_id)
});
$(o.closeButton).click(function() {
close_modal(modal_id)
});
var modal_height = $(modal_id).outerHeight();
var modal_width = $(modal_id).outerWidth();
$("#lean_overlay").css({
"display" : "block",
opacity : 0
});
$("#lean_overlay").fadeTo(200, o.overlay);
$(modal_id).css({
"display" : "block",
"position" : position,
"opacity" : 0,
"z-index" : 11000,
"left" : 50 + "%",
"margin-left" : -(modal_width / 2) + "px",
"top" : o.top + "px"
});
$(modal_id).fadeTo(200, 1);
e.preventDefault()
})
});
function close_modal(modal_id) {
$("#lean_overlay").fadeOut(200);
$(modal_id).css({
"display" : "none"
})
}
}
})
})(jQuery);