JSFiddle - React, Tailwind, and code Playground
HTML
<div class='msg_row' id="msg_1">
<div class='msg_head' id="msg_head_1">
<div class='m_r1'><div class='m_usr'>Username</div><div class='m_time'>Sept 8</div></div>
<div class='m_r2'><input type='checkbox' class='msg_chk'><div class='m_sub' id="id">Subject</div></div>
<div class='m_r3'><div class='m_short_msg' id="id">MESSAGE</div></div>
</div>
</div>
<div class='msg_row' id="msg_2">
<div class='msg_head' id="msg_head_2">
<div class='m_r1'><div class='m_usr'>Username2</div><div class='m_time'>Sept 8</div></div>
<div class='m_r2'><input type='checkbox' class='msg_chk'><div class='m_sub' id="id">Subject2</div></div>
<div class='m_r3'><div class='m_short_msg' id="id">MESSAGE2</div></div>
</div>
</div>
CSS
.msg_row {
position:relative;
border:1px solid #d6e0fa;
margin-top:3px;
padding:.3em 0 .3em 0;
background-color:#f3f4f7;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-khtml-border-radius: 5px;
border-radius: 5px;
cursor:pointer;
}
.msg_head {
position:relative;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-khtml-border-radius: 5px;
border-radius: 5px;
cursor:pointer;
padding-bottom:3px;
}
.msg_row:hover {
background-color:#fff;
background-image:url(../img/gradients/grey.png) !important;
background-repeat:repeat-x;
background-position:-1em -1em;
border:1px solid #CCC;
}
.m_active {
background-color:#fff;
background-image:url(../img/gradients/grey.png) !important;
background-repeat:repeat-x;
background-position:-1em -1em;
border:1px solid #CCC;
cursor: default;
}
/*** Username ****/
.m_usr {
margin-left:3em;
color:#333;
}
/*** Subject ****/
.m_sub {
margin:.2em 0 0 3em;
font-size:108%;
}
.m_sub:before {
content: "\00BB \0020";
}
/*** Short Message ****/
.m_short_msg {
margin:.3em 0 0 3em;
color:#999;
}
/*** Date ****/
.m_time {
position:absolute;
right:7px;
top:2px;
color:#666;
}
.msg_chk {
position:absolute;
left:9px;
padding-top:1px;
}
JavaScript
$('.msg_head').toggle(function(){
var id = "msg_"+idfix($(this).attr('id'),'msg_head_');
mailCloseAll();
$('#'+id).animate({
height: '+=300'
}, 250,
function(){
$(this).addClass('m_active');
jQuery.data(document.body, 'mail_open', id);
});
}, function() {
var id = "msg_"+idfix($(this).attr('id'),'msg_head_');
$('#'+id).animate({
height: '-=300'
}, 250,
function(){
$(this).removeClass('m_active');
jQuery.data(document.body, 'mail_open', '');
});
});
/*
*
* Close Open mail
*
*/
function mailCloseAll() {
if (jQuery.data(document.body, 'mail_open') != null) {
var head_id = "msg_head_" + idfix(jQuery.data(document.body, 'mail_open'),"msg_");
$('#'+head_id).click(function(){
$(this).removeClass('m_active');
jQuery.data(document.body, 'mail_open', '');
});
}
}
/*
* function: idfix
* when: on new code load
* purpose: clears portion of an id ex. 'record_123' we can remove record
*/
function idfix(id,remove_this) {
var re = new RegExp(remove_this,"g");
return id.replace(re,"");
}