Created
August 19, 2009 03:31
-
-
Save quickredfox/170139 to your computer and use it in GitHub Desktop.
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" | |
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> | |
<head> | |
<title>Block Overlay</title> | |
<style type="text/css" media="screen"> | |
*{font-family:helvetica,sans-serif;-moz-border-radius:0.3em;-webkit-border-radius:0.3em;border-radius:0.3em;} | |
#page{position:absolute;left:50%;width:500px;margin-left:-250px;height:500px;border:1px solid #eee;} | |
#header{background:#00c;color:#fff;padding:10px;height:20px;} | |
#content{padding:10px;float:left;width:60%;height:480px;} | |
#sidebar{float:left;width:30%;padding:10px;font-size:0.8em;border-left:1px solid #ccc;height:410px;} | |
#sidebar ul{margin:0;padding:0;list-style-type:none;} | |
#footer{position:absolute;bottom:0;width:490px;text-align:center;padding:5px;border-top:1px solid #99c;color:#999;} | |
.overlay{position:absolute;background:#ccc;width:100%;height:100%;top:0;left:0;bottom:0;right:0;opacity:0.75;} | |
.overlay-message{position:absolute;top:10%;margin-left:10%;margin-right:10%;padding:5%;background:#fff;font-size:10px;} | |
.overlay-close-button{position:absolute;top:10px;right:10px;background:#c00;padding:5px;color:#fff;} | |
.overlay-close-button:hover{background:#f00} | |
.click-me{color:#c00;font-weight:bold;} | |
</style> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script> | |
<script type="text/javascript" charset="utf-8"> | |
$(function($){ | |
$('.click-me').live('click',function(evt){ | |
// prevent default click event from firing | |
evt.preventDefault(); | |
// Ref our link | |
var clickedElement = $(evt.target); | |
// The ovleray stuff | |
var overlay = $('<div />').addClass('overlay'); | |
var message = $('<p />').text( | |
'Duis aute irure dolor in reprehenderit \ | |
in voluptate velit esse cillum dolore eu \ | |
fugiat nulla pariatur. Excepteur sint \ | |
occaecat cupidatat non proident, sunt \ | |
in culpa qui officia deserunt mollit anim\ | |
id est laborum.' | |
).addClass('overlay-message'); | |
// Close button for the overlay... | |
var close = $('<a />').text('close').click(function(e){ | |
e.preventDefault(); | |
overlay.remove(); | |
message.remove() | |
close.remove() | |
}).addClass('overlay-close-button'); | |
var container = clickedElement.closest('div'); | |
// if it's absolute the overlay will stretch fine, elsewise need to relativize | |
// but we DONT want to do the reverse. | |
if(container.css('position') != 'absolute'){ | |
container.css('position','relative'); | |
} | |
container.append(overlay) | |
overlay.after(message) | |
overlay.after(close) | |
}) | |
}) | |
</script> | |
</head> | |
<body> | |
<div id="page"> | |
<div id="header">Example</div> | |
<div id="content">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div> | |
<div id="sidebar"><ul><li><a class="click-me" href="#">Click Me</a></li><li><a href="#">Blah blah</a></li><li><a href="#">Blah blah</a></li></ul></div> | |
<div id="footer"><small>Lorem ipsum dolor sit amet, consectetur adipisicing elit</small></div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment