style
[redakcja.git] / apps / fileupload / templatetags / upload_tags.py
1 # -*- coding: utf-8 -*-
2 from django import template
3
4 register = template.Library()
5
6
7 @register.simple_tag
8 def upload_js():
9     return """
10 <!-- The template to display files available for upload -->
11 <script id="template-upload" type="text/x-tmpl">
12 {% for (var i=0, file; file=o.files[i]; i++) { %}
13     <tr class="template-upload fade">
14         <td class="preview"><span class="fade"></span></td>
15         <td class="name"><span>{%=file.name%}</span></td>
16         <td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
17         {% if (file.error) { %}
18             <td class="error" colspan="2">
19                 <span class="label label-important">{%=locale.fileupload.error%}</span>
20                 {%=locale.fileupload.errors[file.error] || file.error%}
21             </td>
22         {% } else if (o.files.valid && !i) { %}
23             <td>
24                 <div class="progress progress-success progress-striped active">
25                     <div class="bar" style="width:0%;"></div>
26                 </div>
27             </td>
28             <td class="start">{% if (!o.options.autoUpload) { %}
29                 <button class="btn btn-success">
30                     <i class="icon-upload icon-white"></i>
31                     <span>{%=locale.fileupload.start%}</span>
32                 </button>
33             {% } %}</td>
34         {% } else { %}
35             <td colspan="2"></td>
36         {% } %}
37         <td class="cancel">{% if (!i) { %}
38             <button class="btn btn-warning">
39                 <i class="icon-ban-circle icon-white"></i>
40                 <span>{%=locale.fileupload.cancel%}</span>
41             </button>
42         {% } %}</td>
43     </tr>
44 {% } %}
45 </script>
46 <!-- The template to display files available for download -->
47 <script id="template-download" type="text/x-tmpl">
48 {% for (var i=0, file; file=o.files[i]; i++) { %}
49     <tr class="template-download fade">
50         {% if (file.error) { %}
51             <td></td>
52             <td class="name"><span>{%=file.name%}</span></td>
53             <td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
54             <td class="error" colspan="2">
55                 <span class="label label-important">{%=locale.fileupload.error%}</span>
56                 {%=locale.fileupload.errors[file.error] || file.error%}
57             </td>
58         {% } else { %}
59             <td class="preview">{% if (file.thumbnail_url) { %}
60                 <a href="{%=file.url%}" title="{%=file.name%}" rel="gallery" download="{%=file.name%}">
61                     <img src="{%=file.thumbnail_url%}">
62                 </a>
63             {% } %}</td>
64             <td class="name">
65                 <a href="{%=file.url%}" title="{%=file.name%}" rel="{%=file.thumbnail_url&&'gallery'%}"
66                    download="{%=file.name%}">{%=file.name%}</a>
67             </td>
68             <td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
69             <td colspan="2"></td>
70         {% } %}
71         <td class="delete">
72             <button class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}">
73                 <i class="icon-trash icon-white"></i>
74                 <span>{%=locale.fileupload.destroy%}</span>
75             </button>
76             <input type="checkbox" name="delete" value="1">
77         </td>
78     </tr>
79 {% } %}
80 </script>
81 """