* separated plupload widget to partial view

* further localization progress

git-svn-id: http://redmine-dmsf.googlecode.com/svn/trunk/redmine_dmsf@32 5e329b0b-a2ee-ea63-e329-299493fc886d
This commit is contained in:
vit.jonas@gmail.com 2011-05-10 07:01:53 +00:00
parent 959b91052d
commit 47867fda7c
9 changed files with 215 additions and 148 deletions

View File

@ -0,0 +1,128 @@
<div class="box">
<% form_tag({:controller => "dmsf_detail", :action => "upload_files", :id => @project, :folder_id => @folder},
:id => "uploadform", :method=>:post, :multipart => true) do %>
<% if Setting.attachment_max_size.to_i >= 102400 %>
<div class="upload_select">
File size: <select id="uploader_select"><option value="1">&lt; 100 MB</option><option value="2">> 100 MB</option></select>
</div>
<% end %>
<h3>File Upload</h3>
<div style="padding-bottom: 6px; line-height: 1.4em; font-size: 0.9em;">
<span>
<% if Setting.plugin_redmine_dmsf["dmsf_max_file_upload"].to_i > 0 %>There can be uploaded maximum of <%= Setting.plugin_redmine_dmsf["dmsf_max_file_upload"].to_i %> files at once.<% end %>
<% if Setting.attachment_max_size.to_i >= 2097151 %>To upload files greater than 2GB you must have 64b browser.<% end %>
</span>
</div>
<div id="uploader">
<p>
<span id="uploaded_files_fields">
<%= file_field_tag("uploaded_files[1]", :size => 30, :id => nil) %>
</span>
<br />
<small><%= link_to(l(:label_add_another_file), "#", :onclick => "dmsfAddFileField(); return false;" ) %>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</small>
</p>
<%= submit_tag("Upload") %>
</div>
<% end %>
</div>
<% content_for :header_tags do %>
<%= stylesheet_link_tag "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/themes/base/jquery-ui.css" %>
<%= stylesheet_link_tag "plupload/jquery.ui.plupload.css", :plugin => "redmine_dmsf" %>
<%= stylesheet_link_tag "dmsf", :plugin => "redmine_dmsf" %>
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js" %>
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js" %>
<%= javascript_include_tag "plupload/plupload.js", :plugin => "redmine_dmsf" %>
<%= javascript_include_tag "plupload/plupload.flash.js", :plugin => "redmine_dmsf" %>
<%= javascript_include_tag "plupload/plupload.gears.js", :plugin => "redmine_dmsf" %>
<%= javascript_include_tag "plupload/plupload.html5.js", :plugin => "redmine_dmsf" %>
<%= javascript_include_tag "plupload/plupload.html4.js", :plugin => "redmine_dmsf" %>
<%= javascript_include_tag "plupload/jquery.ui.plupload/jquery.ui.plupload.js", :plugin => "redmine_dmsf" %>
<% if I18n.locale && !I18n.locale.to_s.match(/^en.*/) %>
<%= javascript_include_tag "plupload/i18n/#{I18n.locale.to_s.downcase}.js", :plugin => "redmine_dmsf" %>
<% end %>
<script type="text/javascript">
jQuery.noConflict();
var originalUploaderContent;
jQuery(document).ready(function() {
var uploader = jQuery('#uploader');
originalUploaderContent = uploader.html();
jQuery('#uploader_select').change(function() {
if(jQuery(this).val() == 2) {
uploader.html(originalUploaderContent);
} else {
initPlUploader(uploader);
}
});
initPlUploader(uploader);
});
function initPlUploader(uploader) {
uploader.html("<div></div>");
uploader = jQuery("div",uploader);
uploader.plupload({
runtimes : 'gears,html5,flash,html4',
url : '<%= url_for({:controller => "dmsf_detail", :action => "upload_file", :id => @project, :folder_id => @folder}) %>',
max_file_size : "100mb",
max_file_count: '<%= Setting.plugin_redmine_dmsf["dmsf_max_file_upload"].to_i if Setting.plugin_redmine_dmsf["dmsf_max_file_upload"].to_i > 0 %>',
multipart: true,
multipart_params : {authenticity_token : jQuery("input[name=authenticity_token]").val()},
// Rename files by clicking on their titles
rename: true,
// Flash settings
flash_swf_url : '<%= Engines::RailsExtensions::AssetHelpers.plugin_asset_path("redmine_dmsf", "javascripts", "plupload/plupload.flash.swf") %>'
});
jQuery(".plupload_scroll",uploader).resizable({
handles: "s"
});
var pluploader = uploader.plupload('getUploader');
pluploader.bind('FileUploaded', function(pluploader, file, response) {
var responseObject = jQuery.parseJSON(response.response);
var disk_filename_input = jQuery("<input/>").attr("type","hidden")
.attr("name","uploaded[" + dmsfFileFieldCount + "][disk_filename]")
.val(responseObject.disk_filename);
uploader.append(disk_filename_input);
var content_type_input = jQuery("<input/>").attr("type","hidden")
.attr("name","uploaded[" + dmsfFileFieldCount + "][content_type]")
.val(responseObject.content_type);
uploader.append(content_type_input);
var original_filename_input = jQuery("<input/>").attr("type","hidden")
.attr("name","uploaded[" + dmsfFileFieldCount + "][original_filename]")
.val(responseObject.original_filename);
uploader.append(original_filename_input);
if(pluploader.total.uploaded == pluploader.files.length) jQuery('#uploadform').submit();
else dmsfFileFieldCount++;
});
}
var dmsfFileFieldCount = 1;
function dmsfAddFileField() {
if (dmsfFileFieldCount >= 10) return false
dmsfFileFieldCount++;
var f = document.createElement("input");
f.type = "file";
f.name = "uploaded_files[" + dmsfFileFieldCount + "]";
f.size = 30;
var p = document.getElementById("uploaded_files_fields");
p.appendChild(document.createElement("br"));
p.appendChild(f);
}
</script>
<% end %>

View File

@ -85,7 +85,7 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder
{:action => "download_file", :id => @project, :file_id => file},
:class => "icon icon-file #{Redmine::MimeType.css_class_of(file.name)}",
:title => l(:title_title_version_version_download, :title => h(file.last_revision.title), :version => file.last_revision.version)) %>
<div class="filename"><%= h(file.display_name) %></div><br class="clear" />
<div class="filename"><%= h(file.display_name) %></div>
</td>
<td class="size"><%= number_to_human_size(file.last_revision.size) unless file.last_revision.nil? %></td>
<td class="modified">
@ -93,10 +93,10 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder
<% if file.locked_for_user? %>
<%= link_to(image_tag("locked.png", :plugin => "redmine_dmsf"),
{:controller => "users", :action => "show", :id => file.locks[0].user },
:title => "Locked by " + file.locks[0].user.to_s) %>
:title => l(:title_locked_by_user, :user => file.locks[0].user.to_s)) %>
<% else
if file.locked? %>
<%= image_tag("lockedbycurrent.png", :title => "Locked by you",
<%= image_tag("lockedbycurrent.png", :title => l(:title_locked_by_you),
:plugin => "redmine_dmsf") %>
<% end %>
<% end %>
@ -104,9 +104,9 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder
<td class="version">
<%= file.last_revision.version unless file.last_revision.nil? %>
<% case file.last_revision.workflow
when 1 then %><%= image_tag("waitingforapproval.png", :title => "Waiting for Approval",
when 1 then %><%= image_tag("waitingforapproval.png", :title => l(:title_waiting_for_approval),
:plugin => "redmine_dmsf") %>
<% when 2 then %><%= image_tag("approved.png", :title => "Approved",
<% when 2 then %><%= image_tag("approved.png", :title => l(:title_approved),
:plugin => "redmine_dmsf") %>
<% end %>
</td>
@ -121,28 +121,28 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder
<% if file.locked? %>
<%= link_to(image_tag("unlock.png", :plugin => "redmine_dmsf"),
{:controller => "dmsf_state", :action => "unlock_file", :id => @project, :file_id => file },
:title => "Unlock to allow changes for other members") %>
:title => l(:title_unlock_file)) %>
<% else %>
<%= link_to(image_tag("lock.png", :plugin => "redmine_dmsf"),
{:controller => "dmsf_state", :action => "lock_file", :id => @project, :file_id => file },
:title => "Lock to prevent changes for other members") %>
:title => l(:title_lock_file)) %>
<% end %>
&nbsp;
<% end %>
<% if User.current.allowed_to?(:file_manipulation, @project) %>
<%= link_to(image_tag("delete.png", :plugin => "redmine_dmsf"),
{:controller => "dmsf_detail", :action => "delete_file", :id => @project,
:file_id => file}, :class => "delete-link", :title => "Delete") %>
:file_id => file}, :class => "delete-link", :title => l(:title_delete)) %>
<% end %>
<% if User.current.allowed_to?(:file_approval, @project) %>
<% if file.notification %>
<%= link_to(image_tag("notify.png", :plugin => "redmine_dmsf"),
{:controller => "dmsf_state", :action => "file_notify_deactivate", :id => @project,
:file_id => file}, :title => "Notifications active: Deactivate") %>
:file_id => file}, :title => l(:title_notifications_active_deactivate)) %>
<% else %>
<%= link_to(image_tag("notifynot.png", :plugin => "redmine_dmsf"),
{:controller => "dmsf_state", :action => "file_notify_activate", :id => @project,
:file_id => file}, :title => "Notifications not active: Activate") %>
:file_id => file}, :title => l(:title_notifications_not_active_activate)) %>
<% end %>
<% end %>
</div><br class="clear" />
@ -152,68 +152,22 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder
</tbody>
</table>
<div class="controls">
<%= submit_tag("Download", :title => "Download checked in zip archive", :name => "download_entries") %>
<%= submit_tag(l(:submit_download), :title => l(:title_download_checked), :name => "download_entries") %>
<!-- <button type="button" id="EntriesDeleteButton" title="Delete checked">Delete</button> -->
<%= submit_tag("Email", :title => "Send checked by email", :name => "email_entries") %>
<%= submit_tag(l(:submit_email), :title => l(:title_send_checked_by_email), :name => "email_entries") %>
</div>
<br />
<% end %>
<div class="box">
<% form_tag({:controller => "dmsf_detail", :action => "upload_files", :id => @project, :folder_id => @folder},
:id => "uploadform", :method=>:post, :multipart => true) do %>
<% if Setting.attachment_max_size.to_i >= 102400 %>
<div class="upload_select">
File size: <select id="uploader_select"><option value="1">&lt; 100 MB</option><option value="2">> 100 MB</option></select>
</div>
<% end %>
<h3>File Upload</h3>
<div style="padding-bottom: 6px; line-height: 1.4em; font-size: 0.9em;">
<span>
<% if Setting.plugin_redmine_dmsf["dmsf_max_file_upload"].to_i > 0 %>There can be uploaded maximum of <%= Setting.plugin_redmine_dmsf["dmsf_max_file_upload"].to_i %> files at once.<% end %>
<% if Setting.attachment_max_size.to_i >= 2097151 %>To upload files greater than 2GB you must have 64b browser.<% end %>
</span>
</div>
<div id="uploader">
<p>
<span id="uploaded_files_fields">
<%= file_field_tag("uploaded_files[1]", :size => 30, :id => nil) %>
</span>
<br />
<small><%= link_to(l(:label_add_another_file), "#", :onclick => "dmsfAddFileField(); return false;" ) %>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</small>
</p>
<%= submit_tag("Upload") %>
</div>
<% end %>
</div>
<%= render(:partial => "multi_upload") %>
<br />
<%= render(:partial => 'user_pref') %>
<%= render(:partial => "user_pref") %>
<% content_for :header_tags do %>
<%= stylesheet_link_tag "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/themes/base/jquery-ui.css" %>
<%= stylesheet_link_tag "plupload/jquery.ui.plupload.css", :plugin => "redmine_dmsf" %>
<%= stylesheet_link_tag "dmsf", :plugin => "redmine_dmsf" %>
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js" %>
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js" %>
<%= javascript_include_tag "plupload/plupload.js", :plugin => "redmine_dmsf" %>
<%= javascript_include_tag "plupload/plupload.flash.js", :plugin => "redmine_dmsf" %>
<%= javascript_include_tag "plupload/plupload.gears.js", :plugin => "redmine_dmsf" %>
<%= javascript_include_tag "plupload/plupload.html5.js", :plugin => "redmine_dmsf" %>
<%= javascript_include_tag "plupload/plupload.html4.js", :plugin => "redmine_dmsf" %>
<%= javascript_include_tag "plupload/jquery.ui.plupload/jquery.ui.plupload.js", :plugin => "redmine_dmsf" %>
<% if I18n.locale && !I18n.locale.to_s.match(/^en.*/) %>
<%= javascript_include_tag "plupload/i18n/#{I18n.locale.to_s.downcase}.js", :plugin => "redmine_dmsf" %>
<% end %>
<script type="text/javascript">
jQuery.noConflict();
var originalUploaderContent;
jQuery(document).ready(function() {
jQuery("a.delete-link").click(function(event) {
if(!window.confirm("<%= l(:question_do_you_really_want_to_delete_this_entry) %>")) event.preventDefault();
@ -227,92 +181,6 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder
jQuery("input[type=checkbox]", jQuery("#browser > tbody")).prop("checked", false);
}
})
jQuery("#EntriesDeleteButton").click(function(event) {
if(!window.confirm("Really?")) {
event.preventDefault();
return;
}
var operation = jQuery("input[name=EntriesOperation]");
operation.val("delete");
var entries = jQuery("#Entries");
entries.submit();
})
var uploader = jQuery('#uploader');
originalUploaderContent = uploader.html();
jQuery('#uploader_select').change(function() {
if(jQuery(this).val() == 2) {
uploader.html(originalUploaderContent);
} else {
initPlUploader(uploader);
}
});
initPlUploader(uploader);
});
function initPlUploader(uploader) {
uploader.html("<div></div>");
uploader = jQuery("div",uploader);
uploader.plupload({
runtimes : 'gears,html5,flash,html4',
url : '<%= url_for({:controller => "dmsf_detail", :action => "upload_file", :id => @project, :folder_id => @folder}) %>',
max_file_size : "100mb",
max_file_count: '<%= Setting.plugin_redmine_dmsf["dmsf_max_file_upload"].to_i if Setting.plugin_redmine_dmsf["dmsf_max_file_upload"].to_i > 0 %>',
multipart: true,
multipart_params : {authenticity_token : jQuery("input[name=authenticity_token]").val()},
// Rename files by clicking on their titles
rename: true,
// Flash settings
flash_swf_url : '<%= Engines::RailsExtensions::AssetHelpers.plugin_asset_path("redmine_dmsf", "javascripts", "plupload/plupload.flash.swf") %>'
});
jQuery(".plupload_scroll",uploader).resizable({
handles: "s"
});
var pluploader = uploader.plupload('getUploader');
pluploader.bind('FileUploaded', function(pluploader, file, response) {
var responseObject = jQuery.parseJSON(response.response);
var disk_filename_input = jQuery("<input/>").attr("type","hidden")
.attr("name","uploaded[" + dmsfFileFieldCount + "][disk_filename]")
.val(responseObject.disk_filename);
uploader.append(disk_filename_input);
var content_type_input = jQuery("<input/>").attr("type","hidden")
.attr("name","uploaded[" + dmsfFileFieldCount + "][content_type]")
.val(responseObject.content_type);
uploader.append(content_type_input);
var original_filename_input = jQuery("<input/>").attr("type","hidden")
.attr("name","uploaded[" + dmsfFileFieldCount + "][original_filename]")
.val(responseObject.original_filename);
uploader.append(original_filename_input);
if(pluploader.total.uploaded == pluploader.files.length) jQuery('#uploadform').submit();
else dmsfFileFieldCount++;
});
}
var dmsfFileFieldCount = 1;
function dmsfAddFileField() {
if (dmsfFileFieldCount >= 10) return false
dmsfFileFieldCount++;
var f = document.createElement("input");
f.type = "file";
f.name = "uploaded_files[" + dmsfFileFieldCount + "]";
f.size = 30;
var p = document.getElementById("uploaded_files_fields");
p.appendChild(document.createElement("br"));
p.appendChild(f);
}
</script>
<% end %>

View File

@ -50,3 +50,15 @@ cs:
:title_notifications_not_active_activate: "Notifications not active: Activate"
:title_title_version_version_download: "%{title} version %{version} download"
:title_locked_by_user: "Locked by %{user}"
:title_locked_by_you: "Locked by you"
:title_waiting_for_approval: "Waiting for Approval"
:title_approved: "Approved"
:title_unlock_file: "Unlock to allow changes for other members"
:title_lock_file: "Lock to prevent changes for other members"
:submit_download: "Download"
:title_download_checked: "Download checked in Zip archive"
:submit_email: "Email"
:title_send_checked_by_email: "Send checked by email"

View File

@ -49,4 +49,14 @@ de:
:title_notifications_active_deactivate: "Notifications active: Deactivate"
:title_notifications_not_active_activate: "Notifications not active: Activate"
:title_title_version_version_download: "%{title} version %{version} download"
:title_locked_by_user: "Locked by %{user}"
:title_locked_by_you: "Locked by you"
:title_waiting_for_approval: "Waiting for Approval"
:title_approved: "Approved"
:title_unlock_file: "Unlock to allow changes for other members"
:title_lock_file: "Lock to prevent changes for other members"
:submit_download: "Download"
:title_download_checked: "Download checked in Zip archive"
:submit_email: "Email"
:title_send_checked_by_email: "Send checked by email"

View File

@ -49,4 +49,14 @@ en-GB:
:title_notifications_active_deactivate: "Notifications active: Deactivate"
:title_notifications_not_active_activate: "Notifications not active: Activate"
:title_title_version_version_download: "%{title} version %{version} download"
:title_locked_by_user: "Locked by %{user}"
:title_locked_by_you: "Locked by you"
:title_waiting_for_approval: "Waiting for Approval"
:title_approved: "Approved"
:title_unlock_file: "Unlock to allow changes for other members"
:title_lock_file: "Lock to prevent changes for other members"
:submit_download: "Download"
:title_download_checked: "Download checked in Zip archive"
:submit_email: "Email"
:title_send_checked_by_email: "Send checked by email"

View File

@ -49,4 +49,13 @@ en:
:title_notifications_active_deactivate: "Notifications active: Deactivate"
:title_notifications_not_active_activate: "Notifications not active: Activate"
:title_title_version_version_download: "%{title} version %{version} download"
:title_locked_by_user: "Locked by %{user}"
:title_locked_by_you: "Locked by you"
:title_waiting_for_approval: "Waiting for Approval"
:title_approved: "Approved"
:title_unlock_file: "Unlock to allow changes for other members"
:title_lock_file: "Lock to prevent changes for other members"
:submit_download: "Download"
:title_download_checked: "Download checked in Zip archive"
:submit_email: "Email"
:title_send_checked_by_email: "Send checked by email"

View File

@ -49,4 +49,14 @@ es:
:title_notifications_active_deactivate: "Notifications active: Deactivate"
:title_notifications_not_active_activate: "Notifications not active: Activate"
:title_title_version_version_download: "%{title} version %{version} download"
:title_locked_by_user: "Locked by %{user}"
:title_locked_by_you: "Locked by you"
:title_waiting_for_approval: "Waiting for Approval"
:title_approved: "Approved"
:title_unlock_file: "Unlock to allow changes for other members"
:title_lock_file: "Lock to prevent changes for other members"
:submit_download: "Download"
:title_download_checked: "Download checked in Zip archive"
:submit_email: "Email"
:title_send_checked_by_email: "Send checked by email"

View File

@ -49,4 +49,14 @@ fr:
:title_notifications_active_deactivate: "Notifications active: Deactivate"
:title_notifications_not_active_activate: "Notifications not active: Activate"
:title_title_version_version_download: "%{title} version %{version} download"
:title_locked_by_user: "Locked by %{user}"
:title_locked_by_you: "Locked by you"
:title_waiting_for_approval: "Waiting for Approval"
:title_approved: "Approved"
:title_unlock_file: "Unlock to allow changes for other members"
:title_lock_file: "Lock to prevent changes for other members"
:submit_download: "Download"
:title_download_checked: "Download checked in Zip archive"
:submit_email: "Email"
:title_send_checked_by_email: "Send checked by email"

View File

@ -49,4 +49,14 @@ ru:
:title_notifications_active_deactivate: "Notifications active: Deactivate"
:title_notifications_not_active_activate: "Notifications not active: Activate"
:title_title_version_version_download: "%{title} version %{version} download"
:title_locked_by_user: "Locked by %{user}"
:title_locked_by_you: "Locked by you"
:title_waiting_for_approval: "Waiting for Approval"
:title_approved: "Approved"
:title_unlock_file: "Unlock to allow changes for other members"
:title_lock_file: "Lock to prevent changes for other members"
:submit_download: "Download"
:title_download_checked: "Download checked in Zip archive"
:submit_email: "Email"
:title_send_checked_by_email: "Send checked by email"