|
22 | 22 | <!-- Shim to make HTML5 elements usable in older Internet Explorer versions -->
|
23 | 23 | <!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
|
24 | 24 |
|
25 |
| - <form id="fileupload" action="/Upload/UploadHandler.ashx" method="POST" enctype="multipart/form-data"> |
26 |
| - @*<form id="fileupload" action="@Url.Action("UploadFiles")" method="POST" enctype="multipart/form-data">*@ |
| 25 | + @*<form id="fileupload" action="/Upload/UploadHandler.ashx" method="POST" enctype="multipart/form-data">*@ |
| 26 | + <form id="fileupload" action="@Url.Action("UploadFiles")" method="POST" enctype="multipart/form-data"> |
27 | 27 | <input type="hidden" id="maxChunkSize" name="maxChunkSize" value="0" />
|
28 | 28 |
|
29 | 29 | <div class="row fileupload-buttonbar">
|
|
34 | 34 | <span>Add files...</span>
|
35 | 35 | <input type="file" name="files[]" multiple>
|
36 | 36 | </span>
|
| 37 | + <span> |
| 38 | + Quero usar ficheiro de assinatura |
| 39 | + <input type="checkbox" id="useSignatureFile" onchange="ToggleSignatureFiles();" /> |
| 40 | + </span> |
37 | 41 | @*<button type="reset" class="btn btn-warning cancel">
|
38 | 42 | <i class="icon-ban-circle icon-white"></i>
|
39 | 43 | <span>Cancel upload</span>
|
|
52 | 56 | <th>File</th>
|
53 | 57 | <th>Description</th>
|
54 | 58 | @*<th>Size</th>*@
|
55 |
| - <th>Signed?</th> |
56 |
| - <th>Embedded?</th> |
57 |
| - <th>Select Certificate</th> |
| 59 | + <th hidden>Signature File</th> |
58 | 60 | <th>Progress</th>
|
59 | 61 | <th>Action</th>
|
60 | 62 | </tr>
|
61 | 63 | <tbody class="files"></tbody>
|
62 | 64 | </table>
|
63 |
| - <div class="pull-right fileupload-buttonbar"> |
| 65 | + <div class="pull-right fileupload-buttonbar"> |
64 | 66 | <button type="submit" class="btn btn-primary start">
|
65 | 67 | <i class="icon-upload icon-white"></i>
|
66 | 68 | <span>Upload</span>
|
|
73 | 75 | <script id="template-upload" type="text/x-tmpl">
|
74 | 76 | {% for (var i=0, file; file=o.files[i]; i++) { %}
|
75 | 77 | <tr class="template-upload fade">
|
76 |
| - <td class="name"><span>{%=file.name%}</span></td> |
77 |
| - <td> |
| 78 | + <td class="name"> |
| 79 | + <span>{%=file.name%}</span> |
| 80 | + </td> |
| 81 | + <td class="description"> |
78 | 82 | <input type="text" id="fileDescription" name="fileDescription[]" class="text-box" />
|
79 | 83 | </td>
|
80 | 84 | @*<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>*@
|
81 | 85 | {% if (file.error) { %}
|
82 | 86 | <td class="error" colspan="2"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td>
|
83 | 87 | {% } else if (o.files.valid && !i) { %}
|
| 88 | + {% if($("#useSignatureFile").prop('checked')){ %} |
84 | 89 | <td>
|
85 |
| - <input type="checkbox" id="chkIsSigned" name="chkIsSigned[]" onclick="ToggleNextElement(this);" /> |
86 |
| - </td> |
87 |
| - <td> |
88 |
| - <input type="checkbox" id="chkIsEmbedded" name="chkIsEmbedded[]" disabled onclick="ToggleNextElement(this);" /> |
89 |
| - </td> |
90 |
| - <td> |
91 |
| - {% if(!globalIsNextFileSignature) { %} |
92 |
| - <input type="file" id="certificateFile" name="certificateFile[]" disabled onclick="SetSignatureVariable();" onchange="AddToUploadList(this);" /> |
| 90 | + {% }else{ %} |
| 91 | + <td hidden> |
| 92 | + {% } %} |
| 93 | + <input type="file" id="certificateFile" name="certificateFile[]" onchange="AddToUploadList(this);" /> |
93 | 94 | <input type="hidden" name="certificateFileName[]" />
|
94 |
| - {%= SetSignatureVariable() %} |
95 |
| - {% } %} |
96 | 95 | </td>
|
97 | 96 | <td>
|
98 | 97 | <div class="progress progress-success progress-striped active">
|
|
116 | 115 | {% } %}
|
117 | 116 | </td>
|
118 | 117 | {% } else { %}
|
119 |
| - <td colspan="2"></td> |
| 118 | + <td></td> |
120 | 119 | {% } %}
|
121 | 120 | </tr>
|
122 | 121 | {% } %}
|
|
136 | 135 | <td class="error" colspan="2">
|
137 | 136 | <span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}
|
138 | 137 | </td>
|
| 138 | + {% } else if(file.isSignatureFile == "yes") { %} |
| 139 | + @*mostra nada*@ |
139 | 140 | {% } else { %}
|
140 | 141 | <td class="name">
|
141 | 142 | <span>{%=file.name%}</span>
|
142 | 143 | @*<a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}">{%=file.name%}</a>*@
|
143 | 144 | </td>
|
144 |
| - <td class="description"><span>{%=document.getElementById("fileDescription").value%}</span></td> |
| 145 | + <td class="description"> |
| 146 | + <span>{%=document.getElementById("fileDescription").value%}</span> |
| 147 | + </td> |
145 | 148 | @*<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>*@
|
146 |
| - <td class="size"><span>{%=document.getElementById("chkIsSigned").checked ? 'Yes' : 'No'%}</span></td> |
147 |
| - <td class="size"><span>{%=document.getElementById("chkIsEmbedded").checked ? 'Yes' : 'No'%}</span></td> |
148 |
| - {% if(!globalIsNextFileSignature) { %} |
149 | 149 | <td class="description"><span>{%=document.getElementById("certificateFile").value ? document.getElementById("certificateFile").value : 'N/A' %}</span></td>
|
150 |
| - {% } %} |
151 | 150 | <td><span class="label btn-success">Success!</span></td>
|
152 |
| - {% } %} |
153 | 151 | <td>N/A</td>
|
| 152 | + {% } %} |
154 | 153 | @*<td class="delete">
|
155 | 154 | <button class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}">
|
156 | 155 | <i class="icon-trash icon-white"></i>
|
|
163 | 162 |
|
164 | 163 | <script type="text/javascript">
|
165 | 164 |
|
166 |
| - var globalIsNextFileSignature = false; |
167 |
| -
|
168 | 165 | $(document).ready(function () {
|
169 | 166 |
|
170 | 167 | InitializeFileUploader();
|
|
177 | 174 | $("#maxChunkSize").val($("#fileupload").fileupload('option').maxChunkSize);
|
178 | 175 | }
|
179 | 176 |
|
180 |
| - function ToggleNextElement(sender) { |
181 |
| -
|
182 |
| - var elementToToggle = $(sender).parent().next().children(); |
183 |
| - var nextElement = $(elementToToggle).parent().next().children(); |
184 |
| -
|
185 |
| - if (elementToToggle.attr('disabled')) { |
186 |
| - elementToToggle.removeAttr('disabled'); |
187 |
| - } else { |
188 |
| - elementToToggle.attr('disabled', 'disabled'); |
189 |
| - } |
190 |
| -
|
191 |
| - //Para o caso de desactivar o primeiro quando os outros estao activos |
192 |
| - if (elementToToggle.attr('disabled')) { |
193 |
| - elementToToggle.removeAttr('checked'); |
194 |
| - nextElement.attr('disabled', 'disabled'); |
195 |
| - } |
196 |
| - |
| 177 | + function ToggleSignatureFiles(hide) { |
| 178 | + //$('td:nth-child(3),th:nth-child(3)').toggle(); // CSS 3, Nao funca no ie <= 8; |
| 179 | + $('td:first-child+*+*,th:first-child+*+*').toggle(); |
197 | 180 | }
|
198 | 181 |
|
199 | 182 | function AddToUploadList(sender) {
|
200 | 183 |
|
201 |
| - $('#fileupload').fileupload('add', { files: $(sender).prop("files") }); |
| 184 | + //set certificateFileName |
| 185 | + $(sender).next().attr('value', $(sender).prop("files")[0].name); |
| 186 | +
|
| 187 | + //disable file selector |
| 188 | + $(sender).attr('disabled', 'disabled'); |
| 189 | +
|
| 190 | + //send signature file |
| 191 | + $('#fileupload').fileupload('send', { files: $(sender).prop("files") }); |
202 | 192 |
|
203 | 193 | //var signatureFile = $(sender).prop("files");
|
204 | 194 |
|
205 | 195 | //signatureFile.prop('isSignatureFile', 'true');
|
206 | 196 |
|
207 | 197 | //$('#fileupload').fileupload('add', { files: signatureFile });
|
208 | 198 |
|
209 |
| - $(sender).next().attr('value', $(sender).prop("files")[0].name); |
| 199 | +
|
| 200 | + //$(sender).prop("files").setAttribute('oi', 'ola'); |
| 201 | + //alert($(sender).prop("files").getAttribute('oi')); |
210 | 202 | }
|
211 | 203 |
|
212 | 204 | function InitializeFileUploader() {
|
|
217 | 209 |
|
218 | 210 | $('#fileupload').fileupload('option', {
|
219 | 211 | maxFileSize: 9999999999,
|
220 |
| - maxChunkSize: 1024 * 512, //512 KB |
221 |
| - singleFileUploads: 10, |
222 |
| - autoUpload: false |
| 212 | + maxChunkSize: 1024 * 1024, //512 KB |
| 213 | + autoUpload: false, |
223 | 214 | });
|
224 | 215 | }
|
225 | 216 |
|
226 |
| - function SetSignatureVariable() { |
227 |
| -
|
228 |
| - globalIsNextFileSignature = true; |
229 |
| - } |
230 |
| -
|
231 | 217 | </script>
|
232 | 218 |
|
0 commit comments