parent
2aa2f1fd26
commit
86d98e5e42
|
@ -28,6 +28,7 @@
|
||||||
<script>
|
<script>
|
||||||
import UniqueComponentId from '../utils/UniqueComponentId';
|
import UniqueComponentId from '../utils/UniqueComponentId';
|
||||||
import DomHandler from '../utils/DomHandler';
|
import DomHandler from '../utils/DomHandler';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
|
|
|
@ -25,6 +25,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="p-fileupload-empty" v-if="$scopedSlots.empty && !hasFiles">
|
||||||
|
<slot name="empty">
|
||||||
|
</slot>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span :class="basicChooseButtonClass" @mouseup="onBasicUploaderClick" v-else-if="isBasic">
|
<span :class="basicChooseButtonClass" @mouseup="onBasicUploaderClick" v-else-if="isBasic">
|
||||||
|
@ -38,6 +42,7 @@
|
||||||
import Button from '../button/Button';
|
import Button from '../button/Button';
|
||||||
import ProgressBar from '../progressbar/ProgressBar';
|
import ProgressBar from '../progressbar/ProgressBar';
|
||||||
import Message from '../message/Message';
|
import Message from '../message/Message';
|
||||||
|
import DomHandler from '../utils/DomHandler';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
@ -233,17 +238,38 @@ export default {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
onDragEnter() {
|
onDragEnter(event) {
|
||||||
|
console.log('enter');
|
||||||
},
|
if (!this.disabled) {
|
||||||
onDragLeave() {
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onDragOver() {
|
onDragOver() {
|
||||||
|
if (!this.disabled) {
|
||||||
|
DomHandler.addClass(this.$refs.content, 'p-fileupload-highlight');
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onDragLeave() {
|
||||||
|
if (!this.disabled) {
|
||||||
|
DomHandler.removeClass(this.$refs.content, 'p-fileupload-highlight');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onDrop() {
|
onDrop() {
|
||||||
|
if (!this.disabled) {
|
||||||
|
DomHandler.removeClass(this.$refs.content, 'p-fileupload-highlight');
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
const files = event.dataTransfer ? event.dataTransfer.files : event.target.files;
|
||||||
|
const allowDrop = this.multiple || (files && files.length === 1);
|
||||||
|
|
||||||
|
if (allowDrop) {
|
||||||
|
this.onFileSelect(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onBasicUploaderClick() {
|
onBasicUploaderClick() {
|
||||||
if (this.hasFiles) {
|
if (this.hasFiles) {
|
||||||
|
|
|
@ -9,7 +9,11 @@
|
||||||
|
|
||||||
<div class="content-section implementation">
|
<div class="content-section implementation">
|
||||||
<h3>Advanced</h3>
|
<h3>Advanced</h3>
|
||||||
<FileUpload name="demo[]" url="./upload.php" @upload="onUpload" :multiple="true" accept="image/*" :maxFileSize="1000000" />
|
<FileUpload name="demo[]" url="./upload.php" @upload="onUpload" :multiple="true" accept="image/*" :maxFileSize="1000000">
|
||||||
|
<template #empty>
|
||||||
|
<p>Drag and drop files to here to upload.</p>
|
||||||
|
</template>
|
||||||
|
</FileUpload>
|
||||||
|
|
||||||
<h3>Basic</h3>
|
<h3>Basic</h3>
|
||||||
<FileUpload mode="basic" name="demo[]" url="./upload.php" accept="image/*" :maxFileSize="1000000" @upload="onUpload" />
|
<FileUpload mode="basic" name="demo[]" url="./upload.php" accept="image/*" :maxFileSize="1000000" @upload="onUpload" />
|
||||||
|
|
|
@ -56,6 +56,16 @@ import FileUpload from 'primevue/fileupload';
|
||||||
<h3>Request Customization</h3>
|
<h3>Request Customization</h3>
|
||||||
<p>XHR request to upload the files can be customized using the before-upload callback that passes the xhr instance and FormData object as event parameters.</p>
|
<p>XHR request to upload the files can be customized using the before-upload callback that passes the xhr instance and FormData object as event parameters.</p>
|
||||||
|
|
||||||
|
<h3>Empty Template</h3>
|
||||||
|
<p>When there is no file selected, you may use the empty slot to display content.</p>
|
||||||
|
<CodeHighlight>
|
||||||
|
<FileUpload name="demo[]" url="./upload" />
|
||||||
|
<template #empty>
|
||||||
|
<p>Drag and drop files to here to upload.</p>
|
||||||
|
</template>
|
||||||
|
</FileUpload>
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
<h3>Properties</h3>
|
<h3>Properties</h3>
|
||||||
<div class="doc-tablewrapper">
|
<div class="doc-tablewrapper">
|
||||||
<table class="doc-table">
|
<table class="doc-table">
|
||||||
|
@ -252,7 +262,11 @@ import FileUpload from 'primevue/fileupload';
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<template v-pre>
|
<template v-pre>
|
||||||
<h3>Advanced</h3>
|
<h3>Advanced</h3>
|
||||||
<FileUpload name="demo[]" url="./upload.php" @upload="onUpload" :multiple="true" accept="image/*" :maxFileSize="1000000" />
|
<FileUpload name="demo[]" url="./upload.php" @upload="onUpload" :multiple="true" accept="image/*" :maxFileSize="1000000">
|
||||||
|
<template #empty>
|
||||||
|
<p>Drag and drop files to here to upload.</p>
|
||||||
|
</template>
|
||||||
|
</FileUpload>
|
||||||
|
|
||||||
<h3>Basic</h3>
|
<h3>Basic</h3>
|
||||||
<FileUpload mode="basic" name="demo[]" url="./upload.php" accept="image/*" :maxFileSize="1000000" @upload="onUpload" />
|
<FileUpload mode="basic" name="demo[]" url="./upload.php" accept="image/*" :maxFileSize="1000000" @upload="onUpload" />
|
||||||
|
|
Loading…
Reference in New Issue