Created
October 11, 2009 03:31
-
-
Save afahy/207377 to your computer and use it in GitHub Desktop.
Overlay
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
(function($){ | |
$.overlay = (function(){ | |
var f = function(params){ | |
var opts = $.extend({}, f.defaults, params), | |
$window = $(window), | |
winHeight = $window.height(), | |
$elem = $("<div>").css(opts.css); | |
if($elem.appendTo($("body")).height() < winHeight) { //assume needs handholding ala IE6 | |
var $doc = $(document.documentElement), | |
$iframe = $("<iframe>").css({ | |
top: 0, right: 0, | |
opacity: 0, | |
zIndex: opts.zIndex - 1 | |
}); | |
$window.bind("resize.overlay", function(){ | |
$elem.hide() | |
.height($doc.height()) | |
.width($doc.width()) | |
.show(); | |
}); | |
$elem = $elem.add($iframe) | |
.css({ position: "absolute" }) | |
.height($doc.height()) | |
.width($doc.width()); | |
} | |
return $elem.remove(); | |
}; | |
f.defaults = { | |
css: { | |
position: "fixed", | |
top: 0, right: 0, bottom: 0, left: 0, | |
opacity: 0.5, | |
backgroundColor: "#000", | |
zIndex: 3 | |
} | |
}; | |
return f; | |
})(); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment