ng-file-upload
Advanced tools
Comparing version 3.0.1 to 3.0.2
/**! | ||
* AngularJS file upload/drop directive and service with progress and abort | ||
* @author Danial <danial.farid@gmail.com> | ||
* @version 3.0.1 | ||
* @version 3.0.2 | ||
*/ | ||
@@ -30,3 +30,3 @@ (function() { | ||
angularFileUpload.version = '3.0.1'; | ||
angularFileUpload.version = '3.0.2'; | ||
angularFileUpload.service('$upload', ['$http', '$q', '$timeout', function($http, $q, $timeout) { | ||
@@ -397,2 +397,5 @@ function sendHttp(config) { | ||
if (stopPropagation) evt.stopPropagation(); | ||
// handling dragover events from the Chrome download bar | ||
var b = evt.dataTransfer.effectAllowed; | ||
evt.dataTransfer.dropEffect = ('move' === b || 'linkMove' === b) ? 'move' : 'copy'; | ||
$timeout.cancel(leaveTimeout); | ||
@@ -614,3 +617,3 @@ if (!scope.actualDragOverClass) { | ||
* @author Danial <danial.farid@gmail.com> | ||
* @version 3.0.1 | ||
* @version 3.0.2 | ||
*/ | ||
@@ -617,0 +620,0 @@ |
@@ -396,2 +396,5 @@ /**! | ||
if (stopPropagation) evt.stopPropagation(); | ||
// handling dragover events from the Chrome download bar | ||
var b = evt.dataTransfer.effectAllowed; | ||
evt.dataTransfer.dropEffect = ('move' === b || 'linkMove' === b) ? 'move' : 'copy'; | ||
$timeout.cancel(leaveTimeout); | ||
@@ -398,0 +401,0 @@ if (!scope.actualDragOverClass) { |
@@ -5,3 +5,3 @@ "use strict"; | ||
var app = angular.module('fileUpload', [ 'ngFileUpload' ]); | ||
var version = '3.0.0'; | ||
var version = '3.0.2'; | ||
@@ -196,2 +196,3 @@ app.controller('MyCtrl', [ '$scope', '$http', '$timeout', '$compile', '$upload', function($scope, $http, $timeout, $compile, $upload) { | ||
$scope.editHtml = (localStorage && localStorage.getItem("editHtml" + version)) || $scope.defaultHtml; | ||
$scope.editHtml = $scope.defaultHtml; | ||
function htmlEdit(update) { | ||
@@ -226,9 +227,9 @@ document.getElementById("editArea").innerHTML = $scope.editHtml; | ||
window.addEventListener("dragover", function(e) { | ||
angular.element(window).bind("dragover", function(e) { | ||
e.preventDefault(); | ||
}, false); | ||
window.addEventListener("drop", function(e) { | ||
}); | ||
angular.element(window).bind("drop", function(e) { | ||
e.preventDefault(); | ||
}, false); | ||
}); | ||
} ]); |
/**! | ||
* AngularJS file upload/drop directive and service with progress and abort | ||
* @author Danial <danial.farid@gmail.com> | ||
* @version 3.0.1 | ||
* @version 3.0.2 | ||
*/ | ||
@@ -30,3 +30,3 @@ (function() { | ||
angularFileUpload.version = '3.0.1'; | ||
angularFileUpload.version = '3.0.2'; | ||
angularFileUpload.service('$upload', ['$http', '$q', '$timeout', function($http, $q, $timeout) { | ||
@@ -397,2 +397,5 @@ function sendHttp(config) { | ||
if (stopPropagation) evt.stopPropagation(); | ||
// handling dragover events from the Chrome download bar | ||
var b = evt.dataTransfer.effectAllowed; | ||
evt.dataTransfer.dropEffect = ('move' === b || 'linkMove' === b) ? 'move' : 'copy'; | ||
$timeout.cancel(leaveTimeout); | ||
@@ -614,3 +617,3 @@ if (!scope.actualDragOverClass) { | ||
* @author Danial <danial.farid@gmail.com> | ||
* @version 3.0.1 | ||
* @version 3.0.2 | ||
*/ | ||
@@ -617,0 +620,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*! 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)}})}(); | ||
/*! 3.0.2 */ | ||
!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();var e=d.dataTransfer.effectAllowed;d.dataTransfer.dropEffect="move"===e||"linkMove"===e?"move":"copy",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.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(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 3.0.1 | ||
* @version 3.0.2 | ||
*/ | ||
@@ -8,0 +8,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*! 3.0.1 */ | ||
/*! 3.0.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"}))},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 3.0.1 | ||
* @version 3.0.2 | ||
*/ | ||
@@ -30,3 +30,3 @@ (function() { | ||
angularFileUpload.version = '3.0.1'; | ||
angularFileUpload.version = '3.0.2'; | ||
angularFileUpload.service('$upload', ['$http', '$q', '$timeout', function($http, $q, $timeout) { | ||
@@ -397,2 +397,5 @@ function sendHttp(config) { | ||
if (stopPropagation) evt.stopPropagation(); | ||
// handling dragover events from the Chrome download bar | ||
var b = evt.dataTransfer.effectAllowed; | ||
evt.dataTransfer.dropEffect = ('move' === b || 'linkMove' === b) ? 'move' : 'copy'; | ||
$timeout.cancel(leaveTimeout); | ||
@@ -399,0 +402,0 @@ if (!scope.actualDragOverClass) { |
@@ -1,2 +0,2 @@ | ||
/*! 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]}(); | ||
/*! 3.0.2 */ | ||
!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();var e=d.dataTransfer.effectAllowed;d.dataTransfer.dropEffect="move"===e||"linkMove"===e?"move":"copy",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.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(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]}(); |
{ | ||
"name": "ng-file-upload", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"devDependencies": { | ||
@@ -5,0 +5,0 @@ "grunt": "~0.4.1", |
@@ -38,3 +38,3 @@ angular-file-upload | ||
###Sample: | ||
[jsfiddle http://jsfiddle.net/wsoLzeur/](http://jsfiddle.net/wsoLzeur/) | ||
[jsfiddle http://jsfiddle.net/nmdcwf3w/](http://jsfiddle.net/nmdcwf3w/) | ||
```html | ||
@@ -110,3 +110,3 @@ <script src="angular.min.js"></script> | ||
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 | ||
ng-model-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 | ||
@@ -113,0 +113,0 @@ drag-over-class="{accept:'acceptClass', reject:'rejectClass', delay:100}|myDragOverClass| |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2154394
7957