Commit f3577c1b29363d9b8de8aa9e4b853518ceb0dd76
1 parent
f25e4c1b
Exists in
master
and in
29 other branches
Fix: link to add more files on upload of files
Showing
4 changed files
with
8 additions
and
8 deletions
Show diff stats
app/helpers/cms_helper.rb
@@ -9,12 +9,6 @@ module CmsHelper | @@ -9,12 +9,6 @@ module CmsHelper | ||
9 | mime_type.gsub('/', '_').gsub('-', '') | 9 | mime_type.gsub('/', '_').gsub('-', '') |
10 | end | 10 | end |
11 | 11 | ||
12 | - def add_upload_file_field(name, locals) | ||
13 | - button_to_function :add, name, nil do |page| | ||
14 | - page.insert_html :bottom, :uploaded_files, CGI::escapeHTML(render(:partial => 'upload_file', :locals => locals, :object => UploadedFile.new)) | ||
15 | - end | ||
16 | - end | ||
17 | - | ||
18 | def pagination_links(collection, options={}) | 12 | def pagination_links(collection, options={}) |
19 | options = {:previous_label => '« ', :next_label => ' »', :page_links => false}.merge(options) | 13 | options = {:previous_label => '« ', :next_label => ' »', :page_links => false}.merge(options) |
20 | will_paginate(collection, options) | 14 | will_paginate(collection, options) |
app/views/cms/_upload_file.html.erb
app/views/cms/_upload_file_form.html.erb
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | <%= hidden_field_tag('back_to', @back_to) %> | 13 | <%= hidden_field_tag('back_to', @back_to) %> |
14 | 14 | ||
15 | <% button_bar do %> | 15 | <% button_bar do %> |
16 | - <%= add_upload_file_field(_('More files'), {:size => size}) %> | 16 | + <%= button_to_function :add, _('More files'), "add_new_file_fields()" %> |
17 | <% if @back_to %> | 17 | <% if @back_to %> |
18 | <%= submit_button :save, _('Upload'), :cancel => @back_to %> | 18 | <%= submit_button :save, _('Upload'), :cancel => @back_to %> |
19 | <% else %> | 19 | <% else %> |
public/javascripts/application.js
@@ -1128,4 +1128,11 @@ function stop_fetching(element){ | @@ -1128,4 +1128,11 @@ function stop_fetching(element){ | ||
1128 | jQuery('.fetching-overlay', element).remove(); | 1128 | jQuery('.fetching-overlay', element).remove(); |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | +function add_new_file_fields() { | ||
1132 | + var cloned = jQuery('#uploaded_files p:last').clone(); | ||
1133 | + cloned.find("input[type='file']").val(''); | ||
1134 | + cloned.appendTo('#uploaded_files'); | ||
1135 | + jQuery('body').scrollTo(cloned); | ||
1136 | +} | ||
1137 | + | ||
1131 | window.isHidden = function isHidden() { return (typeof(document.hidden) != 'undefined') ? document.hidden : !document.hasFocus() }; | 1138 | window.isHidden = function isHidden() { return (typeof(document.hidden) != 'undefined') ? document.hidden : !document.hasFocus() }; |