Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a couple more customisations to the settings. #169

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/assets/javascripts/s3_direct_upload.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ $.fn.S3Uploader = (options) ->
progress_bar_target: null
click_submit_target: null
allow_multiple_files: true
progress_bar_orientation: 'width'
progress_bar_invert_count: false # inverts the progress count e.g. (100% = 0%)
progress_bar_element: '.bar'

$.extend settings, options

Expand Down Expand Up @@ -60,8 +63,11 @@ $.fn.S3Uploader = (options) ->

progress: (e, data) ->
if data.context
progress = parseInt(data.loaded / data.total * 100, 10)
data.context.find('.bar').css('width', progress + '%')
if settings.progress_bar_invert_count
progress = parseInt(100 - (data.loaded / data.total * 100), 10)
else
progress = parseInt(data.loaded / data.total * 100, 10)
data.context.find(settings.progress_bar_element).css(settings.progress_bar_orientation, progress + '%')

done: (e, data) ->
content = build_content_object $uploadForm, data.files[0], data.result
Expand Down