diff --git a/bug_file_upload_inc.php b/bug_file_upload_inc.php index f56ca915ec..b002c553e3 100644 --- a/bug_file_upload_inc.php +++ b/bug_file_upload_inc.php @@ -57,7 +57,11 @@ $t_block_icon = $t_collapse_block ? 'fa-chevron-down' : 'fa-chevron-up'; $t_file_upload_max_num = max( 1, config_get( 'file_upload_max_num' ) ); ?> -
+>
@@ -107,5 +111,3 @@
-
-
action="bug_report.php?posted=1" class="dropzone-form"> + + action="bug_report.php?posted=1" + class="dropzone-form" +> @@ -718,5 +722,4 @@
-
+>
@@ -176,5 +181,4 @@
. + +/** + * This include file prints out the fileupload widget + * + * @package MantisBT + * @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org + * @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net + * @link http://www.mantisbt.org + * + */ +?> + data-force-fallback="" + data-max-filesize="" + data-accepted-files="" + data-default-message="" + data-fallback-message="" + data-fallback-text="" + data-file-too-big="" + data-invalid-file-type="" + data-response-error="" + data-cancel-upload="" + data-cancel-upload-confirmation="" + data-remove-file="" + data-remove-file-confirmation="" + data-max-files-exceeded="" + data-dropzone-not-supported="" + + diff --git a/fileupload_inc.php b/fileupload_inc.php deleted file mode 100644 index f34d6b8dfd..0000000000 --- a/fileupload_inc.php +++ /dev/null @@ -1,95 +0,0 @@ -. - -/** - * This include file prints out the fileupload widget - * - * @package MantisBT - * @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org - * @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net - * @link http://www.mantisbt.org - * - */ - - -html_css_link( 'dropzone.css' ); -html_javascript_link( 'dropzone.min.js'); -?> - - - diff --git a/js/common.js b/js/common.js index 542c31ce43..bfeb67822b 100644 --- a/js/common.js +++ b/js/common.js @@ -220,6 +220,12 @@ $(document).ready( function() { }); }); + if( $( ".dropzone-form" ).length ) { + enableDropzone( "dropzone", false ); + } + if( $( ".auto-dropzone-form" ).length ) { + enableDropzone( "auto-dropzone", true ); + } $('.bug-jump').find('[name=bug_id]').focus( function() { var bug_label = $('.bug-jump-form').find('[name=bug_label]').val(); @@ -460,3 +466,57 @@ function toggleDisplay(idTag) { setDisplay( idTag, (document.getElementById(idTag).style.display == 'none')?1:0 ); } + +// Dropzone handler +Dropzone.autoDiscover = false; +function enableDropzone( classPrefix, autoUpload ) { + try { + var zone = new Dropzone( "." + classPrefix + "-form", { + forceFallback: $(this).data('force-fallback'), + paramName: "ufile", + autoProcessQueue: autoUpload, + clickable: '.' + classPrefix, + previewsContainer: '#' + classPrefix + '-previews-box', + uploadMultiple: true, + parallelUploads: 100, + maxFilesize: $(this).data('max-filesize'), + addRemoveLinks: !autoUpload, + acceptedFiles: $(this).data('accepted-files'), + previewTemplate: "
\n
\n
\n
\n \n
\n
\n
\n
\n
\n
", + dictDefaultMessage: $(this).data('default-message'), + dictFallbackMessage: $(this).data('fallback-message'), + dictFallbackText: $(this).data('fallback-text'), + dictFileTooBig: $(this).data('file-too-big'), + dictInvalidFileType: $(this).data('invalid-file-type'), + dictResponseError: $(this).data('response-error'), + dictCancelUpload: $(this).data('cancel-upload'), + dictCancelUploadConfirmation: $(this).data('cancel-upload-confirmation'), + dictRemoveFile: $(this).data('remove-file'), + dictRemoveFileConfirmation: $(this).data('remove-file-confirmation'), + dictMaxFilesExceeded: $(this).data('max-files-exceeded'), + + init: function () { + var dropzone = this; + $( "input[type=submit]" ).on( "click", function (e) { + if( dropzone.getQueuedFiles().length ) { + e.preventDefault(); + e.stopPropagation(); + dropzone.processQueue(); + } + }); + this.on( "successmultiple", function( files, response ) { + document.open(); + document.write( response ); + document.close(); + }); + }, + fallback: function() { + if( $( "." + classPrefix ).length ) { + $( "." + classPrefix ).hide(); + } + } + }); + } catch (e) { + alert( $(this).data('dropzone-not-supported') ); + } +}