Project

General

Profile

Feature #8579 ยป _form.html.erb

YongKi Kim, 2013-05-13 08:06

 
<%
currItem = @issue
if Redmine::VERSION::MAJOR >= 2 or
(Redmine::VERSION::MAJOR == 1 and Redmine::VERSION::MINOR < 3) then
currItem ||= @wiki
end
%>
<% content_for :header_tags do %>
<%= stylesheet_link_tag 'attach_screenshot', :plugin => 'redmine_inline_attach_screenshot' %>
<%= javascript_include_tag 'attach_screenshot', :plugin => 'redmine_inline_attach_screenshot' %>
<% end %>
<span id="attachments_fields">
<% if defined?(container) && container && container.saved_attachments %>
<% container.saved_attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>">
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename') +
text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description') +
link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span>
<% end %>
<% end %>
</span>
<span class="add_attachment">
<%= file_field_tag 'attachments[dummy][file]',
:id => nil,
:class => 'file_selector',
:multiple => true,
:onchange => 'addInputFiles(this);',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
:upload_path => uploads_path(:format => 'js'),
:description_placeholder => l(:label_optional_description)
} %>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</span>

<% content_for :header_tags do %>
<%= javascript_include_tag 'attachments' %>
<% end %>

<small><%= link_to l(:label_add_another_file), '#', :onclick => 'addFileField(); return false;' %>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</small>
<br />
<br />
<% if currItem %>
<% if currItem.new_record? %>
<label>
<% end %>
<%= l(:label_screenshots) %>
<% if currItem.new_record? %>
</label>
<% else %>
<br />
<% end %>
<span id="screenshots_fields">
<%= submit_tag(l(:button_add), {:onclick => 'showAttachScreen(); return false;', :type => 'button'})%>
</span>
<small><%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %></small>
<span id="attach_applet" style="display: none; position: absolute; border: solid 1px #bbb;"></span>
<br />
<span id="screenshots"></span>
<script type="text/javascript">
function showAttachScreen() {
document.getElementById('attach_applet').style.display = 'block';
document.getElementById('attach_applet').innerHTML =
'<applet codebase="<%= url_for(:only_path => false, :controller => 'welcome')%>plugin_assets/redmine_inline_attach_screenshot/javascripts/" code="com.axmor.redmine.uploader.Uploader.class" archive="uploader_applet.jar" height="250" width="400" MAYSCRIPT>'+
'<param name="label.image" value="<%= l(:label_image) %>">' +
'<param name="label.button.paste" value="<%= l(:label_button_paste) %>">' +
'<param name="label.button.attach" value="<%= l(:button_attach) %>">' +
'<param name="label.button.cancel" value="<%= l(:button_cancel) %>">' +
'<param name="error.close.msg" value="<%= l(:error_close_msg) %>">' +
'<param name="error.close.title" value="<%= l(:error_close_title) %>">' +
'<param name="attach.url" value="<%= url_for(:only_path => false, :controller => 'welcome')%>attach_screenshot">' +
'<param name="error.attach.msg" value="<%= l(:error_attach_msg) %>">' +
'<param name="error.attach.title" value="<%= l(:error_attach_title) %>">' +
'<param name="rss.key" value="<%= User.current.rss_key %>">' +
'Applet</applet>';
}
function addAttachScreen(fileId) {
var s = document.createElement("div");
s.id = fileId;
s.className = "screen_thumb";

var s1 = document.createElement("div");
s1.className = "st1";
var s2 = document.createElement("div");
s2.className = "st2";

var im = document.createElement("img");
im.width = "240";
im.src = "<%= url_for(:only_path => false, :controller => 'welcome')%>attach_screenshot?id=" + fileId;

var b = document.createElement("input");
b.type = "image";
b.src = "<%= url_for(:only_path => false, :controller => 'welcome')%>images/delete.png"
b.setAttribute("onClick", "deleteAttachScreen('" + fileId + "'); return false;");

var i = document.createElement("input");
i.type = "image";
i.src = "<%= url_for(:only_path => false, :controller => 'welcome')%>images/lightning.png";
i.setAttribute("onClick", "addLinkToAttachScreen('" + fileId + "'); return false;");

var d = document.createElement("input");
d.name = "screenshots[" + fileId + "][description]";
d.type = "text";
d.size = 15;

s1.appendChild(im);
s.appendChild(s1);
s2.appendChild(d);
s2.appendChild(b);
s2.appendChild(i);
s.appendChild(s2);

p = document.getElementById("screenshots");
p.appendChild(s);
}
</script>
<% end %>
    (1-1/1)