-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0c1412
commit e26bdaf
Showing
15 changed files
with
162 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "angularjs-file-upload", | ||
"main": "angular-file-upload.min.js", | ||
"version": "1.1.9", | ||
"version": "1.1.10", | ||
"homepage": "https://github.com/danialfarid/angular-file-upload", | ||
"authors": [ | ||
"danialf <[email protected]>" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/**! | ||
* AngularJS file upload shim for angular XHR HTML5 browsers | ||
* @author Danial <[email protected]> | ||
* @version 1.1.9 | ||
* @version 1.1.10 | ||
*/ | ||
if (window.XMLHttpRequest) { | ||
if (window.FormData) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/**! | ||
* AngularJS file upload shim for HTML5 FormData | ||
* @author Danial <[email protected]> | ||
* @version 1.1.9 | ||
* @version 1.1.10 | ||
*/ | ||
(function() { | ||
|
||
|
@@ -90,6 +90,7 @@ if (window.XMLHttpRequest) { | |
config.data[item.key] = item.val; | ||
} | ||
} | ||
|
||
setTimeout(function() { | ||
xhr.__fileApiXHR = FileAPI.upload(config); | ||
}, 1); | ||
|
@@ -104,6 +105,13 @@ if (window.XMLHttpRequest) { | |
} | ||
|
||
if (!window.FormData) { | ||
var hasFlash = false; | ||
try { | ||
var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); | ||
if (fo) hasFlash = true; | ||
} catch(e) { | ||
if (navigator.mimeTypes["application/x-shockwave-flash"] != undefined) hasFlash = true; | ||
} | ||
var wrapFileApi = function(elem) { | ||
if (!elem.__isWrapped && (elem.getAttribute('ng-file-select') != null || elem.getAttribute('data-ng-file-select') != null)) { | ||
var wrap = document.createElement('div'); | ||
|
@@ -113,6 +121,9 @@ if (!window.FormData) { | |
parent.insertBefore(wrap, elem); | ||
parent.removeChild(elem); | ||
wrap.appendChild(elem); | ||
if (!hasFlash) { | ||
wrap.appendChild(document.createTextNode('Flash is required')); | ||
} | ||
elem.__isWrapped = true; | ||
} | ||
}; | ||
|
@@ -170,7 +181,7 @@ if (!window.FormData) { | |
__isShim: true | ||
}; | ||
}; | ||
|
||
(function () { | ||
//load FileAPI | ||
if (!window.FileAPI || !FileAPI.upload) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
/**! | ||
* AngularJS file upload/drop directive with http post and progress | ||
* @author Danial <[email protected]> | ||
* @version 1.1.9 | ||
* @version 1.1.10 | ||
*/ | ||
(function() { | ||
|
||
var angularFileUpload = angular.module('angularFileUpload', []); | ||
|
||
angularFileUpload.service('$upload', ['$http', '$rootScope', function($http, $rootScope) { | ||
angularFileUpload.service('$upload', ['$http', '$rootScope', '$timeout', function($http, $rootScope, $timeout) { | ||
this.upload = function(config) { | ||
config.method = config.method || 'POST'; | ||
config.headers = config.headers || {}; | ||
|
@@ -41,19 +41,17 @@ angularFileUpload.service('$upload', ['$http', '$rootScope', function($http, $ro | |
config.__XHR = xhr; | ||
xhr.upload.addEventListener('progress', function(e) { | ||
if (config.progress) { | ||
config.progress(e); | ||
if (!$rootScope.$$phase) { | ||
$rootScope.$apply(); | ||
} | ||
$timeout(function() { | ||
config.progress(e); | ||
}); | ||
} | ||
}, false); | ||
//fix for firefox not firing upload progress end | ||
xhr.upload.addEventListener('load', function(e) { | ||
if (e.lengthComputable) { | ||
config.progress(e); | ||
if (!$rootScope.$$phase) { | ||
$rootScope.$apply(); | ||
} | ||
$timeout(function() { | ||
config.progress(e); | ||
}); | ||
} | ||
}, false); | ||
}; | ||
|
@@ -69,7 +67,9 @@ angularFileUpload.service('$upload', ['$http', '$rootScope', function($http, $ro | |
|
||
promise.abort = function() { | ||
if (config.__XHR) { | ||
config.__XHR.abort(); | ||
$timeout(function() { | ||
config.__XHR.abort(); | ||
}); | ||
} | ||
return promise; | ||
}; | ||
|
@@ -85,7 +85,7 @@ angularFileUpload.service('$upload', ['$http', '$rootScope', function($http, $ro | |
}; | ||
}]); | ||
|
||
angularFileUpload.directive('ngFileSelect', [ '$parse', '$http', function($parse, $http) { | ||
angularFileUpload.directive('ngFileSelect', [ '$parse', '$http', '$timeout', function($parse, $http, $timeout) { | ||
return function(scope, elem, attr) { | ||
var fn = $parse(attr['ngFileSelect']); | ||
elem.bind('change', function(evt) { | ||
|
@@ -96,7 +96,7 @@ angularFileUpload.directive('ngFileSelect', [ '$parse', '$http', function($parse | |
files.push(fileList.item(i)); | ||
} | ||
} | ||
scope.$apply(function() { | ||
$timeout(function() { | ||
fn(scope, { | ||
$files : files, | ||
$event : evt | ||
|
@@ -109,22 +109,18 @@ angularFileUpload.directive('ngFileSelect', [ '$parse', '$http', function($parse | |
}; | ||
} ]); | ||
|
||
angularFileUpload.directive('ngFileDropAvailable', [ '$parse', '$http', function($parse, $http) { | ||
angularFileUpload.directive('ngFileDropAvailable', [ '$parse', '$http', '$timeout', function($parse, $http, $timeout) { | ||
return function(scope, elem, attr) { | ||
if ('draggable' in document.createElement('span')) { | ||
var fn = $parse(attr['ngFileDropAvailable']); | ||
if(!scope.$$phase) { | ||
scope.$apply(function() { | ||
fn(scope); | ||
}); | ||
} else { | ||
fn(scope) | ||
} | ||
$timeout(function() { | ||
fn(scope); | ||
}); | ||
} | ||
}; | ||
} ]); | ||
|
||
angularFileUpload.directive('ngFileDrop', [ '$parse', '$http', function($parse, $http) { | ||
angularFileUpload.directive('ngFileDrop', [ '$parse', '$http', '$timeout', function($parse, $http, $timeout) { | ||
return function(scope, elem, attr) { | ||
if ('draggable' in document.createElement('span')) { | ||
var fn = $parse(attr['ngFileDrop']); | ||
|
@@ -146,7 +142,7 @@ angularFileUpload.directive('ngFileDrop', [ '$parse', '$http', function($parse, | |
files.push(fileList.item(i)); | ||
} | ||
} | ||
scope.$apply(function() { | ||
$timeout(function() { | ||
fn(scope, { | ||
$files : files, | ||
$event : evt | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/**! | ||
* AngularJS file upload shim for angular XHR HTML5 browsers | ||
* @author Danial <[email protected]> | ||
* @version 1.1.9 | ||
* @version 1.1.10 | ||
*/ | ||
if (window.XMLHttpRequest) { | ||
if (window.FormData) { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.