|
1 | 1 | /*!
|
2 | 2 | * Uploader - Uploader library implements html5 file upload and provides multiple simultaneous, stable, fault tolerant and resumable uploads
|
3 |
| - * @version v0.0.3 |
| 3 | + * @version v0.0.4 |
4 | 4 | * @author dolymood <[email protected]>
|
5 | 5 | * @link https://github.com/simple-uploader/Uploader
|
6 | 6 | * @license MIT
|
@@ -352,7 +352,7 @@ var event = _dereq_('./event')
|
352 | 352 | var File = _dereq_('./file')
|
353 | 353 | var Chunk = _dereq_('./chunk')
|
354 | 354 |
|
355 |
| -var version = '0.0.3' |
| 355 | +var version = '0.0.4' |
356 | 356 |
|
357 | 357 | // ie10+
|
358 | 358 | var ie10plus = window.navigator.msPointerEnabled
|
@@ -503,6 +503,12 @@ utils.extend(Uploader.prototype, {
|
503 | 503 | this.addFiles([file], evt)
|
504 | 504 | },
|
505 | 505 |
|
| 506 | + cancel: function () { |
| 507 | + for (var i = this.fileList.length - 1; i >= 0; i--) { |
| 508 | + this.fileList[i].cancel() |
| 509 | + } |
| 510 | + }, |
| 511 | + |
506 | 512 | removeFile: function (file) {
|
507 | 513 | File.prototype.removeFile.call(this, file)
|
508 | 514 | this._trigger('fileRemoved', file)
|
@@ -814,6 +820,7 @@ function File (uploader, file, parent) {
|
814 | 820 | this.fileList = []
|
815 | 821 | this.chunks = []
|
816 | 822 | this._errorFiles = []
|
| 823 | + this.id = utils.uid() |
817 | 824 |
|
818 | 825 | if (this.isRoot || !file) {
|
819 | 826 | this.file = null
|
@@ -990,7 +997,7 @@ utils.extend(File.prototype, {
|
990 | 997 | this.averageSpeed = 0
|
991 | 998 | uploader._trigger('fileSuccess', rootFile, this, message, chunk)
|
992 | 999 | if (rootFile.isComplete()) {
|
993 |
| - uploader._trigger('fileComplete', rootFile) |
| 1000 | + uploader._trigger('fileComplete', rootFile, this) |
994 | 1001 | }
|
995 | 1002 | } else if (!this._progeressId) {
|
996 | 1003 | triggerProgress()
|
@@ -1092,12 +1099,6 @@ utils.extend(File.prototype, {
|
1092 | 1099 | },
|
1093 | 1100 |
|
1094 | 1101 | cancel: function () {
|
1095 |
| - if (this.isFolder) { |
1096 |
| - for (var i = this.files.length - 1; i >= 0; i--) { |
1097 |
| - this.files[i].cancel() |
1098 |
| - } |
1099 |
| - return |
1100 |
| - } |
1101 | 1102 | this.uploader.removeFile(this)
|
1102 | 1103 | },
|
1103 | 1104 |
|
@@ -1337,8 +1338,11 @@ var isPlainObject = function (obj) {
|
1337 | 1338 | return serialize.call(obj) === '[object Object]' && Object.getPrototypeOf(obj) === oproto
|
1338 | 1339 | }
|
1339 | 1340 |
|
| 1341 | +var i = 0 |
1340 | 1342 | var utils = {
|
1341 |
| - |
| 1343 | + uid: function () { |
| 1344 | + return ++i |
| 1345 | + }, |
1342 | 1346 | noop: function () {},
|
1343 | 1347 | bind: function (fn, context) {
|
1344 | 1348 | return function () {
|
|
0 commit comments