10
10
/**
11
11
* The angular file upload module
12
12
* @author : nerv
13
- * @version : 0.2.9.8, 2013-12-31
13
+ * @version : 0.2.9.8.1 , 2013-12-31
14
14
*/
15
15
var app = angular . module ( 'angularFileUpload' , [ ] ) ;
16
16
17
17
/**
18
18
* The angular file upload module
19
19
* @author : nerv
20
- * @version : 0.2.9.8, 2013-12-31
20
+ * @version : 0.2.9.8.1 , 2013-12-31
21
21
*/
22
22
23
23
// It is attached to an element that catches the event drop file
@@ -26,7 +26,7 @@ app.directive('ngFileDrop', [ '$fileUploader', function ($fileUploader) {
26
26
27
27
return {
28
28
// don't use drag-n-drop files in IE9, because not File API support
29
- link : ! $fileUploader . hasHTML5 ? angular . noop : function ( scope , element , attributes ) {
29
+ link : ! $fileUploader . isHTML5 ? angular . noop : function ( scope , element , attributes ) {
30
30
element
31
31
. bind ( 'drop' , function ( event ) {
32
32
var dataTransfer = event . dataTransfer ?
@@ -57,7 +57,7 @@ app.directive('ngFileDrop', [ '$fileUploader', function ($fileUploader) {
57
57
/**
58
58
* The angular file upload module
59
59
* @author : nerv
60
- * @version : 0.2.9.8, 2013-12-31
60
+ * @version : 0.2.9.8.1 , 2013-12-31
61
61
*/
62
62
63
63
// It is attached to an element which will be assigned to a class "ng-file-over" or ng-file-over="className"
@@ -78,7 +78,7 @@ app.directive('ngFileOver', function () {
78
78
/**
79
79
* The angular file upload module
80
80
* @author : nerv
81
- * @version : 0.2.9.8, 2013-12-31
81
+ * @version : 0.2.9.8.1 , 2013-12-31
82
82
*/
83
83
84
84
// It is attached to <input type="file"> element like <ng-file-select="options">
@@ -87,19 +87,19 @@ app.directive('ngFileSelect', [ '$fileUploader', function ($fileUploader) {
87
87
88
88
return {
89
89
link : function ( scope , element , attributes ) {
90
- $fileUploader . hasHTML5 || element . removeAttr ( 'multiple' ) ;
90
+ $fileUploader . isHTML5 || element . removeAttr ( 'multiple' ) ;
91
91
92
92
element . bind ( 'change' , function ( ) {
93
93
scope . $emit ( 'file:add' , this . files ? this . files : this , scope . $eval ( attributes . ngFileSelect ) ) ;
94
- $fileUploader . hasHTML5 && element . prop ( 'value' , null ) ;
94
+ $fileUploader . isHTML5 && element . prop ( 'value' , null ) ;
95
95
} ) ;
96
96
}
97
97
} ;
98
98
} ] ) ;
99
99
/**
100
100
* The angular file upload module
101
101
* @author : nerv
102
- * @version : 0.2.9.8, 2013-12-31
102
+ * @version : 0.2.9.8.1 , 2013-12-31
103
103
*/
104
104
105
105
app . factory ( '$fileUploader' , [ '$compile' , '$rootScope' , '$http' , '$window' , function ( $compile , $rootScope , $http , $window ) {
@@ -177,7 +177,7 @@ app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', fun
177
177
* Checks a support the html5 uploader
178
178
* @returns {Boolean }
179
179
*/
180
- hasHTML5 : ! ! ( $window . File && $window . FormData ) ,
180
+ isHTML5 : ! ! ( $window . File && $window . FormData ) ,
181
181
182
182
/**
183
183
* Adds items to the queue
@@ -281,7 +281,7 @@ app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', fun
281
281
uploadItem : function ( value ) {
282
282
var index = this . getIndexOfItem ( value ) ;
283
283
var item = this . queue [ index ] ;
284
- var transport = item . _hasForm ( ) ? '_iframeTransport ' : '_xhrTransport ' ;
284
+ var transport = this . isHTML5 ? '_xhrTransport ' : '_iframeTransport ' ;
285
285
286
286
item . index = item . index || this . _nextIndex ++ ;
287
287
item . isReady = true ;
@@ -303,11 +303,10 @@ app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', fun
303
303
var index = this . getIndexOfItem ( value ) ;
304
304
var item = this . queue [ index ] ;
305
305
306
- if ( item . _hasForm ( ) ) {
307
- // TODO: old browsers
308
- } else {
306
+ if ( this . isHTML5 ) {
309
307
item . _xhr && item . _xhr . abort ( ) ;
310
- delete item . _xhr ;
308
+ } else {
309
+ // TODO: old browsers
311
310
}
312
311
} ,
313
312
@@ -508,7 +507,7 @@ app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', fun
508
507
// item of queue
509
508
function Item ( params ) {
510
509
// fix for old browsers
511
- if ( angular . isElement ( params . file ) ) {
510
+ if ( ! Uploader . prototype . isHTML5 ) {
512
511
var input = angular . element ( params . file ) ;
513
512
var clone = $compile ( input . clone ( ) ) ( params . uploader . scope ) ;
514
513
var form = angular . element ( '<form style="display: none;" />' ) ;
@@ -611,7 +610,7 @@ app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', fun
611
610
create : function ( params ) {
612
611
return new Uploader ( params ) ;
613
612
} ,
614
- hasHTML5 : Uploader . prototype . hasHTML5
613
+ isHTML5 : Uploader . prototype . isHTML5
615
614
} ;
616
615
} ] )
617
616
0 commit comments