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