Add methods

1.0 v0.3.0
git 10 years ago
parent d60d0ab963
commit aa0497701e

@ -73,7 +73,7 @@ npm run build
```
## Dispatch
## $dispatch, methods
addFileUpload
removeFileUpload

24
dist/example.js vendored

@ -766,7 +766,8 @@
iframe.onabort({ type: 'abort' });
}
delete this._files[id];
this.$dispatch('removeFileUpload', file, this);
this.$dispatch && this.$dispatch('removeFileUpload', file, this);
this.removeFileUpload && this.removeFileUpload(file);
}
this._index = 0;
},
@ -873,7 +874,8 @@
len = 1;
}
this._files[id]._file = this.files[len - 1];
this.$dispatch('addFileUpload', this.files[len - 1], this);
this.$dispatch && this.$dispatch('addFileUpload', this.files[len - 1], this);
this.addFileUpload && this.addFileUpload(this.files[len - 1]);
}
} else {
var id = createId();
@ -888,7 +890,8 @@
}
var len = this.files.push(file);
this._files[id]._file = this.files[len - 1];
this.$dispatch('addFileUpload', this.files[len - 1], this);
this.$dispatch && this.$dispatch('addFileUpload', this.files[len - 1], this);
this.addFileUpload && this.addFileUpload(this.files[len - 1]);
}
},
_fileUploads: function _fileUploads() {
@ -974,7 +977,8 @@
speedTime = speedTime2;
}
}
_self.$dispatch('fileUploadProgress', file, _self);
_self.$dispatch && _self.$dispatch('fileUploadProgress', file, _self);
_self.fileUploadProgress && _self.fileUploadProgress(file);
};
var callback = function callback(e) {
@ -1023,7 +1027,8 @@
if (!fileUploads) {
fileUploads = true;
if (!file.removed) {
_self.$dispatch('afterFileUpload', file, _self);
_self.$dispatch && _self.$dispatch('afterFileUpload', file, _self);
_self.afterFileUpload && _self.afterFileUpload(file);
}
setTimeout(function () {
_self._fileUploads();
@ -1068,7 +1073,8 @@
}
}
}, 100);
this.$dispatch('beforeFileUpload', file, this);
this.$dispatch && this.$dispatch('beforeFileUpload', file, this);
this.beforeFileUpload && this.beforeFileUpload(file);
},
_fileUploadPut: function _fileUploadPut(file) {
var _self = this;
@ -1208,7 +1214,8 @@
fileUploads = true;
iframe.parentNode && iframe.parentNode.removeChild(iframe);
if (!file.removed) {
_self.$dispatch('afterFileUpload', file, _self);
_self.$dispatch && _self.$dispatch('afterFileUpload', file, _self);
_self.afterFileUpload && _self.afterFileUpload(file);
}
setTimeout(function () {
_self._fileUploads();
@ -1235,7 +1242,8 @@
}
}
}, 50);
_self.$dispatch('beforeFileUpload', file, this);
_self.$dispatch && _self.$dispatch('beforeFileUpload', file, this);
_self.beforeFileUpload && _self.beforeFileUpload(file);
}, 10);
}
}

File diff suppressed because one or more lines are too long

@ -729,7 +729,8 @@ return /******/ (function(modules) { // webpackBootstrap
iframe.onabort({ type: 'abort' });
}
delete this._files[id];
this.$dispatch('removeFileUpload', file, this);
this.$dispatch && this.$dispatch('removeFileUpload', file, this);
this.removeFileUpload && this.removeFileUpload(file);
}
this._index = 0;
},
@ -836,7 +837,8 @@ return /******/ (function(modules) { // webpackBootstrap
len = 1;
}
this._files[id]._file = this.files[len - 1];
this.$dispatch('addFileUpload', this.files[len - 1], this);
this.$dispatch && this.$dispatch('addFileUpload', this.files[len - 1], this);
this.addFileUpload && this.addFileUpload(this.files[len - 1]);
}
} else {
var id = createId();
@ -851,7 +853,8 @@ return /******/ (function(modules) { // webpackBootstrap
}
var len = this.files.push(file);
this._files[id]._file = this.files[len - 1];
this.$dispatch('addFileUpload', this.files[len - 1], this);
this.$dispatch && this.$dispatch('addFileUpload', this.files[len - 1], this);
this.addFileUpload && this.addFileUpload(this.files[len - 1]);
}
},
_fileUploads: function _fileUploads() {
@ -937,7 +940,8 @@ return /******/ (function(modules) { // webpackBootstrap
speedTime = speedTime2;
}
}
_self.$dispatch('fileUploadProgress', file, _self);
_self.$dispatch && _self.$dispatch('fileUploadProgress', file, _self);
_self.fileUploadProgress && _self.fileUploadProgress(file);
};
var callback = function callback(e) {
@ -986,7 +990,8 @@ return /******/ (function(modules) { // webpackBootstrap
if (!fileUploads) {
fileUploads = true;
if (!file.removed) {
_self.$dispatch('afterFileUpload', file, _self);
_self.$dispatch && _self.$dispatch('afterFileUpload', file, _self);
_self.afterFileUpload && _self.afterFileUpload(file);
}
setTimeout(function () {
_self._fileUploads();
@ -1031,7 +1036,8 @@ return /******/ (function(modules) { // webpackBootstrap
}
}
}, 100);
this.$dispatch('beforeFileUpload', file, this);
this.$dispatch && this.$dispatch('beforeFileUpload', file, this);
this.beforeFileUpload && this.beforeFileUpload(file);
},
_fileUploadPut: function _fileUploadPut(file) {
var _self = this;
@ -1171,7 +1177,8 @@ return /******/ (function(modules) { // webpackBootstrap
fileUploads = true;
iframe.parentNode && iframe.parentNode.removeChild(iframe);
if (!file.removed) {
_self.$dispatch('afterFileUpload', file, _self);
_self.$dispatch && _self.$dispatch('afterFileUpload', file, _self);
_self.afterFileUpload && _self.afterFileUpload(file);
}
setTimeout(function () {
_self._fileUploads();
@ -1198,7 +1205,8 @@ return /******/ (function(modules) { // webpackBootstrap
}
}
}, 50);
_self.$dispatch('beforeFileUpload', file, this);
_self.$dispatch && _self.$dispatch('beforeFileUpload', file, this);
_self.beforeFileUpload && _self.beforeFileUpload(file);
}, 10);
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,7 +1,7 @@
{
"name": "vue-upload-component",
"description": "Vue.js file upload component, Support for multiple file uploads, progress, html5, html4, support ie9",
"version": "0.2.4",
"version": "0.3.0",
"author": "LianYue",
"scripts": {
"dev": "webpack-dev-server --inline --hot",
@ -17,6 +17,7 @@
"keywords": [
"vue.js",
"file",
"put",
"upload",
"uploads",
"multiple",
@ -34,8 +35,6 @@
"dependencies": {
"vue": "^1.0.24"
},
"dependencies": {
},
"devDependencies": {
"babel-runtime": "^6.0.0",
"babel-core": "^6.0.0",

@ -163,7 +163,8 @@ export default {
iframe.onabort({type:'abort'});
}
delete this._files[id];
this.$dispatch('removeFileUpload', file, this);
this.$dispatch && this.$dispatch('removeFileUpload', file, this);
this.removeFileUpload && this.removeFileUpload(file);
}
this._index = 0;
},
@ -276,7 +277,8 @@ export default {
len = 1;
}
this._files[id]._file = this.files[len-1];
this.$dispatch('addFileUpload', this.files[len-1], this);
this.$dispatch && this.$dispatch('addFileUpload', this.files[len-1], this);
this.addFileUpload && this.addFileUpload(this.files[len-1]);
}
} else {
var id = createId();
@ -291,7 +293,8 @@ export default {
}
var len = this.files.push(file);
this._files[id]._file = this.files[len-1];
this.$dispatch('addFileUpload', this.files[len-1], this);
this.$dispatch && this.$dispatch('addFileUpload', this.files[len-1], this);
this.addFileUpload && this.addFileUpload(this.files[len-1]);
}
},
@ -381,7 +384,8 @@ export default {
speedTime = speedTime2;
}
}
_self.$dispatch('fileUploadProgress', file, _self);
_self.$dispatch && _self.$dispatch('fileUploadProgress', file, _self);
_self.fileUploadProgress && _self.fileUploadProgress(file);
};
@ -431,7 +435,8 @@ export default {
if (!fileUploads) {
fileUploads = true;
if (!file.removed) {
_self.$dispatch('afterFileUpload', file, _self);
_self.$dispatch && _self.$dispatch('afterFileUpload', file, _self);
_self.afterFileUpload && _self.afterFileUpload(file);
}
setTimeout(function() {
_self._fileUploads();
@ -479,7 +484,8 @@ export default {
}
}
}, 100);
this.$dispatch('beforeFileUpload', file, this);
this.$dispatch && this.$dispatch('beforeFileUpload', file, this);
this.beforeFileUpload && this.beforeFileUpload(file);
},
_fileUploadPut(file) {
var _self = this;
@ -634,7 +640,9 @@ export default {
fileUploads = true;
iframe.parentNode && iframe.parentNode.removeChild(iframe);
if (!file.removed) {
_self.$dispatch('afterFileUpload', file, _self);
_self.$dispatch && _self.$dispatch('afterFileUpload', file, _self);
_self.afterFileUpload && _self.afterFileUpload(file);
}
setTimeout(function() {
_self._fileUploads();
@ -663,7 +671,8 @@ export default {
}
}
}, 50);
_self.$dispatch('beforeFileUpload', file, this);
_self.$dispatch && _self.$dispatch('beforeFileUpload', file, this);
_self.beforeFileUpload && _self.beforeFileUpload(file);
}, 10);
},

Loading…
Cancel
Save