X96 Web Design
12-16-2009, 04:25 PM
I wanted to make my own Modal-style javascript box so I could implement it into my existing code easier. I got it working, but I want to make it a bit more advanced...
I want to make it recognize the href attribute of the <a> tag being clicked and open the link in a modal. I have it set up as a rel= trigger.
Here's what I have so far:
JS:
<script type="text/javascript">
jQuery(document).ready(function($) {
$("a[rel*=popcorn]").click(function() {
$("div.modal").addClass("show");
return false;
});
$("#closeFancy").click(function() {
$("div.modal").removeClass("show");
return false;
});
});
</script>
CSS:
div.modal {
display: block; width: 560px;
position: absolute; top: -310px; left: 170px;
padding: 90px 20px 20px 20px;
border: solid 1px #999;
background: -webkit-gradient(linear, left top, left bottom, from(rgb(255,255,255)), to(rgb(230,230,230)));
-webkit-box-shadow: 0px 3px 6px rgba(0,0,0,0.25);
-webkit-border-bottom-left-radius: 6px;
-webkit-border-bottom-right-radius: 6px;
-webkit-transition: -webkit-transform 0.25s ease-out;
-webkit-transform: translateY(-570px);
}
div.modal.show { -webkit-transform: translateY(-110px); }
xHTML
<a href="external.html" rel="popcorn">Open Modal</a>
Thanks,
X96
I want to make it recognize the href attribute of the <a> tag being clicked and open the link in a modal. I have it set up as a rel= trigger.
Here's what I have so far:
JS:
<script type="text/javascript">
jQuery(document).ready(function($) {
$("a[rel*=popcorn]").click(function() {
$("div.modal").addClass("show");
return false;
});
$("#closeFancy").click(function() {
$("div.modal").removeClass("show");
return false;
});
});
</script>
CSS:
div.modal {
display: block; width: 560px;
position: absolute; top: -310px; left: 170px;
padding: 90px 20px 20px 20px;
border: solid 1px #999;
background: -webkit-gradient(linear, left top, left bottom, from(rgb(255,255,255)), to(rgb(230,230,230)));
-webkit-box-shadow: 0px 3px 6px rgba(0,0,0,0.25);
-webkit-border-bottom-left-radius: 6px;
-webkit-border-bottom-right-radius: 6px;
-webkit-transition: -webkit-transform 0.25s ease-out;
-webkit-transform: translateY(-570px);
}
div.modal.show { -webkit-transform: translateY(-110px); }
xHTML
<a href="external.html" rel="popcorn">Open Modal</a>
Thanks,
X96