Skip to content
Browse files

Added doChecks, and also name tag so that pressing the form submit

doesn't take you to the top of the page.
  • Loading branch information...
1 parent 3d936a5 commit 51c4f47920e6c4ee60d36de1867f5b90e43da45b Martin Gregory committed May 12, 2009
Showing with 9 additions and 2 deletions.
  1. +9 −2 lib/s3_swf_upload/view_helpers.rb
View
11 lib/s3_swf_upload/view_helpers.rb
@@ -10,6 +10,11 @@ def s3_swf_upload_tag(options = {})
prefix = options[:prefix] || ''
upload = options[:upload] || 'Upload'
initial_message = options[:initial_message] || 'Select file to upload...'
+ do_checks = options[:do_checks] || "0"
+
+ if do_checks != "1" && do_checks != "0"
+ raise "Ooops, do_checks has to be either '0' or '1' (a string)"
+ end
prefix = prefix + "/" unless prefix == ""
@@ -23,11 +28,13 @@ def s3_swf_upload_tag(options = {})
@include_s3_upload = true
end
- out << %(<script type="text/javascript">
+ out << %(<a name="uploadform#{@count}"></a>
+ <script type="text/javascript">
var s3_swf#{@count} = s3_swf_init('s3_swf#{@count}', {
width: #{width},
height: #{height},
initialMessage: '#{initial_message}',
+ doChecks: '#{do_checks}',
onSuccess: function(filename, filesize, contenttype){
#{success}
},
@@ -45,7 +52,7 @@ def s3_swf_upload_tag(options = {})
</div>
<div class="s3-swf-upload-link">
- <a href="#" onclick="s3_swf#{@count}.upload('#{prefix}')">#{upload}</a>
+ <a href="#uploadform#{@count}" onclick="s3_swf#{@count}.upload('#{prefix}')">#{upload}</a>
</div>
)

0 comments on commit 51c4f47

Please sign in to comment.
Something went wrong with that request. Please try again.