Rev 1775 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1775 | Rev 1830 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> |
1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> |
2 | <% |
2 | <% |
- | 3 | //SISTEMA USA O PLUGIN |
|
- | 4 | //http://plugins.krajee.com/file-image-management-demo |
|
- | 5 | ||
3 | String FILE_INPUT_ID = "filesInputId-UPLOAD"; |
6 | String FILE_INPUT_ID = "filesInputId-UPLOAD"; |
4 | request.setAttribute("FILE_INPUT_ID",FILE_INPUT_ID); |
7 | request.setAttribute("FILE_INPUT_ID",FILE_INPUT_ID); |
5 | %> |
8 | %> |
6 | <style> |
9 | <style> |
7 | .file-drop-zone |
10 | .file-drop-zone |
Line 12... | Line 15... | ||
12 | 15 | ||
13 | <script> |
16 | <script> |
14 | var uploadMultipleFiles = false; |
17 | var uploadMultipleFiles = false; |
15 | //Token para transmitir informação entre chamador e chamado |
18 | //Token para transmitir informação entre chamador e chamado |
16 | var token = ""; |
19 | var token = ""; |
- | 20 | ||
- | 21 | var confirmOnUpload = false; |
|
17 | </script> |
22 | </script> |
18 | 23 | ||
19 | 24 | ||
20 | 25 | ||
21 | 26 | ||
Line 76... | Line 81... | ||
76 | 81 | ||
77 | </form> |
82 | </form> |
78 | </div> |
83 | </div> |
79 | <div class="modal-footer"> |
84 | <div class="modal-footer"> |
80 | <button type="button" class="btn btn-danger pull-left" data-dismiss="modal">Cancelar</button> |
85 | <button type="button" class="btn btn-danger pull-left" data-dismiss="modal">Cancelar</button> |
81 | <button class="btn btn-success btn-ok" >Confirmar</button> |
86 | <button id="uploadConfirm" class="btn btn-success btn-ok" >Confirmar</button> |
82 | </div> |
87 | </div> |
83 | </div> |
88 | </div> |
84 | </div> |
89 | </div> |
85 | </div> |
90 | </div> |
86 | 91 | ||
Line 91... | Line 96... | ||
91 | 96 | ||
92 | 97 | ||
93 | $('.filesUploadModal').on('show.bs.modal', function(e) |
98 | $('.filesUploadModal').on('show.bs.modal', function(e) |
94 | { |
99 | { |
95 | 100 | ||
- | 101 | var config = { |
|
- | 102 | uploadUrl: '<%=request.getContextPath()%>/filesUpload', |
|
- | 103 | maxFilePreviewSize: 4096, |
|
- | 104 | uploadAsync: false, |
|
- | 105 | language: "pt", |
|
- | 106 | multiple: "true", |
|
- | 107 | slugCallback: function(filename) { |
|
- | 108 | ||
- | 109 | return filename.replace(/[^\x00-\x7F]/g, ""); |
|
- | 110 | } |
|
- | 111 | }; |
|
- | 112 | ||
- | 113 | if($(e.relatedTarget).data('allowed-extensions') != null) |
|
- | 114 | { |
|
- | 115 | var ext = $(e.relatedTarget).data('allowed-extensions').split(","); |
|
- | 116 | config.allowedFileExtensions = ext; |
|
- | 117 | } |
|
96 | 118 | ||
- | 119 | $("#${FILE_INPUT_ID}").fileinput( config ); |
|
97 | 120 | ||
98 | $("#filesUploadModal .modal-title .title-wrap").html($(e.relatedTarget).data('title')); |
121 | $("#filesUploadModal .modal-title .title-wrap").html($(e.relatedTarget).data('title')); |
99 | if($(e.relatedTarget).data('multiple') != null && $(e.relatedTarget).data('multiple') == true) |
122 | if($(e.relatedTarget).data('multiple') != null && $(e.relatedTarget).data('multiple') == true) |
100 | { |
123 | { |
101 | uploadMultipleFiles = true; |
124 | uploadMultipleFiles = true; |
Line 112... | Line 135... | ||
112 | } |
135 | } |
113 | 136 | ||
114 | token = ""; |
137 | token = ""; |
115 | dataCallbackTargetFunction = ""; |
138 | dataCallbackTargetFunction = ""; |
116 | 139 | ||
- | 140 | if($(e.relatedTarget).data('confirmonupload')) |
|
- | 141 | { |
|
- | 142 | confirmOnUpload = $(e.relatedTarget).data('confirmonupload'); |
|
- | 143 | } |
|
- | 144 | ||
117 | if($(e.relatedTarget).data('token')) |
145 | if($(e.relatedTarget).data('token')) |
118 | { |
146 | { |
119 | 147 | ||
120 | token = $(e.relatedTarget).data('token'); |
148 | token = $(e.relatedTarget).data('token'); |
121 | 149 | ||
122 | } |
150 | } |
123 | else if($(e.relatedTarget).data('data-callback-target-function-token-parameter')) |
151 | else if($(e.relatedTarget).data('callback-target-function-token-parameter')) |
124 | { |
152 | { |
125 | 153 | ||
126 | token = $(e.relatedTarget).data('data-callback-target-function-token-parameter'); |
154 | token = $(e.relatedTarget).data('callback-target-function-token-parameter'); |
127 | 155 | ||
128 | } |
156 | } |
129 | 157 | ||
130 | if($(e.relatedTarget).data('data-callback-target-function')) |
158 | if($(e.relatedTarget).data('callback-target-function')) |
131 | { |
159 | { |
132 | 160 | ||
133 | dataCallbackTargetFunction = $(e.relatedTarget).data('data-callback-target-function'); |
161 | dataCallbackTargetFunction = $(e.relatedTarget).data('callback-target-function'); |
134 | 162 | ||
135 | } |
163 | } |
136 | 164 | ||
137 | 165 | ||
138 | 166 | ||
Line 152... | Line 180... | ||
152 | angular.element($("#filesUploadModal")).scope().uploadedFiles = []; |
180 | angular.element($("#filesUploadModal")).scope().uploadedFiles = []; |
153 | angular.element($("#filesUploadModal")).scope().$apply(); |
181 | angular.element($("#filesUploadModal")).scope().$apply(); |
154 | 182 | ||
155 | jsonTargetId = $(e.relatedTarget).data('jsontargetid'); |
183 | jsonTargetId = $(e.relatedTarget).data('jsontargetid'); |
156 | $(this).find('.btn-ok').unbind('click').click( |
184 | $(this).find('.btn-ok').unbind('click').click( |
157 | function() |
185 | function(){ |
158 | { |
- | |
159 | var filesCount = $('#${FILE_INPUT_ID}').fileinput('getFilesCount'); |
186 | var filesCount = $('#${FILE_INPUT_ID}').fileinput('getFilesCount'); |
160 | if(filesCount > 0) |
187 | if(filesCount > 0) |
161 | { |
188 | { |
162 | var msg = "Existem ficheiros pendentes de CARREGAR!! Por favor clique em CARREGAR para enviar os ficheiros selecionados para o Servidor."; |
189 | var msg = "Existem ficheiros pendentes de CARREGAR!! Por favor clique em CARREGAR para enviar os ficheiros selecionados para o Servidor."; |
163 | if(angular.element($("#filesUploadModal")).scope().uploadedFiles.length > 0) |
190 | if(angular.element($("#filesUploadModal")).scope().uploadedFiles.length > 0) |
Line 171... | Line 198... | ||
171 | else |
198 | else |
172 | { |
199 | { |
173 | var jsonContent = $("#jsonFiles").val(); |
200 | var jsonContent = $("#jsonFiles").val(); |
174 | if(dataCallbackTargetFunction != "") |
201 | if(dataCallbackTargetFunction != "") |
175 | { |
202 | { |
176 | eval(dataCallbackTargetFunction)(jsonContent,token); |
203 | eval(dataCallbackTargetFunction)(JSON.parse(jsonContent),token,e.relatedTarget); |
177 | } |
204 | } |
178 | else |
205 | else |
179 | { |
206 | { |
180 | $(jsonTargetId).val(jsonContent); |
207 | $(jsonTargetId).val(jsonContent); |
181 | $(jsonTargetId).change(); |
208 | $(jsonTargetId).change(); |
Line 184... | Line 211... | ||
184 | 211 | ||
185 | angular.element($("#filesUploadModal")).scope().uploadedFiles = []; |
212 | angular.element($("#filesUploadModal")).scope().uploadedFiles = []; |
186 | angular.element($("#filesUploadModal")).scope().$apply(); |
213 | angular.element($("#filesUploadModal")).scope().$apply(); |
187 | $('#filesUploadModal').modal('hide'); |
214 | $('#filesUploadModal').modal('hide'); |
188 | } |
215 | } |
189 | - | ||
190 | } |
216 | } |
191 | ); |
217 | ); |
192 | $("#${FILE_INPUT_ID}").fileinput('clear'); |
218 | $("#${FILE_INPUT_ID}").fileinput('clear'); |
193 | 219 | ||
194 | 220 | ||
Line 328... | Line 354... | ||
328 | return str.replace(/[^\u0000-\u007E]/g, function(a){ |
354 | return str.replace(/[^\u0000-\u007E]/g, function(a){ |
329 | return diacriticsMap[a] || a; |
355 | return diacriticsMap[a] || a; |
330 | }); |
356 | }); |
331 | }*/ |
357 | }*/ |
332 | 358 | ||
- | 359 | /* |
|
333 | $(document).ready( function() { |
360 | $(document).ready( function() { |
334 | $("#${FILE_INPUT_ID}").fileinput({ |
361 | $("#${FILE_INPUT_ID}").fileinput({ |
335 | uploadUrl: '<%=request.getContextPath()%>/filesUpload', |
362 | uploadUrl: '<%=request.getContextPath()%>/filesUpload', |
336 | maxFilePreviewSize: 4096, |
363 | maxFilePreviewSize: 4096, |
337 | uploadAsync: false, |
364 | uploadAsync: false, |
Line 342... | Line 369... | ||
342 | return filename.replace(/[^\x00-\x7F]/g, ""); |
369 | return filename.replace(/[^\x00-\x7F]/g, ""); |
343 | 370 | ||
344 | } |
371 | } |
345 | 372 | ||
346 | }); |
373 | }); |
347 | }); |
374 | });*/ |
348 | 375 | ||
349 | $("#${FILE_INPUT_ID}").on('filebatchuploadsuccess', function(event, data, previewId, index) |
376 | $("#${FILE_INPUT_ID}").on('filebatchuploadsuccess', function(event, data, previewId, index) |
350 | { |
377 | { |
351 | updateUploadedFiles(data.response,"#${FILE_INPUT_ID}"); |
378 | updateUploadedFiles(data.response,"#${FILE_INPUT_ID}"); |
352 | }); |
379 | }); |
Line 365... | Line 392... | ||
365 | } |
392 | } |
366 | else if(response.service == "ok") |
393 | else if(response.service == "ok") |
367 | { |
394 | { |
368 | $(id).fileinput('clear'); |
395 | $(id).fileinput('clear'); |
369 | angular.element($("#filesUploadModal")).scope().addRows(response.uploadedFiles); |
396 | angular.element($("#filesUploadModal")).scope().addRows(response.uploadedFiles); |
- | 397 | if(confirmOnUpload == true) |
|
- | 398 | { |
|
- | 399 | $("#filesUploadModal #uploadConfirm").click(); |
|
- | 400 | } |
|
370 | } |
401 | } |
371 | } |
402 | } |
- | 403 | ||
- | 404 | ||
372 | </script> |
405 | </script> |
373 | 406 |