Adds a button to remove a file upload before submission (#5670).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6212 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
e6104d344f
commit
e63f0c615c
|
@ -1,8 +1,10 @@
|
||||||
<span id="attachments_fields">
|
<span id="attachments_fields">
|
||||||
<%= file_field_tag 'attachments[1][file]', :size => 30, :id => nil -%><label class="inline"><span id="attachment_description_label_content"><%= l(:label_optional_description) %></span><%= text_field_tag 'attachments[1][description]', '', :size => 60, :id => nil %>
|
<span>
|
||||||
</label>
|
<%= file_field_tag 'attachments[1][file]', :size => 30, :id => nil, :class => 'file' -%>
|
||||||
|
<label class="inline"><%= l(:label_optional_description) %><%= text_field_tag 'attachments[1][description]', '', :size => 60, :id => nil, :class => 'description' %></label>
|
||||||
|
<%= link_to_function(image_tag('delete.png'), 'removeFileField(this)', :title => (l(:button_delete))) %>
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<br />
|
|
||||||
<small><%= link_to l(:label_add_another_file), '#', :onclick => 'addFileField(); return false;' %>
|
<small><%= link_to l(:label_add_another_file), '#', :onclick => 'addFileField(); return false;' %>
|
||||||
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
|
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
|
||||||
</small>
|
</small>
|
||||||
|
|
|
@ -86,9 +86,9 @@ function hideFieldset(el) {
|
||||||
var fileFieldCount = 1;
|
var fileFieldCount = 1;
|
||||||
|
|
||||||
function addFileField() {
|
function addFileField() {
|
||||||
if (fileFieldCount >= 10) return false
|
|
||||||
fileFieldCount++;
|
|
||||||
var fields = $('attachments_fields');
|
var fields = $('attachments_fields');
|
||||||
|
if (fields.childElements().length >= 10) return false;
|
||||||
|
fileFieldCount++;
|
||||||
var s = document.createElement("span");
|
var s = document.createElement("span");
|
||||||
s.update(fields.down('span').innerHTML);
|
s.update(fields.down('span').innerHTML);
|
||||||
s.down('input.file').name = "attachments[" + fileFieldCount + "][file]";
|
s.down('input.file').name = "attachments[" + fileFieldCount + "][file]";
|
||||||
|
@ -96,6 +96,16 @@ function addFileField() {
|
||||||
fields.appendChild(s);
|
fields.appendChild(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeFileField(el) {
|
||||||
|
var fields = $('attachments_fields');
|
||||||
|
var s = Element.up(el, 'span');
|
||||||
|
if (fields.childElements().length > 1) {
|
||||||
|
s.remove();
|
||||||
|
} else {
|
||||||
|
s.update(s.innerHTML);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function showTab(name) {
|
function showTab(name) {
|
||||||
var f = $$('div#content .tab-content');
|
var f = $$('div#content .tab-content');
|
||||||
for(var i=0; i<f.length; i++){
|
for(var i=0; i<f.length; i++){
|
||||||
|
|
|
@ -445,6 +445,8 @@ fieldset#notified_events .parent { padding-left: 20px; }
|
||||||
.summary {font-style: italic;}
|
.summary {font-style: italic;}
|
||||||
|
|
||||||
#attachments_fields input[type=text] {margin-left: 8px; }
|
#attachments_fields input[type=text] {margin-left: 8px; }
|
||||||
|
#attachments_fields span {display:block; white-space:nowrap;}
|
||||||
|
#attachments_fields img {vertical-align: middle;}
|
||||||
|
|
||||||
div.attachments { margin-top: 12px; }
|
div.attachments { margin-top: 12px; }
|
||||||
div.attachments p { margin:4px 0 2px 0; }
|
div.attachments p { margin:4px 0 2px 0; }
|
||||||
|
|
Loading…
Reference in New Issue