@@ 53-80 (lines=28) @@ | ||
50 | //clickable: ".fileinput-button", // Define the element that should be used as click trigger to select files. |
|
51 | }); |
|
52 | ||
53 | mediaDropzone.on("addedfile", function (file) { |
|
54 | var fileId = 'media' + document.querySelectorAll('.media-list-item').length; |
|
55 | file.previewElement.getElementsByTagName('input')[0].setAttribute('id', fileId); |
|
56 | file.previewElement.getElementsByTagName('label')[0].setAttribute('for', fileId); |
|
57 | ||
58 | var imagesFileTypes = ['image/png', 'image/jpg', 'image/jpeg', 'image/gif']; |
|
59 | if (imagesFileTypes.indexOf(file.type) != -1) { |
|
60 | file.previewElement.querySelector('.media-item-file-details').style.display = 'none'; |
|
61 | } else if (file.type === 'application/pdf') { |
|
62 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
|
63 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-pdf"></i>'; |
|
64 | } else if (file.type === 'application/doc' | 'application/docx') { |
|
65 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
|
66 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-word"></i>'; |
|
67 | } else if (file.type === 'application/ppt' | 'application/pptx') { |
|
68 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
|
69 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-powerpoint"></i>'; |
|
70 | } else if (file.type === 'video/mp4' | 'video/webm' | 'video/mkv') { |
|
71 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
|
72 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-video"></i>'; |
|
73 | } else if (file.type === 'audio/mpeg') { |
|
74 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
|
75 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-audio"></i>'; |
|
76 | } else { |
|
77 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
|
78 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file"></i>'; |
|
79 | } |
|
80 | }); |
|
81 | ||
82 | mediaDropzone.on("success", function (file, resp) { |
|
83 | file.previewElement.querySelector(".media-list-item").classList.remove('uploading'); |
@@ 59-87 (lines=29) @@ | ||
56 | previewTemplate: dropzoneCardsFilePreviewTemplate |
|
57 | }); |
|
58 | ||
59 | dropzoneCards.on("addedfile", function (file) { |
|
60 | console.log('titit'); |
|
61 | var fileId = 'media' + document.querySelectorAll('.media-list-item').length; |
|
62 | file.previewElement.getElementsByTagName('input')[0].setAttribute('id', fileId); |
|
63 | file.previewElement.getElementsByTagName('label')[0].setAttribute('for', fileId); |
|
64 | ||
65 | var imagesFileTypes = ['image/png', 'image/jpg', 'image/jpeg', 'image/gif']; |
|
66 | if (imagesFileTypes.indexOf(file.type) != -1) { |
|
67 | file.previewElement.querySelector('.media-item-file-details').style.display = 'none'; |
|
68 | } else if (file.type === 'application/pdf') { |
|
69 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
|
70 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-pdf"></i>'; |
|
71 | } else if (file.type === 'application/doc' | 'application/docx') { |
|
72 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
|
73 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-word"></i>'; |
|
74 | } else if (file.type === 'application/ppt' | 'application/pptx') { |
|
75 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
|
76 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-powerpoint"></i>'; |
|
77 | } else if (file.type === 'video/mp4' | 'video/webm' | 'video/mkv') { |
|
78 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
|
79 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-video"></i>'; |
|
80 | } else if (file.type === 'audio/mpeg') { |
|
81 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
|
82 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-audio"></i>'; |
|
83 | } else { |
|
84 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
|
85 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file"></i>'; |
|
86 | } |
|
87 | }); |
|
88 | ||
89 | dropzoneCards.on("success", function (file, resp) { |
|
90 | file.previewElement.querySelector(".media-list-item").classList.remove('uploading'); |