add attr events

1.0 v0.3.5
git 10 years ago
parent 10811a3c32
commit 7091fb7013

30
dist/example.js vendored

@ -10764,6 +10764,10 @@
}, },
size: { size: {
type: Number type: Number
},
events: {
type: Object,
default: function _default() {}
} }
}, },
@ -10844,8 +10848,7 @@
iframe.onabort({ type: 'abort' }); iframe.onabort({ type: 'abort' });
} }
delete this._files[id]; delete this._files[id];
this.$dispatch && this.$dispatch('removeFileUpload', file, this); this._events('removeFileUpload', file);
this.removeFileUpload && this.removeFileUpload(file);
} }
this._index = 0; this._index = 0;
}, },
@ -10867,6 +10870,11 @@
this.files.splice(0, this.files.length); this.files.splice(0, this.files.length);
} }
}, },
_events: function _events(name, file) {
this.$dispatch && this.$dispatch(name, file, this);
this[name] && this[name](file);
this.events && this.events[name] && this.events[name](file, this);
},
_drop: function _drop(value) { _drop: function _drop(value) {
if (this.dropElement && this.$mode === 'html5') { if (this.dropElement && this.$mode === 'html5') {
try { try {
@ -10943,8 +10951,7 @@
this._files[file.id] = hiddenData; this._files[file.id] = hiddenData;
file = this.files[this.files.push(file) - 1]; file = this.files[this.files.push(file) - 1];
this._files[file.id]._file = file; this._files[file.id]._file = file;
this.$dispatch && this.$dispatch('addFileUpload', file, this); this._events('addFileUpload', file);
this.addFileUpload && this.addFileUpload(file);
}, },
_onDrop: function _onDrop(e) { _onDrop: function _onDrop(e) {
this._dropActive = 0; this._dropActive = 0;
@ -11060,8 +11067,7 @@
speedTime = speedTime2; speedTime = speedTime2;
} }
} }
_self.$dispatch && _self.$dispatch('fileUploadProgress', file, _self); _self._events('fileUploadProgress', file);
_self.fileUploadProgress && _self.fileUploadProgress(file);
}; };
var callback = function callback(e) { var callback = function callback(e) {
@ -11110,8 +11116,7 @@
if (!fileUploads) { if (!fileUploads) {
fileUploads = true; fileUploads = true;
if (!file.removed) { if (!file.removed) {
_self.$dispatch && _self.$dispatch('afterFileUpload', file, _self); _self._events('afterFileUpload', file);
_self.afterFileUpload && _self.afterFileUpload(file);
} }
setTimeout(function () { setTimeout(function () {
_self._fileUploads(); _self._fileUploads();
@ -11156,8 +11161,7 @@
} }
} }
}, 100); }, 100);
this.$dispatch && this.$dispatch('beforeFileUpload', file, this); this._events('beforeFileUpload', file);
this.beforeFileUpload && this.beforeFileUpload(file);
}, },
_fileUploadPut: function _fileUploadPut(file) { _fileUploadPut: function _fileUploadPut(file) {
var _self = this; var _self = this;
@ -11304,8 +11308,7 @@
fileUploads = true; fileUploads = true;
iframe.parentNode && iframe.parentNode.removeChild(iframe); iframe.parentNode && iframe.parentNode.removeChild(iframe);
if (!file.removed) { if (!file.removed) {
_self.$dispatch && _self.$dispatch('afterFileUpload', file, _self); _self._events('afterFileUpload', file);
_self.afterFileUpload && _self.afterFileUpload(file);
} }
setTimeout(function () { setTimeout(function () {
_self._fileUploads(); _self._fileUploads();
@ -11332,8 +11335,7 @@
} }
} }
}, 50); }, 50);
_self.$dispatch && _self.$dispatch('beforeFileUpload', file, this); _self._events('beforeFileUpload', file);
_self.beforeFileUpload && _self.beforeFileUpload(file);
}, 10); }, 10);
} }
} }

File diff suppressed because one or more lines are too long

@ -650,6 +650,10 @@ return /******/ (function(modules) { // webpackBootstrap
}, },
size: { size: {
type: Number type: Number
},
events: {
type: Object,
default: function _default() {}
} }
}, },
@ -730,8 +734,7 @@ return /******/ (function(modules) { // webpackBootstrap
iframe.onabort({ type: 'abort' }); iframe.onabort({ type: 'abort' });
} }
delete this._files[id]; delete this._files[id];
this.$dispatch && this.$dispatch('removeFileUpload', file, this); this._events('removeFileUpload', file);
this.removeFileUpload && this.removeFileUpload(file);
} }
this._index = 0; this._index = 0;
}, },
@ -753,6 +756,11 @@ return /******/ (function(modules) { // webpackBootstrap
this.files.splice(0, this.files.length); this.files.splice(0, this.files.length);
} }
}, },
_events: function _events(name, file) {
this.$dispatch && this.$dispatch(name, file, this);
this[name] && this[name](file);
this.events && this.events[name] && this.events[name](file, this);
},
_drop: function _drop(value) { _drop: function _drop(value) {
if (this.dropElement && this.$mode === 'html5') { if (this.dropElement && this.$mode === 'html5') {
try { try {
@ -829,8 +837,7 @@ return /******/ (function(modules) { // webpackBootstrap
this._files[file.id] = hiddenData; this._files[file.id] = hiddenData;
file = this.files[this.files.push(file) - 1]; file = this.files[this.files.push(file) - 1];
this._files[file.id]._file = file; this._files[file.id]._file = file;
this.$dispatch && this.$dispatch('addFileUpload', file, this); this._events('addFileUpload', file);
this.addFileUpload && this.addFileUpload(file);
}, },
_onDrop: function _onDrop(e) { _onDrop: function _onDrop(e) {
this._dropActive = 0; this._dropActive = 0;
@ -946,8 +953,7 @@ return /******/ (function(modules) { // webpackBootstrap
speedTime = speedTime2; speedTime = speedTime2;
} }
} }
_self.$dispatch && _self.$dispatch('fileUploadProgress', file, _self); _self._events('fileUploadProgress', file);
_self.fileUploadProgress && _self.fileUploadProgress(file);
}; };
var callback = function callback(e) { var callback = function callback(e) {
@ -996,8 +1002,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (!fileUploads) { if (!fileUploads) {
fileUploads = true; fileUploads = true;
if (!file.removed) { if (!file.removed) {
_self.$dispatch && _self.$dispatch('afterFileUpload', file, _self); _self._events('afterFileUpload', file);
_self.afterFileUpload && _self.afterFileUpload(file);
} }
setTimeout(function () { setTimeout(function () {
_self._fileUploads(); _self._fileUploads();
@ -1042,8 +1047,7 @@ return /******/ (function(modules) { // webpackBootstrap
} }
} }
}, 100); }, 100);
this.$dispatch && this.$dispatch('beforeFileUpload', file, this); this._events('beforeFileUpload', file);
this.beforeFileUpload && this.beforeFileUpload(file);
}, },
_fileUploadPut: function _fileUploadPut(file) { _fileUploadPut: function _fileUploadPut(file) {
var _self = this; var _self = this;
@ -1190,8 +1194,7 @@ 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 && _self.$dispatch('afterFileUpload', file, _self); _self._events('afterFileUpload', file);
_self.afterFileUpload && _self.afterFileUpload(file);
} }
setTimeout(function () { setTimeout(function () {
_self._fileUploads(); _self._fileUploads();
@ -1218,8 +1221,7 @@ return /******/ (function(modules) { // webpackBootstrap
} }
} }
}, 50); }, 50);
_self.$dispatch && _self.$dispatch('beforeFileUpload', file, this); _self._events('beforeFileUpload', file);
_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.3.4", "version": "0.3.5",
"author": "LianYue", "author": "LianYue",
"scripts": { "scripts": {
"dev": "webpack-dev-server --inline --hot", "dev": "webpack-dev-server --inline --hot",

@ -78,6 +78,10 @@ export default {
size: { size: {
type: Number, type: Number,
}, },
events: {
type: Object,
default: () => {},
},
}, },
components: { components: {
@ -162,8 +166,7 @@ export default {
iframe.onabort({type:'abort'}); iframe.onabort({type:'abort'});
} }
delete this._files[id]; delete this._files[id];
this.$dispatch && this.$dispatch('removeFileUpload', file, this); this._events('removeFileUpload', file);
this.removeFileUpload && this.removeFileUpload(file);
} }
this._index = 0; this._index = 0;
}, },
@ -188,6 +191,12 @@ export default {
} }
}, },
_events(name, file) {
this.$dispatch && this.$dispatch(name, file, this);
this[name] && this[name](file);
this.events && this.events[name] && this.events[name](file, this);
},
_drop(value) { _drop(value) {
if (this.dropElement && this.$mode === 'html5') { if (this.dropElement && this.$mode === 'html5') {
try { try {
@ -266,8 +275,7 @@ export default {
this._files[file.id] = hiddenData; this._files[file.id] = hiddenData;
file = this.files[this.files.push(file) - 1]; file = this.files[this.files.push(file) - 1];
this._files[file.id]._file = file; this._files[file.id]._file = file;
this.$dispatch && this.$dispatch('addFileUpload', file, this); this._events('addFileUpload', file);
this.addFileUpload && this.addFileUpload(file);
}, },
_onDrop(e) { _onDrop(e) {
this._dropActive = 0; this._dropActive = 0;
@ -389,8 +397,7 @@ export default {
speedTime = speedTime2; speedTime = speedTime2;
} }
} }
_self.$dispatch && _self.$dispatch('fileUploadProgress', file, _self); _self._events('fileUploadProgress', file);
_self.fileUploadProgress && _self.fileUploadProgress(file);
}; };
@ -440,8 +447,7 @@ export default {
if (!fileUploads) { if (!fileUploads) {
fileUploads = true; fileUploads = true;
if (!file.removed) { if (!file.removed) {
_self.$dispatch && _self.$dispatch('afterFileUpload', file, _self); _self._events('afterFileUpload', file);
_self.afterFileUpload && _self.afterFileUpload(file);
} }
setTimeout(function() { setTimeout(function() {
_self._fileUploads(); _self._fileUploads();
@ -489,8 +495,7 @@ export default {
} }
} }
}, 100); }, 100);
this.$dispatch && this.$dispatch('beforeFileUpload', file, this); this._events('beforeFileUpload', file);
this.beforeFileUpload && this.beforeFileUpload(file);
}, },
_fileUploadPut(file) { _fileUploadPut(file) {
var _self = this; var _self = this;
@ -652,8 +657,7 @@ 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 && _self.$dispatch('afterFileUpload', file, _self); _self._events('afterFileUpload', file);
_self.afterFileUpload && _self.afterFileUpload(file);
} }
setTimeout(function() { setTimeout(function() {
@ -663,7 +667,6 @@ export default {
}; };
setTimeout(function() { setTimeout(function() {
document.body.appendChild(iframe).appendChild(form).submit(); document.body.appendChild(iframe).appendChild(form).submit();
iframe.onload = callback; iframe.onload = callback;
@ -683,8 +686,7 @@ export default {
} }
} }
}, 50); }, 50);
_self.$dispatch && _self.$dispatch('beforeFileUpload', file, this); _self._events('beforeFileUpload', file);
_self.beforeFileUpload && _self.beforeFileUpload(file);
}, 10); }, 10);
}, },

Loading…
Cancel
Save