1 {% from 'forms/_form.html' import form_header, form_footer, form_rows, form_row %}
4 {{ form_header(form, id='dropzone', classes='dropzone', action=action) }}
5 {% if existing_attachment %}
6 <div class=
"form-group" id=
"form-group-protected">
7 <div class=
"form-label form-block">
8 <label>{% trans %}File{% endtrans %}
</label>
10 <div class=
"form-field form-block">
11 <div class=
"dropzone-area">
12 <div class=
"dropzone-area-inner">
13 <div class=
"dropzone-previews">
14 <div class=
"dz-message"></div>
16 <div class=
"select-files-btn">
17 <button type=
"button" class=
"i-button">
18 {%- trans %}Choose from your computer{% endtrans -%}
23 <p class=
"form-field-description">
24 <em>{% trans %}Already uploaded file. Replace it by adding a new file.{% endtrans %}
</em>
28 <input id=
"file-change-trigger" type=
"hidden" value=
"0" name=
"__file_change_trigger">
30 <div class=
"dropzone-area">
31 <div class=
"dropzone-previews">
32 <div class=
"dz-message">
33 {% trans %}Drag files here{% endtrans %}
34 <span class=
"message-seperator">- or -
</span>
37 <div class=
"select-files-btn">
38 <button class=
"i-button" type=
"button">
39 {%- trans %}Choose from your computer{% endtrans -%}
44 {{ form_rows(form, skip=('folder', 'protected', 'acl')) }}
45 {{ form_row(form.folder) }}
46 {{ form_row(form.protected) }}
47 {{ form_row(form.acl, allow_missing=true) }}
48 {% call form_footer(attach_form) %}
49 <div class=
"dropzone-upload-btn">
50 {% if existing_attachment -%}
51 <input class=
"i-button big highlight js-dropzone-save" type=
"submit"
52 value=
"{% trans %}Save{% endtrans %}" data-disabled-until-change
>
54 <input class=
"i-button big highlight js-dropzone-upload" type=
"submit" disabled
55 value=
"{% trans %}Upload{% endtrans %}">
57 <button class=
"i-button big" data-button-back
>{% trans %}Cancel{% endtrans %}
</button>
64 $('#folder').nullableselector();
65 aclIfProtected($('#protected'), $('#acl'));
66 $('#dropzone').dropzone({
67 clickable
: '.dropzone-area',
68 previewsContainer
: '.dropzone-previews',
69 autoProcessQueue
: false,
73 paramName: function() { return 'file'; },
75 var uploadButton
= $('.js-dropzone-upload');
76 var saveButton
= $('.js-dropzone-save');
78 var form
= $('#dropzone');
80 {% if existing_attachment
%}
81 self
.options
.maxFiles
= 1;
83 name
: {{ existing_attachment
.file
.filename
| tojson
}},
84 size
: {{ existing_attachment
.file
.size
| tojson
}},
88 self
.emit('addedfile', existingFile
);
89 $('.dz-progress').hide();
90 self
.files
[0] = existingFile
;
93 uploadButton
.on('click', function(e
) {
96 $('.dz-progress').show();
100 saveButton
.on('click', function(e
) {
101 if (self
.getQueuedFiles().length
) {
105 $('.dz-progress').show();
109 self
.on('addedfile', function() {
110 {% if existing_attachment
%}
111 self
.removeFile(self
.files
[0]);
112 $('#file-change-trigger').val('1');
113 $('#dropzone').trigger('change');
115 uploadButton
.prop('disabled', false);
116 $('.dz-message').hide();
117 $('.dz-progress').hide();
120 self
.on('sendingmultiple', function() {
121 form
.trigger('ajaxDialog:beforeSubmit');
124 self
.on('successmultiple', function(e
, response
) {
125 form
.trigger('ajaxDialog:success', [response
]);
128 self
.on('error', function(e
, msg
, xhr
) {
130 form
.trigger('ajaxDialog:error', [xhr
]);