##// END OF EJS Templates
Adds a button to remove a file upload before submission (#5670)....
Jean-Philippe Lang -
r6092:e63f0c615cb3
parent child
Show More
@@ -1,8 +1,10
1 <span id="attachments_fields">
1 <span id="attachments_fields">
2 <%= 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 %>
2 <span>
3 </label>
3 <%= file_field_tag 'attachments[1][file]', :size => 30, :id => nil, :class => 'file' -%>
4 <label class="inline"><%= l(:label_optional_description) %><%= text_field_tag 'attachments[1][description]', '', :size => 60, :id => nil, :class => 'description' %></label>
5 <%= link_to_function(image_tag('delete.png'), 'removeFileField(this)', :title => (l(:button_delete))) %>
6 </span>
4 </span>
7 </span>
5 <br />
6 <small><%= link_to l(:label_add_another_file), '#', :onclick => 'addFileField(); return false;' %>
8 <small><%= link_to l(:label_add_another_file), '#', :onclick => 'addFileField(); return false;' %>
7 (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
9 (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
8 </small>
10 </small>
@@ -86,9 +86,9 function hideFieldset(el) {
86 var fileFieldCount = 1;
86 var fileFieldCount = 1;
87
87
88 function addFileField() {
88 function addFileField() {
89 if (fileFieldCount >= 10) return false
90 fileFieldCount++;
91 var fields = $('attachments_fields');
89 var fields = $('attachments_fields');
90 if (fields.childElements().length >= 10) return false;
91 fileFieldCount++;
92 var s = document.createElement("span");
92 var s = document.createElement("span");
93 s.update(fields.down('span').innerHTML);
93 s.update(fields.down('span').innerHTML);
94 s.down('input.file').name = "attachments[" + fileFieldCount + "][file]";
94 s.down('input.file').name = "attachments[" + fileFieldCount + "][file]";
@@ -96,6 +96,16 function addFileField() {
96 fields.appendChild(s);
96 fields.appendChild(s);
97 }
97 }
98
98
99 function removeFileField(el) {
100 var fields = $('attachments_fields');
101 var s = Element.up(el, 'span');
102 if (fields.childElements().length > 1) {
103 s.remove();
104 } else {
105 s.update(s.innerHTML);
106 }
107 }
108
99 function showTab(name) {
109 function showTab(name) {
100 var f = $$('div#content .tab-content');
110 var f = $$('div#content .tab-content');
101 for(var i=0; i<f.length; i++){
111 for(var i=0; i<f.length; i++){
@@ -445,6 +445,8 fieldset#notified_events .parent { padding-left: 20px; }
445 .summary {font-style: italic;}
445 .summary {font-style: italic;}
446
446
447 #attachments_fields input[type=text] {margin-left: 8px; }
447 #attachments_fields input[type=text] {margin-left: 8px; }
448 #attachments_fields span {display:block; white-space:nowrap;}
449 #attachments_fields img {vertical-align: middle;}
448
450
449 div.attachments { margin-top: 12px; }
451 div.attachments { margin-top: 12px; }
450 div.attachments p { margin:4px 0 2px 0; }
452 div.attachments p { margin:4px 0 2px 0; }
General Comments 0
You need to be logged in to leave comments. Login now