Created
November 27, 2016 20:52
-
-
Save mtairu/b9410e86c9c210927763937b403024a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
//open popup | |
$(".pop").click(function () { | |
$(this).parent().find("form .overlay_form").fadeIn(1000); | |
positionPopup(); | |
}); | |
//close popup | |
$(".close").click(function () { | |
$(".overlay_form").fadeOut(500); | |
}); | |
}); | |
//position the popup at the center of the page | |
function positionPopup() { | |
if (!$(".overlay_form").is(':visible')) { | |
return; | |
} | |
$(".overlay_form").css({ | |
left: ($(window).width() - $('.overlay_form').width()) / 2, | |
top: ($(window).width() - $('.overlay_form').width()) / 7, | |
position: 'absolute' | |
}); | |
} | |
//maintain the popup at center of the page when browser resized | |
$(window).bind('resize', positionPopup); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment