<% attachment_param ||= 'attachments' %>
+<% attachment_format_custom_field ||= false %>
<% saved_attachments ||= container.saved_attachments if defined?(container) && container %>
<% multiple = true unless defined?(multiple) && multiple == false %>
<% show_add = multiple || saved_attachments.blank? %>
<% description = (defined?(description) && description == false ? false : true) %>
-<% css_class = (defined?(filedrop) && filedrop == false ? '' : 'filedrop') %>
+<% css_class = (defined?(filedrop) && filedrop == false ? '' : (attachment_format_custom_field ? 'custom-field-filedrop' : 'filedrop')) %>
<span class="attachments_form">
<span class="attachments_fields">
:multiple => multiple,
:onchange => 'addInputFiles(this);',
:data => {
- :max_number_of_files_message => l(:error_attachments_too_many, :max_number_of_files => 10),
+ :max_number_of_files_message => l(:error_attachments_too_many, :max_number_of_files => (multiple ? 10 : 1)),
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
:multiple => false,
:description => false,
:saved_attachments => [attachment].compact,
- :filedrop => false
+ :filedrop => true,
+ :attachment_format_custom_field => true
})
end
end
if ($.inArray('Files', e.dataTransfer.types) > -1) {
handleFileDropEvent.target = e.target;
- uploadAndAttachFiles(e.dataTransfer.files, $('input:file.filedrop').first());
+ if ($(this).hasClass('custom-field-filedroplistner')){
+ uploadAndAttachFiles(e.dataTransfer.files, $(this).find('input:file.custom-field-filedrop').first());
+ } else {
+ uploadAndAttachFiles(e.dataTransfer.files, $(this).find('input:file.filedrop').first());
+ }
}
}
handleFileDropEvent.target = '';
paste: copyImageFromClipboard
}).addClass('filedroplistner');
});
+
+ $('form div.box input:file.custom-field-filedrop').closest('p').not('.custom-field-filedroplistner').each(function() {
+ $(this).on({
+ dragover: dragOverHandler,
+ dragleave: dragOutHandler,
+ drop: handleFileDropEvent
+ }).addClass('custom-field-filedroplistner');
+ });
}
}
a.remove-upload:hover {text-decoration:none !important;}
.existing-attachment.deleted .filename {text-decoration:line-through; color:#999 !important;}
-div.fileover { background-color: lavender; }
+div.fileover, p.custom-field-filedroplistner.fileover { background-color: lavender; }
div.attachments p { margin:4px 0 2px 0; }
div.attachments img { vertical-align: middle; }