You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.3 KiB
53 lines
1.3 KiB
// 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: '.modal_close'
|
|
};
|
|
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);
|
|
$("#lean_overlay").click(function() {
|
|
close_modal(modal_id)
|
|
});
|
|
$(o.closeButton).click(function() {
|
|
close_modal(modal_id)
|
|
});
|
|
var modal_height = $(modal_id).height();
|
|
var modal_width = $(modal_id).width();
|
|
$("#lean_overlay").css({
|
|
"display": "block",
|
|
opacity: 0
|
|
});
|
|
$("#lean_overlay").fadeTo(200, o.overlay);
|
|
$(modal_id).css({
|
|
"display": "block",
|
|
"position": "fixed",
|
|
"opacity": 0,
|
|
"z-index": 11,
|
|
"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); |