forked from waynehoover/s3_direct_upload
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Wayne
committed
Sep 30, 2012
1 parent
b7375cd
commit 9d2b11c
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
.DS_Store | ||
spec/gallery-jquery/fileupload | ||
spec/gallery-jquery-fileupload | ||
*.gem | ||
*.rbc | ||
.bundle | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#= require jquery-fileupload/basic | ||
#= require jquery-fileupload/vendor/tmpl | ||
|
||
jQuery -> | ||
$('#fileupload').fileupload | ||
add: (e, data) -> | ||
file = data.files[0] | ||
data.context = $(tmpl("template-upload", file)) | ||
$('#fileupload').append(data.context) | ||
data.submit() | ||
|
||
progress: (e, data) -> | ||
if data.context | ||
progress = parseInt(data.loaded / data.total * 100, 10) | ||
data.context.find('.bar').css('width', progress + '%') | ||
|
||
done: (e, data) -> | ||
file = data.files[0] | ||
domain = $('#fileupload').attr('action') | ||
path = $('#fileupload input[name=key]').val().replace('${filename}', file.name) | ||
to = $('#fileupload').data('post') | ||
content = {} | ||
content[$('#fileupload').data('as')] = domain + path | ||
$.post(to, content) | ||
data.context.remove() if data.context # remove progress bar | ||
|
||
fail: (e, data) -> | ||
alert("#{data.files[0].name} failed to upload.") | ||
console.log("Upload failed:") | ||
console.log(data) |
17 changes: 17 additions & 0 deletions
17
app/assets/stylesheets/s3_direct_upload_progress_bars.css.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.upload { | ||
border-top: solid 1px #CCC; | ||
width: 400px; | ||
padding-top: 10px; | ||
margin-top: 10px; | ||
|
||
.progress { | ||
margin-top: 8px; | ||
border: solid 1px #555; | ||
border-radius: 3px; | ||
-moz-border-radius: 3px; | ||
.bar { | ||
height: 10px; | ||
background: #3EC144; | ||
} | ||
} | ||
} |