Created
July 25, 2011 21:26
-
-
Save eboyer/1105275 to your computer and use it in GitHub Desktop.
Shaun Crittenden Modals
This file contains hidden or 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
concentrated.modals = function(btn,modal){ | |
var $btn = $(btn); | |
var $modal = $(modal); | |
var $overlay = $('#overlay'); | |
var $close = $('a.close', $modal); | |
// set overlay height | |
var docHeight = $(document).height(); | |
$overlay.css({ height : docHeight }); | |
// open link | |
$btn.each(function(){ | |
$(this).click(function(e){ | |
e.preventDefault(); | |
var $url = $(this).attr("href"); | |
$overlay.fadeTo('fast',.9,function(){ | |
//populate modal | |
$modal.load($url); | |
// center modal | |
$modal.css("top", ($(window).height() - 600) / 2+$(window).scrollTop() + "px"); | |
$modal.css("left", ($(window).width() - $modal.width() ) / 2+$(window).scrollLeft() + "px"); | |
//fade in modal | |
$modal.fadeIn('slow'); | |
}); | |
}); | |
}); | |
// overlay close | |
$overlay.click(function(){ | |
$modal.fadeOut('slow',function(){ | |
$overlay.fadeOut('fast'); | |
$modal.html(""); | |
}); | |
}); | |
// close | |
$close.live("click", function(e){ | |
e.preventDefault(); | |
$modal.fadeOut('slow',function(){ | |
$overlay.fadeOut('fast'); | |
$modal.html(""); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment