Skip to content

Instantly share code, notes, and snippets.

@stugoo
Created October 12, 2012 16:38
Show Gist options
  • Save stugoo/3880152 to your computer and use it in GitHub Desktop.
Save stugoo/3880152 to your computer and use it in GitHub Desktop.
simple jquery overlay
<body>
<a href="#linkToTsnCs" class="showTerms">terms &amp; conditions</a>
<body>
/* requires jQuery */
$('.showTerms').click(function(e){
e.preventDefault();
$('body').append('<div id="site_mask"></div><div id="tsncs_hold"><h1 class="alpha">Terms &amp; Conditions</h1><div id="tsncs"></div><a href="close" class="button closeTerms">close</a></div>');
$('#site_mask, #tsncs_hold').css({opacity : 0});
$('#site_mask').fadeTo(400,0.6,function(){
$('#tsncs_hold').addClass('loading').fadeTo(400,1);
});
$('#tsncs').load(that.config.termsURL,function(){
$(this).removeClass('loading');
});
});
$(document).on("click", '.closeTerms', function(e){
$('#tsncs_hold').fadeTo(400,0,function(){
$('#site_mask').addClass('loading').fadeTo(400,0,function(){
$('#site_mask, #tsncs_hold').remove();
});
});
return false;
});
* Terms and conditions */
#site_mask { position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #000;
z-index: 10000000;
opacity: 0.6;
}
#tsncs_hold{ position: fixed;
top: 50%;
margin-top: -240px;
background: #fff;
padding: 44px;
height: 480px;
width: 540px;
z-index: 10000000;
left: 50%;
margin-left: -270px;
border: 7px solid #333;}
#tsncs{
display: block;
height: 190px;
overflow: scroll;
overflow-x:hidden;
border: 1px solid #333;
padding: 10px;
}
#tsncs > pre {
font-size: 13px;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
font-family: 'ITCAvantGardeGothicStdMedium', sans-serif;
}
#tsncs p { font-size: 16px; line-height: 18px; margin-bottom: 1em;}
#tsncs_hold > h1.alpha {
text-align: left;
margin-bottom: 24px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment