mail: make clicking on a row open the associated pdf

This commit is contained in:
Frédéric Péters 2015-07-07 15:22:11 +02:00
parent 7835f218ad
commit 1521ee6372
5 changed files with 19 additions and 2 deletions

View File

@ -0,0 +1,3 @@
window.addEventListener('message', function(event) {
PDFViewerApplication.open(event.data);
}, false);

View File

@ -4,11 +4,11 @@
<div class="mails">
<ul>
{% for mail in mails %}
<li>{{ mail.creation_timestamp }}</li>
<li data-pdf-href="{{ mail.content.url }}">{{ mail.creation_timestamp }}</li>
{% endfor %}
</ul>
</div>
<iframe src="{% url 'mail-viewer' %}">
<iframe id="pdf-viewer" src="{% url 'mail-viewer' %}">
</iframe>
</div>

View File

@ -45,6 +45,8 @@ http://sourceforge.net/adobe/cmap/wiki/License/
PDFJS.workerSrc = "{% static 'pdf/build/pdf.worker.js' %}";
</script>
<script src="{% static 'js/welco.viewer.js' %}"></script>
</head>
<body tabindex="1" class="loadingInProgress">

6
welco/static/js/welco.js Normal file
View File

@ -0,0 +1,6 @@
$(function() {
$('.mails ul li[data-pdf-href]').on('click', function() {
$('#pdf-viewer')[0].contentWindow.postMessage($(this).data('pdf-href'),
window.location.protocol + '//' + window.location.host);
});
});

View File

@ -1,7 +1,13 @@
{% extends "gadjo/base.html" %}
{% load static %}
{% block page-title %}Welco{% endblock %}
{% block site-title %}Welco{% endblock %}
{% block more-user-links %}
{% endblock %}
{% block extrascripts %}
{{ block.super }}
<script src="{% static "js/welco.js" %}"></script>
{% endblock %}