Skip to content

Commit

Permalink
added support for single file progress bar without js template
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Fracczak committed May 29, 2013
1 parent d647ad2 commit 337b141
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,29 @@ jQuery ->
progress_bar_target: $('.js-progress-bars')
click_submit_target: $('.submit-target')
```
### Example with single file upload bar without script template

This demonstrates how to use progress_bar_target and allow_multiple_files (only works with false option - single file) to show only one progress bar without script template.

```coffeescript
jQuery ->
$("#myS3Uploader").S3Uploader
progress_bar_target: $('.js-progress-bars')
allow_multiple_files: false
```

Target for progress bar

```ruby
<div class= "upload js-progress-bars">
<div class="progress">
<div class="bars"> </div>
</div>
</div>
```




### Public methods
You can change the settings on your form later on by accessing the jQuery instance:
Expand Down
7 changes: 5 additions & 2 deletions app/assets/javascripts/s3_direct_upload.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ $.fn.S3Uploader = (options) ->
file.unique_id = Math.random().toString(36).substr(2,16)

unless settings.before_add and not settings.before_add(file)
data.context = $($.trim(tmpl("template-upload", file))) if $('#template-upload').length > 0
$(data.context).appendTo(settings.progress_bar_target || $uploadForm)
if $('#template-upload').length > 0
data.context = $($.trim(tmpl("template-upload", file)))
$(data.context).appendTo(settings.progress_bar_target || $uploadForm)
else if !setting.allow_multiple_files
data.context = settings.progress_bar_target
if settings.click_submit_target
if settings.allow_multiple_files
forms_for_submit.push data
Expand Down

0 comments on commit 337b141

Please sign in to comment.