@osimatic/helpers-js 1.3.5 → 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/multi_files_input.js +13 -13
- package/package.json +1 -1
- package/user.js +1 -1
- package/visitor.js +1 -1
package/multi_files_input.js
CHANGED
|
@@ -19,34 +19,34 @@ class MultiFilesInput {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const dropzone = fileInput.parent().find('.multi_files_input_dropzone');
|
|
22
|
-
const filesPreview = fileInput.parent().find('.multi_files_input_files_preview');
|
|
22
|
+
const filesPreview = fileInput.parent().find('.multi_files_input_files_preview').empty();
|
|
23
23
|
|
|
24
24
|
fileInput.addClass('hide');
|
|
25
25
|
|
|
26
26
|
// Dropzone interactions
|
|
27
|
-
dropzone.on('click', function (e) {
|
|
27
|
+
dropzone.off('click').on('click', function (e) {
|
|
28
28
|
e.preventDefault();
|
|
29
29
|
e.stopPropagation();
|
|
30
30
|
fileInput.trigger('click');
|
|
31
31
|
});
|
|
32
|
-
dropzone.on('dragover', function (e) {
|
|
32
|
+
dropzone.off('click').on('dragover', function (e) {
|
|
33
33
|
e.preventDefault();
|
|
34
34
|
e.stopPropagation();
|
|
35
35
|
$(this).addClass('border-primary');
|
|
36
36
|
});
|
|
37
|
-
dropzone.on('dragleave', function (e) {
|
|
37
|
+
dropzone.off('click').on('dragleave', function (e) {
|
|
38
38
|
e.preventDefault();
|
|
39
39
|
e.stopPropagation();
|
|
40
40
|
$(this).removeClass('border-primary');
|
|
41
41
|
});
|
|
42
|
-
dropzone.on('drop', function (e) {
|
|
42
|
+
dropzone.off('click').on('drop', function (e) {
|
|
43
43
|
e.preventDefault();
|
|
44
44
|
e.stopPropagation();
|
|
45
45
|
$(this).removeClass('border-primary');
|
|
46
46
|
const dtFiles = (e.originalEvent.dataTransfer || {}).files || [];
|
|
47
47
|
handleFiles(Array.from(dtFiles));
|
|
48
48
|
});
|
|
49
|
-
fileInput.on('change', (e) => {
|
|
49
|
+
fileInput.off('change').on('change', (e) => {
|
|
50
50
|
handleFiles(Array.from(e.target.files));
|
|
51
51
|
fileInput.val('');
|
|
52
52
|
});
|
|
@@ -70,12 +70,12 @@ class MultiFilesInput {
|
|
|
70
70
|
function renderPreview(file) {
|
|
71
71
|
const id = 'f_' + Math.random().toString(36).slice(2, 9);
|
|
72
72
|
const wrap = $(`
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
<div class="border rounded p-2 d-inline-flex align-items-center" data-file-id="${id}" style="background:white;">
|
|
74
|
+
<div class="me-2 preview-thumb" style="width:64px; height:48px; display:flex; align-items:center; justify-content:center; overflow:hidden;"></div>
|
|
75
|
+
<div class="small text-truncate" style="max-width:160px;">${file.name}</div>
|
|
76
|
+
<button type="button" class="btn-close btn-close-small ms-2" aria-label="Supprimer" style="margin-left:8px;"></button>
|
|
77
|
+
</div>
|
|
78
|
+
`);
|
|
79
79
|
filesPreview.append(wrap);
|
|
80
80
|
filesPreview.removeClass('hide');
|
|
81
81
|
|
|
@@ -90,7 +90,7 @@ class MultiFilesInput {
|
|
|
90
90
|
wrap.find('.preview-thumb').html(`<i class="fas fa-file fa-2x text-muted"></i>`);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
wrap.find('.btn-close').on('click', function () {
|
|
93
|
+
wrap.find('.btn-close').off('click').on('click', function () {
|
|
94
94
|
const idx = $(this).closest('[data-file-id]').index();
|
|
95
95
|
// remove by reference: find corresponding file by name+size (best-effort)
|
|
96
96
|
const name = file.name, size = file.size;
|
package/package.json
CHANGED
package/user.js
CHANGED