app/views/uploads/_swf_javascript.html.erb in uploader-0.1.20 vs app/views/uploads/_swf_javascript.html.erb in uploader-0.2.0
- old
+ new
@@ -1,45 +1,64 @@
+<% if !defined?(@swfupload_scripts_included) -%>
+ <% @swfupload_scripts_included = true -%>
+ <% content_for :head do -%>
+ <%= javascript_include_tag %w{
+ swfupload/swfupload.js
+ swfupload/swfupload.swfobject
+ swfupload/swfupload.cookies
+ swfupload/swfupload.queue
+ swfupload/fileprogress.js
+ swfupload/handlers.js }, :cache => 'swf_js_cached' %>
+ <%= stylesheet_link_tag 'swfupload' %>
+ <% end -%>
+<% end -%>
+
<% content_for :head do -%>
- <%= javascript_include_tag %w{
- swfupload/swfupload.js
- swfupload/swfupload.swfobject
- swfupload/swfupload.cookies
- swfupload/swfupload.queue
- swfupload/fileprogress.js
- swfupload/handlers.js }, :cache => 'swf_js_cached' %>
- <%= stylesheet_link_tag 'swfupload' %>
+ <% if options[:transparent] -%>
+ <style type="text/css">
+ #<%=container_prefix%>swfupload_container .swfupload {position: absolute;z-index: 1;}
+ </style>
+ <% end -%>
+<% end -%>
+<% content_for :head do -%>
<script type='text/javascript'>
- var swfu;
+ var <%=container_prefix%>swfu;
- SWFUpload.onload = function () {
- var settings = {
-
+ jQuery(document).ready(function() {
+ var settings = {
+
flash_url : '/swf/swfupload.swf',
- upload_url: '<%= new_upload_path_with_session_information(parent) %>',
-
- file_size_limit : "100 MB",
- file_types : "*.*",
- file_types_description : "All Files",
- file_upload_limit : 100,
+ upload_url: '<%= options[:upload_url] || new_upload_path_with_session_information(parent) %>',
+
+ file_size_limit : '<%= options[:file_size_limit] || "100 MB" %>',
+ file_types : '<%= options[:file_types] || "*.*" %>',
+ file_types_description : '<%= options[:file_types_description] || "All Files" %>',
+ file_upload_limit : <%= options[:file_upload_limit] || 100 %>,
file_queue_limit : 0,
post_params : {
authenticity_token : '<%= u form_authenticity_token.inspect -%>',
},
custom_settings : {
- <%= 'progressTarget : "swf_fs_upload_progress",' if display_upload_indicators -%>
- cancelButtonId : "swf_cancel_button"
+ <%= 'progressTarget : "' + container_prefix + 'swf_fs_upload_progress",' if display_upload_indicators -%>
+ cancelButtonId : "<%=container_prefix%>swf_cancel_button"
},
debug: false,
// Button Settings
- button_image_url : "/images/SWFUploadButton.png", // Relative to the SWF file
- button_placeholder_id : "swf_button_holder",
- button_width: 61,
- button_height: 22,
-
+ button_placeholder_id : '<%=container_prefix%>swf_button_holder',
+ button_width: <%= options[:button_width] || 61 %>,
+ button_height: <%= options[:button_height] || 22 %>,
+
+ <% if options[:transparent] -%>
+ button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
+ button_cursor: SWFUpload.CURSOR.HAND,
+ <% else -%>
+ button_image_url : '<%= options[:button_image_url] || "/images/SWFUploadButton.png" %>', // Relative to the SWF file
+ <% end -%>
+
// The event handler functions are defined in handlers.js
swfupload_loaded_handler : swfUploadLoaded,
file_queued_handler : fileQueued,
file_queue_error_handler : fileQueueError,
file_dialog_complete_handler : fileDialogComplete,
@@ -54,10 +73,10 @@
minimum_flash_version : "9.0.28",
swfupload_pre_load_handler : swfUploadPreLoad,
swfupload_load_failed_handler : swfUploadLoadFailed
};
- swfu = new SWFUpload(settings);
- }
-
+ <%=container_prefix%>swfu = new SWFUpload(settings);
+ });
+
</script>
<% end -%>
\ No newline at end of file