Project

General

Profile

Feature #3816 » _form.rhtml

William Roush, 2012-02-09 16:47

 
1
<% content_for :header_tags do %>
2
    <%= stylesheet_link_tag 'attach_screenshot', :plugin => 'redmine_attach_screenshot' %>
3
    <%= javascript_include_tag 'attach_screenshot', :plugin => 'redmine_attach_screenshot' %>
4
<% end %>
5
<span id="attachments_fields">
6
  <span>
7
    <%= file_field_tag 'attachments[1][file]', :size => 30, :id => nil, :class => 'file',
8
          :onchange => "checkFileSize(this, #{Setting.attachment_max_size.to_i.kilobytes}, '#{escape_javascript(l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)))}');"  -%>
9
    <label class="inline"><%= l(:label_optional_description) %><%= text_field_tag 'attachments[1][description]', '', :size => 60, :id => nil, :class => 'description' %></label>
10
    <%= link_to_function(image_tag('delete.png'), 'removeFileField(this)', :title => (l(:button_delete))) %>
11
  </span>
12
</span>
13
<small><%= link_to l(:label_add_another_file), '#', :onclick => 'addFileField(); return false;' %>
14
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
15
</small>
16
<br />
17
<br />
18
<% if @issue %>
19
<% if @issue.new_record? %>
20
    <label>
21
<% end %>
22
<%= l(:label_screenshots) %>
23
<% if @issue.new_record? %>
24
    </label>
25
<% else %>
26
    <br />
27
<% end %>
28
<span id="attach_applet" style="display: none; position: fixed; top: 50px; left: 10px; border: solid 1px #BBB;"></span>
29
<span id="screenshots_fields">
30
<%= submit_tag l(:button_add), :onclick => 'showAttachScreen(); return false;'%>
31
</span>
32
<small><%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>
33
</small>
34
<br />
35
<span id="screenshots"></span>
36
<br />
37

    
38
<script type="text/javascript">
39
    function showAttachScreen() {
40
        document.getElementById('attach_applet').style.display = 'block';
41
        document.getElementById('attach_applet').innerHTML = '<applet codebase="<%= url_for(:only_path => false, :controller => 'welcome')%>plugin_assets/redmine_attach_screenshot/javascripts/" code="com.axmor.redmine.uploader.Uploader.class" archive="uploader_applet.jar" height="600" width="700" MAYSCRIPT>'+
42
                                                             '<param name="label.image" value="<%= l(:label_image) %>">' +
43
                                                             '<param name="label.button.paste" value="<%= l(:label_button_paste) %>">' +
44
                                                             '<param name="label.button.attach" value="<%= l(:button_attach) %>">' +
45
                                                             '<param name="label.button.cancel" value="<%= l(:button_cancel) %>">' +
46
                                                             '<param name="error.close.msg" value="<%= l(:error_close_msg) %>">' +
47
                                                             '<param name="error.close.title" value="<%= l(:error_close_title) %>">' +
48
                                                             '<param name="attach.url" value="<%= url_for(:only_path => false, :controller => 'welcome')%>attach_screenshot">' +
49
                                                             '<param name="error.attach.msg" value="<%= l(:error_attach_msg) %>">' +
50
                                                             '<param name="error.attach.title" value="<%= l(:error_attach_title) %>">'	 +
51
                                                             '<param name="rss.key" value="<%= User.current.rss_key %>">'	 +
52
                                                             'Applet</applet>';
53
    }
54
    function addAttachScreen(fileId) {
55
        var s = document.createElement("span");
56
        s.id = fileId;
57
        s.className = "screen_thumb";
58

    
59
        var s1 = document.createElement("span");
60
        s1.className = "st1";
61
        var s2 = document.createElement("span");
62
        s2.className = "st2";
63

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

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

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

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

    
82
        s1.appendChild(im);
83
        s.appendChild(s1);
84
        s2.appendChild(d);
85
        s2.appendChild(b);
86
        s2.appendChild(i);
87
        s.appendChild(s2);
88

    
89
        p = document.getElementById("screenshots");
90
        p.appendChild(s);
91
    }
92
</script>
93
<% end %>
(16-16/24)