_form.html.erb

YongKi Kim, 2013-05-13 08:06

Download (5.43 KB)

 
1
<%
2
        currItem = @issue
3
    if Redmine::VERSION::MAJOR >= 2 or
4
        (Redmine::VERSION::MAJOR == 1 and Redmine::VERSION::MINOR < 3) then
5
        currItem ||= @wiki
6
    end
7
%>
8
<% content_for :header_tags do %>
9
    <%= stylesheet_link_tag 'attach_screenshot', :plugin => 'redmine_inline_attach_screenshot' %>
10
    <%= javascript_include_tag 'attach_screenshot', :plugin => 'redmine_inline_attach_screenshot' %>
11
<% end %>
12
<span id="attachments_fields">
13
<% if defined?(container) && container && container.saved_attachments %>
14
  <% container.saved_attachments.each_with_index do |attachment, i| %>
15
    <span id="attachments_p<%= i %>">
16
      <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename') +
17
          text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description') +
18
          link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
19
      <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
20
    </span>
21
  <% end %>
22
<% end %>
23
</span>
24
<span class="add_attachment">
25
<%= file_field_tag 'attachments[dummy][file]',
26
      :id => nil,
27
      :class => 'file_selector',
28
      :multiple => true,
29
      :onchange => 'addInputFiles(this);',
30
      :data => {
31
        :max_file_size => Setting.attachment_max_size.to_i.kilobytes,
32
        :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
33
        :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
34
        :upload_path => uploads_path(:format => 'js'),
35
        :description_placeholder => l(:label_optional_description)
36
      } %>
37
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
38
</span>
39

    
40
<% content_for :header_tags do %>
41
  <%= javascript_include_tag 'attachments' %>
42
<% end %>
43

    
44
<small><%= link_to l(:label_add_another_file), '#', :onclick => 'addFileField(); return false;' %>
45
        (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
46
</small>
47
<br />
48
<br />
49
<% if currItem %>
50
        <% if currItem.new_record? %>
51
                <label>
52
        <% end %>
53
        <%= l(:label_screenshots) %>
54
        <% if currItem.new_record? %>
55
                </label>
56
        <% else %>
57
                <br />
58
        <% end %>
59
        <span id="screenshots_fields">
60
        <%= submit_tag(l(:button_add), {:onclick => 'showAttachScreen(); return false;', :type => 'button'})%>
61
        </span>
62
        <small><%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %></small>
63
        <span id="attach_applet" style="display: none; position: absolute; border: solid 1px #bbb;"></span>
64
        <br />
65
        <span id="screenshots"></span>
66
        <script type="text/javascript">
67
                function showAttachScreen() {
68
                        document.getElementById('attach_applet').style.display = 'block';
69
                        document.getElementById('attach_applet').innerHTML = 
70
                                '<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>'+
71
                                '<param name="label.image" value="<%= l(:label_image) %>">' +
72
                                '<param name="label.button.paste" value="<%= l(:label_button_paste) %>">' +
73
                                '<param name="label.button.attach" value="<%= l(:button_attach) %>">' +
74
                                '<param name="label.button.cancel" value="<%= l(:button_cancel) %>">' +
75
                                '<param name="error.close.msg" value="<%= l(:error_close_msg) %>">' +
76
                                '<param name="error.close.title" value="<%= l(:error_close_title) %>">' +
77
                                '<param name="attach.url" value="<%= url_for(:only_path => false, :controller => 'welcome')%>attach_screenshot">' +
78
                                '<param name="error.attach.msg" value="<%= l(:error_attach_msg) %>">' +
79
                                '<param name="error.attach.title" value="<%= l(:error_attach_title) %>">'         +
80
                                '<param name="rss.key" value="<%= User.current.rss_key %>">'         +
81
                                'Applet</applet>';
82
                }
83
                function addAttachScreen(fileId) {
84
                        var s = document.createElement("div");
85
                        s.id = fileId;
86
                        s.className = "screen_thumb";
87

    
88
                        var s1 = document.createElement("div");
89
                        s1.className = "st1";
90
                        var s2 = document.createElement("div");
91
                        s2.className = "st2";
92

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

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

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

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

    
112
                        s1.appendChild(im);
113
                        s.appendChild(s1);
114
                        s2.appendChild(d);
115
                        s2.appendChild(b);
116
                        s2.appendChild(i);
117
                        s.appendChild(s2);
118

    
119
                        p = document.getElementById("screenshots");
120
                        p.appendChild(s);
121
                }
122
        </script>
123
<% end %>