Commit 63f475de6734cd3e1bc1f7a0890a0a821450c4bc
Exists in
master
and in
27 other branches
Merge branch 'add-more-files' into 'master'
Add more files See merge request !508
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 | 9 | mime_type.gsub('/', '_').gsub('-', '') |
10 | 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 | 12 | def pagination_links(collection, options={}) |
19 | 13 | options = {:previous_label => '« ', :next_label => ' »', :page_links => false}.merge(options) |
20 | 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 | 13 | <%= hidden_field_tag('back_to', @back_to) %> |
14 | 14 | |
15 | 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 | 17 | <% if @back_to %> |
18 | 18 | <%= submit_button :save, _('Upload'), :cancel => @back_to %> |
19 | 19 | <% else %> | ... | ... |
public/javascripts/application.js
... | ... | @@ -1128,4 +1128,11 @@ function stop_fetching(element){ |
1128 | 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 | 1138 | window.isHidden = function isHidden() { return (typeof(document.hidden) != 'undefined') ? document.hidden : !document.hasFocus() }; | ... | ... |