Modal Window for jsFiddle
Modal Window for jsFiddle
HTML
<a id="open" href="#">open modal (webkit only)</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">
<textarea></textarea>
</div>
</div>
CSS
@-webkit-keyframes dissolve {
0% { -webkit-transform: scale(1); }
100% { -webkit-transform: scale(0.8); }
}
@-webkit-keyframes appear {
0% { -webkit-transform: scale(0.8); }
40% { -webkit-transform: scale(1.1); }
100% { -webkit-transform: scale(1); }
}
.modalWrap {
-webkit-transform-style: preserve-3d;
-webkit-perspective: 0;
-webkit-transition: opacity 0.27s ease-out;
opacity: 0;
}
.modalWrap.dissolved {
-webkit-animation: dissolve 0.27s ease-out;
opacity: 0;
}
.modalWrap.appear {
-webkit-animation: appear 0.27s ease-out;
opacity: 1;
}
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: relative;
padding: 0;
border: solid 10px rgba(0,0,0,0.3);
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
float: left;
opacity: 0;
}
.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;
}
textarea {
display: block;
border: solid 1px #ADADAD;
height: 100px;
width: 250px;
background: url(http://img685.imageshack.us/img685/3267/62399046.png) 0 0 repeat-x;
}
hr {
clear: both;
width:...
JavaScript
var CSS_TRANSITIONS = (Browser.Engine.Webkit);
Element.implement({
closeModal: function(){
this
.removeClass('appear')
.addClass('dissolved');
},
openModal: function(){
this
.removeClass('dissolved')
.addClass('appear');
}
});
$$('.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();
}
});
var myDrag = new Drag.Move('modal-a', {
snap: 0,
handle: $$('.modalHeading')
});