Modal Window for jsFiddle (IE7+)
Modal Window for jsFiddle (IE7+)
HTML
<a id="open" href="#">Open modal</a>
<hr />
<div id="modal-a" class="modalWrap">
<div class="modalHeading">
<h3>Lorem ipsum</h3>
<a class="close" href="#">Close window</a>
</div>
<div class="modalBody"></div>
</div>
CSS
body {
background: url(http://farm3.static.flickr.com/2052/1603973924_c61c6bf3a1.jpg);
font-family: "Lucida Grande", sans-serif;
}
.modalHeading {
position: relative;
background: #32648F url(http://img691.imageshack.us/img691/4270/96006254.png) 0 0 repeat-x;
height: 39px;
-moz-border-radius-topleft: 6px;
-moz-border-radius-topright: 6px;
-webkit-border-top-left-radius: 6px;
-webkit-border-top-right-radius: 6px;
}
.close {
background: url(http://img41.imageshack.us/img41/4012/27262087.png) 0 0 no-repeat;
width: 12px;
height: 13px;
display: block;
position: absolute;
top: 13px;
left: 10px;
text-indent: -9000em;
}
.modalWrap {
position: absolute;
padding: 10px;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
background: rgba(0, 0, 0, 0.3);
float: left;
}
.modalBody {
position: relative;
-webkit-border-bottom-left-radius: 6px;
-webkit-border-bottom-right-radius: 6px;
-moz-border-radius-bottomleft: 6px;
-moz-border-radius-bottomright: 6px;
background: #fff;
padding: 10px;
width: 300px;
height: 100px;
}
a {
color: #fff;
}
h3 {
color: #fff;
text-shadow: 0 1px 0 #183048;
text-align: center;
font-size: .8em;
padding: 9px 0;
}
JavaScript
var IE = Browser.Engine.trident;
Element.implement({
closeModal: function(){
if (IE){
this.set('styles', {
'display': 'none'
});
} else {
this.morph({
'margin-top': 20,
'opacity': 0
});
}
},
openModal: function(){
if (IE){
this.set('styles', {
'display': 'block',
'background': 'transparent',
'zoom': '1',
'filter': 'progid:DXImageTransform.Microsoft.gradient(startColorstr=#55000000,endColorstr=#55000000);'
});
} else {
this.morph({
'margin-top': [-10, 0],
'opacity': 1
});
}
}
});
$$('.close').each(function(el){
el.addEvents({
click: function(e){
e.stop();
this.getParent('.modalWrap').closeModal();
}
});
});
$('open').addEvents({
click: function(e){
e.stop();
$$('.modalWrap')[0].openModal();
}
});