Source

HackersEdge / he_one / templates / he_one / mailbox_detail.html

Full commit
{% extends "base.html" %}
{% load hackers_edge %}
{% load url from future %}
{% load cache %}

{% block css %}.jtable tr .ui-state-hover { font-weight: normal; }{% endblock %}

{% block javascript %}
{% cache 3600 emails object.pk %}
  var emails = [
{% for message in object.messages.all %}
   {'subject':'{{message}}',
    'from_user':'{{message.from_user}}',
    'to_user':'{{message.to_user}}',
    'message':'{{message.body}}',
    'trash_link':'{% url 'message-delete' message.pk %}'
   },
{% endfor %}
  ];
{% endcache %}
  openMessage = function(message){
   $("#from_user").val(emails[message]['from_user']);
   $("#to_user").val(emails[message]['to_user']);
   $("#subject").val(emails[message]['subject']);
   $("textarea#message").val(emails[message]['message']);
   $('#dialog-message').dialog('open');
   return false;
  }
{% endblock %}

{% block jquery %}
{{block.super}}
  $(".jtable th").each(function(){ $(this).addClass("ui-state-default"); });
  $(".jtable td").each(function(){ $(this).addClass("ui-widget-content"); });
  $(".jtable tr").hover(function(){
   $(this).children("td").addClass("ui-state-hover");
  }, function(){
   $(this).children("td").removeClass("ui-state-hover");
  });
  $("#dialog-message").dialog({autoOpen:false,modal:true,buttons:
    {"Close": function(){
     $(this).dialog("close");
    }, Cancel: function() {
     $(this).dialog("close");
    }}});
{% endblock %}

{% block title %}{{object}}{% endblock %}

{% block tools %}
      {{block.super}}
{% endblock %}

{% block content %}
<h2>{{object}}</h2>
<table class="jtable" width="600">
<thead><tr><th>Subject</th><th>From</th><th>To</th><th>Options</th></tr></thead>
<tbody>
<script type="text/javascript">
 for (message in emails){
 document.write('<tr><td><a href="#" onclick="return openMessage(message);">{% showicon "mail-closed" %}'+emails[message]['subject']+'</a></td><td>'+emails[message]['from_user']+'</td><td>'+emails[message]['to_user']+'</td><td><a href="'+emails[message]['trash_link']+'"><span class="ui-icon ui-icon-trash" style="float:left;"></span></a></td></tr>');
 }
</script>
</tbody>
</table>
{% endblock %}

{% block footer %}
 <div id="dialog-message" title="Read message">
  <form><fieldset>
    <label for="from_user">From</label>
    <input type="text" name="from_user" id="from_user" class="text ui-widget-content ui-corner-all" /><br/>
    <label for="to_user">To</label>
    <input type="text" name="to_user" id="to_user" class="text ui-widget-content ui-corner-all" /><br/>
    <label for="subject">Subject</label>
    <input type="text" name="subject" id="subject" class="text ui-widget-content ui-corner-all" /><br/>
    <label for="message">Message</label><br/>
    <textarea name="message" id="message" class="text ui-widget-content ui-corner-all"></textarea>
  </fieldset></form>
 </div>
{% endblock %}