Socket
Socket
Sign inDemoInstall

ng-file-upload

Package Overview
Dependencies
Maintainers
1
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-file-upload - npm Package Compare versions

Comparing version 2.2.2 to 3.0.1

demo/war/js/ng-file-upload-all.js

319

demo/war/js/angular-file-upload-all.js
/**!
* AngularJS file upload/drop directive and service with progress and abort
* @author Danial <danial.farid@gmail.com>
* @version 2.2.2
* @version 3.0.1
*/

@@ -29,3 +29,4 @@ (function() {

var angularFileUpload = angular.module('angularFileUpload', []);
angularFileUpload.version = '2.2.2';
angularFileUpload.version = '3.0.1';
angularFileUpload.service('$upload', ['$http', '$q', '$timeout', function($http, $q, $timeout) {

@@ -110,37 +111,27 @@ function sendHttp(config) {

config.headers['Content-Type'] = undefined;
config.transformRequest = config.transformRequest || $http.defaults.transformRequest;
var formData = new FormData();
var origTransformRequest = config.transformRequest;
var origData = config.data;
config.transformRequest = function(formData, headerGetter) {
function transform(data) {
if (typeof origTransformRequest == 'function') {
data = origTransformRequest(data, headerGetter);
} else {
for (var i = 0; i < origTransformRequest.length; i++) {
if (typeof origTransformRequest[i] == 'function') {
data = origTransformRequest[i](data, headerGetter);
}
}
config.transformRequest = config.transformRequest ?
(Object.prototype.toString.call(config.transformRequest) === '[object Array]' ?
config.transformRequest : [config.transformRequest]) : [];
config.transformRequest.push(function(data, headerGetter) {
var formData = new FormData();
var allFields = {};
for (var key in config.fields) allFields[key] = config.fields[key];
if (data) allFields['data'] = data;
if (config.formDataAppender) {
for (var key in allFields) {
config.formDataAppender(formData, key, allFields[key]);
}
return data
}
if (origData) {
if (config.formDataAppender) {
for (var key in origData) {
var val = origData[key];
config.formDataAppender(formData, key, val);
}
} else if (config.sendDataAsJson) {
origData = transform(origData);
formData.append('data', new Blob([origData], { type: 'application/json' }));
} else {
for (var key in origData) {
var val = transform(origData[key]);
if (val !== undefined) {
if (config.sendObjectAsJson && typeof val === 'object' &&
Object.prototype.toString.call(fileFormName) !== '[object String]') {
formData.append(key, new Blob(val), { type: 'application/json' });
} else {
for (var key in allFields) {
var val = allFields[key];
if (val !== undefined) {
if (Object.prototype.toString.call(val) === '[object String]') {
formData.append(key, val);
} else {
if (config.sendObjectsAsJsonBlob && typeof val === 'object') {
formData.append(key, new Blob([val], { type: 'application/json' }));
} else {
formData.append(key, val);
formData.append(key, JSON.stringify(val));
}

@@ -166,6 +157,4 @@ }

return formData;
};
});
config.data = formData;
return sendHttp(config);

@@ -179,3 +168,4 @@ };

angularFileUpload.directive('ngFileSelect', [ '$parse', '$timeout', '$compile', function($parse, $timeout, $compile) { return {
angularFileUpload.directive('ngFileSelect', [ '$parse', '$timeout', '$compile',
function($parse, $timeout, $compile) { return {
restrict: 'AEC',

@@ -189,19 +179,66 @@ require:'?ngModel',

function handleFileSelect(scope, elem, attr, ngModel, $parse, $timeout, $compile) {
if (attr.ngMultiple && $parse(attr.ngMultiple)(scope)) {
elem.attr('multiple', 'true');
attr['multiple'] = 'true';
function isInputTypeFile() {
return elem[0].tagName.toLowerCase() === 'input' && elem.attr('type') && elem.attr('type').toLowerCase() === 'file';
}
var accept = attr.ngAccept && $parse(attr.ngAccept)(scope);
if (accept) {
elem.attr('accept', accept);
attr['accept'] = accept;
var watchers = [];
function watch(attrVal) {
$timeout(function() {
if (elem.parent().length) {
watchers.push(scope.$watch(attrVal, function(val, oldVal) {
if (val != oldVal) {
recompileElem();
}
}));
}
});
}
var capture = attr.ngCapture && $parse(attr.ngCapture)(scope)
if (capture) {
elem.attr('capture', capture);
attr['capture'] = capture;
function recompileElem() {
var clone = elem.clone();
if (elem.attr('__afu_gen__')) {
angular.element(document.getElementById(elem.attr('id').substring(1))).remove();
}
if (elem.parent().length) {
for (var i = 0; i < watchers.length; i++) {
watchers[i]();
}
elem.replaceWith(clone);
$compile(clone)(scope);
}
return clone;
}
if (elem[0].tagName.toLowerCase() !== 'input' || (elem.attr('type') && elem.attr('type').toLowerCase()) !== 'file') {
var id = '--ng-file-upload-' + Math.random();
var fileElem = angular.element('<input type="file" id="' + id + '">')
function bindAttr(bindAttr, attrName) {
if (bindAttr) {
watch(bindAttr);
var val = $parse(bindAttr)(scope);
if (val) {
elem.attr(attrName, val);
attr[attrName] = val;
} else {
elem.attr(attrName, null);
delete attr[attrName];
}
}
}
bindAttr(attr.ngMultiple, 'multiple');
bindAttr(attr.ngAccept, 'accept');
bindAttr(attr.ngCapture, 'capture');
if (attr['ngFileSelect'] != '') {
attr.ngFileChange = attr.ngFileSelect;
}
function onChangeFn(evt) {
var files = [], fileList, i;
fileList = evt.__files_ || (evt.target && evt.target.files);
updateModel(fileList, attr, ngModel, scope, evt);
};
var fileElem = elem;
if (!isInputTypeFile()) {
fileElem = angular.element('<input type="file">')
if (attr['multiple']) fileElem.attr('multiple', attr['multiple']);

@@ -219,57 +256,85 @@ if (attr['accept']) fileElem.attr('accept', attr['accept']);

fileElem.css('width', '0px').css('height', '0px').css('position', 'absolute').css('padding', 0).css('margin', 0)
.css('overflow', 'hidden').attr('tabindex', '-1').css('opacity', 0).attr('ng-file-generated-elem--', true);
.css('overflow', 'hidden').attr('tabindex', '-1').css('opacity', 0).attr('__afu_gen__', true);
elem.attr('__refElem__', true);
fileElem[0].__refElem__ = elem[0];
elem.parent()[0].insertBefore(fileElem[0], elem[0])
elem.attr('onclick', 'document.getElementById("' + id + '").click()')
// elem.__afu_fileClickDelegate__ = function() {
// fileElem[0].click();
// };
// elem.bind('click', elem.__afu_fileClickDelegate__);
elem.css('overflow', 'hidden');
elem.attr('id', 'e' + id);
var origElem = elem;
elem = fileElem;
elem.bind('click', function(e) {
if (!resetAndClick(e)) {
fileElem[0].click();
}
});
} else {
elem.bind('click', resetAndClick);
}
if (attr['ngFileSelect'] != '') {
attr.ngFileChange = attr.ngFileSelect;
}
if ($parse(attr.resetOnClick)(scope) != false) {
if (navigator.appVersion.indexOf("MSIE 10") !== -1) {
// fix for IE10 cannot set the value of the input to null programmatically by replacing input
var replaceElem = function(evt) {
var inputFile = elem.clone();
inputFile.val('');
elem.replaceWith(inputFile);
$compile(inputFile)(scope);
fileElem = inputFile;
elem = inputFile;
elem.bind('change', onChangeFn);
elem.unbind('click');
elem[0].click();
elem.bind('click', replaceElem);
evt.preventDefault();
evt.stopPropagation();
};
elem.bind('click', replaceElem);
} else {
elem.bind('click', function(evt) {
elem[0].value = null;
});
function resetAndClick(evt) {
var isChanged = fileElem[0].value != null && fileElem[0].value != '';
// reset the value to allow selecting the same file again
fileElem[0].value = null;
// chrome fires change event on popup cancel so no need for special handling but for others
// we cannot detect the user clicking cancel on file select popup and it doesn't fire change event,
// so we fire a null change event before the popup opens for these browsers so if the user
// clicks cancel the previous file value will be removed and model will be notified.
if (navigator.userAgent.indexOf("Chrome") === -1) {
// if this is manual click trigger we don't need to reset again
if (!elem.attr('__afu_clone__')) {
if (isChanged) {
onChangeFn({target: {files: []}});
}
// fix for IE10 cannot set the value of the input to null programmatically by cloning and replacing input
if (navigator.appVersion.indexOf("MSIE 10") !== -1) {
var clone = recompileElem();
clone.attr('__afu_clone__', true);
clone[0].click();
evt.preventDefault();
evt.stopPropagation();
return true;
}
} else {
elem.attr('__afu_clone__', null);
}
}
}
var onChangeFn = function(evt) {
var files = [], fileList, i;
fileList = evt.__files_ || evt.target.files;
updateModel(fileList, attr, ngModel, scope, evt);
};
elem.bind('change', onChangeFn);
fileElem.bind('change', onChangeFn);
elem.on('$destroy', function() {
for (var i = 0; i < watchers.length; i++) {
watchers[i]();
}
if (elem[0] != fileElem[0]) fileElem.remove();
});
watchers.push(scope.$watch(attr.ngModel, function(val, oldVal) {
if (val != oldVal && (val == null || !val.length)) {
if (navigator.appVersion.indexOf("MSIE 10") !== -1) {
recompileElem();
} else {
fileElem[0].value = null;
}
}
}));
function updateModel(fileList, attr, ngModel, scope, evt) {
var files = [];
var files = [], rejFiles = [];
var regexp = attr['accept'] ? new RegExp(globStringToRegex(attr['accept']), 'gi') : null;
for (var i = 0; i < fileList.length; i++) {
files.push(fileList.item(i));
var file = fileList.item(i);
if (!regexp || file.type.match(regexp) || (file.name != null && file.name.match(regexp))) {
files.push(file);
} else {
rejFiles.push(file);
}
}
if (ngModel) {
$timeout(function() {
scope[attr.ngModel] ? scope[attr.ngModel].value = files : scope[attr.ngModel] = files;
if (scope[attr.ngModel]) scope[attr.ngModel].value = files
scope[attr.ngModel] = files;
ngModel && ngModel.$setViewValue(files != null && files.length == 0 ? '' : files);
if (attr['ngModelRejected']) {
if (scope[attr.ngModelRejected]) scope[attr.ngModelRejected].value = rejFiles;
scope[attr.ngModelRejected] = rejFiles;
}
});

@@ -280,4 +345,5 @@ }

$parse(attr.ngFileChange)(scope, {
$files : files,
$event : evt
$files: files,
$rejectedFiles: rejFiles,
$event: evt
});

@@ -332,3 +398,3 @@ });

var accept = $parse(attr.ngAccept)(scope) || attr.accept;
var regexp = accept ? new RegExp(globStringToRegex(accept)) : null;
var regexp = accept ? new RegExp(globStringToRegex(accept), 'gi') : null;
var actualDragOverClass;

@@ -363,16 +429,18 @@ elem[0].addEventListener('dragover', function(evt) {

extractFiles(evt, function(files, rejFiles) {
if (ngModel) {
scope[attr.ngModel] ? scope[attr.ngModel].value = files : scope[attr.ngModel] = files;
ngModel && ngModel.$setViewValue(files != null && files.length == 0 ? '' : files);
}
if (attr['ngFileRejectedModel']) {
scope[attr.ngFileRejectedModel] ? scope[attr.ngFileRejectedModel].value = rejFiles :
scope[attr.ngFileRejectedModel] = rejFiles;
}
$timeout(function() {
if (ngModel) {
if (scope[attr.ngModel]) scope[attr.ngModel].value = files;
scope[attr.ngModel] = files;
ngModel && ngModel.$setViewValue(files != null && files.length == 0 ? '' : files);
}
if (attr['ngModelRejected']) {
if (scope[attr.ngModelRejected]) scope[attr.ngModelRejected].value = rejFiles;
scope[attr.ngModelRejected] = rejFiles;
}
});
$timeout(function() {
$parse(attr.ngFileChange)(scope, {
$files : files,
$files: files,
$rejectedFiles: rejFiles,
$event : evt
$event: evt
});

@@ -526,2 +594,5 @@ });

for (var i = 0; i < split.length; i++) {
if (split[i].indexOf('.') == 0) {
split[i] = '*' + split[i];
}
result += '(' + globStringToRegex(split[i]) + ')';

@@ -539,2 +610,8 @@ if (i < split.length - 1) {

var ngFileUpload = angular.module('ngFileUpload', []);
for (key in angularFileUpload) {
ngFileUpload[key] = angularFileUpload[key];
}
})();

@@ -546,3 +623,3 @@

* @author Danial <danial.farid@gmail.com>
* @version 2.2.2
* @version 3.0.1
*/

@@ -676,3 +753,3 @@

}
}, 10000);
}, FileAPI.noContentTimeout || 10000);
}

@@ -712,8 +789,18 @@ },

if (!el.attr('disabled')) {
if (!el.hasClass('js-fileapi-wrapper') && (el.attr('ng-file-select') != null || el.attr('data-ng-file-select') != null ||
el.attr('ng-file-generated-elem--') != null)) {
var hasFileSelect = false;
for (var i = 0; i < el[0].attributes.length; i++) {
var attrib = el[0].attributes[i];
if (attrib.name.indexOf('file-select') !== -1) {
hasFileSelect = true;
break;
}
}
if (!el.hasClass('js-fileapi-wrapper') && (hasFileSelect || el.attr('__afu_gen__') != null)) {
el.addClass('js-fileapi-wrapper');
if (el.attr('ng-file-generated-elem--') != null) {
var ref = angular.element(document.getElementById('e' + el.attr('id')));
if (el.attr('__afu_gen__') != null) {
var ref = (el[0].__refElem__ && angular.element(el[0].__refElem__)) || el;
while (ref && !ref.attr('__refElem__')) {
ref = angular.element(ref[0].nextSibling);
}
ref.bind('mouseover', function() {

@@ -884,3 +971,3 @@ if (el.parent().css('position') === '' || el.parent().css('position') === 'static') {

loadStarted = true;
_this.onloadstart && this.onloadstart(constructEvent('loadstart', evt));
_this.onloadstart && _this.onloadstart(constructEvent('loadstart', evt));
}

@@ -887,0 +974,0 @@ if (evt.type === 'load') {

@@ -134,3 +134,3 @@ /**!

}
}, 10000);
}, FileAPI.noContentTimeout || 10000);
}

@@ -170,8 +170,18 @@ },

if (!el.attr('disabled')) {
if (!el.hasClass('js-fileapi-wrapper') && (el.attr('ng-file-select') != null || el.attr('data-ng-file-select') != null ||
el.attr('ng-file-generated-elem--') != null)) {
var hasFileSelect = false;
for (var i = 0; i < el[0].attributes.length; i++) {
var attrib = el[0].attributes[i];
if (attrib.name.indexOf('file-select') !== -1) {
hasFileSelect = true;
break;
}
}
if (!el.hasClass('js-fileapi-wrapper') && (hasFileSelect || el.attr('__afu_gen__') != null)) {
el.addClass('js-fileapi-wrapper');
if (el.attr('ng-file-generated-elem--') != null) {
var ref = angular.element(document.getElementById('e' + el.attr('id')));
if (el.attr('__afu_gen__') != null) {
var ref = (el[0].__refElem__ && angular.element(el[0].__refElem__)) || el;
while (ref && !ref.attr('__refElem__')) {
ref = angular.element(ref[0].nextSibling);
}
ref.bind('mouseover', function() {

@@ -342,3 +352,3 @@ if (el.parent().css('position') === '' || el.parent().css('position') === 'static') {

loadStarted = true;
_this.onloadstart && this.onloadstart(constructEvent('loadstart', evt));
_this.onloadstart && _this.onloadstart(constructEvent('loadstart', evt));
}

@@ -345,0 +355,0 @@ if (evt.type === 'load') {

@@ -29,2 +29,3 @@ /**!

var angularFileUpload = angular.module('angularFileUpload', []);
angularFileUpload.version = '<%= pkg.version %>';

@@ -110,37 +111,27 @@ angularFileUpload.service('$upload', ['$http', '$q', '$timeout', function($http, $q, $timeout) {

config.headers['Content-Type'] = undefined;
config.transformRequest = config.transformRequest || $http.defaults.transformRequest;
var formData = new FormData();
var origTransformRequest = config.transformRequest;
var origData = config.data;
config.transformRequest = function(formData, headerGetter) {
function transform(data) {
if (typeof origTransformRequest == 'function') {
data = origTransformRequest(data, headerGetter);
} else {
for (var i = 0; i < origTransformRequest.length; i++) {
if (typeof origTransformRequest[i] == 'function') {
data = origTransformRequest[i](data, headerGetter);
}
}
config.transformRequest = config.transformRequest ?
(Object.prototype.toString.call(config.transformRequest) === '[object Array]' ?
config.transformRequest : [config.transformRequest]) : [];
config.transformRequest.push(function(data, headerGetter) {
var formData = new FormData();
var allFields = {};
for (var key in config.fields) allFields[key] = config.fields[key];
if (data) allFields['data'] = data;
if (config.formDataAppender) {
for (var key in allFields) {
config.formDataAppender(formData, key, allFields[key]);
}
return data
}
if (origData) {
if (config.formDataAppender) {
for (var key in origData) {
var val = origData[key];
config.formDataAppender(formData, key, val);
}
} else if (config.sendDataAsJson) {
origData = transform(origData);
formData.append('data', new Blob([origData], { type: 'application/json' }));
} else {
for (var key in origData) {
var val = transform(origData[key]);
if (val !== undefined) {
if (config.sendObjectAsJson && typeof val === 'object' &&
Object.prototype.toString.call(fileFormName) !== '[object String]') {
formData.append(key, new Blob(val), { type: 'application/json' });
} else {
for (var key in allFields) {
var val = allFields[key];
if (val !== undefined) {
if (Object.prototype.toString.call(val) === '[object String]') {
formData.append(key, val);
} else {
if (config.sendObjectsAsJsonBlob && typeof val === 'object') {
formData.append(key, new Blob([val], { type: 'application/json' }));
} else {
formData.append(key, val);
formData.append(key, JSON.stringify(val));
}

@@ -166,6 +157,4 @@ }

return formData;
};
});
config.data = formData;
return sendHttp(config);

@@ -179,3 +168,4 @@ };

angularFileUpload.directive('ngFileSelect', [ '$parse', '$timeout', '$compile', function($parse, $timeout, $compile) { return {
angularFileUpload.directive('ngFileSelect', [ '$parse', '$timeout', '$compile',
function($parse, $timeout, $compile) { return {
restrict: 'AEC',

@@ -189,19 +179,66 @@ require:'?ngModel',

function handleFileSelect(scope, elem, attr, ngModel, $parse, $timeout, $compile) {
if (attr.ngMultiple && $parse(attr.ngMultiple)(scope)) {
elem.attr('multiple', 'true');
attr['multiple'] = 'true';
function isInputTypeFile() {
return elem[0].tagName.toLowerCase() === 'input' && elem.attr('type') && elem.attr('type').toLowerCase() === 'file';
}
var accept = attr.ngAccept && $parse(attr.ngAccept)(scope);
if (accept) {
elem.attr('accept', accept);
attr['accept'] = accept;
var watchers = [];
function watch(attrVal) {
$timeout(function() {
if (elem.parent().length) {
watchers.push(scope.$watch(attrVal, function(val, oldVal) {
if (val != oldVal) {
recompileElem();
}
}));
}
});
}
var capture = attr.ngCapture && $parse(attr.ngCapture)(scope)
if (capture) {
elem.attr('capture', capture);
attr['capture'] = capture;
function recompileElem() {
var clone = elem.clone();
if (elem.attr('__afu_gen__')) {
angular.element(document.getElementById(elem.attr('id').substring(1))).remove();
}
if (elem.parent().length) {
for (var i = 0; i < watchers.length; i++) {
watchers[i]();
}
elem.replaceWith(clone);
$compile(clone)(scope);
}
return clone;
}
if (elem[0].tagName.toLowerCase() !== 'input' || (elem.attr('type') && elem.attr('type').toLowerCase()) !== 'file') {
var id = '--ng-file-upload-' + Math.random();
var fileElem = angular.element('<input type="file" id="' + id + '">')
function bindAttr(bindAttr, attrName) {
if (bindAttr) {
watch(bindAttr);
var val = $parse(bindAttr)(scope);
if (val) {
elem.attr(attrName, val);
attr[attrName] = val;
} else {
elem.attr(attrName, null);
delete attr[attrName];
}
}
}
bindAttr(attr.ngMultiple, 'multiple');
bindAttr(attr.ngAccept, 'accept');
bindAttr(attr.ngCapture, 'capture');
if (attr['ngFileSelect'] != '') {
attr.ngFileChange = attr.ngFileSelect;
}
function onChangeFn(evt) {
var files = [], fileList, i;
fileList = evt.__files_ || (evt.target && evt.target.files);
updateModel(fileList, attr, ngModel, scope, evt);
};
var fileElem = elem;
if (!isInputTypeFile()) {
fileElem = angular.element('<input type="file">')
if (attr['multiple']) fileElem.attr('multiple', attr['multiple']);

@@ -219,57 +256,85 @@ if (attr['accept']) fileElem.attr('accept', attr['accept']);

fileElem.css('width', '0px').css('height', '0px').css('position', 'absolute').css('padding', 0).css('margin', 0)
.css('overflow', 'hidden').attr('tabindex', '-1').css('opacity', 0).attr('ng-file-generated-elem--', true);
.css('overflow', 'hidden').attr('tabindex', '-1').css('opacity', 0).attr('__afu_gen__', true);
elem.attr('__refElem__', true);
fileElem[0].__refElem__ = elem[0];
elem.parent()[0].insertBefore(fileElem[0], elem[0])
elem.attr('onclick', 'document.getElementById("' + id + '").click()')
// elem.__afu_fileClickDelegate__ = function() {
// fileElem[0].click();
// };
// elem.bind('click', elem.__afu_fileClickDelegate__);
elem.css('overflow', 'hidden');
elem.attr('id', 'e' + id);
var origElem = elem;
elem = fileElem;
elem.bind('click', function(e) {
if (!resetAndClick(e)) {
fileElem[0].click();
}
});
} else {
elem.bind('click', resetAndClick);
}
if (attr['ngFileSelect'] != '') {
attr.ngFileChange = attr.ngFileSelect;
}
if ($parse(attr.resetOnClick)(scope) != false) {
if (navigator.appVersion.indexOf("MSIE 10") !== -1) {
// fix for IE10 cannot set the value of the input to null programmatically by replacing input
var replaceElem = function(evt) {
var inputFile = elem.clone();
inputFile.val('');
elem.replaceWith(inputFile);
$compile(inputFile)(scope);
fileElem = inputFile;
elem = inputFile;
elem.bind('change', onChangeFn);
elem.unbind('click');
elem[0].click();
elem.bind('click', replaceElem);
evt.preventDefault();
evt.stopPropagation();
};
elem.bind('click', replaceElem);
} else {
elem.bind('click', function(evt) {
elem[0].value = null;
});
function resetAndClick(evt) {
var isChanged = fileElem[0].value != null && fileElem[0].value != '';
// reset the value to allow selecting the same file again
fileElem[0].value = null;
// chrome fires change event on popup cancel so no need for special handling but for others
// we cannot detect the user clicking cancel on file select popup and it doesn't fire change event,
// so we fire a null change event before the popup opens for these browsers so if the user
// clicks cancel the previous file value will be removed and model will be notified.
if (navigator.userAgent.indexOf("Chrome") === -1) {
// if this is manual click trigger we don't need to reset again
if (!elem.attr('__afu_clone__')) {
if (isChanged) {
onChangeFn({target: {files: []}});
}
// fix for IE10 cannot set the value of the input to null programmatically by cloning and replacing input
if (navigator.appVersion.indexOf("MSIE 10") !== -1) {
var clone = recompileElem();
clone.attr('__afu_clone__', true);
clone[0].click();
evt.preventDefault();
evt.stopPropagation();
return true;
}
} else {
elem.attr('__afu_clone__', null);
}
}
}
var onChangeFn = function(evt) {
var files = [], fileList, i;
fileList = evt.__files_ || evt.target.files;
updateModel(fileList, attr, ngModel, scope, evt);
};
elem.bind('change', onChangeFn);
fileElem.bind('change', onChangeFn);
elem.on('$destroy', function() {
for (var i = 0; i < watchers.length; i++) {
watchers[i]();
}
if (elem[0] != fileElem[0]) fileElem.remove();
});
watchers.push(scope.$watch(attr.ngModel, function(val, oldVal) {
if (val != oldVal && (val == null || !val.length)) {
if (navigator.appVersion.indexOf("MSIE 10") !== -1) {
recompileElem();
} else {
fileElem[0].value = null;
}
}
}));
function updateModel(fileList, attr, ngModel, scope, evt) {
var files = [];
var files = [], rejFiles = [];
var regexp = attr['accept'] ? new RegExp(globStringToRegex(attr['accept']), 'gi') : null;
for (var i = 0; i < fileList.length; i++) {
files.push(fileList.item(i));
var file = fileList.item(i);
if (!regexp || file.type.match(regexp) || (file.name != null && file.name.match(regexp))) {
files.push(file);
} else {
rejFiles.push(file);
}
}
if (ngModel) {
$timeout(function() {
scope[attr.ngModel] ? scope[attr.ngModel].value = files : scope[attr.ngModel] = files;
if (scope[attr.ngModel]) scope[attr.ngModel].value = files
scope[attr.ngModel] = files;
ngModel && ngModel.$setViewValue(files != null && files.length == 0 ? '' : files);
if (attr['ngModelRejected']) {
if (scope[attr.ngModelRejected]) scope[attr.ngModelRejected].value = rejFiles;
scope[attr.ngModelRejected] = rejFiles;
}
});

@@ -280,4 +345,5 @@ }

$parse(attr.ngFileChange)(scope, {
$files : files,
$event : evt
$files: files,
$rejectedFiles: rejFiles,
$event: evt
});

@@ -332,3 +398,3 @@ });

var accept = $parse(attr.ngAccept)(scope) || attr.accept;
var regexp = accept ? new RegExp(globStringToRegex(accept)) : null;
var regexp = accept ? new RegExp(globStringToRegex(accept), 'gi') : null;
var actualDragOverClass;

@@ -363,16 +429,18 @@ elem[0].addEventListener('dragover', function(evt) {

extractFiles(evt, function(files, rejFiles) {
if (ngModel) {
scope[attr.ngModel] ? scope[attr.ngModel].value = files : scope[attr.ngModel] = files;
ngModel && ngModel.$setViewValue(files != null && files.length == 0 ? '' : files);
}
if (attr['ngFileRejectedModel']) {
scope[attr.ngFileRejectedModel] ? scope[attr.ngFileRejectedModel].value = rejFiles :
scope[attr.ngFileRejectedModel] = rejFiles;
}
$timeout(function() {
if (ngModel) {
if (scope[attr.ngModel]) scope[attr.ngModel].value = files;
scope[attr.ngModel] = files;
ngModel && ngModel.$setViewValue(files != null && files.length == 0 ? '' : files);
}
if (attr['ngModelRejected']) {
if (scope[attr.ngModelRejected]) scope[attr.ngModelRejected].value = rejFiles;
scope[attr.ngModelRejected] = rejFiles;
}
});
$timeout(function() {
$parse(attr.ngFileChange)(scope, {
$files : files,
$files: files,
$rejectedFiles: rejFiles,
$event : evt
$event: evt
});

@@ -526,2 +594,5 @@ });

for (var i = 0; i < split.length; i++) {
if (split[i].indexOf('.') == 0) {
split[i] = '*' + split[i];
}
result += '(' + globStringToRegex(split[i]) + ')';

@@ -539,2 +610,8 @@ if (i < split.length - 1) {

var ngFileUpload = angular.module('ngFileUpload', []);
for (key in angularFileUpload) {
ngFileUpload[key] = angularFileUpload[key];
}
})();
"use strict";
var app = angular.module('fileUpload', [ 'angularFileUpload' ]);
var version = '2.2.2';
var app = angular.module('fileUpload', [ 'ngFileUpload' ]);
var version = '3.0.0';

@@ -25,8 +25,6 @@ app.controller('MyCtrl', [ '$scope', '$http', '$timeout', '$compile', '$upload', function($scope, $http, $timeout, $compile, $upload) {

(function(file) {
$scope.generateThumb(file);
eval($scope.uploadScript);
generateThumbAndUpload(file);
})(files[i]);
}
}
storeS3UploadConfigInLocalStore();
});

@@ -37,9 +35,18 @@

if (files != null) {
var file = files[0];
$scope.generateThumb(file);
$scope.errorMsg = null;
eval($scope.uploadScript);
generateThumbAndUpload(files[0])
}
}
function generateThumbAndUpload(file) {
$scope.errorMsg = null;
$scope.generateThumb(file);
if ($scope.howToSend == 1) {
uploadUsing$upload(file);
} else if ($scope.howToSend == 2) {
uploadUsing$http(file);
} else {
uploadS3(file);
}
}
$scope.generateThumb = function(file) {

@@ -61,2 +68,95 @@ if (file != null) {

function uploadUsing$upload(file) {
file.upload = $upload.upload({
url: 'https://angular-file-upload-cors-srv.appspot.com/upload' + $scope.getReqParams(),
method: 'POST',
headers: {
'my-header' : 'my-header-value'
},
data: {aaa:'aaa'},
sendObjectsAsJsonBlob: false,
fields: {username: $scope.username},
file: file,
fileFormDataName: 'myFile',
});
file.upload.then(function(response) {
$timeout(function() {
file.result = response.data;
});
}, function(response) {
if (response.status > 0)
$scope.errorMsg = response.status + ': ' + response.data;
});
file.upload.progress(function(evt) {
// Math.min is to fix IE which reports 200% sometimes
file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
});
file.upload.xhr(function(xhr) {
// xhr.upload.addEventListener('abort', function(){console.log('abort complete')}, false);
});
}
function uploadUsing$http(file) {
var fileReader = new FileReader();
fileReader.onload = function(e) {
$timeout(function() {
file.upload = $upload.http({
url: 'https://angular-file-upload-cors-srv.appspot.com/upload' + $scope.getReqParams(),
method: 'POST',
headers : {
'Content-Type': file.type
},
data: e.target.result
});
file.upload.then(function(response) {
file.result = response.data;
}, function(response) {
if (response.status > 0)
$scope.errorMsg = response.status + ': ' + response.data;
});
file.upload.progress(function(evt) {
file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
});
}, 5000);
}
fileReader.readAsArrayBuffer(file);
}
function uploadS3(file) {
file.upload = $upload
.upload({
url : $scope.s3url,
method : 'POST',
fields : {
key : file.name,
AWSAccessKeyId : $scope.AWSAccessKeyId,
acl : $scope.acl,
policy : $scope.policy,
signature : $scope.signature,
"Content-Type" : file.type === null || file.type === '' ? 'application/octet-stream' : file.type,
filename : file.name
},
file : file,
});
file.upload.then(function(response) {
$timeout(function() {
file.result = response.data;
});
}, function(response) {
if (response.status > 0)
$scope.errorMsg = response.status + ': ' + response.data;
});
file.upload.progress(function(evt) {
file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
});
storeS3UploadConfigInLocalStore();
}
$scope.generateSignature = function() {

@@ -95,9 +195,2 @@ $http.post('/s3sign?aws-secret-key=' + encodeURIComponent($scope.AWSSecretKey), $scope.jsonPolicy).

(function handleDynamicEditingOfScriptsAndHtml($scope, $http) {
$scope.defaultUploadScript = [];
$http.get('js/upload-upload.js').success(function(data) {
$scope.defaultUploadScript[1] = data; $scope.uploadScript = $scope.uploadScript || data
});
$http.get('js/upload-http.js').success(function(data) {$scope.defaultUploadScript[2] = data});
$http.get('js/upload-s3.js').success(function(data) {$scope.defaultUploadScript[3] = data});
$scope.defaultHtml = document.getElementById('editArea').innerHTML.replace(/\t\t\t\t/g, '');

@@ -114,13 +207,2 @@

$scope.$watch("howToSend", function(newVal, oldVal) {
$scope.uploadScript && localStorage && localStorage.setItem("uploadScript" + oldVal + version, $scope.uploadScript);
$scope.uploadScript = (localStorage && localStorage.getItem("uploadScript" + newVal + version)) || $scope.defaultUploadScript[newVal];
});
function jsEdit(update) {
$scope.uploadScript && localStorage && localStorage.setItem("uploadScript" + $scope.howToSend + version, $scope.uploadScript);
if ($scope.uploadScript != $scope.jsEditor.getValue()) $scope.jsEditor.setValue($scope.uploadScript);
}
$scope.$watch("uploadScript", jsEdit);
$scope.htmlEditor = CodeMirror(document.getElementById('htmlEdit'), {

@@ -136,12 +218,2 @@ lineNumbers: true, indentUnit: 4,

});
$scope.jsEditor = CodeMirror(document.getElementById('jsEdit'), {
lineNumbers: true, indentUnit: 4,
mode: "javascript"
});
$scope.jsEditor.on('change', function() {
if ($scope.uploadScript != $scope.jsEditor.getValue()) {
$scope.uploadScript = $scope.jsEditor.getValue();
jsEdit();
}
});
})($scope, $http);

@@ -148,0 +220,0 @@

/**!
* AngularJS file upload/drop directive and service with progress and abort
* @author Danial <danial.farid@gmail.com>
* @version 2.2.2
* @version 3.0.1
*/

@@ -29,3 +29,4 @@ (function() {

var angularFileUpload = angular.module('angularFileUpload', []);
angularFileUpload.version = '2.2.2';
angularFileUpload.version = '3.0.1';
angularFileUpload.service('$upload', ['$http', '$q', '$timeout', function($http, $q, $timeout) {

@@ -110,37 +111,27 @@ function sendHttp(config) {

config.headers['Content-Type'] = undefined;
config.transformRequest = config.transformRequest || $http.defaults.transformRequest;
var formData = new FormData();
var origTransformRequest = config.transformRequest;
var origData = config.data;
config.transformRequest = function(formData, headerGetter) {
function transform(data) {
if (typeof origTransformRequest == 'function') {
data = origTransformRequest(data, headerGetter);
} else {
for (var i = 0; i < origTransformRequest.length; i++) {
if (typeof origTransformRequest[i] == 'function') {
data = origTransformRequest[i](data, headerGetter);
}
}
config.transformRequest = config.transformRequest ?
(Object.prototype.toString.call(config.transformRequest) === '[object Array]' ?
config.transformRequest : [config.transformRequest]) : [];
config.transformRequest.push(function(data, headerGetter) {
var formData = new FormData();
var allFields = {};
for (var key in config.fields) allFields[key] = config.fields[key];
if (data) allFields['data'] = data;
if (config.formDataAppender) {
for (var key in allFields) {
config.formDataAppender(formData, key, allFields[key]);
}
return data
}
if (origData) {
if (config.formDataAppender) {
for (var key in origData) {
var val = origData[key];
config.formDataAppender(formData, key, val);
}
} else if (config.sendDataAsJson) {
origData = transform(origData);
formData.append('data', new Blob([origData], { type: 'application/json' }));
} else {
for (var key in origData) {
var val = transform(origData[key]);
if (val !== undefined) {
if (config.sendObjectAsJson && typeof val === 'object' &&
Object.prototype.toString.call(fileFormName) !== '[object String]') {
formData.append(key, new Blob(val), { type: 'application/json' });
} else {
for (var key in allFields) {
var val = allFields[key];
if (val !== undefined) {
if (Object.prototype.toString.call(val) === '[object String]') {
formData.append(key, val);
} else {
if (config.sendObjectsAsJsonBlob && typeof val === 'object') {
formData.append(key, new Blob([val], { type: 'application/json' }));
} else {
formData.append(key, val);
formData.append(key, JSON.stringify(val));
}

@@ -166,6 +157,4 @@ }

return formData;
};
});
config.data = formData;
return sendHttp(config);

@@ -179,3 +168,4 @@ };

angularFileUpload.directive('ngFileSelect', [ '$parse', '$timeout', '$compile', function($parse, $timeout, $compile) { return {
angularFileUpload.directive('ngFileSelect', [ '$parse', '$timeout', '$compile',
function($parse, $timeout, $compile) { return {
restrict: 'AEC',

@@ -189,19 +179,66 @@ require:'?ngModel',

function handleFileSelect(scope, elem, attr, ngModel, $parse, $timeout, $compile) {
if (attr.ngMultiple && $parse(attr.ngMultiple)(scope)) {
elem.attr('multiple', 'true');
attr['multiple'] = 'true';
function isInputTypeFile() {
return elem[0].tagName.toLowerCase() === 'input' && elem.attr('type') && elem.attr('type').toLowerCase() === 'file';
}
var accept = attr.ngAccept && $parse(attr.ngAccept)(scope);
if (accept) {
elem.attr('accept', accept);
attr['accept'] = accept;
var watchers = [];
function watch(attrVal) {
$timeout(function() {
if (elem.parent().length) {
watchers.push(scope.$watch(attrVal, function(val, oldVal) {
if (val != oldVal) {
recompileElem();
}
}));
}
});
}
var capture = attr.ngCapture && $parse(attr.ngCapture)(scope)
if (capture) {
elem.attr('capture', capture);
attr['capture'] = capture;
function recompileElem() {
var clone = elem.clone();
if (elem.attr('__afu_gen__')) {
angular.element(document.getElementById(elem.attr('id').substring(1))).remove();
}
if (elem.parent().length) {
for (var i = 0; i < watchers.length; i++) {
watchers[i]();
}
elem.replaceWith(clone);
$compile(clone)(scope);
}
return clone;
}
if (elem[0].tagName.toLowerCase() !== 'input' || (elem.attr('type') && elem.attr('type').toLowerCase()) !== 'file') {
var id = '--ng-file-upload-' + Math.random();
var fileElem = angular.element('<input type="file" id="' + id + '">')
function bindAttr(bindAttr, attrName) {
if (bindAttr) {
watch(bindAttr);
var val = $parse(bindAttr)(scope);
if (val) {
elem.attr(attrName, val);
attr[attrName] = val;
} else {
elem.attr(attrName, null);
delete attr[attrName];
}
}
}
bindAttr(attr.ngMultiple, 'multiple');
bindAttr(attr.ngAccept, 'accept');
bindAttr(attr.ngCapture, 'capture');
if (attr['ngFileSelect'] != '') {
attr.ngFileChange = attr.ngFileSelect;
}
function onChangeFn(evt) {
var files = [], fileList, i;
fileList = evt.__files_ || (evt.target && evt.target.files);
updateModel(fileList, attr, ngModel, scope, evt);
};
var fileElem = elem;
if (!isInputTypeFile()) {
fileElem = angular.element('<input type="file">')
if (attr['multiple']) fileElem.attr('multiple', attr['multiple']);

@@ -219,57 +256,85 @@ if (attr['accept']) fileElem.attr('accept', attr['accept']);

fileElem.css('width', '0px').css('height', '0px').css('position', 'absolute').css('padding', 0).css('margin', 0)
.css('overflow', 'hidden').attr('tabindex', '-1').css('opacity', 0).attr('ng-file-generated-elem--', true);
.css('overflow', 'hidden').attr('tabindex', '-1').css('opacity', 0).attr('__afu_gen__', true);
elem.attr('__refElem__', true);
fileElem[0].__refElem__ = elem[0];
elem.parent()[0].insertBefore(fileElem[0], elem[0])
elem.attr('onclick', 'document.getElementById("' + id + '").click()')
// elem.__afu_fileClickDelegate__ = function() {
// fileElem[0].click();
// };
// elem.bind('click', elem.__afu_fileClickDelegate__);
elem.css('overflow', 'hidden');
elem.attr('id', 'e' + id);
var origElem = elem;
elem = fileElem;
elem.bind('click', function(e) {
if (!resetAndClick(e)) {
fileElem[0].click();
}
});
} else {
elem.bind('click', resetAndClick);
}
if (attr['ngFileSelect'] != '') {
attr.ngFileChange = attr.ngFileSelect;
}
if ($parse(attr.resetOnClick)(scope) != false) {
if (navigator.appVersion.indexOf("MSIE 10") !== -1) {
// fix for IE10 cannot set the value of the input to null programmatically by replacing input
var replaceElem = function(evt) {
var inputFile = elem.clone();
inputFile.val('');
elem.replaceWith(inputFile);
$compile(inputFile)(scope);
fileElem = inputFile;
elem = inputFile;
elem.bind('change', onChangeFn);
elem.unbind('click');
elem[0].click();
elem.bind('click', replaceElem);
evt.preventDefault();
evt.stopPropagation();
};
elem.bind('click', replaceElem);
} else {
elem.bind('click', function(evt) {
elem[0].value = null;
});
function resetAndClick(evt) {
var isChanged = fileElem[0].value != null && fileElem[0].value != '';
// reset the value to allow selecting the same file again
fileElem[0].value = null;
// chrome fires change event on popup cancel so no need for special handling but for others
// we cannot detect the user clicking cancel on file select popup and it doesn't fire change event,
// so we fire a null change event before the popup opens for these browsers so if the user
// clicks cancel the previous file value will be removed and model will be notified.
if (navigator.userAgent.indexOf("Chrome") === -1) {
// if this is manual click trigger we don't need to reset again
if (!elem.attr('__afu_clone__')) {
if (isChanged) {
onChangeFn({target: {files: []}});
}
// fix for IE10 cannot set the value of the input to null programmatically by cloning and replacing input
if (navigator.appVersion.indexOf("MSIE 10") !== -1) {
var clone = recompileElem();
clone.attr('__afu_clone__', true);
clone[0].click();
evt.preventDefault();
evt.stopPropagation();
return true;
}
} else {
elem.attr('__afu_clone__', null);
}
}
}
var onChangeFn = function(evt) {
var files = [], fileList, i;
fileList = evt.__files_ || evt.target.files;
updateModel(fileList, attr, ngModel, scope, evt);
};
elem.bind('change', onChangeFn);
fileElem.bind('change', onChangeFn);
elem.on('$destroy', function() {
for (var i = 0; i < watchers.length; i++) {
watchers[i]();
}
if (elem[0] != fileElem[0]) fileElem.remove();
});
watchers.push(scope.$watch(attr.ngModel, function(val, oldVal) {
if (val != oldVal && (val == null || !val.length)) {
if (navigator.appVersion.indexOf("MSIE 10") !== -1) {
recompileElem();
} else {
fileElem[0].value = null;
}
}
}));
function updateModel(fileList, attr, ngModel, scope, evt) {
var files = [];
var files = [], rejFiles = [];
var regexp = attr['accept'] ? new RegExp(globStringToRegex(attr['accept']), 'gi') : null;
for (var i = 0; i < fileList.length; i++) {
files.push(fileList.item(i));
var file = fileList.item(i);
if (!regexp || file.type.match(regexp) || (file.name != null && file.name.match(regexp))) {
files.push(file);
} else {
rejFiles.push(file);
}
}
if (ngModel) {
$timeout(function() {
scope[attr.ngModel] ? scope[attr.ngModel].value = files : scope[attr.ngModel] = files;
if (scope[attr.ngModel]) scope[attr.ngModel].value = files
scope[attr.ngModel] = files;
ngModel && ngModel.$setViewValue(files != null && files.length == 0 ? '' : files);
if (attr['ngModelRejected']) {
if (scope[attr.ngModelRejected]) scope[attr.ngModelRejected].value = rejFiles;
scope[attr.ngModelRejected] = rejFiles;
}
});

@@ -280,4 +345,5 @@ }

$parse(attr.ngFileChange)(scope, {
$files : files,
$event : evt
$files: files,
$rejectedFiles: rejFiles,
$event: evt
});

@@ -332,3 +398,3 @@ });

var accept = $parse(attr.ngAccept)(scope) || attr.accept;
var regexp = accept ? new RegExp(globStringToRegex(accept)) : null;
var regexp = accept ? new RegExp(globStringToRegex(accept), 'gi') : null;
var actualDragOverClass;

@@ -363,16 +429,18 @@ elem[0].addEventListener('dragover', function(evt) {

extractFiles(evt, function(files, rejFiles) {
if (ngModel) {
scope[attr.ngModel] ? scope[attr.ngModel].value = files : scope[attr.ngModel] = files;
ngModel && ngModel.$setViewValue(files != null && files.length == 0 ? '' : files);
}
if (attr['ngFileRejectedModel']) {
scope[attr.ngFileRejectedModel] ? scope[attr.ngFileRejectedModel].value = rejFiles :
scope[attr.ngFileRejectedModel] = rejFiles;
}
$timeout(function() {
if (ngModel) {
if (scope[attr.ngModel]) scope[attr.ngModel].value = files;
scope[attr.ngModel] = files;
ngModel && ngModel.$setViewValue(files != null && files.length == 0 ? '' : files);
}
if (attr['ngModelRejected']) {
if (scope[attr.ngModelRejected]) scope[attr.ngModelRejected].value = rejFiles;
scope[attr.ngModelRejected] = rejFiles;
}
});
$timeout(function() {
$parse(attr.ngFileChange)(scope, {
$files : files,
$files: files,
$rejectedFiles: rejFiles,
$event : evt
$event: evt
});

@@ -526,2 +594,5 @@ });

for (var i = 0; i < split.length; i++) {
if (split[i].indexOf('.') == 0) {
split[i] = '*' + split[i];
}
result += '(' + globStringToRegex(split[i]) + ')';

@@ -539,2 +610,8 @@ if (i < split.length - 1) {

var ngFileUpload = angular.module('ngFileUpload', []);
for (key in angularFileUpload) {
ngFileUpload[key] = angularFileUpload[key];
}
})();

@@ -546,3 +623,3 @@

* @author Danial <danial.farid@gmail.com>
* @version 2.2.2
* @version 3.0.1
*/

@@ -676,3 +753,3 @@

}
}, 10000);
}, FileAPI.noContentTimeout || 10000);
}

@@ -712,8 +789,18 @@ },

if (!el.attr('disabled')) {
if (!el.hasClass('js-fileapi-wrapper') && (el.attr('ng-file-select') != null || el.attr('data-ng-file-select') != null ||
el.attr('ng-file-generated-elem--') != null)) {
var hasFileSelect = false;
for (var i = 0; i < el[0].attributes.length; i++) {
var attrib = el[0].attributes[i];
if (attrib.name.indexOf('file-select') !== -1) {
hasFileSelect = true;
break;
}
}
if (!el.hasClass('js-fileapi-wrapper') && (hasFileSelect || el.attr('__afu_gen__') != null)) {
el.addClass('js-fileapi-wrapper');
if (el.attr('ng-file-generated-elem--') != null) {
var ref = angular.element(document.getElementById('e' + el.attr('id')));
if (el.attr('__afu_gen__') != null) {
var ref = (el[0].__refElem__ && angular.element(el[0].__refElem__)) || el;
while (ref && !ref.attr('__refElem__')) {
ref = angular.element(ref[0].nextSibling);
}
ref.bind('mouseover', function() {

@@ -884,3 +971,3 @@ if (el.parent().css('position') === '' || el.parent().css('position') === 'static') {

loadStarted = true;
_this.onloadstart && this.onloadstart(constructEvent('loadstart', evt));
_this.onloadstart && _this.onloadstart(constructEvent('loadstart', evt));
}

@@ -887,0 +974,0 @@ if (evt.type === 'load') {

@@ -1,2 +0,2 @@

/*! 2.2.2 */
!function(){function a(a,b){window.XMLHttpRequest.prototype[a]=b(window.XMLHttpRequest.prototype[a])}function b(a,b,c,d,e,f,g){function h(a,b,c,d,g){for(var h=[],i=0;i<a.length;i++)h.push(a.item(i));c&&f(function(){d[b.ngModel]?d[b.ngModel].value=h:d[b.ngModel]=h,c&&c.$setViewValue(null!=h&&0==h.length?"":h)}),b.ngFileChange&&""!=b.ngFileChange&&f(function(){e(b.ngFileChange)(d,{$files:h,$event:g})})}c.ngMultiple&&e(c.ngMultiple)(a)&&(b.attr("multiple","true"),c.multiple="true");var i=c.ngAccept&&e(c.ngAccept)(a);i&&(b.attr("accept",i),c.accept=i);var j=c.ngCapture&&e(c.ngCapture)(a);if(j&&(b.attr("capture",j),c.capture=j),"input"!==b[0].tagName.toLowerCase()||"file"!==(b.attr("type")&&b.attr("type").toLowerCase())){var k="--ng-file-upload-"+Math.random(),l=angular.element('<input type="file" id="'+k+'">');c.multiple&&l.attr("multiple",c.multiple),c.accept&&l.attr("accept",c.accept),c.capture&&l.attr("capture",c.capture);for(var m in c)if(0==m.indexOf("inputFile")){var n=m.substring("inputFile".length);n=n[0].toLowerCase()+n.substring(1),l.attr(n,c[m])}l.css("width","0px").css("height","0px").css("position","absolute").css("padding",0).css("margin",0).css("overflow","hidden").attr("tabindex","-1").css("opacity",0).attr("ng-file-generated-elem--",!0),b.parent()[0].insertBefore(l[0],b[0]),b.attr("onclick",'document.getElementById("'+k+'").click()'),b.css("overflow","hidden"),b.attr("id","e"+k);b=l}if(""!=c.ngFileSelect&&(c.ngFileChange=c.ngFileSelect),0!=e(c.resetOnClick)(a))if(-1!==navigator.appVersion.indexOf("MSIE 10")){var o=function(c){var d=b.clone();d.val(""),b.replaceWith(d),g(d)(a),l=d,b=d,b.bind("change",p),b.unbind("click"),b[0].click(),b.bind("click",o),c.preventDefault(),c.stopPropagation()};b.bind("click",o)}else b.bind("click",function(){b[0].value=null});var p=function(b){var e;e=b.__files_||b.target.files,h(e,c,d,a,b)};b.bind("change",p)}function c(a,b,c,g,h,i,j){function k(a,b,c){var d=!0;if(s){var e=c.dataTransfer.items;if(null!=e)for(var f=0;f<e.length&&d;f++)d=d&&("file"==e[f].kind||""==e[f].kind)&&(null!=e[f].type.match(s)||null!=e[f].name&&null!=e[f].name.match(s))}var g=h(b.dragOverClass)(a,{$event:c});return g&&(g.delay&&(q=g.delay),g.accept&&(g=d?g.accept:g.reject)),g||b.dragOverClass||"dragover"}function l(a,b,c,d){function f(a){!s||a.type.match(s)||null!=a.name&&a.name.match(s)?h.push(a):k.push(a)}function g(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;f({name:b.name,type:"directory",path:d});var e=b.createReader(),h=[];m++;var i=function(){e.readEntries(function(d){try{if(d.length)h=h.concat(Array.prototype.slice.call(d||[],0)),i();else{for(var e=0;e<h.length;e++)g(a,h[e],(c?c:"")+b.name+"/");m--}}catch(f){m--,console.error(f)}},function(){m--})};i()}else m++,b.file(function(a){try{m--,a.path=(c?c:"")+a.name,f(a)}catch(b){m--,console.error(b)}},function(){m--})}var h=[],k=[],l=a.dataTransfer.items,m=0;if(l&&l.length>0&&"file"!=j.protocol())for(var n=0;n<l.length;n++){if(l[n].webkitGetAsEntry&&l[n].webkitGetAsEntry()&&l[n].webkitGetAsEntry().isDirectory){var o=l[n].webkitGetAsEntry();if(o.isDirectory&&!c)continue;null!=o&&(e(o.name)?g(h,o):l[n].webkitGetAsEntry().isDirectory||f(l[n].getAsFile()))}else{var p=l[n].getAsFile();null!=p&&f(p)}if(!d&&h.length>0)break}else{var q=a.dataTransfer.files;if(null!=q)for(var n=0;n<q.length&&(f(q.item(n)),d||!(h.length>0));n++);}var r=0;!function t(a){i(function(){if(m)10*r++<2e4&&t(10);else{if(!d&&h.length>1){for(var a=0;"directory"==h[a].type;)a++;h=[h[a]]}b(h,k)}},a||0)}()}var m=d();if(c.dropAvailable&&i(function(){a.dropAvailable?a.dropAvailable.value=m:a.dropAvailable=m}),!m)return 0!=h(c.hideOnDropNotAvailable)(a)&&b.css("display","none"),void 0;var n,o=null,p=h(c.stopPropagation)(a),q=1,r=h(c.ngAccept)(a)||c.accept,s=r?new RegExp(f(r)):null;b[0].addEventListener("dragover",function(d){d.preventDefault(),p&&d.stopPropagation(),i.cancel(o),a.actualDragOverClass||(n=k(a,c,d)),b.addClass(n)},!1),b[0].addEventListener("dragenter",function(a){a.preventDefault(),p&&a.stopPropagation()},!1),b[0].addEventListener("dragleave",function(){o=i(function(){b.removeClass(n),n=null},q||1)},!1),""!=c.ngFileDrop&&(c.ngFileChange=a.ngFileDrop),b[0].addEventListener("drop",function(d){d.preventDefault(),p&&d.stopPropagation(),b.removeClass(n),n=null,l(d,function(b,e){g&&(a[c.ngModel]?a[c.ngModel].value=b:a[c.ngModel]=b,g&&g.$setViewValue(null!=b&&0==b.length?"":b)),c.ngFileRejectedModel&&(a[c.ngFileRejectedModel]?a[c.ngFileRejectedModel].value=e:a[c.ngFileRejectedModel]=e),i(function(){h(c.ngFileChange)(a,{$files:b,$rejectedFiles:e,$event:d})})},0!=h(c.allowDir)(a),c.multiple||h(c.ngMultiple)(a))},!1)}function d(){var a=document.createElement("div");return"draggable"in a&&"ondrop"in a}function e(a){return/^[\000-\177]*$/.test(a)}function f(a){if(a.length>2&&"/"===a[0]&&"/"===a[a.length-1])return a.substring(1,a.length-1);var b=a.split(","),c="";if(b.length>1)for(var d=0;d<b.length;d++)c+="("+f(b[d])+")",d<b.length-1&&(c+="|");else c="^"+a.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$",c=c.replace(/\\\*/g,".*").replace(/\\\?/g,".");return c}window.XMLHttpRequest&&!window.XMLHttpRequest.__isFileAPIShim&&a("setRequestHeader",function(a){return function(b,c){if("__setXHR_"===b){var d=c(this);d instanceof Function&&d(this)}else a.apply(this,arguments)}});var g=angular.module("angularFileUpload",[]);g.version="2.2.2",g.service("$upload",["$http","$q","$timeout",function(a,b,c){function d(d){d.method=d.method||"POST",d.headers=d.headers||{},d.transformRequest=d.transformRequest||function(b,c){return window.ArrayBuffer&&b instanceof window.ArrayBuffer?b:a.defaults.transformRequest[0](b,c)};var e=b.defer(),f=e.promise;return d.headers.__setXHR_=function(){return function(a){a&&(d.__XHR=a,d.xhrFn&&d.xhrFn(a),a.upload.addEventListener("progress",function(a){a.config=d,e.notify?e.notify(a):f.progress_fn&&c(function(){f.progress_fn(a)})},!1),a.upload.addEventListener("load",function(a){a.lengthComputable&&(a.config=d,e.notify?e.notify(a):f.progress_fn&&c(function(){f.progress_fn(a)}))},!1))}},a(d).then(function(a){e.resolve(a)},function(a){e.reject(a)},function(a){e.notify(a)}),f.success=function(a){return f.then(function(b){a(b.data,b.status,b.headers,d)}),f},f.error=function(a){return f.then(null,function(b){a(b.data,b.status,b.headers,d)}),f},f.progress=function(a){return f.progress_fn=a,f.then(null,null,function(b){a(b)}),f},f.abort=function(){return d.__XHR&&c(function(){d.__XHR.abort()}),f},f.xhr=function(a){return d.xhrFn=function(b){return function(){b&&b.apply(f,arguments),a.apply(f,arguments)}}(d.xhrFn),f},f}this.upload=function(b){b.headers=b.headers||{},b.headers["Content-Type"]=void 0,b.transformRequest=b.transformRequest||a.defaults.transformRequest;var c=new FormData,e=b.transformRequest,f=b.data;return b.transformRequest=function(a,c){function d(a){if("function"==typeof e)a=e(a,c);else for(var b=0;b<e.length;b++)"function"==typeof e[b]&&(a=e[b](a,c));return a}if(f)if(b.formDataAppender)for(var g in f){var h=f[g];b.formDataAppender(a,g,h)}else if(b.sendDataAsJson)f=d(f),a.append("data",new Blob([f],{type:"application/json"}));else for(var g in f){var h=d(f[g]);void 0!==h&&(b.sendObjectAsJson&&"object"==typeof h&&"[object String]"!==Object.prototype.toString.call(i)?a.append(g,new Blob(h),{type:"application/json"}):a.append(g,h))}if(null!=b.file){var i=b.fileFormDataName||"file";if("[object Array]"===Object.prototype.toString.call(b.file))for(var j="[object String]"===Object.prototype.toString.call(i),k=0;k<b.file.length;k++)a.append(j?i:i[k],b.file[k],b.fileName&&b.fileName[k]||b.file[k].name);else a.append(i,b.file,b.fileName||b.file.name)}return a},b.data=c,d(b)},this.http=function(a){return d(a)}}]),g.directive("ngFileSelect",["$parse","$timeout","$compile",function(a,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){b(e,f,g,h,a,c,d)}}}]),g.directive("ngFileDrop",["$parse","$timeout","$location",function(a,b,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){c(e,f,g,h,a,b,d)}}}]),g.directive("ngNoFileDrop",function(){return function(a,b){d()&&b.css("display","none")}}),g.directive("ngFileDropAvailable",["$parse","$timeout",function(a,b){return function(c,e,f){if(d()){var g=a(f.ngFileDropAvailable);b(function(){g(c)})}}}])}(),function(){function a(a,b){window.XMLHttpRequest.prototype[a]=b(window.XMLHttpRequest.prototype[a])}function b(a,b,c){try{Object.defineProperty(a,b,{get:c})}catch(d){}}var c=function(){try{var a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if(a)return!0}catch(b){if(void 0!=navigator.mimeTypes["application/x-shockwave-flash"])return!0}return!1};if(window.XMLHttpRequest&&!window.FormData||window.FileAPI&&FileAPI.forceLoad){var d=function(a){if(!a.__listeners){a.upload||(a.upload={}),a.__listeners=[];var b=a.upload.addEventListener;a.upload.addEventListener=function(c,d){a.__listeners[c]=d,b&&b.apply(this,arguments)}}};a("open",function(a){return function(b,c,e){d(this),this.__url=c;try{a.apply(this,[b,c,e])}catch(f){f.message.indexOf("Access is denied")>-1&&a.apply(this,[b,"_fix_for_ie_crossdomain__",e])}}}),a("getResponseHeader",function(a){return function(b){return this.__fileApiXHR&&this.__fileApiXHR.getResponseHeader?this.__fileApiXHR.getResponseHeader(b):null==a?null:a.apply(this,[b])}}),a("getAllResponseHeaders",function(a){return function(){return this.__fileApiXHR&&this.__fileApiXHR.getAllResponseHeaders?this.__fileApiXHR.getAllResponseHeaders():null==a?null:a.apply(this)}}),a("abort",function(a){return function(){return this.__fileApiXHR&&this.__fileApiXHR.abort?this.__fileApiXHR.abort():null==a?null:a.apply(this)}}),a("setRequestHeader",function(a){return function(b,c){if("__setXHR_"===b){d(this);var e=c(this);e instanceof Function&&e(this)}else this.__requestHeaders=this.__requestHeaders||{},this.__requestHeaders[b]=c,a.apply(this,arguments)}}),a("send",function(a){return function(){var d=this;if(arguments[0]&&arguments[0].__isFileAPIShim){var e=arguments[0],f={url:d.__url,jsonp:!1,cache:!0,complete:function(a,c){d.__completed=!0,!a&&d.__listeners.load&&d.__listeners.load({type:"load",loaded:d.__loaded,total:d.__total,target:d,lengthComputable:!0}),!a&&d.__listeners.loadend&&d.__listeners.loadend({type:"loadend",loaded:d.__loaded,total:d.__total,target:d,lengthComputable:!0}),"abort"===a&&d.__listeners.abort&&d.__listeners.abort({type:"abort",loaded:d.__loaded,total:d.__total,target:d,lengthComputable:!0}),void 0!==c.status&&b(d,"status",function(){return 0==c.status&&a&&"abort"!==a?500:c.status}),void 0!==c.statusText&&b(d,"statusText",function(){return c.statusText}),b(d,"readyState",function(){return 4}),void 0!==c.response&&b(d,"response",function(){return c.response});var e=c.responseText||(a&&0==c.status&&"abort"!==a?a:void 0);b(d,"responseText",function(){return e}),b(d,"response",function(){return e}),a&&b(d,"err",function(){return a}),d.__fileApiXHR=c,d.onreadystatechange&&d.onreadystatechange(),d.onload&&d.onload()},fileprogress:function(a){if(a.target=d,d.__listeners.progress&&d.__listeners.progress(a),d.__total=a.total,d.__loaded=a.loaded,a.total===a.loaded){var b=this;setTimeout(function(){d.__completed||(d.getAllResponseHeaders=function(){},b.complete(null,{status:204,statusText:"No Content"}))},1e4)}},headers:d.__requestHeaders};f.data={},f.files={};for(var g=0;g<e.data.length;g++){var h=e.data[g];null!=h.val&&null!=h.val.name&&null!=h.val.size&&null!=h.val.type?f.files[h.key]=h.val:f.data[h.key]=h.val}setTimeout(function(){if(!c())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';d.__fileApiXHR=FileAPI.upload(f)},1)}else a.apply(d,arguments)}}),window.XMLHttpRequest.__isFileAPIShim=!0;var e=function(a){if(!c())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';var b=angular.element(a);if(!(b.attr("disabled")||b.hasClass("js-fileapi-wrapper")||null==b.attr("ng-file-select")&&null==b.attr("data-ng-file-select")&&null==b.attr("ng-file-generated-elem--")||(b.addClass("js-fileapi-wrapper"),null==b.attr("ng-file-generated-elem--")))){var d=angular.element(document.getElementById("e"+b.attr("id")));d.bind("mouseover",function(){(""===b.parent().css("position")||"static"===b.parent().css("position"))&&b.parent().css("position","relative"),b.css("position","absolute").css("top",d[0].offsetTop+"px").css("left",d[0].offsetLeft+"px").css("width",d[0].offsetWidth+"px").css("height",d[0].offsetHeight+"px").css("padding",d.css("padding")).css("margin",d.css("margin")).css("filter","alpha(opacity=0)"),d.attr("onclick",""),b.css("z-index","1000")})}},f=function(a){return function(b){for(var c=FileAPI.getFiles(b),d=0;d<c.length;d++)void 0===c[d].size&&(c[d].size=0),void 0===c[d].name&&(c[d].name="file"),void 0===c[d].type&&(c[d].type="undefined");b.target||(b.target={}),b.target.files=c,b.target.files!=c&&(b.__files_=c),(b.__files_||b.target.files).item=function(a){return(b.__files_||b.target.files)[a]||null},a&&a.apply(this,[b])}},g=function(a,b){return("change"===b.toLowerCase()||"onchange"===b.toLowerCase())&&"file"==a.getAttribute("type")};HTMLInputElement.prototype.addEventListener&&(HTMLInputElement.prototype.addEventListener=function(a){return function(b,c,d,h){g(this,b)?(e(this),a.apply(this,[b,f(c),d,h])):a.apply(this,[b,c,d,h])}}(HTMLInputElement.prototype.addEventListener)),HTMLInputElement.prototype.attachEvent&&(HTMLInputElement.prototype.attachEvent=function(a){return function(b,c){g(this,b)?(e(this),window.jQuery?angular.element(this).bind("change",f(null)):a.apply(this,[b,f(c)])):a.apply(this,[b,c])}}(HTMLInputElement.prototype.attachEvent)),window.FormData=FormData=function(){return{append:function(a,b,c){b.__isFileAPIBlobShim&&(b=b.data[0]),this.data.push({key:a,val:b,name:c})},data:[],__isFileAPIShim:!0}},window.Blob=Blob=function(a){return{data:a,__isFileAPIBlobShim:!0}},function(){if(window.FileAPI||(window.FileAPI={}),FileAPI.forceLoad&&(FileAPI.html5=!1),!FileAPI.upload){var a,b,d,e,f,g=document.createElement("script"),h=document.getElementsByTagName("script");if(window.FileAPI.jsUrl)a=window.FileAPI.jsUrl;else if(window.FileAPI.jsPath)b=window.FileAPI.jsPath;else for(d=0;d<h.length;d++)if(f=h[d].src,e=f.search(/\/angular\-file\-upload[\-a-zA-z0-9\.]*\.js/),e>-1){b=f.substring(0,e+1);break}null==FileAPI.staticPath&&(FileAPI.staticPath=b),g.setAttribute("src",a||b+"FileAPI.min.js"),document.getElementsByTagName("head")[0].appendChild(g),FileAPI.hasFlash=c()}}(),FileAPI.disableFileInput=function(a,b){b?a.removeClass("js-fileapi-wrapper"):a.addClass("js-fileapi-wrapper")}}window.FileReader||(window.FileReader=function(){var a=this,b=!1;this.listeners={},this.addEventListener=function(b,c){a.listeners[b]=a.listeners[b]||[],a.listeners[b].push(c)},this.removeEventListener=function(b,c){a.listeners[b]&&a.listeners[b].splice(a.listeners[b].indexOf(c),1)},this.dispatchEvent=function(b){var c=a.listeners[b.type];if(c)for(var d=0;d<c.length;d++)c[d].call(a,b)},this.onabort=this.onerror=this.onload=this.onloadstart=this.onloadend=this.onprogress=null;var c=function(b,c){var d={type:b,target:a,loaded:c.loaded,total:c.total,error:c.error};return null!=c.result&&(d.target.result=c.result),d},d=function(d){if(b||(b=!0,a.onloadstart&&this.onloadstart(c("loadstart",d))),"load"===d.type){a.onloadend&&a.onloadend(c("loadend",d));var e=c("load",d);a.onload&&a.onload(e),a.dispatchEvent(e)}else if("progress"===d.type){var e=c("progress",d);a.onprogress&&a.onprogress(e),a.dispatchEvent(e)}else{var e=c("error",d);a.onerror&&a.onerror(e),a.dispatchEvent(e)}};this.readAsArrayBuffer=function(a){FileAPI.readAsBinaryString(a,d)},this.readAsBinaryString=function(a){FileAPI.readAsBinaryString(a,d)},this.readAsDataURL=function(a){FileAPI.readAsDataURL(a,d)},this.readAsText=function(a){FileAPI.readAsText(a,d)}})}();
/*! 3.0.1 */
!function(){function a(a,b){window.XMLHttpRequest.prototype[a]=b(window.XMLHttpRequest.prototype[a])}function b(a,b,c,d,e,g,h){function i(){return"input"===b[0].tagName.toLowerCase()&&b.attr("type")&&"file"===b.attr("type").toLowerCase()}function j(c){g(function(){b.parent().length&&p.push(a.$watch(c,function(a,b){a!=b&&k()}))})}function k(){var c=b.clone();if(b.attr("__afu_gen__")&&angular.element(document.getElementById(b.attr("id").substring(1))).remove(),b.parent().length){for(var d=0;d<p.length;d++)p[d]();b.replaceWith(c),h(c)(a)}return c}function l(d,f){if(d){j(d);var g=e(d)(a);g?(b.attr(f,g),c[f]=g):(b.attr(f,null),delete c[f])}}function m(b){var e;e=b.__files_||b.target&&b.target.files,o(e,c,d,a,b)}function n(a){var c=null!=q[0].value&&""!=q[0].value;if(q[0].value=null,-1===navigator.userAgent.indexOf("Chrome"))if(b.attr("__afu_clone__"))b.attr("__afu_clone__",null);else if(c&&m({target:{files:[]}}),-1!==navigator.appVersion.indexOf("MSIE 10")){var d=k();return d.attr("__afu_clone__",!0),d[0].click(),a.preventDefault(),a.stopPropagation(),!0}}function o(a,b,c,d,h){for(var i=[],j=[],k=b.accept?new RegExp(f(b.accept),"gi"):null,l=0;l<a.length;l++){var m=a.item(l);!k||m.type.match(k)||null!=m.name&&m.name.match(k)?i.push(m):j.push(m)}c&&g(function(){d[b.ngModel]&&(d[b.ngModel].value=i),d[b.ngModel]=i,c&&c.$setViewValue(null!=i&&0==i.length?"":i),b.ngModelRejected&&(d[b.ngModelRejected]&&(d[b.ngModelRejected].value=j),d[b.ngModelRejected]=j)}),b.ngFileChange&&""!=b.ngFileChange&&g(function(){e(b.ngFileChange)(d,{$files:i,$rejectedFiles:j,$event:h})})}var p=[];l(c.ngMultiple,"multiple"),l(c.ngAccept,"accept"),l(c.ngCapture,"capture"),""!=c.ngFileSelect&&(c.ngFileChange=c.ngFileSelect);var q=b;if(i())b.bind("click",n);else{q=angular.element('<input type="file">'),c.multiple&&q.attr("multiple",c.multiple),c.accept&&q.attr("accept",c.accept),c.capture&&q.attr("capture",c.capture);for(var r in c)if(0==r.indexOf("inputFile")){var s=r.substring("inputFile".length);s=s[0].toLowerCase()+s.substring(1),q.attr(s,c[r])}q.css("width","0px").css("height","0px").css("position","absolute").css("padding",0).css("margin",0).css("overflow","hidden").attr("tabindex","-1").css("opacity",0).attr("__afu_gen__",!0),b.attr("__refElem__",!0),q[0].__refElem__=b[0],b.parent()[0].insertBefore(q[0],b[0]),b.css("overflow","hidden"),b.bind("click",function(a){n(a)||q[0].click()})}q.bind("change",m),b.on("$destroy",function(){for(var a=0;a<p.length;a++)p[a]();b[0]!=q[0]&&q.remove()}),p.push(a.$watch(c.ngModel,function(a,b){a==b||null!=a&&a.length||(-1!==navigator.appVersion.indexOf("MSIE 10")?k():q[0].value=null)}))}function c(a,b,c,g,h,i,j){function k(a,b,c){var d=!0;if(s){var e=c.dataTransfer.items;if(null!=e)for(var f=0;f<e.length&&d;f++)d=d&&("file"==e[f].kind||""==e[f].kind)&&(null!=e[f].type.match(s)||null!=e[f].name&&null!=e[f].name.match(s))}var g=h(b.dragOverClass)(a,{$event:c});return g&&(g.delay&&(q=g.delay),g.accept&&(g=d?g.accept:g.reject)),g||b.dragOverClass||"dragover"}function l(a,b,c,d){function f(a){!s||a.type.match(s)||null!=a.name&&a.name.match(s)?h.push(a):k.push(a)}function g(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;f({name:b.name,type:"directory",path:d});var e=b.createReader(),h=[];m++;var i=function(){e.readEntries(function(d){try{if(d.length)h=h.concat(Array.prototype.slice.call(d||[],0)),i();else{for(var e=0;e<h.length;e++)g(a,h[e],(c?c:"")+b.name+"/");m--}}catch(f){m--,console.error(f)}},function(){m--})};i()}else m++,b.file(function(a){try{m--,a.path=(c?c:"")+a.name,f(a)}catch(b){m--,console.error(b)}},function(){m--})}var h=[],k=[],l=a.dataTransfer.items,m=0;if(l&&l.length>0&&"file"!=j.protocol())for(var n=0;n<l.length;n++){if(l[n].webkitGetAsEntry&&l[n].webkitGetAsEntry()&&l[n].webkitGetAsEntry().isDirectory){var o=l[n].webkitGetAsEntry();if(o.isDirectory&&!c)continue;null!=o&&(e(o.name)?g(h,o):l[n].webkitGetAsEntry().isDirectory||f(l[n].getAsFile()))}else{var p=l[n].getAsFile();null!=p&&f(p)}if(!d&&h.length>0)break}else{var q=a.dataTransfer.files;if(null!=q)for(var n=0;n<q.length&&(f(q.item(n)),d||!(h.length>0));n++);}var r=0;!function t(a){i(function(){if(m)10*r++<2e4&&t(10);else{if(!d&&h.length>1){for(var a=0;"directory"==h[a].type;)a++;h=[h[a]]}b(h,k)}},a||0)}()}var m=d();if(c.dropAvailable&&i(function(){a.dropAvailable?a.dropAvailable.value=m:a.dropAvailable=m}),!m)return 0!=h(c.hideOnDropNotAvailable)(a)&&b.css("display","none"),void 0;var n,o=null,p=h(c.stopPropagation)(a),q=1,r=h(c.ngAccept)(a)||c.accept,s=r?new RegExp(f(r),"gi"):null;b[0].addEventListener("dragover",function(d){d.preventDefault(),p&&d.stopPropagation(),i.cancel(o),a.actualDragOverClass||(n=k(a,c,d)),b.addClass(n)},!1),b[0].addEventListener("dragenter",function(a){a.preventDefault(),p&&a.stopPropagation()},!1),b[0].addEventListener("dragleave",function(){o=i(function(){b.removeClass(n),n=null},q||1)},!1),""!=c.ngFileDrop&&(c.ngFileChange=a.ngFileDrop),b[0].addEventListener("drop",function(d){d.preventDefault(),p&&d.stopPropagation(),b.removeClass(n),n=null,l(d,function(b,e){i(function(){g&&(a[c.ngModel]&&(a[c.ngModel].value=b),a[c.ngModel]=b,g&&g.$setViewValue(null!=b&&0==b.length?"":b)),c.ngModelRejected&&(a[c.ngModelRejected]&&(a[c.ngModelRejected].value=e),a[c.ngModelRejected]=e)}),i(function(){h(c.ngFileChange)(a,{$files:b,$rejectedFiles:e,$event:d})})},0!=h(c.allowDir)(a),c.multiple||h(c.ngMultiple)(a))},!1)}function d(){var a=document.createElement("div");return"draggable"in a&&"ondrop"in a}function e(a){return/^[\000-\177]*$/.test(a)}function f(a){if(a.length>2&&"/"===a[0]&&"/"===a[a.length-1])return a.substring(1,a.length-1);var b=a.split(","),c="";if(b.length>1)for(var d=0;d<b.length;d++)0==b[d].indexOf(".")&&(b[d]="*"+b[d]),c+="("+f(b[d])+")",d<b.length-1&&(c+="|");else c="^"+a.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$",c=c.replace(/\\\*/g,".*").replace(/\\\?/g,".");return c}window.XMLHttpRequest&&!window.XMLHttpRequest.__isFileAPIShim&&a("setRequestHeader",function(a){return function(b,c){if("__setXHR_"===b){var d=c(this);d instanceof Function&&d(this)}else a.apply(this,arguments)}});var g=angular.module("angularFileUpload",[]);g.version="3.0.1",g.service("$upload",["$http","$q","$timeout",function(a,b,c){function d(d){d.method=d.method||"POST",d.headers=d.headers||{},d.transformRequest=d.transformRequest||function(b,c){return window.ArrayBuffer&&b instanceof window.ArrayBuffer?b:a.defaults.transformRequest[0](b,c)};var e=b.defer(),f=e.promise;return d.headers.__setXHR_=function(){return function(a){a&&(d.__XHR=a,d.xhrFn&&d.xhrFn(a),a.upload.addEventListener("progress",function(a){a.config=d,e.notify?e.notify(a):f.progress_fn&&c(function(){f.progress_fn(a)})},!1),a.upload.addEventListener("load",function(a){a.lengthComputable&&(a.config=d,e.notify?e.notify(a):f.progress_fn&&c(function(){f.progress_fn(a)}))},!1))}},a(d).then(function(a){e.resolve(a)},function(a){e.reject(a)},function(a){e.notify(a)}),f.success=function(a){return f.then(function(b){a(b.data,b.status,b.headers,d)}),f},f.error=function(a){return f.then(null,function(b){a(b.data,b.status,b.headers,d)}),f},f.progress=function(a){return f.progress_fn=a,f.then(null,null,function(b){a(b)}),f},f.abort=function(){return d.__XHR&&c(function(){d.__XHR.abort()}),f},f.xhr=function(a){return d.xhrFn=function(b){return function(){b&&b.apply(f,arguments),a.apply(f,arguments)}}(d.xhrFn),f},f}this.upload=function(a){a.headers=a.headers||{},a.headers["Content-Type"]=void 0;a.transformRequest;return a.transformRequest=a.transformRequest?"[object Array]"===Object.prototype.toString.call(a.transformRequest)?a.transformRequest:[a.transformRequest]:[],a.transformRequest.push(function(b){var c=new FormData,d={};for(var e in a.fields)d[e]=a.fields[e];if(b&&(d.data=b),a.formDataAppender)for(var e in d)a.formDataAppender(c,e,d[e]);else for(var e in d){var f=d[e];void 0!==f&&("[object String]"===Object.prototype.toString.call(f)?c.append(e,f):a.sendObjectsAsJsonBlob&&"object"==typeof f?c.append(e,new Blob([f],{type:"application/json"})):c.append(e,JSON.stringify(f)))}if(null!=a.file){var g=a.fileFormDataName||"file";if("[object Array]"===Object.prototype.toString.call(a.file))for(var h="[object String]"===Object.prototype.toString.call(g),i=0;i<a.file.length;i++)c.append(h?g:g[i],a.file[i],a.fileName&&a.fileName[i]||a.file[i].name);else c.append(g,a.file,a.fileName||a.file.name)}return c}),d(a)},this.http=function(a){return d(a)}}]),g.directive("ngFileSelect",["$parse","$timeout","$compile",function(a,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){b(e,f,g,h,a,c,d)}}}]),g.directive("ngFileDrop",["$parse","$timeout","$location",function(a,b,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){c(e,f,g,h,a,b,d)}}}]),g.directive("ngNoFileDrop",function(){return function(a,b){d()&&b.css("display","none")}}),g.directive("ngFileDropAvailable",["$parse","$timeout",function(a,b){return function(c,e,f){if(d()){var g=a(f.ngFileDropAvailable);b(function(){g(c)})}}}]);var h=angular.module("ngFileUpload",[]);for(key in g)h[key]=g[key]}(),function(){function a(a,b){window.XMLHttpRequest.prototype[a]=b(window.XMLHttpRequest.prototype[a])}function b(a,b,c){try{Object.defineProperty(a,b,{get:c})}catch(d){}}var c=function(){try{var a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if(a)return!0}catch(b){if(void 0!=navigator.mimeTypes["application/x-shockwave-flash"])return!0}return!1};if(window.XMLHttpRequest&&!window.FormData||window.FileAPI&&FileAPI.forceLoad){var d=function(a){if(!a.__listeners){a.upload||(a.upload={}),a.__listeners=[];var b=a.upload.addEventListener;a.upload.addEventListener=function(c,d){a.__listeners[c]=d,b&&b.apply(this,arguments)}}};a("open",function(a){return function(b,c,e){d(this),this.__url=c;try{a.apply(this,[b,c,e])}catch(f){f.message.indexOf("Access is denied")>-1&&a.apply(this,[b,"_fix_for_ie_crossdomain__",e])}}}),a("getResponseHeader",function(a){return function(b){return this.__fileApiXHR&&this.__fileApiXHR.getResponseHeader?this.__fileApiXHR.getResponseHeader(b):null==a?null:a.apply(this,[b])}}),a("getAllResponseHeaders",function(a){return function(){return this.__fileApiXHR&&this.__fileApiXHR.getAllResponseHeaders?this.__fileApiXHR.getAllResponseHeaders():null==a?null:a.apply(this)}}),a("abort",function(a){return function(){return this.__fileApiXHR&&this.__fileApiXHR.abort?this.__fileApiXHR.abort():null==a?null:a.apply(this)}}),a("setRequestHeader",function(a){return function(b,c){if("__setXHR_"===b){d(this);var e=c(this);e instanceof Function&&e(this)}else this.__requestHeaders=this.__requestHeaders||{},this.__requestHeaders[b]=c,a.apply(this,arguments)}}),a("send",function(a){return function(){var d=this;if(arguments[0]&&arguments[0].__isFileAPIShim){var e=arguments[0],f={url:d.__url,jsonp:!1,cache:!0,complete:function(a,c){d.__completed=!0,!a&&d.__listeners.load&&d.__listeners.load({type:"load",loaded:d.__loaded,total:d.__total,target:d,lengthComputable:!0}),!a&&d.__listeners.loadend&&d.__listeners.loadend({type:"loadend",loaded:d.__loaded,total:d.__total,target:d,lengthComputable:!0}),"abort"===a&&d.__listeners.abort&&d.__listeners.abort({type:"abort",loaded:d.__loaded,total:d.__total,target:d,lengthComputable:!0}),void 0!==c.status&&b(d,"status",function(){return 0==c.status&&a&&"abort"!==a?500:c.status}),void 0!==c.statusText&&b(d,"statusText",function(){return c.statusText}),b(d,"readyState",function(){return 4}),void 0!==c.response&&b(d,"response",function(){return c.response});var e=c.responseText||(a&&0==c.status&&"abort"!==a?a:void 0);b(d,"responseText",function(){return e}),b(d,"response",function(){return e}),a&&b(d,"err",function(){return a}),d.__fileApiXHR=c,d.onreadystatechange&&d.onreadystatechange(),d.onload&&d.onload()},fileprogress:function(a){if(a.target=d,d.__listeners.progress&&d.__listeners.progress(a),d.__total=a.total,d.__loaded=a.loaded,a.total===a.loaded){var b=this;setTimeout(function(){d.__completed||(d.getAllResponseHeaders=function(){},b.complete(null,{status:204,statusText:"No Content"}))},FileAPI.noContentTimeout||1e4)}},headers:d.__requestHeaders};f.data={},f.files={};for(var g=0;g<e.data.length;g++){var h=e.data[g];null!=h.val&&null!=h.val.name&&null!=h.val.size&&null!=h.val.type?f.files[h.key]=h.val:f.data[h.key]=h.val}setTimeout(function(){if(!c())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';d.__fileApiXHR=FileAPI.upload(f)},1)}else a.apply(d,arguments)}}),window.XMLHttpRequest.__isFileAPIShim=!0;var e=function(a){if(!c())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';var b=angular.element(a);if(!b.attr("disabled")){for(var d=!1,e=0;e<b[0].attributes.length;e++){var f=b[0].attributes[e];if(-1!==f.name.indexOf("file-select")){d=!0;break}}if(!b.hasClass("js-fileapi-wrapper")&&(d||null!=b.attr("__afu_gen__"))&&(b.addClass("js-fileapi-wrapper"),null!=b.attr("__afu_gen__"))){for(var g=b[0].__refElem__&&angular.element(b[0].__refElem__)||b;g&&!g.attr("__refElem__");)g=angular.element(g[0].nextSibling);g.bind("mouseover",function(){(""===b.parent().css("position")||"static"===b.parent().css("position"))&&b.parent().css("position","relative"),b.css("position","absolute").css("top",g[0].offsetTop+"px").css("left",g[0].offsetLeft+"px").css("width",g[0].offsetWidth+"px").css("height",g[0].offsetHeight+"px").css("padding",g.css("padding")).css("margin",g.css("margin")).css("filter","alpha(opacity=0)"),g.attr("onclick",""),b.css("z-index","1000")})}}},f=function(a){return function(b){for(var c=FileAPI.getFiles(b),d=0;d<c.length;d++)void 0===c[d].size&&(c[d].size=0),void 0===c[d].name&&(c[d].name="file"),void 0===c[d].type&&(c[d].type="undefined");b.target||(b.target={}),b.target.files=c,b.target.files!=c&&(b.__files_=c),(b.__files_||b.target.files).item=function(a){return(b.__files_||b.target.files)[a]||null},a&&a.apply(this,[b])}},g=function(a,b){return("change"===b.toLowerCase()||"onchange"===b.toLowerCase())&&"file"==a.getAttribute("type")};HTMLInputElement.prototype.addEventListener&&(HTMLInputElement.prototype.addEventListener=function(a){return function(b,c,d,h){g(this,b)?(e(this),a.apply(this,[b,f(c),d,h])):a.apply(this,[b,c,d,h])}}(HTMLInputElement.prototype.addEventListener)),HTMLInputElement.prototype.attachEvent&&(HTMLInputElement.prototype.attachEvent=function(a){return function(b,c){g(this,b)?(e(this),window.jQuery?angular.element(this).bind("change",f(null)):a.apply(this,[b,f(c)])):a.apply(this,[b,c])}}(HTMLInputElement.prototype.attachEvent)),window.FormData=FormData=function(){return{append:function(a,b,c){b.__isFileAPIBlobShim&&(b=b.data[0]),this.data.push({key:a,val:b,name:c})},data:[],__isFileAPIShim:!0}},window.Blob=Blob=function(a){return{data:a,__isFileAPIBlobShim:!0}},function(){if(window.FileAPI||(window.FileAPI={}),FileAPI.forceLoad&&(FileAPI.html5=!1),!FileAPI.upload){var a,b,d,e,f,g=document.createElement("script"),h=document.getElementsByTagName("script");if(window.FileAPI.jsUrl)a=window.FileAPI.jsUrl;else if(window.FileAPI.jsPath)b=window.FileAPI.jsPath;else for(d=0;d<h.length;d++)if(f=h[d].src,e=f.search(/\/angular\-file\-upload[\-a-zA-z0-9\.]*\.js/),e>-1){b=f.substring(0,e+1);break}null==FileAPI.staticPath&&(FileAPI.staticPath=b),g.setAttribute("src",a||b+"FileAPI.min.js"),document.getElementsByTagName("head")[0].appendChild(g),FileAPI.hasFlash=c()}}(),FileAPI.disableFileInput=function(a,b){b?a.removeClass("js-fileapi-wrapper"):a.addClass("js-fileapi-wrapper")}}window.FileReader||(window.FileReader=function(){var a=this,b=!1;this.listeners={},this.addEventListener=function(b,c){a.listeners[b]=a.listeners[b]||[],a.listeners[b].push(c)},this.removeEventListener=function(b,c){a.listeners[b]&&a.listeners[b].splice(a.listeners[b].indexOf(c),1)},this.dispatchEvent=function(b){var c=a.listeners[b.type];if(c)for(var d=0;d<c.length;d++)c[d].call(a,b)},this.onabort=this.onerror=this.onload=this.onloadstart=this.onloadend=this.onprogress=null;var c=function(b,c){var d={type:b,target:a,loaded:c.loaded,total:c.total,error:c.error};return null!=c.result&&(d.target.result=c.result),d},d=function(d){if(b||(b=!0,a.onloadstart&&a.onloadstart(c("loadstart",d))),"load"===d.type){a.onloadend&&a.onloadend(c("loadend",d));var e=c("load",d);a.onload&&a.onload(e),a.dispatchEvent(e)}else if("progress"===d.type){var e=c("progress",d);a.onprogress&&a.onprogress(e),a.dispatchEvent(e)}else{var e=c("error",d);a.onerror&&a.onerror(e),a.dispatchEvent(e)}};this.readAsArrayBuffer=function(a){FileAPI.readAsBinaryString(a,d)},this.readAsBinaryString=function(a){FileAPI.readAsBinaryString(a,d)},this.readAsDataURL=function(a){FileAPI.readAsDataURL(a,d)},this.readAsText=function(a){FileAPI.readAsText(a,d)}})}();

@@ -5,3 +5,3 @@ /**!

* @author Danial <danial.farid@gmail.com>
* @version 2.2.2
* @version 3.0.1
*/

@@ -135,3 +135,3 @@

}
}, 10000);
}, FileAPI.noContentTimeout || 10000);
}

@@ -171,8 +171,18 @@ },

if (!el.attr('disabled')) {
if (!el.hasClass('js-fileapi-wrapper') && (el.attr('ng-file-select') != null || el.attr('data-ng-file-select') != null ||
el.attr('ng-file-generated-elem--') != null)) {
var hasFileSelect = false;
for (var i = 0; i < el[0].attributes.length; i++) {
var attrib = el[0].attributes[i];
if (attrib.name.indexOf('file-select') !== -1) {
hasFileSelect = true;
break;
}
}
if (!el.hasClass('js-fileapi-wrapper') && (hasFileSelect || el.attr('__afu_gen__') != null)) {
el.addClass('js-fileapi-wrapper');
if (el.attr('ng-file-generated-elem--') != null) {
var ref = angular.element(document.getElementById('e' + el.attr('id')));
if (el.attr('__afu_gen__') != null) {
var ref = (el[0].__refElem__ && angular.element(el[0].__refElem__)) || el;
while (ref && !ref.attr('__refElem__')) {
ref = angular.element(ref[0].nextSibling);
}
ref.bind('mouseover', function() {

@@ -343,3 +353,3 @@ if (el.parent().css('position') === '' || el.parent().css('position') === 'static') {

loadStarted = true;
_this.onloadstart && this.onloadstart(constructEvent('loadstart', evt));
_this.onloadstart && _this.onloadstart(constructEvent('loadstart', evt));
}

@@ -346,0 +356,0 @@ if (evt.type === 'load') {

@@ -1,2 +0,2 @@

/*! 2.2.2 */
!function(){function a(a,b){window.XMLHttpRequest.prototype[a]=b(window.XMLHttpRequest.prototype[a])}function b(a,b,c){try{Object.defineProperty(a,b,{get:c})}catch(d){}}var c=function(){try{var a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if(a)return!0}catch(b){if(void 0!=navigator.mimeTypes["application/x-shockwave-flash"])return!0}return!1};if(window.XMLHttpRequest&&!window.FormData||window.FileAPI&&FileAPI.forceLoad){var d=function(a){if(!a.__listeners){a.upload||(a.upload={}),a.__listeners=[];var b=a.upload.addEventListener;a.upload.addEventListener=function(c,d){a.__listeners[c]=d,b&&b.apply(this,arguments)}}};a("open",function(a){return function(b,c,e){d(this),this.__url=c;try{a.apply(this,[b,c,e])}catch(f){f.message.indexOf("Access is denied")>-1&&a.apply(this,[b,"_fix_for_ie_crossdomain__",e])}}}),a("getResponseHeader",function(a){return function(b){return this.__fileApiXHR&&this.__fileApiXHR.getResponseHeader?this.__fileApiXHR.getResponseHeader(b):null==a?null:a.apply(this,[b])}}),a("getAllResponseHeaders",function(a){return function(){return this.__fileApiXHR&&this.__fileApiXHR.getAllResponseHeaders?this.__fileApiXHR.getAllResponseHeaders():null==a?null:a.apply(this)}}),a("abort",function(a){return function(){return this.__fileApiXHR&&this.__fileApiXHR.abort?this.__fileApiXHR.abort():null==a?null:a.apply(this)}}),a("setRequestHeader",function(a){return function(b,c){if("__setXHR_"===b){d(this);var e=c(this);e instanceof Function&&e(this)}else this.__requestHeaders=this.__requestHeaders||{},this.__requestHeaders[b]=c,a.apply(this,arguments)}}),a("send",function(a){return function(){var d=this;if(arguments[0]&&arguments[0].__isFileAPIShim){var e=arguments[0],f={url:d.__url,jsonp:!1,cache:!0,complete:function(a,c){d.__completed=!0,!a&&d.__listeners.load&&d.__listeners.load({type:"load",loaded:d.__loaded,total:d.__total,target:d,lengthComputable:!0}),!a&&d.__listeners.loadend&&d.__listeners.loadend({type:"loadend",loaded:d.__loaded,total:d.__total,target:d,lengthComputable:!0}),"abort"===a&&d.__listeners.abort&&d.__listeners.abort({type:"abort",loaded:d.__loaded,total:d.__total,target:d,lengthComputable:!0}),void 0!==c.status&&b(d,"status",function(){return 0==c.status&&a&&"abort"!==a?500:c.status}),void 0!==c.statusText&&b(d,"statusText",function(){return c.statusText}),b(d,"readyState",function(){return 4}),void 0!==c.response&&b(d,"response",function(){return c.response});var e=c.responseText||(a&&0==c.status&&"abort"!==a?a:void 0);b(d,"responseText",function(){return e}),b(d,"response",function(){return e}),a&&b(d,"err",function(){return a}),d.__fileApiXHR=c,d.onreadystatechange&&d.onreadystatechange(),d.onload&&d.onload()},fileprogress:function(a){if(a.target=d,d.__listeners.progress&&d.__listeners.progress(a),d.__total=a.total,d.__loaded=a.loaded,a.total===a.loaded){var b=this;setTimeout(function(){d.__completed||(d.getAllResponseHeaders=function(){},b.complete(null,{status:204,statusText:"No Content"}))},1e4)}},headers:d.__requestHeaders};f.data={},f.files={};for(var g=0;g<e.data.length;g++){var h=e.data[g];null!=h.val&&null!=h.val.name&&null!=h.val.size&&null!=h.val.type?f.files[h.key]=h.val:f.data[h.key]=h.val}setTimeout(function(){if(!c())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';d.__fileApiXHR=FileAPI.upload(f)},1)}else a.apply(d,arguments)}}),window.XMLHttpRequest.__isFileAPIShim=!0;var e=function(a){if(!c())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';var b=angular.element(a);if(!(b.attr("disabled")||b.hasClass("js-fileapi-wrapper")||null==b.attr("ng-file-select")&&null==b.attr("data-ng-file-select")&&null==b.attr("ng-file-generated-elem--")||(b.addClass("js-fileapi-wrapper"),null==b.attr("ng-file-generated-elem--")))){var d=angular.element(document.getElementById("e"+b.attr("id")));d.bind("mouseover",function(){(""===b.parent().css("position")||"static"===b.parent().css("position"))&&b.parent().css("position","relative"),b.css("position","absolute").css("top",d[0].offsetTop+"px").css("left",d[0].offsetLeft+"px").css("width",d[0].offsetWidth+"px").css("height",d[0].offsetHeight+"px").css("padding",d.css("padding")).css("margin",d.css("margin")).css("filter","alpha(opacity=0)"),d.attr("onclick",""),b.css("z-index","1000")})}},f=function(a){return function(b){for(var c=FileAPI.getFiles(b),d=0;d<c.length;d++)void 0===c[d].size&&(c[d].size=0),void 0===c[d].name&&(c[d].name="file"),void 0===c[d].type&&(c[d].type="undefined");b.target||(b.target={}),b.target.files=c,b.target.files!=c&&(b.__files_=c),(b.__files_||b.target.files).item=function(a){return(b.__files_||b.target.files)[a]||null},a&&a.apply(this,[b])}},g=function(a,b){return("change"===b.toLowerCase()||"onchange"===b.toLowerCase())&&"file"==a.getAttribute("type")};HTMLInputElement.prototype.addEventListener&&(HTMLInputElement.prototype.addEventListener=function(a){return function(b,c,d,h){g(this,b)?(e(this),a.apply(this,[b,f(c),d,h])):a.apply(this,[b,c,d,h])}}(HTMLInputElement.prototype.addEventListener)),HTMLInputElement.prototype.attachEvent&&(HTMLInputElement.prototype.attachEvent=function(a){return function(b,c){g(this,b)?(e(this),window.jQuery?angular.element(this).bind("change",f(null)):a.apply(this,[b,f(c)])):a.apply(this,[b,c])}}(HTMLInputElement.prototype.attachEvent)),window.FormData=FormData=function(){return{append:function(a,b,c){b.__isFileAPIBlobShim&&(b=b.data[0]),this.data.push({key:a,val:b,name:c})},data:[],__isFileAPIShim:!0}},window.Blob=Blob=function(a){return{data:a,__isFileAPIBlobShim:!0}},function(){if(window.FileAPI||(window.FileAPI={}),FileAPI.forceLoad&&(FileAPI.html5=!1),!FileAPI.upload){var a,b,d,e,f,g=document.createElement("script"),h=document.getElementsByTagName("script");if(window.FileAPI.jsUrl)a=window.FileAPI.jsUrl;else if(window.FileAPI.jsPath)b=window.FileAPI.jsPath;else for(d=0;d<h.length;d++)if(f=h[d].src,e=f.search(/\/angular\-file\-upload[\-a-zA-z0-9\.]*\.js/),e>-1){b=f.substring(0,e+1);break}null==FileAPI.staticPath&&(FileAPI.staticPath=b),g.setAttribute("src",a||b+"FileAPI.min.js"),document.getElementsByTagName("head")[0].appendChild(g),FileAPI.hasFlash=c()}}(),FileAPI.disableFileInput=function(a,b){b?a.removeClass("js-fileapi-wrapper"):a.addClass("js-fileapi-wrapper")}}window.FileReader||(window.FileReader=function(){var a=this,b=!1;this.listeners={},this.addEventListener=function(b,c){a.listeners[b]=a.listeners[b]||[],a.listeners[b].push(c)},this.removeEventListener=function(b,c){a.listeners[b]&&a.listeners[b].splice(a.listeners[b].indexOf(c),1)},this.dispatchEvent=function(b){var c=a.listeners[b.type];if(c)for(var d=0;d<c.length;d++)c[d].call(a,b)},this.onabort=this.onerror=this.onload=this.onloadstart=this.onloadend=this.onprogress=null;var c=function(b,c){var d={type:b,target:a,loaded:c.loaded,total:c.total,error:c.error};return null!=c.result&&(d.target.result=c.result),d},d=function(d){if(b||(b=!0,a.onloadstart&&this.onloadstart(c("loadstart",d))),"load"===d.type){a.onloadend&&a.onloadend(c("loadend",d));var e=c("load",d);a.onload&&a.onload(e),a.dispatchEvent(e)}else if("progress"===d.type){var e=c("progress",d);a.onprogress&&a.onprogress(e),a.dispatchEvent(e)}else{var e=c("error",d);a.onerror&&a.onerror(e),a.dispatchEvent(e)}};this.readAsArrayBuffer=function(a){FileAPI.readAsBinaryString(a,d)},this.readAsBinaryString=function(a){FileAPI.readAsBinaryString(a,d)},this.readAsDataURL=function(a){FileAPI.readAsDataURL(a,d)},this.readAsText=function(a){FileAPI.readAsText(a,d)}})}();
/*! 3.0.1 */
!function(){function a(a,b){window.XMLHttpRequest.prototype[a]=b(window.XMLHttpRequest.prototype[a])}function b(a,b,c){try{Object.defineProperty(a,b,{get:c})}catch(d){}}var c=function(){try{var a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if(a)return!0}catch(b){if(void 0!=navigator.mimeTypes["application/x-shockwave-flash"])return!0}return!1};if(window.XMLHttpRequest&&!window.FormData||window.FileAPI&&FileAPI.forceLoad){var d=function(a){if(!a.__listeners){a.upload||(a.upload={}),a.__listeners=[];var b=a.upload.addEventListener;a.upload.addEventListener=function(c,d){a.__listeners[c]=d,b&&b.apply(this,arguments)}}};a("open",function(a){return function(b,c,e){d(this),this.__url=c;try{a.apply(this,[b,c,e])}catch(f){f.message.indexOf("Access is denied")>-1&&a.apply(this,[b,"_fix_for_ie_crossdomain__",e])}}}),a("getResponseHeader",function(a){return function(b){return this.__fileApiXHR&&this.__fileApiXHR.getResponseHeader?this.__fileApiXHR.getResponseHeader(b):null==a?null:a.apply(this,[b])}}),a("getAllResponseHeaders",function(a){return function(){return this.__fileApiXHR&&this.__fileApiXHR.getAllResponseHeaders?this.__fileApiXHR.getAllResponseHeaders():null==a?null:a.apply(this)}}),a("abort",function(a){return function(){return this.__fileApiXHR&&this.__fileApiXHR.abort?this.__fileApiXHR.abort():null==a?null:a.apply(this)}}),a("setRequestHeader",function(a){return function(b,c){if("__setXHR_"===b){d(this);var e=c(this);e instanceof Function&&e(this)}else this.__requestHeaders=this.__requestHeaders||{},this.__requestHeaders[b]=c,a.apply(this,arguments)}}),a("send",function(a){return function(){var d=this;if(arguments[0]&&arguments[0].__isFileAPIShim){var e=arguments[0],f={url:d.__url,jsonp:!1,cache:!0,complete:function(a,c){d.__completed=!0,!a&&d.__listeners.load&&d.__listeners.load({type:"load",loaded:d.__loaded,total:d.__total,target:d,lengthComputable:!0}),!a&&d.__listeners.loadend&&d.__listeners.loadend({type:"loadend",loaded:d.__loaded,total:d.__total,target:d,lengthComputable:!0}),"abort"===a&&d.__listeners.abort&&d.__listeners.abort({type:"abort",loaded:d.__loaded,total:d.__total,target:d,lengthComputable:!0}),void 0!==c.status&&b(d,"status",function(){return 0==c.status&&a&&"abort"!==a?500:c.status}),void 0!==c.statusText&&b(d,"statusText",function(){return c.statusText}),b(d,"readyState",function(){return 4}),void 0!==c.response&&b(d,"response",function(){return c.response});var e=c.responseText||(a&&0==c.status&&"abort"!==a?a:void 0);b(d,"responseText",function(){return e}),b(d,"response",function(){return e}),a&&b(d,"err",function(){return a}),d.__fileApiXHR=c,d.onreadystatechange&&d.onreadystatechange(),d.onload&&d.onload()},fileprogress:function(a){if(a.target=d,d.__listeners.progress&&d.__listeners.progress(a),d.__total=a.total,d.__loaded=a.loaded,a.total===a.loaded){var b=this;setTimeout(function(){d.__completed||(d.getAllResponseHeaders=function(){},b.complete(null,{status:204,statusText:"No Content"}))},FileAPI.noContentTimeout||1e4)}},headers:d.__requestHeaders};f.data={},f.files={};for(var g=0;g<e.data.length;g++){var h=e.data[g];null!=h.val&&null!=h.val.name&&null!=h.val.size&&null!=h.val.type?f.files[h.key]=h.val:f.data[h.key]=h.val}setTimeout(function(){if(!c())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';d.__fileApiXHR=FileAPI.upload(f)},1)}else a.apply(d,arguments)}}),window.XMLHttpRequest.__isFileAPIShim=!0;var e=function(a){if(!c())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';var b=angular.element(a);if(!b.attr("disabled")){for(var d=!1,e=0;e<b[0].attributes.length;e++){var f=b[0].attributes[e];if(-1!==f.name.indexOf("file-select")){d=!0;break}}if(!b.hasClass("js-fileapi-wrapper")&&(d||null!=b.attr("__afu_gen__"))&&(b.addClass("js-fileapi-wrapper"),null!=b.attr("__afu_gen__"))){for(var g=b[0].__refElem__&&angular.element(b[0].__refElem__)||b;g&&!g.attr("__refElem__");)g=angular.element(g[0].nextSibling);g.bind("mouseover",function(){(""===b.parent().css("position")||"static"===b.parent().css("position"))&&b.parent().css("position","relative"),b.css("position","absolute").css("top",g[0].offsetTop+"px").css("left",g[0].offsetLeft+"px").css("width",g[0].offsetWidth+"px").css("height",g[0].offsetHeight+"px").css("padding",g.css("padding")).css("margin",g.css("margin")).css("filter","alpha(opacity=0)"),g.attr("onclick",""),b.css("z-index","1000")})}}},f=function(a){return function(b){for(var c=FileAPI.getFiles(b),d=0;d<c.length;d++)void 0===c[d].size&&(c[d].size=0),void 0===c[d].name&&(c[d].name="file"),void 0===c[d].type&&(c[d].type="undefined");b.target||(b.target={}),b.target.files=c,b.target.files!=c&&(b.__files_=c),(b.__files_||b.target.files).item=function(a){return(b.__files_||b.target.files)[a]||null},a&&a.apply(this,[b])}},g=function(a,b){return("change"===b.toLowerCase()||"onchange"===b.toLowerCase())&&"file"==a.getAttribute("type")};HTMLInputElement.prototype.addEventListener&&(HTMLInputElement.prototype.addEventListener=function(a){return function(b,c,d,h){g(this,b)?(e(this),a.apply(this,[b,f(c),d,h])):a.apply(this,[b,c,d,h])}}(HTMLInputElement.prototype.addEventListener)),HTMLInputElement.prototype.attachEvent&&(HTMLInputElement.prototype.attachEvent=function(a){return function(b,c){g(this,b)?(e(this),window.jQuery?angular.element(this).bind("change",f(null)):a.apply(this,[b,f(c)])):a.apply(this,[b,c])}}(HTMLInputElement.prototype.attachEvent)),window.FormData=FormData=function(){return{append:function(a,b,c){b.__isFileAPIBlobShim&&(b=b.data[0]),this.data.push({key:a,val:b,name:c})},data:[],__isFileAPIShim:!0}},window.Blob=Blob=function(a){return{data:a,__isFileAPIBlobShim:!0}},function(){if(window.FileAPI||(window.FileAPI={}),FileAPI.forceLoad&&(FileAPI.html5=!1),!FileAPI.upload){var a,b,d,e,f,g=document.createElement("script"),h=document.getElementsByTagName("script");if(window.FileAPI.jsUrl)a=window.FileAPI.jsUrl;else if(window.FileAPI.jsPath)b=window.FileAPI.jsPath;else for(d=0;d<h.length;d++)if(f=h[d].src,e=f.search(/\/angular\-file\-upload[\-a-zA-z0-9\.]*\.js/),e>-1){b=f.substring(0,e+1);break}null==FileAPI.staticPath&&(FileAPI.staticPath=b),g.setAttribute("src",a||b+"FileAPI.min.js"),document.getElementsByTagName("head")[0].appendChild(g),FileAPI.hasFlash=c()}}(),FileAPI.disableFileInput=function(a,b){b?a.removeClass("js-fileapi-wrapper"):a.addClass("js-fileapi-wrapper")}}window.FileReader||(window.FileReader=function(){var a=this,b=!1;this.listeners={},this.addEventListener=function(b,c){a.listeners[b]=a.listeners[b]||[],a.listeners[b].push(c)},this.removeEventListener=function(b,c){a.listeners[b]&&a.listeners[b].splice(a.listeners[b].indexOf(c),1)},this.dispatchEvent=function(b){var c=a.listeners[b.type];if(c)for(var d=0;d<c.length;d++)c[d].call(a,b)},this.onabort=this.onerror=this.onload=this.onloadstart=this.onloadend=this.onprogress=null;var c=function(b,c){var d={type:b,target:a,loaded:c.loaded,total:c.total,error:c.error};return null!=c.result&&(d.target.result=c.result),d},d=function(d){if(b||(b=!0,a.onloadstart&&a.onloadstart(c("loadstart",d))),"load"===d.type){a.onloadend&&a.onloadend(c("loadend",d));var e=c("load",d);a.onload&&a.onload(e),a.dispatchEvent(e)}else if("progress"===d.type){var e=c("progress",d);a.onprogress&&a.onprogress(e),a.dispatchEvent(e)}else{var e=c("error",d);a.onerror&&a.onerror(e),a.dispatchEvent(e)}};this.readAsArrayBuffer=function(a){FileAPI.readAsBinaryString(a,d)},this.readAsBinaryString=function(a){FileAPI.readAsBinaryString(a,d)},this.readAsDataURL=function(a){FileAPI.readAsDataURL(a,d)},this.readAsText=function(a){FileAPI.readAsText(a,d)}})}();
/**!
* AngularJS file upload/drop directive and service with progress and abort
* @author Danial <danial.farid@gmail.com>
* @version 2.2.2
* @version 3.0.1
*/

@@ -29,3 +29,4 @@ (function() {

var angularFileUpload = angular.module('angularFileUpload', []);
angularFileUpload.version = '2.2.2';
angularFileUpload.version = '3.0.1';
angularFileUpload.service('$upload', ['$http', '$q', '$timeout', function($http, $q, $timeout) {

@@ -110,37 +111,27 @@ function sendHttp(config) {

config.headers['Content-Type'] = undefined;
config.transformRequest = config.transformRequest || $http.defaults.transformRequest;
var formData = new FormData();
var origTransformRequest = config.transformRequest;
var origData = config.data;
config.transformRequest = function(formData, headerGetter) {
function transform(data) {
if (typeof origTransformRequest == 'function') {
data = origTransformRequest(data, headerGetter);
} else {
for (var i = 0; i < origTransformRequest.length; i++) {
if (typeof origTransformRequest[i] == 'function') {
data = origTransformRequest[i](data, headerGetter);
}
}
config.transformRequest = config.transformRequest ?
(Object.prototype.toString.call(config.transformRequest) === '[object Array]' ?
config.transformRequest : [config.transformRequest]) : [];
config.transformRequest.push(function(data, headerGetter) {
var formData = new FormData();
var allFields = {};
for (var key in config.fields) allFields[key] = config.fields[key];
if (data) allFields['data'] = data;
if (config.formDataAppender) {
for (var key in allFields) {
config.formDataAppender(formData, key, allFields[key]);
}
return data
}
if (origData) {
if (config.formDataAppender) {
for (var key in origData) {
var val = origData[key];
config.formDataAppender(formData, key, val);
}
} else if (config.sendDataAsJson) {
origData = transform(origData);
formData.append('data', new Blob([origData], { type: 'application/json' }));
} else {
for (var key in origData) {
var val = transform(origData[key]);
if (val !== undefined) {
if (config.sendObjectAsJson && typeof val === 'object' &&
Object.prototype.toString.call(fileFormName) !== '[object String]') {
formData.append(key, new Blob(val), { type: 'application/json' });
} else {
for (var key in allFields) {
var val = allFields[key];
if (val !== undefined) {
if (Object.prototype.toString.call(val) === '[object String]') {
formData.append(key, val);
} else {
if (config.sendObjectsAsJsonBlob && typeof val === 'object') {
formData.append(key, new Blob([val], { type: 'application/json' }));
} else {
formData.append(key, val);
formData.append(key, JSON.stringify(val));
}

@@ -166,6 +157,4 @@ }

return formData;
};
});
config.data = formData;
return sendHttp(config);

@@ -179,3 +168,4 @@ };

angularFileUpload.directive('ngFileSelect', [ '$parse', '$timeout', '$compile', function($parse, $timeout, $compile) { return {
angularFileUpload.directive('ngFileSelect', [ '$parse', '$timeout', '$compile',
function($parse, $timeout, $compile) { return {
restrict: 'AEC',

@@ -189,19 +179,66 @@ require:'?ngModel',

function handleFileSelect(scope, elem, attr, ngModel, $parse, $timeout, $compile) {
if (attr.ngMultiple && $parse(attr.ngMultiple)(scope)) {
elem.attr('multiple', 'true');
attr['multiple'] = 'true';
function isInputTypeFile() {
return elem[0].tagName.toLowerCase() === 'input' && elem.attr('type') && elem.attr('type').toLowerCase() === 'file';
}
var accept = attr.ngAccept && $parse(attr.ngAccept)(scope);
if (accept) {
elem.attr('accept', accept);
attr['accept'] = accept;
var watchers = [];
function watch(attrVal) {
$timeout(function() {
if (elem.parent().length) {
watchers.push(scope.$watch(attrVal, function(val, oldVal) {
if (val != oldVal) {
recompileElem();
}
}));
}
});
}
var capture = attr.ngCapture && $parse(attr.ngCapture)(scope)
if (capture) {
elem.attr('capture', capture);
attr['capture'] = capture;
function recompileElem() {
var clone = elem.clone();
if (elem.attr('__afu_gen__')) {
angular.element(document.getElementById(elem.attr('id').substring(1))).remove();
}
if (elem.parent().length) {
for (var i = 0; i < watchers.length; i++) {
watchers[i]();
}
elem.replaceWith(clone);
$compile(clone)(scope);
}
return clone;
}
if (elem[0].tagName.toLowerCase() !== 'input' || (elem.attr('type') && elem.attr('type').toLowerCase()) !== 'file') {
var id = '--ng-file-upload-' + Math.random();
var fileElem = angular.element('<input type="file" id="' + id + '">')
function bindAttr(bindAttr, attrName) {
if (bindAttr) {
watch(bindAttr);
var val = $parse(bindAttr)(scope);
if (val) {
elem.attr(attrName, val);
attr[attrName] = val;
} else {
elem.attr(attrName, null);
delete attr[attrName];
}
}
}
bindAttr(attr.ngMultiple, 'multiple');
bindAttr(attr.ngAccept, 'accept');
bindAttr(attr.ngCapture, 'capture');
if (attr['ngFileSelect'] != '') {
attr.ngFileChange = attr.ngFileSelect;
}
function onChangeFn(evt) {
var files = [], fileList, i;
fileList = evt.__files_ || (evt.target && evt.target.files);
updateModel(fileList, attr, ngModel, scope, evt);
};
var fileElem = elem;
if (!isInputTypeFile()) {
fileElem = angular.element('<input type="file">')
if (attr['multiple']) fileElem.attr('multiple', attr['multiple']);

@@ -219,57 +256,85 @@ if (attr['accept']) fileElem.attr('accept', attr['accept']);

fileElem.css('width', '0px').css('height', '0px').css('position', 'absolute').css('padding', 0).css('margin', 0)
.css('overflow', 'hidden').attr('tabindex', '-1').css('opacity', 0).attr('ng-file-generated-elem--', true);
.css('overflow', 'hidden').attr('tabindex', '-1').css('opacity', 0).attr('__afu_gen__', true);
elem.attr('__refElem__', true);
fileElem[0].__refElem__ = elem[0];
elem.parent()[0].insertBefore(fileElem[0], elem[0])
elem.attr('onclick', 'document.getElementById("' + id + '").click()')
// elem.__afu_fileClickDelegate__ = function() {
// fileElem[0].click();
// };
// elem.bind('click', elem.__afu_fileClickDelegate__);
elem.css('overflow', 'hidden');
elem.attr('id', 'e' + id);
var origElem = elem;
elem = fileElem;
elem.bind('click', function(e) {
if (!resetAndClick(e)) {
fileElem[0].click();
}
});
} else {
elem.bind('click', resetAndClick);
}
if (attr['ngFileSelect'] != '') {
attr.ngFileChange = attr.ngFileSelect;
}
if ($parse(attr.resetOnClick)(scope) != false) {
if (navigator.appVersion.indexOf("MSIE 10") !== -1) {
// fix for IE10 cannot set the value of the input to null programmatically by replacing input
var replaceElem = function(evt) {
var inputFile = elem.clone();
inputFile.val('');
elem.replaceWith(inputFile);
$compile(inputFile)(scope);
fileElem = inputFile;
elem = inputFile;
elem.bind('change', onChangeFn);
elem.unbind('click');
elem[0].click();
elem.bind('click', replaceElem);
evt.preventDefault();
evt.stopPropagation();
};
elem.bind('click', replaceElem);
} else {
elem.bind('click', function(evt) {
elem[0].value = null;
});
function resetAndClick(evt) {
var isChanged = fileElem[0].value != null && fileElem[0].value != '';
// reset the value to allow selecting the same file again
fileElem[0].value = null;
// chrome fires change event on popup cancel so no need for special handling but for others
// we cannot detect the user clicking cancel on file select popup and it doesn't fire change event,
// so we fire a null change event before the popup opens for these browsers so if the user
// clicks cancel the previous file value will be removed and model will be notified.
if (navigator.userAgent.indexOf("Chrome") === -1) {
// if this is manual click trigger we don't need to reset again
if (!elem.attr('__afu_clone__')) {
if (isChanged) {
onChangeFn({target: {files: []}});
}
// fix for IE10 cannot set the value of the input to null programmatically by cloning and replacing input
if (navigator.appVersion.indexOf("MSIE 10") !== -1) {
var clone = recompileElem();
clone.attr('__afu_clone__', true);
clone[0].click();
evt.preventDefault();
evt.stopPropagation();
return true;
}
} else {
elem.attr('__afu_clone__', null);
}
}
}
var onChangeFn = function(evt) {
var files = [], fileList, i;
fileList = evt.__files_ || evt.target.files;
updateModel(fileList, attr, ngModel, scope, evt);
};
elem.bind('change', onChangeFn);
fileElem.bind('change', onChangeFn);
elem.on('$destroy', function() {
for (var i = 0; i < watchers.length; i++) {
watchers[i]();
}
if (elem[0] != fileElem[0]) fileElem.remove();
});
watchers.push(scope.$watch(attr.ngModel, function(val, oldVal) {
if (val != oldVal && (val == null || !val.length)) {
if (navigator.appVersion.indexOf("MSIE 10") !== -1) {
recompileElem();
} else {
fileElem[0].value = null;
}
}
}));
function updateModel(fileList, attr, ngModel, scope, evt) {
var files = [];
var files = [], rejFiles = [];
var regexp = attr['accept'] ? new RegExp(globStringToRegex(attr['accept']), 'gi') : null;
for (var i = 0; i < fileList.length; i++) {
files.push(fileList.item(i));
var file = fileList.item(i);
if (!regexp || file.type.match(regexp) || (file.name != null && file.name.match(regexp))) {
files.push(file);
} else {
rejFiles.push(file);
}
}
if (ngModel) {
$timeout(function() {
scope[attr.ngModel] ? scope[attr.ngModel].value = files : scope[attr.ngModel] = files;
if (scope[attr.ngModel]) scope[attr.ngModel].value = files
scope[attr.ngModel] = files;
ngModel && ngModel.$setViewValue(files != null && files.length == 0 ? '' : files);
if (attr['ngModelRejected']) {
if (scope[attr.ngModelRejected]) scope[attr.ngModelRejected].value = rejFiles;
scope[attr.ngModelRejected] = rejFiles;
}
});

@@ -280,4 +345,5 @@ }

$parse(attr.ngFileChange)(scope, {
$files : files,
$event : evt
$files: files,
$rejectedFiles: rejFiles,
$event: evt
});

@@ -332,3 +398,3 @@ });

var accept = $parse(attr.ngAccept)(scope) || attr.accept;
var regexp = accept ? new RegExp(globStringToRegex(accept)) : null;
var regexp = accept ? new RegExp(globStringToRegex(accept), 'gi') : null;
var actualDragOverClass;

@@ -363,16 +429,18 @@ elem[0].addEventListener('dragover', function(evt) {

extractFiles(evt, function(files, rejFiles) {
if (ngModel) {
scope[attr.ngModel] ? scope[attr.ngModel].value = files : scope[attr.ngModel] = files;
ngModel && ngModel.$setViewValue(files != null && files.length == 0 ? '' : files);
}
if (attr['ngFileRejectedModel']) {
scope[attr.ngFileRejectedModel] ? scope[attr.ngFileRejectedModel].value = rejFiles :
scope[attr.ngFileRejectedModel] = rejFiles;
}
$timeout(function() {
if (ngModel) {
if (scope[attr.ngModel]) scope[attr.ngModel].value = files;
scope[attr.ngModel] = files;
ngModel && ngModel.$setViewValue(files != null && files.length == 0 ? '' : files);
}
if (attr['ngModelRejected']) {
if (scope[attr.ngModelRejected]) scope[attr.ngModelRejected].value = rejFiles;
scope[attr.ngModelRejected] = rejFiles;
}
});
$timeout(function() {
$parse(attr.ngFileChange)(scope, {
$files : files,
$files: files,
$rejectedFiles: rejFiles,
$event : evt
$event: evt
});

@@ -526,2 +594,5 @@ });

for (var i = 0; i < split.length; i++) {
if (split[i].indexOf('.') == 0) {
split[i] = '*' + split[i];
}
result += '(' + globStringToRegex(split[i]) + ')';

@@ -539,2 +610,8 @@ if (i < split.length - 1) {

var ngFileUpload = angular.module('ngFileUpload', []);
for (key in angularFileUpload) {
ngFileUpload[key] = angularFileUpload[key];
}
})();

@@ -1,2 +0,2 @@

/*! 2.2.2 */
!function(){function a(a,b){window.XMLHttpRequest.prototype[a]=b(window.XMLHttpRequest.prototype[a])}function b(a,b,c,d,e,f,g){function h(a,b,c,d,g){for(var h=[],i=0;i<a.length;i++)h.push(a.item(i));c&&f(function(){d[b.ngModel]?d[b.ngModel].value=h:d[b.ngModel]=h,c&&c.$setViewValue(null!=h&&0==h.length?"":h)}),b.ngFileChange&&""!=b.ngFileChange&&f(function(){e(b.ngFileChange)(d,{$files:h,$event:g})})}c.ngMultiple&&e(c.ngMultiple)(a)&&(b.attr("multiple","true"),c.multiple="true");var i=c.ngAccept&&e(c.ngAccept)(a);i&&(b.attr("accept",i),c.accept=i);var j=c.ngCapture&&e(c.ngCapture)(a);if(j&&(b.attr("capture",j),c.capture=j),"input"!==b[0].tagName.toLowerCase()||"file"!==(b.attr("type")&&b.attr("type").toLowerCase())){var k="--ng-file-upload-"+Math.random(),l=angular.element('<input type="file" id="'+k+'">');c.multiple&&l.attr("multiple",c.multiple),c.accept&&l.attr("accept",c.accept),c.capture&&l.attr("capture",c.capture);for(var m in c)if(0==m.indexOf("inputFile")){var n=m.substring("inputFile".length);n=n[0].toLowerCase()+n.substring(1),l.attr(n,c[m])}l.css("width","0px").css("height","0px").css("position","absolute").css("padding",0).css("margin",0).css("overflow","hidden").attr("tabindex","-1").css("opacity",0).attr("ng-file-generated-elem--",!0),b.parent()[0].insertBefore(l[0],b[0]),b.attr("onclick",'document.getElementById("'+k+'").click()'),b.css("overflow","hidden"),b.attr("id","e"+k);b=l}if(""!=c.ngFileSelect&&(c.ngFileChange=c.ngFileSelect),0!=e(c.resetOnClick)(a))if(-1!==navigator.appVersion.indexOf("MSIE 10")){var o=function(c){var d=b.clone();d.val(""),b.replaceWith(d),g(d)(a),l=d,b=d,b.bind("change",p),b.unbind("click"),b[0].click(),b.bind("click",o),c.preventDefault(),c.stopPropagation()};b.bind("click",o)}else b.bind("click",function(){b[0].value=null});var p=function(b){var e;e=b.__files_||b.target.files,h(e,c,d,a,b)};b.bind("change",p)}function c(a,b,c,g,h,i,j){function k(a,b,c){var d=!0;if(s){var e=c.dataTransfer.items;if(null!=e)for(var f=0;f<e.length&&d;f++)d=d&&("file"==e[f].kind||""==e[f].kind)&&(null!=e[f].type.match(s)||null!=e[f].name&&null!=e[f].name.match(s))}var g=h(b.dragOverClass)(a,{$event:c});return g&&(g.delay&&(q=g.delay),g.accept&&(g=d?g.accept:g.reject)),g||b.dragOverClass||"dragover"}function l(a,b,c,d){function f(a){!s||a.type.match(s)||null!=a.name&&a.name.match(s)?h.push(a):k.push(a)}function g(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;f({name:b.name,type:"directory",path:d});var e=b.createReader(),h=[];m++;var i=function(){e.readEntries(function(d){try{if(d.length)h=h.concat(Array.prototype.slice.call(d||[],0)),i();else{for(var e=0;e<h.length;e++)g(a,h[e],(c?c:"")+b.name+"/");m--}}catch(f){m--,console.error(f)}},function(){m--})};i()}else m++,b.file(function(a){try{m--,a.path=(c?c:"")+a.name,f(a)}catch(b){m--,console.error(b)}},function(){m--})}var h=[],k=[],l=a.dataTransfer.items,m=0;if(l&&l.length>0&&"file"!=j.protocol())for(var n=0;n<l.length;n++){if(l[n].webkitGetAsEntry&&l[n].webkitGetAsEntry()&&l[n].webkitGetAsEntry().isDirectory){var o=l[n].webkitGetAsEntry();if(o.isDirectory&&!c)continue;null!=o&&(e(o.name)?g(h,o):l[n].webkitGetAsEntry().isDirectory||f(l[n].getAsFile()))}else{var p=l[n].getAsFile();null!=p&&f(p)}if(!d&&h.length>0)break}else{var q=a.dataTransfer.files;if(null!=q)for(var n=0;n<q.length&&(f(q.item(n)),d||!(h.length>0));n++);}var r=0;!function t(a){i(function(){if(m)10*r++<2e4&&t(10);else{if(!d&&h.length>1){for(var a=0;"directory"==h[a].type;)a++;h=[h[a]]}b(h,k)}},a||0)}()}var m=d();if(c.dropAvailable&&i(function(){a.dropAvailable?a.dropAvailable.value=m:a.dropAvailable=m}),!m)return 0!=h(c.hideOnDropNotAvailable)(a)&&b.css("display","none"),void 0;var n,o=null,p=h(c.stopPropagation)(a),q=1,r=h(c.ngAccept)(a)||c.accept,s=r?new RegExp(f(r)):null;b[0].addEventListener("dragover",function(d){d.preventDefault(),p&&d.stopPropagation(),i.cancel(o),a.actualDragOverClass||(n=k(a,c,d)),b.addClass(n)},!1),b[0].addEventListener("dragenter",function(a){a.preventDefault(),p&&a.stopPropagation()},!1),b[0].addEventListener("dragleave",function(){o=i(function(){b.removeClass(n),n=null},q||1)},!1),""!=c.ngFileDrop&&(c.ngFileChange=a.ngFileDrop),b[0].addEventListener("drop",function(d){d.preventDefault(),p&&d.stopPropagation(),b.removeClass(n),n=null,l(d,function(b,e){g&&(a[c.ngModel]?a[c.ngModel].value=b:a[c.ngModel]=b,g&&g.$setViewValue(null!=b&&0==b.length?"":b)),c.ngFileRejectedModel&&(a[c.ngFileRejectedModel]?a[c.ngFileRejectedModel].value=e:a[c.ngFileRejectedModel]=e),i(function(){h(c.ngFileChange)(a,{$files:b,$rejectedFiles:e,$event:d})})},0!=h(c.allowDir)(a),c.multiple||h(c.ngMultiple)(a))},!1)}function d(){var a=document.createElement("div");return"draggable"in a&&"ondrop"in a}function e(a){return/^[\000-\177]*$/.test(a)}function f(a){if(a.length>2&&"/"===a[0]&&"/"===a[a.length-1])return a.substring(1,a.length-1);var b=a.split(","),c="";if(b.length>1)for(var d=0;d<b.length;d++)c+="("+f(b[d])+")",d<b.length-1&&(c+="|");else c="^"+a.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$",c=c.replace(/\\\*/g,".*").replace(/\\\?/g,".");return c}window.XMLHttpRequest&&!window.XMLHttpRequest.__isFileAPIShim&&a("setRequestHeader",function(a){return function(b,c){if("__setXHR_"===b){var d=c(this);d instanceof Function&&d(this)}else a.apply(this,arguments)}});var g=angular.module("angularFileUpload",[]);g.version="2.2.2",g.service("$upload",["$http","$q","$timeout",function(a,b,c){function d(d){d.method=d.method||"POST",d.headers=d.headers||{},d.transformRequest=d.transformRequest||function(b,c){return window.ArrayBuffer&&b instanceof window.ArrayBuffer?b:a.defaults.transformRequest[0](b,c)};var e=b.defer(),f=e.promise;return d.headers.__setXHR_=function(){return function(a){a&&(d.__XHR=a,d.xhrFn&&d.xhrFn(a),a.upload.addEventListener("progress",function(a){a.config=d,e.notify?e.notify(a):f.progress_fn&&c(function(){f.progress_fn(a)})},!1),a.upload.addEventListener("load",function(a){a.lengthComputable&&(a.config=d,e.notify?e.notify(a):f.progress_fn&&c(function(){f.progress_fn(a)}))},!1))}},a(d).then(function(a){e.resolve(a)},function(a){e.reject(a)},function(a){e.notify(a)}),f.success=function(a){return f.then(function(b){a(b.data,b.status,b.headers,d)}),f},f.error=function(a){return f.then(null,function(b){a(b.data,b.status,b.headers,d)}),f},f.progress=function(a){return f.progress_fn=a,f.then(null,null,function(b){a(b)}),f},f.abort=function(){return d.__XHR&&c(function(){d.__XHR.abort()}),f},f.xhr=function(a){return d.xhrFn=function(b){return function(){b&&b.apply(f,arguments),a.apply(f,arguments)}}(d.xhrFn),f},f}this.upload=function(b){b.headers=b.headers||{},b.headers["Content-Type"]=void 0,b.transformRequest=b.transformRequest||a.defaults.transformRequest;var c=new FormData,e=b.transformRequest,f=b.data;return b.transformRequest=function(a,c){function d(a){if("function"==typeof e)a=e(a,c);else for(var b=0;b<e.length;b++)"function"==typeof e[b]&&(a=e[b](a,c));return a}if(f)if(b.formDataAppender)for(var g in f){var h=f[g];b.formDataAppender(a,g,h)}else if(b.sendDataAsJson)f=d(f),a.append("data",new Blob([f],{type:"application/json"}));else for(var g in f){var h=d(f[g]);void 0!==h&&(b.sendObjectAsJson&&"object"==typeof h&&"[object String]"!==Object.prototype.toString.call(i)?a.append(g,new Blob(h),{type:"application/json"}):a.append(g,h))}if(null!=b.file){var i=b.fileFormDataName||"file";if("[object Array]"===Object.prototype.toString.call(b.file))for(var j="[object String]"===Object.prototype.toString.call(i),k=0;k<b.file.length;k++)a.append(j?i:i[k],b.file[k],b.fileName&&b.fileName[k]||b.file[k].name);else a.append(i,b.file,b.fileName||b.file.name)}return a},b.data=c,d(b)},this.http=function(a){return d(a)}}]),g.directive("ngFileSelect",["$parse","$timeout","$compile",function(a,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){b(e,f,g,h,a,c,d)}}}]),g.directive("ngFileDrop",["$parse","$timeout","$location",function(a,b,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){c(e,f,g,h,a,b,d)}}}]),g.directive("ngNoFileDrop",function(){return function(a,b){d()&&b.css("display","none")}}),g.directive("ngFileDropAvailable",["$parse","$timeout",function(a,b){return function(c,e,f){if(d()){var g=a(f.ngFileDropAvailable);b(function(){g(c)})}}}])}();
/*! 3.0.1 */
!function(){function a(a,b){window.XMLHttpRequest.prototype[a]=b(window.XMLHttpRequest.prototype[a])}function b(a,b,c,d,e,g,h){function i(){return"input"===b[0].tagName.toLowerCase()&&b.attr("type")&&"file"===b.attr("type").toLowerCase()}function j(c){g(function(){b.parent().length&&p.push(a.$watch(c,function(a,b){a!=b&&k()}))})}function k(){var c=b.clone();if(b.attr("__afu_gen__")&&angular.element(document.getElementById(b.attr("id").substring(1))).remove(),b.parent().length){for(var d=0;d<p.length;d++)p[d]();b.replaceWith(c),h(c)(a)}return c}function l(d,f){if(d){j(d);var g=e(d)(a);g?(b.attr(f,g),c[f]=g):(b.attr(f,null),delete c[f])}}function m(b){var e;e=b.__files_||b.target&&b.target.files,o(e,c,d,a,b)}function n(a){var c=null!=q[0].value&&""!=q[0].value;if(q[0].value=null,-1===navigator.userAgent.indexOf("Chrome"))if(b.attr("__afu_clone__"))b.attr("__afu_clone__",null);else if(c&&m({target:{files:[]}}),-1!==navigator.appVersion.indexOf("MSIE 10")){var d=k();return d.attr("__afu_clone__",!0),d[0].click(),a.preventDefault(),a.stopPropagation(),!0}}function o(a,b,c,d,h){for(var i=[],j=[],k=b.accept?new RegExp(f(b.accept),"gi"):null,l=0;l<a.length;l++){var m=a.item(l);!k||m.type.match(k)||null!=m.name&&m.name.match(k)?i.push(m):j.push(m)}c&&g(function(){d[b.ngModel]&&(d[b.ngModel].value=i),d[b.ngModel]=i,c&&c.$setViewValue(null!=i&&0==i.length?"":i),b.ngModelRejected&&(d[b.ngModelRejected]&&(d[b.ngModelRejected].value=j),d[b.ngModelRejected]=j)}),b.ngFileChange&&""!=b.ngFileChange&&g(function(){e(b.ngFileChange)(d,{$files:i,$rejectedFiles:j,$event:h})})}var p=[];l(c.ngMultiple,"multiple"),l(c.ngAccept,"accept"),l(c.ngCapture,"capture"),""!=c.ngFileSelect&&(c.ngFileChange=c.ngFileSelect);var q=b;if(i())b.bind("click",n);else{q=angular.element('<input type="file">'),c.multiple&&q.attr("multiple",c.multiple),c.accept&&q.attr("accept",c.accept),c.capture&&q.attr("capture",c.capture);for(var r in c)if(0==r.indexOf("inputFile")){var s=r.substring("inputFile".length);s=s[0].toLowerCase()+s.substring(1),q.attr(s,c[r])}q.css("width","0px").css("height","0px").css("position","absolute").css("padding",0).css("margin",0).css("overflow","hidden").attr("tabindex","-1").css("opacity",0).attr("__afu_gen__",!0),b.attr("__refElem__",!0),q[0].__refElem__=b[0],b.parent()[0].insertBefore(q[0],b[0]),b.css("overflow","hidden"),b.bind("click",function(a){n(a)||q[0].click()})}q.bind("change",m),b.on("$destroy",function(){for(var a=0;a<p.length;a++)p[a]();b[0]!=q[0]&&q.remove()}),p.push(a.$watch(c.ngModel,function(a,b){a==b||null!=a&&a.length||(-1!==navigator.appVersion.indexOf("MSIE 10")?k():q[0].value=null)}))}function c(a,b,c,g,h,i,j){function k(a,b,c){var d=!0;if(s){var e=c.dataTransfer.items;if(null!=e)for(var f=0;f<e.length&&d;f++)d=d&&("file"==e[f].kind||""==e[f].kind)&&(null!=e[f].type.match(s)||null!=e[f].name&&null!=e[f].name.match(s))}var g=h(b.dragOverClass)(a,{$event:c});return g&&(g.delay&&(q=g.delay),g.accept&&(g=d?g.accept:g.reject)),g||b.dragOverClass||"dragover"}function l(a,b,c,d){function f(a){!s||a.type.match(s)||null!=a.name&&a.name.match(s)?h.push(a):k.push(a)}function g(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;f({name:b.name,type:"directory",path:d});var e=b.createReader(),h=[];m++;var i=function(){e.readEntries(function(d){try{if(d.length)h=h.concat(Array.prototype.slice.call(d||[],0)),i();else{for(var e=0;e<h.length;e++)g(a,h[e],(c?c:"")+b.name+"/");m--}}catch(f){m--,console.error(f)}},function(){m--})};i()}else m++,b.file(function(a){try{m--,a.path=(c?c:"")+a.name,f(a)}catch(b){m--,console.error(b)}},function(){m--})}var h=[],k=[],l=a.dataTransfer.items,m=0;if(l&&l.length>0&&"file"!=j.protocol())for(var n=0;n<l.length;n++){if(l[n].webkitGetAsEntry&&l[n].webkitGetAsEntry()&&l[n].webkitGetAsEntry().isDirectory){var o=l[n].webkitGetAsEntry();if(o.isDirectory&&!c)continue;null!=o&&(e(o.name)?g(h,o):l[n].webkitGetAsEntry().isDirectory||f(l[n].getAsFile()))}else{var p=l[n].getAsFile();null!=p&&f(p)}if(!d&&h.length>0)break}else{var q=a.dataTransfer.files;if(null!=q)for(var n=0;n<q.length&&(f(q.item(n)),d||!(h.length>0));n++);}var r=0;!function t(a){i(function(){if(m)10*r++<2e4&&t(10);else{if(!d&&h.length>1){for(var a=0;"directory"==h[a].type;)a++;h=[h[a]]}b(h,k)}},a||0)}()}var m=d();if(c.dropAvailable&&i(function(){a.dropAvailable?a.dropAvailable.value=m:a.dropAvailable=m}),!m)return 0!=h(c.hideOnDropNotAvailable)(a)&&b.css("display","none"),void 0;var n,o=null,p=h(c.stopPropagation)(a),q=1,r=h(c.ngAccept)(a)||c.accept,s=r?new RegExp(f(r),"gi"):null;b[0].addEventListener("dragover",function(d){d.preventDefault(),p&&d.stopPropagation(),i.cancel(o),a.actualDragOverClass||(n=k(a,c,d)),b.addClass(n)},!1),b[0].addEventListener("dragenter",function(a){a.preventDefault(),p&&a.stopPropagation()},!1),b[0].addEventListener("dragleave",function(){o=i(function(){b.removeClass(n),n=null},q||1)},!1),""!=c.ngFileDrop&&(c.ngFileChange=a.ngFileDrop),b[0].addEventListener("drop",function(d){d.preventDefault(),p&&d.stopPropagation(),b.removeClass(n),n=null,l(d,function(b,e){i(function(){g&&(a[c.ngModel]&&(a[c.ngModel].value=b),a[c.ngModel]=b,g&&g.$setViewValue(null!=b&&0==b.length?"":b)),c.ngModelRejected&&(a[c.ngModelRejected]&&(a[c.ngModelRejected].value=e),a[c.ngModelRejected]=e)}),i(function(){h(c.ngFileChange)(a,{$files:b,$rejectedFiles:e,$event:d})})},0!=h(c.allowDir)(a),c.multiple||h(c.ngMultiple)(a))},!1)}function d(){var a=document.createElement("div");return"draggable"in a&&"ondrop"in a}function e(a){return/^[\000-\177]*$/.test(a)}function f(a){if(a.length>2&&"/"===a[0]&&"/"===a[a.length-1])return a.substring(1,a.length-1);var b=a.split(","),c="";if(b.length>1)for(var d=0;d<b.length;d++)0==b[d].indexOf(".")&&(b[d]="*"+b[d]),c+="("+f(b[d])+")",d<b.length-1&&(c+="|");else c="^"+a.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$",c=c.replace(/\\\*/g,".*").replace(/\\\?/g,".");return c}window.XMLHttpRequest&&!window.XMLHttpRequest.__isFileAPIShim&&a("setRequestHeader",function(a){return function(b,c){if("__setXHR_"===b){var d=c(this);d instanceof Function&&d(this)}else a.apply(this,arguments)}});var g=angular.module("angularFileUpload",[]);g.version="3.0.1",g.service("$upload",["$http","$q","$timeout",function(a,b,c){function d(d){d.method=d.method||"POST",d.headers=d.headers||{},d.transformRequest=d.transformRequest||function(b,c){return window.ArrayBuffer&&b instanceof window.ArrayBuffer?b:a.defaults.transformRequest[0](b,c)};var e=b.defer(),f=e.promise;return d.headers.__setXHR_=function(){return function(a){a&&(d.__XHR=a,d.xhrFn&&d.xhrFn(a),a.upload.addEventListener("progress",function(a){a.config=d,e.notify?e.notify(a):f.progress_fn&&c(function(){f.progress_fn(a)})},!1),a.upload.addEventListener("load",function(a){a.lengthComputable&&(a.config=d,e.notify?e.notify(a):f.progress_fn&&c(function(){f.progress_fn(a)}))},!1))}},a(d).then(function(a){e.resolve(a)},function(a){e.reject(a)},function(a){e.notify(a)}),f.success=function(a){return f.then(function(b){a(b.data,b.status,b.headers,d)}),f},f.error=function(a){return f.then(null,function(b){a(b.data,b.status,b.headers,d)}),f},f.progress=function(a){return f.progress_fn=a,f.then(null,null,function(b){a(b)}),f},f.abort=function(){return d.__XHR&&c(function(){d.__XHR.abort()}),f},f.xhr=function(a){return d.xhrFn=function(b){return function(){b&&b.apply(f,arguments),a.apply(f,arguments)}}(d.xhrFn),f},f}this.upload=function(a){a.headers=a.headers||{},a.headers["Content-Type"]=void 0;a.transformRequest;return a.transformRequest=a.transformRequest?"[object Array]"===Object.prototype.toString.call(a.transformRequest)?a.transformRequest:[a.transformRequest]:[],a.transformRequest.push(function(b){var c=new FormData,d={};for(var e in a.fields)d[e]=a.fields[e];if(b&&(d.data=b),a.formDataAppender)for(var e in d)a.formDataAppender(c,e,d[e]);else for(var e in d){var f=d[e];void 0!==f&&("[object String]"===Object.prototype.toString.call(f)?c.append(e,f):a.sendObjectsAsJsonBlob&&"object"==typeof f?c.append(e,new Blob([f],{type:"application/json"})):c.append(e,JSON.stringify(f)))}if(null!=a.file){var g=a.fileFormDataName||"file";if("[object Array]"===Object.prototype.toString.call(a.file))for(var h="[object String]"===Object.prototype.toString.call(g),i=0;i<a.file.length;i++)c.append(h?g:g[i],a.file[i],a.fileName&&a.fileName[i]||a.file[i].name);else c.append(g,a.file,a.fileName||a.file.name)}return c}),d(a)},this.http=function(a){return d(a)}}]),g.directive("ngFileSelect",["$parse","$timeout","$compile",function(a,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){b(e,f,g,h,a,c,d)}}}]),g.directive("ngFileDrop",["$parse","$timeout","$location",function(a,b,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){c(e,f,g,h,a,b,d)}}}]),g.directive("ngNoFileDrop",function(){return function(a,b){d()&&b.css("display","none")}}),g.directive("ngFileDropAvailable",["$parse","$timeout",function(a,b){return function(c,e,f){if(d()){var g=a(f.ngFileDropAvailable);b(function(){g(c)})}}}]);var h=angular.module("ngFileUpload",[]);for(key in g)h[key]=g[key]}();

@@ -15,3 +15,3 @@ module.exports = function(grunt) {

cwd : 'demo/war/js/',
src : '<%= pkg.name %>*.js',
src : 'angular-file-upload*.js',
dest : 'dist/',

@@ -65,5 +65,5 @@ flatten : true,

files: {
'demo/war/js/<%= pkg.name %>-all.js':
['demo/war/js/<%= pkg.name %>.js',
'demo/war/js/<%= pkg.name %>-shim.js']
'demo/war/js/angular-file-upload-all.js':
['demo/war/js/angular-file-upload.js',
'demo/war/js/angular-file-upload-shim.js']
}

@@ -78,5 +78,5 @@ }

files : [ {
'dist/<%= pkg.name %>.min.js' : 'dist/<%= pkg.name %>.js',
'dist/<%= pkg.name %>-shim.min.js' : 'dist/<%= pkg.name %>-shim.js',
'dist/<%= pkg.name %>-all.min.js' : 'dist/<%= pkg.name %>-all.js'
'dist/angular-file-upload.min.js' : 'dist/angular-file-upload.js',
'dist/angular-file-upload-shim.min.js' : 'dist/angular-file-upload-shim.js',
'dist/angular-file-upload-all.min.js' : 'dist/angular-file-upload-all.js'
} ]

@@ -83,0 +83,0 @@ }

{
"name": "ng-file-upload",
"version": "2.2.2",
"version": "3.0.1",
"devDependencies": {

@@ -29,3 +29,3 @@ "grunt": "~0.4.1",

],
"author": "Danial Farid",
"author": "danial.farid@gmail.com",
"license": "MIT",

@@ -32,0 +32,0 @@ "bugs": {

angular-file-upload
===================
Lightweight Angular JS directive to upload files.<br/><br/>**Here is the <a href="https://angular-file-upload.appspot.com/" target="_blank">DEMO</a> page**.<br/> To help development of this module get me a <a target="_blank" href="https://angular-file-upload.appspot.com/donate.html">cup of tea <img src="https://angular-file-upload.appspot.com/img/tea.png" width="40" height="24" title="Icon made by Freepik.com"></a> or give it a thumbs up at [ngmodules](http://ngmodules.org/modules/angular-file-upload).
Lightweight Angular JS directive to upload files.<br/><br/>**Here is the <a href="https://angular-file-upload.appspot.com/" target="_blank">DEMO</a> page**.<br/> To help development of this module give it a thumbs up at [ngmodules](http://ngmodules.org/modules/angular-file-upload) or get me a <a target="_blank" href="https://angular-file-upload.appspot.com/donate.html">cup of tea <img src="https://angular-file-upload.appspot.com/img/tea.png" width="40" height="24" title="Icon made by Freepik.com"></a>.
**Migrate to version 3.x** [Change log](https://github.com/danialfarid/angular-file-upload/releases/tag/3.0.0)

@@ -24,2 +25,3 @@ Table of Content:

* [NuGet](#nuget)
* [npm](#npm)
* [Questions, Issues and Contribution](#contrib)

@@ -37,2 +39,3 @@

###Sample:
[jsfiddle http://jsfiddle.net/wsoLzeur/](http://jsfiddle.net/wsoLzeur/)
```html

@@ -44,31 +47,40 @@ <script src="angular.min.js"></script>

<div ng-controller="MyCtrl">
Select File: <div class="button" ng-file-select ng-model="files">Select File</div>
Drop File: <div ng-file-drop ng-model="files" class="drop-box"
drag-over-class="dragover" multiple="true"
allow-dir="true" accept="image/*,application/pdf">
Drop Images or PDFs files here
</div>
<div ng-no-file-drop>File Farg/Drop is not supported for this browser</div>
</div>
<div ng-app="fileUpload" ng-controller="MyCtrl">
watching model:
<div class="button" ng-file-select ng-model="files">Upload ussing model $watch</div>
<div class="button" ng-file-select ng-file-change="upload($files)">Upload on file change</div>
Drop File:
<div ng-file-drop ng-model="files" class="drop-box"
drag-over-class="dragover" ng-multiple="true" allow-dir="true"
accept=".jpg,.png,.pdf">Drop Images or PDFs files here</div>
<div ng-no-file-drop>File Drag/Drop is not supported for this browser</div>
```
JS:
```js
//inject angular file upload directives and service.
angular.module('myApp', ['angularFileUpload']);
//inject angular file upload directives and services.
var app = angular.module('fileUpload', ['angularFileUpload']);
myApp.controller('MyCtrl') = [ '$scope', '$upload', function($scope, $upload) {
$scope.$watch('files', function() {
$scope.upload = $upload.upload({
url: 'server/upload/url',
data: {myObj: $scope.myModelObj},
file: $scope.files
}).progress(function(evt) {
console.log('progress: ' + parseInt(100.0 * evt.loaded / evt.total) + '% file :'+ evt.config.file.name);
}).success(function(data, status, headers, config) {
console.log('file ' + config.file.name + 'is uploaded successfully. Response: ' + data);
app.controller('MyCtrl', ['$scope', '$upload', function ($scope, $upload) {
$scope.$watch('files', function () {
$scope.upload($scope.files);
});
}
})];
$scope.upload = function (files) {
if (files && files.length) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
$upload.upload({
url: 'upload/url',
fields: {'username': $scope.username},
file: file
}).progress(function (evt) {
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
console.log('progress: ' + progressPercentage + '% ' + evt.config.file.name);
}).success(function (data, status, headers, config) {
console.log('file ' + config.file.name + 'uploaded. Response: ' + data);
});
}
}
};
}]);
```

@@ -87,6 +99,6 @@

ng-capture="'camera'|'other'" // allows mobile devices to capture using camera
accept="image/*,*.pdf,*.xml" // see standard HTML file input accept attribute
input-file-...="..." // if you prefix the attr with (data-)input-file- it would
// propagate that property to underlying <input type="file"...>
// see #462. Use only if the elememt is not input type="file" already
ng-accept="'image/*'" // see standard HTML file input accept attribute
ng-model-rejected="rejFiles" // bind to dropped files that do not match the accept wildcard
input-file-...="..." // if element is not input file the attributes prefix with (data-)input-file-
// will be added to underlying <input type="file"...> see #462.
>Upload</button>

@@ -100,4 +112,4 @@ ```

ng-multiple="true|false" // default false, allows selecting multiple files.
accept="image/*" // wildcard filter for file types allowed for drop (comma separated)
ng-file-rejected-model="rejFiles" // bind to dropped files that do not match the accept wildcard
ng-accept="'.pdf,.jpg'" // wildcard filter for file types allowed for drop (comma separated)
ng-mode-rejected="rejFiles" // bind to dropped files that do not match the accept wildcard
allow-dir="true|false" // default true, allow dropping files only for Chrome webkit browser

@@ -131,16 +143,15 @@ drag-over-class="{accept:'acceptClass', reject:'rejectClass', delay:100}|myDragOverClass|

/*
data map. each field will be sent as a form field unless sendDataAsJson is true.
The values are converted to json string unless sendObjectAsJson or transformRequest is specified. */
data: {myObj: $scope.myModelObj},
/*
send the whole data object as a json blob with the key "data". Server will recieve a "data"
form field binary of type 'application/json'. default false html5 only */
sendDataAsJson: true|false,
map of extra form data fields to send along with file. each field will be sent as a form field.
The values are converted to json string or jsob blob depending on 'sendObjectsAsJsonBlob' option. */
fields: {key: $scope.myValue, ...},
/*
if the value of a form field is an object it will send it as an 'application/json' blob type
rather than json string. default false. */
sendObjectAsJson: true|false,
if the value of a form field is an object it will be sent as 'application/json' blob
rather than json string, default false. */
sendObjectsAsJsonBlob: true|false,
/* customize how data is added to the formData. See #40#issuecomment-28612000 for sample code. */
formDataAppender: function(formData, key, val){},
transforRequest: muTransformRequestFn, //called on each field or whole "data" depending on sendDataAsJson
/*
data will be sent as a separate form data field called "data". It will be converted to json string
or jsob blob depending on 'sendObjectsAsJsonBlob' option*/
data: {}.
withCredentials: true|false,

@@ -180,2 +191,3 @@ ... and all other angular $http() options could be used here.

`delay` param is there to fix css3 transition issues from dragging over/out/over [#277](https://github.com/danialfarid/angular-file-upload/issues/277).
##<a name="old_browsers"></a> Old browsers

@@ -201,2 +213,3 @@

//forceLoad: true, html5: false //to debug flash in HTML5 browsers
//noContentTimeout: 10000 (see #528)
}

@@ -226,3 +239,3 @@ </script>

#### <a name="php"></a>PHP
[Wiki Sample] (https://github.com/danialfarid/angular-file-upload/wiki/PHP-Example)
[Wiki Sample] (https://github.com/danialfarid/angular-file-upload/wiki/PHP-Example) and related issue [only one file in $_FILES when uploading multiple files] (https://github.com/danialfarid/angular-file-upload/issues/475)
#### <a name="net"></a>.Net

@@ -362,2 +375,7 @@ Sample client and server code [demo/C#] (https://github.com/danialfarid/angular-file-upload/tree/master/demo/C%23) provided by [AtomStar](https://github.com/AtomStar)

####<a name="npm"></a> NPM
```
npm install ng-file-upload
```
##<a name="contrib"></a> Issues & Contribution

@@ -364,0 +382,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc