{% extends "myhome_base.html" %}
{% load seahub_tags avatar_tags %}

{% block nav_group_class %}class="cur"{% endblock %}

{% block main_panel %}
<div class="main fleft">
<h2>留言</h2>
<div>
    <span>{% avatar msg.from_email 48 %}</span>
    <div class="info">
    <span class="from">{{ msg.from_email }}</span>
    <span class="ts">{{ msg.timestamp|date:"Y-m-d H:i" }}</span>
    </div>
    <div class="reply">
    <span class="msg">{{ msg.message }}</span>
    </div>    
</div>

<div id="reply">
<form action="" method="post">{% csrf_token %}
  <textarea name="message" id="message">{{ form.data.message }}</textarea><br />
  <input type="submit" value="回复" class="submit" />  
  {% for error in form.message.errors %}
  <span class="error">{{ error|escape }}</span>
  {% endfor %}
</form>
</div>

</div>

{% endblock %}

{% block extra_script %}
<script type="text/javascript">

    $("table tr:gt(0)").hover(
        function() {
            $(this).find('img').css('cursor', 'pointer').removeClass('vh');
        },
        function() {
            $(this).find('img').addClass('vh');
        }
    );

    $('.download').click(function() {
        window.open($(this).attr('data'));
    });

    $('.reply').each(function() {
        $(this).click(function() {
            var reply_to = $(this).attr('data');
            $('#to_email').val(reply_to);            
            $('#message').text("回复" + reply_to + "：");
            $('#message').focus();
        });
    });
</script>
{% endblock %}
