Skip to content

Commit 88bf47c

Browse files
author
nerv
committed
Renamed: uploader.hasHTML5 => uploader.isHTML5
1 parent 730d074 commit 88bf47c

File tree

10 files changed

+38
-40
lines changed

10 files changed

+38
-40
lines changed

angular-file-upload.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
/**
1111
* The angular file upload module
1212
* @author: nerv
13-
* @version: 0.2.9.8, 2013-12-31
13+
* @version: 0.2.9.8.1, 2013-12-31
1414
*/
1515
var app = angular.module('angularFileUpload', []);
1616

1717
/**
1818
* The angular file upload module
1919
* @author: nerv
20-
* @version: 0.2.9.8, 2013-12-31
20+
* @version: 0.2.9.8.1, 2013-12-31
2121
*/
2222

2323
// It is attached to an element that catches the event drop file
@@ -26,7 +26,7 @@ app.directive('ngFileDrop', [ '$fileUploader', function ($fileUploader) {
2626

2727
return {
2828
// 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) {
3030
element
3131
.bind('drop', function (event) {
3232
var dataTransfer = event.dataTransfer ?
@@ -57,7 +57,7 @@ app.directive('ngFileDrop', [ '$fileUploader', function ($fileUploader) {
5757
/**
5858
* The angular file upload module
5959
* @author: nerv
60-
* @version: 0.2.9.8, 2013-12-31
60+
* @version: 0.2.9.8.1, 2013-12-31
6161
*/
6262

6363
// 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 () {
7878
/**
7979
* The angular file upload module
8080
* @author: nerv
81-
* @version: 0.2.9.8, 2013-12-31
81+
* @version: 0.2.9.8.1, 2013-12-31
8282
*/
8383

8484
// It is attached to <input type="file"> element like <ng-file-select="options">
@@ -87,19 +87,19 @@ app.directive('ngFileSelect', [ '$fileUploader', function ($fileUploader) {
8787

8888
return {
8989
link: function (scope, element, attributes) {
90-
$fileUploader.hasHTML5 || element.removeAttr('multiple');
90+
$fileUploader.isHTML5 || element.removeAttr('multiple');
9191

9292
element.bind('change', function () {
9393
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);
9595
});
9696
}
9797
};
9898
}]);
9999
/**
100100
* The angular file upload module
101101
* @author: nerv
102-
* @version: 0.2.9.8, 2013-12-31
102+
* @version: 0.2.9.8.1, 2013-12-31
103103
*/
104104

105105
app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', function ($compile, $rootScope, $http, $window) {
@@ -177,7 +177,7 @@ app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', fun
177177
* Checks a support the html5 uploader
178178
* @returns {Boolean}
179179
*/
180-
hasHTML5: !!($window.File && $window.FormData),
180+
isHTML5: !!($window.File && $window.FormData),
181181

182182
/**
183183
* Adds items to the queue
@@ -281,7 +281,7 @@ app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', fun
281281
uploadItem: function (value) {
282282
var index = this.getIndexOfItem(value);
283283
var item = this.queue[ index ];
284-
var transport = item._hasForm() ? '_iframeTransport' : '_xhrTransport';
284+
var transport = this.isHTML5 ? '_xhrTransport' : '_iframeTransport';
285285

286286
item.index = item.index || this._nextIndex++;
287287
item.isReady = true;
@@ -303,11 +303,10 @@ app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', fun
303303
var index = this.getIndexOfItem(value);
304304
var item = this.queue[ index ];
305305

306-
if (item._hasForm()) {
307-
// TODO: old browsers
308-
} else {
306+
if (this.isHTML5) {
309307
item._xhr && item._xhr.abort();
310-
delete item._xhr;
308+
} else {
309+
// TODO: old browsers
311310
}
312311
},
313312

@@ -508,7 +507,7 @@ app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', fun
508507
// item of queue
509508
function Item(params) {
510509
// fix for old browsers
511-
if (angular.isElement(params.file)) {
510+
if (!Uploader.prototype.isHTML5) {
512511
var input = angular.element(params.file);
513512
var clone = $compile(input.clone())(params.uploader.scope);
514513
var form = angular.element('<form style="display: none;" />');
@@ -611,7 +610,7 @@ app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', fun
611610
create: function (params) {
612611
return new Uploader(params);
613612
},
614-
hasHTML5: Uploader.prototype.hasHTML5
613+
isHTML5: Uploader.prototype.isHTML5
615614
};
616615
}])
617616

angular-file-upload.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

angular-file-upload.min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-file-upload",
3-
"version": "0.2.9.8",
3+
"version": "0.2.9.8.1",
44
"main": "angular-file-upload.js",
55
"ignore": [],
66
"dependencies": {

examples/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
<h3>Select files</h3>
4949

50-
<div ng-show="uploader.hasHTML5">
50+
<div ng-show="uploader.isHTML5">
5151
<!-- 3. ng-file-over | ng-file-over="className" -->
5252
<div class="well my-drop-zone" ng-file-over>
5353
Base drop zone
@@ -73,17 +73,17 @@ <h3>Upload queue</h3>
7373
<thead>
7474
<tr>
7575
<th width="50%">Name</th>
76-
<th ng-show="uploader.hasHTML5">Size</th>
77-
<th ng-show="uploader.hasHTML5">Progress</th>
76+
<th ng-show="uploader.isHTML5">Size</th>
77+
<th ng-show="uploader.isHTML5">Progress</th>
7878
<th>Status</th>
7979
<th>Actions</th>
8080
</tr>
8181
</thead>
8282
<tbody>
8383
<tr ng-repeat="item in uploader.queue">
8484
<td><strong>{{ item.file.name }}</strong></td>
85-
<td ng-show="uploader.hasHTML5" nowrap>{{ item.file.size/1024/1024|number:2 }} MB</td>
86-
<td ng-show="uploader.hasHTML5">
85+
<td ng-show="uploader.isHTML5" nowrap>{{ item.file.size/1024/1024|number:2 }} MB</td>
86+
<td ng-show="uploader.isHTML5">
8787
<div class="progress" style="margin-bottom: 0;">
8888
<div class="progress-bar" role="progressbar" ng-style="{ 'width': item.progress + '%' }"></div>
8989
</div>

src/scripts/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* The angular file upload module
33
* @author: nerv
4-
* @version: 0.2.9.8, 2013-12-31
4+
* @version: 0.2.9.8.1, 2013-12-31
55
*/
66
var app = angular.module('angularFileUpload', []);

src/scripts/directives/ngFileDrop.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* The angular file upload module
33
* @author: nerv
4-
* @version: 0.2.9.8, 2013-12-31
4+
* @version: 0.2.9.8.1, 2013-12-31
55
*/
66

77
// It is attached to an element that catches the event drop file
@@ -10,7 +10,7 @@ app.directive('ngFileDrop', [ '$fileUploader', function ($fileUploader) {
1010

1111
return {
1212
// don't use drag-n-drop files in IE9, because not File API support
13-
link: !$fileUploader.hasHTML5 ? angular.noop : function (scope, element, attributes) {
13+
link: !$fileUploader.isHTML5 ? angular.noop : function (scope, element, attributes) {
1414
element
1515
.bind('drop', function (event) {
1616
var dataTransfer = event.dataTransfer ?

src/scripts/directives/ngFileOver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* The angular file upload module
33
* @author: nerv
4-
* @version: 0.2.9.8, 2013-12-31
4+
* @version: 0.2.9.8.1, 2013-12-31
55
*/
66

77
// It is attached to an element which will be assigned to a class "ng-file-over" or ng-file-over="className"

src/scripts/directives/ngFileSelect.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* The angular file upload module
33
* @author: nerv
4-
* @version: 0.2.9.8, 2013-12-31
4+
* @version: 0.2.9.8.1, 2013-12-31
55
*/
66

77
// It is attached to <input type="file"> element like <ng-file-select="options">
@@ -10,11 +10,11 @@ app.directive('ngFileSelect', [ '$fileUploader', function ($fileUploader) {
1010

1111
return {
1212
link: function (scope, element, attributes) {
13-
$fileUploader.hasHTML5 || element.removeAttr('multiple');
13+
$fileUploader.isHTML5 || element.removeAttr('multiple');
1414

1515
element.bind('change', function () {
1616
scope.$emit('file:add', this.files ? this.files : this, scope.$eval(attributes.ngFileSelect));
17-
$fileUploader.hasHTML5 && element.prop('value', null);
17+
$fileUploader.isHTML5 && element.prop('value', null);
1818
});
1919
}
2020
};

src/scripts/services/$fileUploader.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* The angular file upload module
33
* @author: nerv
4-
* @version: 0.2.9.8, 2013-12-31
4+
* @version: 0.2.9.8.1, 2013-12-31
55
*/
66

77
app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', function ($compile, $rootScope, $http, $window) {
@@ -79,7 +79,7 @@ app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', fun
7979
* Checks a support the html5 uploader
8080
* @returns {Boolean}
8181
*/
82-
hasHTML5: !!($window.File && $window.FormData),
82+
isHTML5: !!($window.File && $window.FormData),
8383

8484
/**
8585
* Adds items to the queue
@@ -183,7 +183,7 @@ app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', fun
183183
uploadItem: function (value) {
184184
var index = this.getIndexOfItem(value);
185185
var item = this.queue[ index ];
186-
var transport = item._hasForm() ? '_iframeTransport' : '_xhrTransport';
186+
var transport = this.isHTML5 ? '_xhrTransport' : '_iframeTransport';
187187

188188
item.index = item.index || this._nextIndex++;
189189
item.isReady = true;
@@ -205,11 +205,10 @@ app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', fun
205205
var index = this.getIndexOfItem(value);
206206
var item = this.queue[ index ];
207207

208-
if (item._hasForm()) {
209-
// TODO: old browsers
210-
} else {
208+
if (this.isHTML5) {
211209
item._xhr && item._xhr.abort();
212-
delete item._xhr;
210+
} else {
211+
// TODO: old browsers
213212
}
214213
},
215214

@@ -410,7 +409,7 @@ app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', fun
410409
// item of queue
411410
function Item(params) {
412411
// fix for old browsers
413-
if (angular.isElement(params.file)) {
412+
if (!Uploader.prototype.isHTML5) {
414413
var input = angular.element(params.file);
415414
var clone = $compile(input.clone())(params.uploader.scope);
416415
var form = angular.element('<form style="display: none;" />');
@@ -513,6 +512,6 @@ app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', fun
513512
create: function (params) {
514513
return new Uploader(params);
515514
},
516-
hasHTML5: Uploader.prototype.hasHTML5
515+
isHTML5: Uploader.prototype.isHTML5
517516
};
518517
}])

0 commit comments

Comments
 (0)