(file)
| 592 | // Called when a file is added to the queue |
| 593 | // Receives `file` |
| 594 | addedfile(file) { |
| 595 | if (this.element === this.previewsContainer) { |
| 596 | this.element.classList.add("dz-started"); |
| 597 | } |
| 598 | |
| 599 | if (this.previewsContainer && !this.options.disablePreviews) { |
| 600 | file.previewElement = Dropzone.createElement( |
| 601 | this.options.previewTemplate.trim() |
| 602 | ); |
| 603 | file.previewTemplate = file.previewElement; // Backwards compatibility |
| 604 | |
| 605 | this.previewsContainer.appendChild(file.previewElement); |
| 606 | for (var node of file.previewElement.querySelectorAll("[data-dz-name]")) { |
| 607 | node.textContent = file.name; |
| 608 | } |
| 609 | for (node of file.previewElement.querySelectorAll("[data-dz-size]")) { |
| 610 | node.innerHTML = this.filesize(file.size); |
| 611 | } |
| 612 | |
| 613 | if (this.options.addRemoveLinks) { |
| 614 | file._removeLink = Dropzone.createElement( |
| 615 | `<a class="dz-remove" href="javascript:undefined;" data-dz-remove>${this.options.dictRemoveFile}</a>` |
| 616 | ); |
| 617 | file.previewElement.appendChild(file._removeLink); |
| 618 | } |
| 619 | |
| 620 | let removeFileEvent = (e) => { |
| 621 | e.preventDefault(); |
| 622 | e.stopPropagation(); |
| 623 | if (file.status === Dropzone.UPLOADING) { |
| 624 | return Dropzone.confirm( |
| 625 | this.options.dictCancelUploadConfirmation, |
| 626 | () => this.removeFile(file) |
| 627 | ); |
| 628 | } else { |
| 629 | if (this.options.dictRemoveFileConfirmation) { |
| 630 | return Dropzone.confirm( |
| 631 | this.options.dictRemoveFileConfirmation, |
| 632 | () => this.removeFile(file) |
| 633 | ); |
| 634 | } else { |
| 635 | return this.removeFile(file); |
| 636 | } |
| 637 | } |
| 638 | }; |
| 639 | |
| 640 | for (let removeLink of file.previewElement.querySelectorAll( |
| 641 | "[data-dz-remove]" |
| 642 | )) { |
| 643 | removeLink.addEventListener("click", removeFileEvent); |
| 644 | } |
| 645 | } |
| 646 | }, |
| 647 | |
| 648 | // Called whenever a file is removed. |
| 649 | removedfile(file) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…