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 addFileUpload
removeFileUpload removeFileUpload

24
dist/example.js vendored

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

File diff suppressed because one or more lines are too long

@ -729,7 +729,8 @@ return /******/ (function(modules) { // webpackBootstrap
iframe.onabort({ type: 'abort' }); iframe.onabort({ type: 'abort' });
} }
delete this._files[id]; delete this._files[id];
this.$dispatch('removeFileUpload', file, this); this.$dispatch && this.$dispatch('removeFileUpload', file, this);
this.removeFileUpload && this.removeFileUpload(file);
} }
this._index = 0; this._index = 0;
}, },
@ -836,7 +837,8 @@ return /******/ (function(modules) { // webpackBootstrap
len = 1; len = 1;
} }
this._files[id]._file = this.files[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 { } else {
var id = createId(); var id = createId();
@ -851,7 +853,8 @@ return /******/ (function(modules) { // webpackBootstrap
} }
var len = this.files.push(file); var len = this.files.push(file);
this._files[id]._file = this.files[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]);
} }
}, },
_fileUploads: function _fileUploads() { _fileUploads: function _fileUploads() {
@ -937,7 +940,8 @@ return /******/ (function(modules) { // webpackBootstrap
speedTime = speedTime2; speedTime = speedTime2;
} }
} }
_self.$dispatch('fileUploadProgress', file, _self); _self.$dispatch && _self.$dispatch('fileUploadProgress', file, _self);
_self.fileUploadProgress && _self.fileUploadProgress(file);
}; };
var callback = function callback(e) { var callback = function callback(e) {
@ -986,7 +990,8 @@ return /******/ (function(modules) { // webpackBootstrap
if (!fileUploads) { if (!fileUploads) {
fileUploads = true; fileUploads = true;
if (!file.removed) { if (!file.removed) {
_self.$dispatch('afterFileUpload', file, _self); _self.$dispatch && _self.$dispatch('afterFileUpload', file, _self);
_self.afterFileUpload && _self.afterFileUpload(file);
} }
setTimeout(function () { setTimeout(function () {
_self._fileUploads(); _self._fileUploads();
@ -1031,7 +1036,8 @@ return /******/ (function(modules) { // webpackBootstrap
} }
} }
}, 100); }, 100);
this.$dispatch('beforeFileUpload', file, this); this.$dispatch && this.$dispatch('beforeFileUpload', file, this);
this.beforeFileUpload && this.beforeFileUpload(file);
}, },
_fileUploadPut: function _fileUploadPut(file) { _fileUploadPut: function _fileUploadPut(file) {
var _self = this; var _self = this;
@ -1171,7 +1177,8 @@ return /******/ (function(modules) { // webpackBootstrap
fileUploads = true; fileUploads = true;
iframe.parentNode && iframe.parentNode.removeChild(iframe); iframe.parentNode && iframe.parentNode.removeChild(iframe);
if (!file.removed) { if (!file.removed) {
_self.$dispatch('afterFileUpload', file, _self); _self.$dispatch && _self.$dispatch('afterFileUpload', file, _self);
_self.afterFileUpload && _self.afterFileUpload(file);
} }
setTimeout(function () { setTimeout(function () {
_self._fileUploads(); _self._fileUploads();
@ -1198,7 +1205,8 @@ return /******/ (function(modules) { // webpackBootstrap
} }
} }
}, 50); }, 50);
_self.$dispatch('beforeFileUpload', file, this); _self.$dispatch && _self.$dispatch('beforeFileUpload', file, this);
_self.beforeFileUpload && _self.beforeFileUpload(file);
}, 10); }, 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", "name": "vue-upload-component",
"description": "Vue.js file upload component, Support for multiple file uploads, progress, html5, html4, support ie9", "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", "author": "LianYue",
"scripts": { "scripts": {
"dev": "webpack-dev-server --inline --hot", "dev": "webpack-dev-server --inline --hot",
@ -17,6 +17,7 @@
"keywords": [ "keywords": [
"vue.js", "vue.js",
"file", "file",
"put",
"upload", "upload",
"uploads", "uploads",
"multiple", "multiple",
@ -34,8 +35,6 @@
"dependencies": { "dependencies": {
"vue": "^1.0.24" "vue": "^1.0.24"
}, },
"dependencies": {
},
"devDependencies": { "devDependencies": {
"babel-runtime": "^6.0.0", "babel-runtime": "^6.0.0",
"babel-core": "^6.0.0", "babel-core": "^6.0.0",

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

Loading…
Cancel
Save