ng-file-upload
Advanced tools
Comparing version 5.2.0 to 6.0.0
@@ -1,2 +0,2 @@ | ||
/*! 5.2.0 */ | ||
/*! 6.0.0 */ | ||
/*! FileAPI 2.0.7 - BSD | git://github.com/mailru/FileAPI.git | ||
@@ -3,0 +3,0 @@ * FileAPI — a set of javascript tools for working with files. Multiupload, drag'n'drop and chunked file upload. Images: crop, resize and auto orientation by EXIF. |
@@ -5,3 +5,3 @@ /**! | ||
* @author Danial <danial.farid@gmail.com> | ||
* @version 5.2.0 | ||
* @version 6.0.0 | ||
*/ | ||
@@ -434,3 +434,3 @@ | ||
* @author Danial <danial.farid@gmail.com> | ||
* @version 5.2.0 | ||
* @version 6.0.0 | ||
*/ | ||
@@ -456,3 +456,3 @@ | ||
ngFileUpload.version = '5.2.0'; | ||
ngFileUpload.version = '6.0.0'; | ||
ngFileUpload.defaults = {}; | ||
@@ -689,4 +689,5 @@ | ||
/** @namespace attr.ngModel */ | ||
/** @namespace attr.ngModelRejected */ | ||
/** @namespace attr.ngfModel */ | ||
/** @namespace attr.ngModelRejected */ | ||
/** @namespace attr.ngfModelRejected */ | ||
/** @namespace attr.ngfMultiple */ | ||
@@ -945,16 +946,17 @@ /** @namespace attr.ngfCapture */ | ||
} | ||
var file = files && files[0]; | ||
var file = files && files.length ? files[0] : null; | ||
if (ngModel) { | ||
$parse(getAttr(attr, 'ngModel')).assign(scope, files); | ||
var singleModel = !$parse(getAttr(attr, 'multiple'))(scope) && !keep; | ||
var ngfModel = getAttr(attr, 'ngfModel'); | ||
if (ngfModel) { | ||
$parse(ngfModel).assign(scope, singleModel ? file : files); | ||
} | ||
var singleModel = !$parse(getAttr(attr, 'ngfMultiple'))(scope) && ! getAttr(attr, 'multiple') && !keep; | ||
$parse(getAttr(attr, 'ngModel')).assign(scope, singleModel ? file : files); | ||
$timeout(function () { | ||
if (ngModel) { | ||
ngModel.$setViewValue(files != null && files.length === 0 ? null : files); | ||
ngModel.$setViewValue(singleModel ? file : (files != null && files.length === 0 ? null : files)); | ||
} | ||
}); | ||
} | ||
var ngfModel = getAttr(attr, 'ngfModel'); | ||
if (ngfModel) { | ||
$parse(ngfModel).assign(scope, files); | ||
} | ||
if (getAttr(attr, 'ngModelRejected')) { | ||
@@ -961,0 +963,0 @@ $parse(getAttr(attr, 'ngModelRejected')).assign(scope, rejFiles); |
@@ -1,2 +0,2 @@ | ||
/*! 5.2.0 */ | ||
!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){}}if(window.FileAPI||(window.FileAPI={}),FileAPI.shouldLoad=window.XMLHttpRequest&&!window.FormData||FileAPI.forceLoad,FileAPI.shouldLoad){var c=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,d,e){c(this),this.__url=d;try{a.apply(this,[b,d,e])}catch(f){f.message.indexOf("Access is denied")>-1&&(this.__origError=f,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,d){if("__setXHR_"===b){c(this);var e=d(this);e instanceof Function&&e(this)}else this.__requestHeaders=this.__requestHeaders||{},this.__requestHeaders[b]=d,a.apply(this,arguments)}}),a("send",function(a){return function(){var c=this;if(arguments[0]&&arguments[0].__isFileAPIShim){var d=arguments[0],e={url:c.__url,jsonp:!1,cache:!0,complete:function(a,d){c.__completed=!0,!a&&c.__listeners.load&&c.__listeners.load({type:"load",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),!a&&c.__listeners.loadend&&c.__listeners.loadend({type:"loadend",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),"abort"===a&&c.__listeners.abort&&c.__listeners.abort({type:"abort",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),void 0!==d.status&&b(c,"status",function(){return 0===d.status&&a&&"abort"!==a?500:d.status}),void 0!==d.statusText&&b(c,"statusText",function(){return d.statusText}),b(c,"readyState",function(){return 4}),void 0!==d.response&&b(c,"response",function(){return d.response});var e=d.responseText||(a&&0===d.status&&"abort"!==a?a:void 0);b(c,"responseText",function(){return e}),b(c,"response",function(){return e}),a&&b(c,"err",function(){return a}),c.__fileApiXHR=d,c.onreadystatechange&&c.onreadystatechange(),c.onload&&c.onload()},progress:function(a){if(a.target=c,c.__listeners.progress&&c.__listeners.progress(a),c.__total=a.total,c.__loaded=a.loaded,a.total===a.loaded){var b=this;setTimeout(function(){c.__completed||(c.getAllResponseHeaders=function(){},b.complete(null,{status:204,statusText:"No Content"}))},FileAPI.noContentTimeout||1e4)}},headers:c.__requestHeaders};e.data={},e.files={};for(var f=0;f<d.data.length;f++){var g=d.data[f];null!=g.val&&null!=g.val.name&&null!=g.val.size&&null!=g.val.type?e.files[g.key]=g.val:e.data[g.key]=g.val}setTimeout(function(){if(!FileAPI.hasFlash)throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';c.__fileApiXHR=FileAPI.upload(e)},1)}else{if(this.__origError)throw this.__origError;a.apply(c,arguments)}}}),window.XMLHttpRequest.__isFileAPIShim=!0,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(){function a(a){return"input"===a[0].tagName.toLowerCase()&&a.attr("type")&&"file"===a.attr("type").toLowerCase()}function b(){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}function c(a){var b=0,c=0;if(window.jQuery)return jQuery(a).offset();if(a.offsetParent)do b+=a.offsetLeft-a.scrollLeft,c+=a.offsetTop-a.scrollTop,a=a.offsetParent;while(a);return{left:b,top:c}}if(FileAPI.shouldLoad){if(FileAPI.forceLoad&&(FileAPI.html5=!1),!FileAPI.upload){var d,e,f,g,h,i=document.createElement("script"),j=document.getElementsByTagName("script");if(window.FileAPI.jsUrl)d=window.FileAPI.jsUrl;else if(window.FileAPI.jsPath)e=window.FileAPI.jsPath;else for(f=0;f<j.length;f++)if(h=j[f].src,g=h.search(/\/ng\-file\-upload[\-a-zA-z0-9\.]*\.js/),g>-1){e=h.substring(0,g+1);break}null==FileAPI.staticPath&&(FileAPI.staticPath=e),i.setAttribute("src",d||e+"FileAPI.min.js"),document.getElementsByTagName("head")[0].appendChild(i),FileAPI.hasFlash=b()}FileAPI.ngfFixIE=function(d,e,f,g){if(!b())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';var h=function(){if(d.attr("disabled"))d.$$ngfRefElem.removeClass("js-fileapi-wrapper");else{var b=d.$$ngfRefElem;b?f(d.$$ngfRefElem):(b=d.$$ngfRefElem=e(),b.addClass("js-fileapi-wrapper"),!a(d),setTimeout(function(){b.bind("mouseenter",h)},10),b.bind("change",function(a){i.apply(this,[a]),g.apply(this,[a])})),a(d)||b.css("position","absolute").css("top",c(d[0]).top+"px").css("left",c(d[0]).left+"px").css("width",d[0].offsetWidth+"px").css("height",d[0].offsetHeight+"px").css("filter","alpha(opacity=0)").css("display",d.css("display")).css("overflow","hidden").css("z-index","900000").css("visibility","visible")}};d.bind("mouseenter",h);var i=function(a){for(var b=FileAPI.getFiles(a),c=0;c<b.length;c++)void 0===b[c].size&&(b[c].size=0),void 0===b[c].name&&(b[c].name="file"),void 0===b[c].type&&(b[c].type="undefined");a.target||(a.target={}),a.target.files=b,a.target.files!==b&&(a.__files_=b),(a.__files_||a.target.files).item=function(b){return(a.__files_||a.target.files)[b]||null}}},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){b||(b=!0,a.onloadstart&&a.onloadstart(c("loadstart",d)));var e;"load"===d.type?(a.onloadend&&a.onloadend(c("loadend",d)),e=c("load",d),a.onload&&a.onload(e),a.dispatchEvent(e)):"progress"===d.type?(e=c("progress",d),a.onprogress&&a.onprogress(e),a.dispatchEvent(e)):(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)}}),!window.XMLHttpRequest||window.FileAPI&&FileAPI.shouldLoad||(window.XMLHttpRequest.prototype.setRequestHeader=function(a){return function(b,c){if("__setXHR_"===b){var d=c(this);d instanceof Function&&d(this)}else a.apply(this,arguments)}}(window.XMLHttpRequest.prototype.setRequestHeader));var ngFileUpload=angular.module("ngFileUpload",[]);ngFileUpload.version="5.2.0",ngFileUpload.defaults={},ngFileUpload.service("Upload",["$http","$q","$timeout",function(a,b,c){function d(d){d.method=d.method||"POST",d.headers=d.headers||{};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.progressFunc&&c(function(){f.progressFunc(a)})},!1),a.upload.addEventListener("load",function(a){a.lengthComputable&&(a.config=d,e.notify?e.notify(a):f.progressFunc&&c(function(){f.progressFunc(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.progressFunc=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){function b(c,d,e){if(void 0!==d)if(angular.isDate(d)&&(d=d.toISOString()),angular.isString(d))c.append(e,d);else if("form"===a.sendFieldsAs)if(angular.isObject(d))for(var f in d)d.hasOwnProperty(f)&&b(c,d[f],e+"["+f+"]");else c.append(e,d);else d=angular.isString(d)?d:JSON.stringify(d),"json-blob"===a.sendFieldsAs?c.append(e,new Blob([d],{type:"application/json"})):c.append(e,d)}return a.headers=a.headers||{},a.headers["Content-Type"]=void 0,a.transformRequest=a.transformRequest?angular.isArray(a.transformRequest)?a.transformRequest:[a.transformRequest]:[],a.transformRequest.push(function(c){var d,e=new FormData,f={};for(d in a.fields)a.fields.hasOwnProperty(d)&&(f[d]=a.fields[d]);c&&(f.data=c);for(d in f)if(f.hasOwnProperty(d)){var g=f[d];a.formDataAppender?a.formDataAppender(e,d,g):b(e,g,d)}if(null!=a.file){var h=a.fileFormDataName||"file";if(angular.isArray(a.file))for(var i=angular.isString(h),j=0;j<a.file.length;j++)e.append(i?h:h[j],a.file[j],a.fileName&&a.fileName[j]||a.file[j].name);else e.append(h,a.file,a.fileName||a.file.name)}return e}),d(a)},this.http=function(b){return b.transformRequest=b.transformRequest||function(b){return window.ArrayBuffer&&b instanceof window.ArrayBuffer||b instanceof Blob?b:a.defaults.transformRequest[0](arguments)},d(b)},this.dataUrl=function(a,b,d){window.FileReader&&a&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 8")||a.size<2e4)&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 9")||a.size<4e6)?c(function(){var e=window.URL||window.webkitURL;if(e&&e.createObjectURL&&!d)b(e.createObjectURL(a));else{var f=new FileReader;f.readAsDataURL(a),f.onload=function(a){c(function(){b(a.target.result)})}}}):b(null)},this.setDefaults=function(a){ngFileUpload.defaults=a||{}}}]),function(){function a(a,f,g,h,i,j,k){function l(){return"input"===f[0].tagName.toLowerCase()&&g.type&&"file"===g.type.toLowerCase()}function m(b){if(!s){s=!0;try{for(var f=b.__files_||b.target&&b.target.files,k=[],l=[],m=0;m<f.length;m++){var n=f.item(m);d(a,i,g,n,b)?k.push(n):l.push(n)}e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),k,l,b),0===k.length&&(b.target.value=k)}finally{s=!1}}}function n(b){c(g,"ngfMultiple")&&b.attr("multiple",i(c(g,"ngfMultiple"))(a)),c(g,"ngfCapture")&&b.attr("capture",i(c(g,"ngfCapture"))(a)),c(g,"accept")&&b.attr("accept",c(g,"accept"));for(var d=0;d<f[0].attributes.length;d++){var e=f[0].attributes[d];(l()&&"type"!==e.name||"type"!==e.name&&"class"!==e.name&&"id"!==e.name&&"style"!==e.name)&&b.attr(e.name,e.value)}}function o(b,c){if(!c&&(b||l()))return f.$$ngfRefElem||f;var d=angular.element('<input type="file">');return n(d),l()?(f.replaceWith(d),f=d,d.attr("__ngf_gen__",!0),k(f)(a)):(d.css("visibility","hidden").css("position","absolute").css("overflow","hidden").css("width","0px").css("height","0px").css("z-index","-100000").css("border","none").css("margin","0px").css("padding","0px").attr("tabindex","-1"),f.$$ngfRefElem&&f.$$ngfRefElem.remove(),f.$$ngfRefElem=d,document.body.appendChild(d[0])),d}function p(b){e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),[],[],b,!0)}function q(d){function e(a){a&&a.clientY>0&&k[0].click(),!l()&&a||!j||f.bind("click touchend touchstart",q)}if(f.attr("disabled")||r)return!1;if(null!=d){if("touchstart"===d.type)return t=d.originalEvent.touches[0].clientY,!0;if(d.stopPropagation(),d.preventDefault(),"touchend"===d.type){var h=d.originalEvent.changedTouches[0].clientY;if(Math.abs(h-t)>20)return!1}}var j=i(c(g,"ngfResetOnClick"))(a)!==!1,k=o(d,j);return k&&((!d||j)&&k.bind("change",m),d&&j&&i(c(g,"ngfResetModelOnClick"))(a)!==!1&&p(d),b(navigator.userAgent)?setTimeout(function(){e(d)},0):e(d)),!1}if(!f.attr("__ngf_gen__")){a.$on("$destroy",function(){f.$$ngfRefElem&&f.$$ngfRefElem.remove()});var r=!1;-1===c(g,"ngfSelect").search(/\W+$files\W+/)&&a.$watch(c(g,"ngfSelect"),function(a){r=a===!1});var s=!1,t=0;window.FileAPI&&window.FileAPI.ngfFixIE?window.FileAPI.ngfFixIE(f,o,n,m):q()}}function b(a){var b=a.match(/Android[^\d]*(\d+)\.(\d+)/);if(b&&b.length>2){var c=ngFileUpload.defaults.androidFixMinorVersion||4;return parseInt(b[1])<4||parseInt(b[1])===c&&parseInt(b[2])<c}return-1===a.indexOf("Chrome")&&/.*Windows.*Safari.*/.test(a)}ngFileUpload.getAttrWithDefaults=function(a,b){return null!=a[b]?a[b]:null==ngFileUpload.defaults[b]?ngFileUpload.defaults[b]:ngFileUpload.defaults[b].toString()};var c=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfSelect",["$parse","$timeout","$compile",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.validate=function(a,b,d,e,f){function g(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+="("+g(b[d])+")",d<b.length-1&&(c+="|");else 0===a.indexOf(".")&&(a="*"+a),c="^"+a.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$",c=c.replace(/\\\*/g,".*").replace(/\\\?/g,".");return c}if(null==e)return!1;var h=b(c(d,"ngfAccept"))(a,{$file:e,$event:f}),i=b(c(d,"ngfMaxSize"))(a,{$file:e,$event:f})||9007199254740991,j=b(c(d,"ngfMinSize"))(a,{$file:e,$event:f})||-1;if(null!=h&&angular.isString(h)){var k=new RegExp(g(h),"gi");if(h=null!=e.type&&k.test(e.type.toLowerCase())||null!=e.name&&k.test(e.name.toLowerCase()),!h)return e.$error="accept",!1}else if(h===!1)return e.$error="accept",!1;return null==e.size?!0:e.size>i?(e.$error="maxSize",!1):e.size<j?(e.$error="minSize",!1):!0},ngFileUpload.updateModel=function(a,b,d,e,f,g,h,i,j,k){function l(){var k=a(c(f,"ngfKeep"))(d);if(k===!0){var l=(e.$modelValue||[]).slice(0);if(h&&h.length)if(a(c(f,"ngfKeepDistinct"))(d)===!0){for(var m=l.length,n=0;n<h.length;n++){for(var o=0;m>o&&h[n].name!==l[o].name;o++);o===m&&l.push(h[n])}h=l}else h=l.concat(h);else h=l}var p=h&&h[0];if(e){a(c(f,"ngModel")).assign(d,h);var q=!a(c(f,"multiple"))(d)&&!k,r=c(f,"ngfModel");r&&a(r).assign(d,q?p:h),b(function(){e&&e.$setViewValue(null!=h&&0===h.length?null:h)})}c(f,"ngModelRejected")&&a(c(f,"ngModelRejected")).assign(d,i),g&&a(g)(d,{$files:h,$file:p,$rejectedFiles:i,$event:j})}k?l():b(function(){l()})};var d=ngFileUpload.validate,e=ngFileUpload.updateModel}(),function(){function a(a,f,g,h,i,j,k){function l(a,b,d){var f=!0,g=d.dataTransfer.items;if(null!=g)for(var h=0;h<g.length&&f;h++)f=f&&("file"===g[h].kind||""===g[h].kind)&&c(a,i,b,g[h],d);var j=i(e(b,"ngfDragOverClass"))(a,{$event:d});return j&&(j.delay&&(s=j.delay),j.accept&&(j=f?j.accept:j.reject)),j||e(b,"ngfDragOverClass")||"dragover"}function m(b,d,e,f){function h(d){c(a,i,g,d,b)?m.push(d):n.push(d)}function l(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;h({name:b.name,type:"directory",path:d});var e=b.createReader(),f=[];p++;var g=function(){e.readEntries(function(d){try{if(d.length)f=f.concat(Array.prototype.slice.call(d||[],0)),g();else{for(var e=0;e<f.length;e++)l(a,f[e],(c?c:"")+b.name+"/");p--}}catch(h){p--,console.error(h)}},function(){p--})};g()}else p++,b.file(function(a){try{p--,a.path=(c?c:"")+a.name,h(a)}catch(b){p--,console.error(b)}},function(){p--})}var m=[],n=[],o=b.dataTransfer.items,p=0;if(o&&o.length>0&&"file"!==k.protocol())for(var q=0;q<o.length;q++){if(o[q].webkitGetAsEntry&&o[q].webkitGetAsEntry()&&o[q].webkitGetAsEntry().isDirectory){var r=o[q].webkitGetAsEntry();if(r.isDirectory&&!e)continue;null!=r&&l(m,r)}else{var s=o[q].getAsFile();null!=s&&h(s)}if(!f&&m.length>0)break}else{var t=b.dataTransfer.files;if(null!=t)for(var u=0;u<t.length&&(h(t.item(u)),f||!(m.length>0));u++);}var v=0;!function w(a){j(function(){if(p)10*v++<2e4&&w(10);else{if(!f&&m.length>1){for(q=0;"directory"===m[q].type;)q++;m=[m[q]]}d(m,n)}},a||0)}()}var n=b();if(e(g,"dropAvailable")&&j(function(){a[e(g,"dropAvailable")]?a[e(g,"dropAvailable")].value=n:a[e(g,"dropAvailable")]=n}),!n)return void(i(e(g,"ngfHideOnDropNotAvailable"))(a)===!0&&f.css("display","none"));var o=!1;-1===e(g,"ngfDrop").search(/\W+$files\W+/)&&a.$watch(e(g,"ngfDrop"),function(a){o=a===!1});var p,q=null,r=i(e(g,"ngfStopPropagation")),s=1;f[0].addEventListener("dragover",function(b){if(!f.attr("disabled")&&!o){if(b.preventDefault(),r(a)&&b.stopPropagation(),navigator.userAgent.indexOf("Chrome")>-1){var c=b.dataTransfer.effectAllowed;b.dataTransfer.dropEffect="move"===c||"linkMove"===c?"move":"copy"}j.cancel(q),a.actualDragOverClass||(p=l(a,g,b)),f.addClass(p)}},!1),f[0].addEventListener("dragenter",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation())},!1),f[0].addEventListener("dragleave",function(){f.attr("disabled")||o||(q=j(function(){f.removeClass(p),p=null},s||1))},!1),f[0].addEventListener("drop",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation(),f.removeClass(p),p=null,m(b,function(c,f){d(i,j,a,h,g,e(g,"ngfChange")||e(g,"ngfDrop"),c,f,b)},i(e(g,"ngfAllowDir"))(a)!==!1,e(g,"multiple")||i(e(g,"ngfMultiple"))(a)))},!1)}function b(){var a=document.createElement("div");return"draggable"in a&&"ondrop"in a}var c=ngFileUpload.validate,d=ngFileUpload.updateModel,e=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfDrop",["$parse","$timeout","$location",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.directive("ngfNoFileDrop",function(){return function(a,c){b()&&c.css("display","none")}}),ngFileUpload.directive("ngfDropAvailable",["$parse","$timeout",function(a,c){return function(d,f,g){if(b()){var h=a(e(g,"ngfDropAvailable"));c(function(){h(d),h.assign&&h.assign(d,!0)})}}}])}(),function(){function a(a,b,c,d,e,f,g){b.$watch(e,function(e){window.FileReader&&ngFileUpload.validate(b,c,d,e,null)&&a.dataUrl(e,function(a){g?g(a):e.dataUrl=a||c(f)(b)},c(d.ngfNoObjectUrl)(b))})}ngFileUpload.directive("ngfSrc",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfSrc,f.ngfDefaultSrc,function(a){e.attr("src",a)})}}}]),ngFileUpload.directive("ngfBackground",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfBackground,f.ngfDefaultBackground,function(a){e.css("background-image","url("+a+")")})}}}]),ngFileUpload.directive("ngfDataUrl",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfDataUrl,f.ngfDefaultDataUrl)}}}])}(); | ||
/*! 6.0.0 */ | ||
!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){}}if(window.FileAPI||(window.FileAPI={}),FileAPI.shouldLoad=window.XMLHttpRequest&&!window.FormData||FileAPI.forceLoad,FileAPI.shouldLoad){var c=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,d,e){c(this),this.__url=d;try{a.apply(this,[b,d,e])}catch(f){f.message.indexOf("Access is denied")>-1&&(this.__origError=f,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,d){if("__setXHR_"===b){c(this);var e=d(this);e instanceof Function&&e(this)}else this.__requestHeaders=this.__requestHeaders||{},this.__requestHeaders[b]=d,a.apply(this,arguments)}}),a("send",function(a){return function(){var c=this;if(arguments[0]&&arguments[0].__isFileAPIShim){var d=arguments[0],e={url:c.__url,jsonp:!1,cache:!0,complete:function(a,d){c.__completed=!0,!a&&c.__listeners.load&&c.__listeners.load({type:"load",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),!a&&c.__listeners.loadend&&c.__listeners.loadend({type:"loadend",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),"abort"===a&&c.__listeners.abort&&c.__listeners.abort({type:"abort",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),void 0!==d.status&&b(c,"status",function(){return 0===d.status&&a&&"abort"!==a?500:d.status}),void 0!==d.statusText&&b(c,"statusText",function(){return d.statusText}),b(c,"readyState",function(){return 4}),void 0!==d.response&&b(c,"response",function(){return d.response});var e=d.responseText||(a&&0===d.status&&"abort"!==a?a:void 0);b(c,"responseText",function(){return e}),b(c,"response",function(){return e}),a&&b(c,"err",function(){return a}),c.__fileApiXHR=d,c.onreadystatechange&&c.onreadystatechange(),c.onload&&c.onload()},progress:function(a){if(a.target=c,c.__listeners.progress&&c.__listeners.progress(a),c.__total=a.total,c.__loaded=a.loaded,a.total===a.loaded){var b=this;setTimeout(function(){c.__completed||(c.getAllResponseHeaders=function(){},b.complete(null,{status:204,statusText:"No Content"}))},FileAPI.noContentTimeout||1e4)}},headers:c.__requestHeaders};e.data={},e.files={};for(var f=0;f<d.data.length;f++){var g=d.data[f];null!=g.val&&null!=g.val.name&&null!=g.val.size&&null!=g.val.type?e.files[g.key]=g.val:e.data[g.key]=g.val}setTimeout(function(){if(!FileAPI.hasFlash)throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';c.__fileApiXHR=FileAPI.upload(e)},1)}else{if(this.__origError)throw this.__origError;a.apply(c,arguments)}}}),window.XMLHttpRequest.__isFileAPIShim=!0,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(){function a(a){return"input"===a[0].tagName.toLowerCase()&&a.attr("type")&&"file"===a.attr("type").toLowerCase()}function b(){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}function c(a){var b=0,c=0;if(window.jQuery)return jQuery(a).offset();if(a.offsetParent)do b+=a.offsetLeft-a.scrollLeft,c+=a.offsetTop-a.scrollTop,a=a.offsetParent;while(a);return{left:b,top:c}}if(FileAPI.shouldLoad){if(FileAPI.forceLoad&&(FileAPI.html5=!1),!FileAPI.upload){var d,e,f,g,h,i=document.createElement("script"),j=document.getElementsByTagName("script");if(window.FileAPI.jsUrl)d=window.FileAPI.jsUrl;else if(window.FileAPI.jsPath)e=window.FileAPI.jsPath;else for(f=0;f<j.length;f++)if(h=j[f].src,g=h.search(/\/ng\-file\-upload[\-a-zA-z0-9\.]*\.js/),g>-1){e=h.substring(0,g+1);break}null==FileAPI.staticPath&&(FileAPI.staticPath=e),i.setAttribute("src",d||e+"FileAPI.min.js"),document.getElementsByTagName("head")[0].appendChild(i),FileAPI.hasFlash=b()}FileAPI.ngfFixIE=function(d,e,f,g){if(!b())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';var h=function(){if(d.attr("disabled"))d.$$ngfRefElem.removeClass("js-fileapi-wrapper");else{var b=d.$$ngfRefElem;b?f(d.$$ngfRefElem):(b=d.$$ngfRefElem=e(),b.addClass("js-fileapi-wrapper"),!a(d),setTimeout(function(){b.bind("mouseenter",h)},10),b.bind("change",function(a){i.apply(this,[a]),g.apply(this,[a])})),a(d)||b.css("position","absolute").css("top",c(d[0]).top+"px").css("left",c(d[0]).left+"px").css("width",d[0].offsetWidth+"px").css("height",d[0].offsetHeight+"px").css("filter","alpha(opacity=0)").css("display",d.css("display")).css("overflow","hidden").css("z-index","900000").css("visibility","visible")}};d.bind("mouseenter",h);var i=function(a){for(var b=FileAPI.getFiles(a),c=0;c<b.length;c++)void 0===b[c].size&&(b[c].size=0),void 0===b[c].name&&(b[c].name="file"),void 0===b[c].type&&(b[c].type="undefined");a.target||(a.target={}),a.target.files=b,a.target.files!==b&&(a.__files_=b),(a.__files_||a.target.files).item=function(b){return(a.__files_||a.target.files)[b]||null}}},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){b||(b=!0,a.onloadstart&&a.onloadstart(c("loadstart",d)));var e;"load"===d.type?(a.onloadend&&a.onloadend(c("loadend",d)),e=c("load",d),a.onload&&a.onload(e),a.dispatchEvent(e)):"progress"===d.type?(e=c("progress",d),a.onprogress&&a.onprogress(e),a.dispatchEvent(e)):(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)}}),!window.XMLHttpRequest||window.FileAPI&&FileAPI.shouldLoad||(window.XMLHttpRequest.prototype.setRequestHeader=function(a){return function(b,c){if("__setXHR_"===b){var d=c(this);d instanceof Function&&d(this)}else a.apply(this,arguments)}}(window.XMLHttpRequest.prototype.setRequestHeader));var ngFileUpload=angular.module("ngFileUpload",[]);ngFileUpload.version="6.0.0",ngFileUpload.defaults={},ngFileUpload.service("Upload",["$http","$q","$timeout",function(a,b,c){function d(d){d.method=d.method||"POST",d.headers=d.headers||{};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.progressFunc&&c(function(){f.progressFunc(a)})},!1),a.upload.addEventListener("load",function(a){a.lengthComputable&&(a.config=d,e.notify?e.notify(a):f.progressFunc&&c(function(){f.progressFunc(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.progressFunc=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){function b(c,d,e){if(void 0!==d)if(angular.isDate(d)&&(d=d.toISOString()),angular.isString(d))c.append(e,d);else if("form"===a.sendFieldsAs)if(angular.isObject(d))for(var f in d)d.hasOwnProperty(f)&&b(c,d[f],e+"["+f+"]");else c.append(e,d);else d=angular.isString(d)?d:JSON.stringify(d),"json-blob"===a.sendFieldsAs?c.append(e,new Blob([d],{type:"application/json"})):c.append(e,d)}return a.headers=a.headers||{},a.headers["Content-Type"]=void 0,a.transformRequest=a.transformRequest?angular.isArray(a.transformRequest)?a.transformRequest:[a.transformRequest]:[],a.transformRequest.push(function(c){var d,e=new FormData,f={};for(d in a.fields)a.fields.hasOwnProperty(d)&&(f[d]=a.fields[d]);c&&(f.data=c);for(d in f)if(f.hasOwnProperty(d)){var g=f[d];a.formDataAppender?a.formDataAppender(e,d,g):b(e,g,d)}if(null!=a.file){var h=a.fileFormDataName||"file";if(angular.isArray(a.file))for(var i=angular.isString(h),j=0;j<a.file.length;j++)e.append(i?h:h[j],a.file[j],a.fileName&&a.fileName[j]||a.file[j].name);else e.append(h,a.file,a.fileName||a.file.name)}return e}),d(a)},this.http=function(b){return b.transformRequest=b.transformRequest||function(b){return window.ArrayBuffer&&b instanceof window.ArrayBuffer||b instanceof Blob?b:a.defaults.transformRequest[0](arguments)},d(b)},this.dataUrl=function(a,b,d){window.FileReader&&a&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 8")||a.size<2e4)&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 9")||a.size<4e6)?c(function(){var e=window.URL||window.webkitURL;if(e&&e.createObjectURL&&!d)b(e.createObjectURL(a));else{var f=new FileReader;f.readAsDataURL(a),f.onload=function(a){c(function(){b(a.target.result)})}}}):b(null)},this.setDefaults=function(a){ngFileUpload.defaults=a||{}}}]),function(){function a(a,f,g,h,i,j,k){function l(){return"input"===f[0].tagName.toLowerCase()&&g.type&&"file"===g.type.toLowerCase()}function m(b){if(!s){s=!0;try{for(var f=b.__files_||b.target&&b.target.files,k=[],l=[],m=0;m<f.length;m++){var n=f.item(m);d(a,i,g,n,b)?k.push(n):l.push(n)}e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),k,l,b),0===k.length&&(b.target.value=k)}finally{s=!1}}}function n(b){c(g,"ngfMultiple")&&b.attr("multiple",i(c(g,"ngfMultiple"))(a)),c(g,"ngfCapture")&&b.attr("capture",i(c(g,"ngfCapture"))(a)),c(g,"accept")&&b.attr("accept",c(g,"accept"));for(var d=0;d<f[0].attributes.length;d++){var e=f[0].attributes[d];(l()&&"type"!==e.name||"type"!==e.name&&"class"!==e.name&&"id"!==e.name&&"style"!==e.name)&&b.attr(e.name,e.value)}}function o(b,c){if(!c&&(b||l()))return f.$$ngfRefElem||f;var d=angular.element('<input type="file">');return n(d),l()?(f.replaceWith(d),f=d,d.attr("__ngf_gen__",!0),k(f)(a)):(d.css("visibility","hidden").css("position","absolute").css("overflow","hidden").css("width","0px").css("height","0px").css("z-index","-100000").css("border","none").css("margin","0px").css("padding","0px").attr("tabindex","-1"),f.$$ngfRefElem&&f.$$ngfRefElem.remove(),f.$$ngfRefElem=d,document.body.appendChild(d[0])),d}function p(b){e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),[],[],b,!0)}function q(d){function e(a){a&&a.clientY>0&&k[0].click(),!l()&&a||!j||f.bind("click touchend touchstart",q)}if(f.attr("disabled")||r)return!1;if(null!=d){if("touchstart"===d.type)return t=d.originalEvent.touches[0].clientY,!0;if(d.stopPropagation(),d.preventDefault(),"touchend"===d.type){var h=d.originalEvent.changedTouches[0].clientY;if(Math.abs(h-t)>20)return!1}}var j=i(c(g,"ngfResetOnClick"))(a)!==!1,k=o(d,j);return k&&((!d||j)&&k.bind("change",m),d&&j&&i(c(g,"ngfResetModelOnClick"))(a)!==!1&&p(d),b(navigator.userAgent)?setTimeout(function(){e(d)},0):e(d)),!1}if(!f.attr("__ngf_gen__")){a.$on("$destroy",function(){f.$$ngfRefElem&&f.$$ngfRefElem.remove()});var r=!1;-1===c(g,"ngfSelect").search(/\W+$files\W+/)&&a.$watch(c(g,"ngfSelect"),function(a){r=a===!1});var s=!1,t=0;window.FileAPI&&window.FileAPI.ngfFixIE?window.FileAPI.ngfFixIE(f,o,n,m):q()}}function b(a){var b=a.match(/Android[^\d]*(\d+)\.(\d+)/);if(b&&b.length>2){var c=ngFileUpload.defaults.androidFixMinorVersion||4;return parseInt(b[1])<4||parseInt(b[1])===c&&parseInt(b[2])<c}return-1===a.indexOf("Chrome")&&/.*Windows.*Safari.*/.test(a)}ngFileUpload.getAttrWithDefaults=function(a,b){return null!=a[b]?a[b]:null==ngFileUpload.defaults[b]?ngFileUpload.defaults[b]:ngFileUpload.defaults[b].toString()};var c=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfSelect",["$parse","$timeout","$compile",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.validate=function(a,b,d,e,f){function g(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+="("+g(b[d])+")",d<b.length-1&&(c+="|");else 0===a.indexOf(".")&&(a="*"+a),c="^"+a.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$",c=c.replace(/\\\*/g,".*").replace(/\\\?/g,".");return c}if(null==e)return!1;var h=b(c(d,"ngfAccept"))(a,{$file:e,$event:f}),i=b(c(d,"ngfMaxSize"))(a,{$file:e,$event:f})||9007199254740991,j=b(c(d,"ngfMinSize"))(a,{$file:e,$event:f})||-1;if(null!=h&&angular.isString(h)){var k=new RegExp(g(h),"gi");if(h=null!=e.type&&k.test(e.type.toLowerCase())||null!=e.name&&k.test(e.name.toLowerCase()),!h)return e.$error="accept",!1}else if(h===!1)return e.$error="accept",!1;return null==e.size?!0:e.size>i?(e.$error="maxSize",!1):e.size<j?(e.$error="minSize",!1):!0},ngFileUpload.updateModel=function(a,b,d,e,f,g,h,i,j,k){function l(){var k=a(c(f,"ngfKeep"))(d);if(k===!0){var l=(e.$modelValue||[]).slice(0);if(h&&h.length)if(a(c(f,"ngfKeepDistinct"))(d)===!0){for(var m=l.length,n=0;n<h.length;n++){for(var o=0;m>o&&h[n].name!==l[o].name;o++);o===m&&l.push(h[n])}h=l}else h=l.concat(h);else h=l}var p=h&&h.length?h[0]:null;if(e){var q=!a(c(f,"ngfMultiple"))(d)&&!c(f,"multiple")&&!k;a(c(f,"ngModel")).assign(d,q?p:h),b(function(){e&&e.$setViewValue(q?p:null!=h&&0===h.length?null:h)})}var r=c(f,"ngfModel");r&&a(r).assign(d,h),c(f,"ngModelRejected")&&a(c(f,"ngModelRejected")).assign(d,i),g&&a(g)(d,{$files:h,$file:p,$rejectedFiles:i,$event:j})}k?l():b(function(){l()})};var d=ngFileUpload.validate,e=ngFileUpload.updateModel}(),function(){function a(a,f,g,h,i,j,k){function l(a,b,d){var f=!0,g=d.dataTransfer.items;if(null!=g)for(var h=0;h<g.length&&f;h++)f=f&&("file"===g[h].kind||""===g[h].kind)&&c(a,i,b,g[h],d);var j=i(e(b,"ngfDragOverClass"))(a,{$event:d});return j&&(j.delay&&(s=j.delay),j.accept&&(j=f?j.accept:j.reject)),j||e(b,"ngfDragOverClass")||"dragover"}function m(b,d,e,f){function h(d){c(a,i,g,d,b)?m.push(d):n.push(d)}function l(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;h({name:b.name,type:"directory",path:d});var e=b.createReader(),f=[];p++;var g=function(){e.readEntries(function(d){try{if(d.length)f=f.concat(Array.prototype.slice.call(d||[],0)),g();else{for(var e=0;e<f.length;e++)l(a,f[e],(c?c:"")+b.name+"/");p--}}catch(h){p--,console.error(h)}},function(){p--})};g()}else p++,b.file(function(a){try{p--,a.path=(c?c:"")+a.name,h(a)}catch(b){p--,console.error(b)}},function(){p--})}var m=[],n=[],o=b.dataTransfer.items,p=0;if(o&&o.length>0&&"file"!==k.protocol())for(var q=0;q<o.length;q++){if(o[q].webkitGetAsEntry&&o[q].webkitGetAsEntry()&&o[q].webkitGetAsEntry().isDirectory){var r=o[q].webkitGetAsEntry();if(r.isDirectory&&!e)continue;null!=r&&l(m,r)}else{var s=o[q].getAsFile();null!=s&&h(s)}if(!f&&m.length>0)break}else{var t=b.dataTransfer.files;if(null!=t)for(var u=0;u<t.length&&(h(t.item(u)),f||!(m.length>0));u++);}var v=0;!function w(a){j(function(){if(p)10*v++<2e4&&w(10);else{if(!f&&m.length>1){for(q=0;"directory"===m[q].type;)q++;m=[m[q]]}d(m,n)}},a||0)}()}var n=b();if(e(g,"dropAvailable")&&j(function(){a[e(g,"dropAvailable")]?a[e(g,"dropAvailable")].value=n:a[e(g,"dropAvailable")]=n}),!n)return void(i(e(g,"ngfHideOnDropNotAvailable"))(a)===!0&&f.css("display","none"));var o=!1;-1===e(g,"ngfDrop").search(/\W+$files\W+/)&&a.$watch(e(g,"ngfDrop"),function(a){o=a===!1});var p,q=null,r=i(e(g,"ngfStopPropagation")),s=1;f[0].addEventListener("dragover",function(b){if(!f.attr("disabled")&&!o){if(b.preventDefault(),r(a)&&b.stopPropagation(),navigator.userAgent.indexOf("Chrome")>-1){var c=b.dataTransfer.effectAllowed;b.dataTransfer.dropEffect="move"===c||"linkMove"===c?"move":"copy"}j.cancel(q),a.actualDragOverClass||(p=l(a,g,b)),f.addClass(p)}},!1),f[0].addEventListener("dragenter",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation())},!1),f[0].addEventListener("dragleave",function(){f.attr("disabled")||o||(q=j(function(){f.removeClass(p),p=null},s||1))},!1),f[0].addEventListener("drop",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation(),f.removeClass(p),p=null,m(b,function(c,f){d(i,j,a,h,g,e(g,"ngfChange")||e(g,"ngfDrop"),c,f,b)},i(e(g,"ngfAllowDir"))(a)!==!1,e(g,"multiple")||i(e(g,"ngfMultiple"))(a)))},!1)}function b(){var a=document.createElement("div");return"draggable"in a&&"ondrop"in a}var c=ngFileUpload.validate,d=ngFileUpload.updateModel,e=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfDrop",["$parse","$timeout","$location",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.directive("ngfNoFileDrop",function(){return function(a,c){b()&&c.css("display","none")}}),ngFileUpload.directive("ngfDropAvailable",["$parse","$timeout",function(a,c){return function(d,f,g){if(b()){var h=a(e(g,"ngfDropAvailable"));c(function(){h(d),h.assign&&h.assign(d,!0)})}}}])}(),function(){function a(a,b,c,d,e,f,g){b.$watch(e,function(e){window.FileReader&&ngFileUpload.validate(b,c,d,e,null)&&a.dataUrl(e,function(a){g?g(a):e.dataUrl=a||c(f)(b)},c(d.ngfNoObjectUrl)(b))})}ngFileUpload.directive("ngfSrc",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfSrc,f.ngfDefaultSrc,function(a){e.attr("src",a)})}}}]),ngFileUpload.directive("ngfBackground",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfBackground,f.ngfDefaultBackground,function(a){e.css("background-image","url("+a+")")})}}}]),ngFileUpload.directive("ngfDataUrl",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfDataUrl,f.ngfDefaultDataUrl)}}}])}(); |
@@ -5,3 +5,3 @@ /**! | ||
* @author Danial <danial.farid@gmail.com> | ||
* @version 5.2.0 | ||
* @version 6.0.0 | ||
*/ | ||
@@ -8,0 +8,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*! 5.2.0 */ | ||
/*! 6.0.0 */ | ||
!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){}}if(window.FileAPI||(window.FileAPI={}),FileAPI.shouldLoad=window.XMLHttpRequest&&!window.FormData||FileAPI.forceLoad,FileAPI.shouldLoad){var c=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,d,e){c(this),this.__url=d;try{a.apply(this,[b,d,e])}catch(f){f.message.indexOf("Access is denied")>-1&&(this.__origError=f,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,d){if("__setXHR_"===b){c(this);var e=d(this);e instanceof Function&&e(this)}else this.__requestHeaders=this.__requestHeaders||{},this.__requestHeaders[b]=d,a.apply(this,arguments)}}),a("send",function(a){return function(){var c=this;if(arguments[0]&&arguments[0].__isFileAPIShim){var d=arguments[0],e={url:c.__url,jsonp:!1,cache:!0,complete:function(a,d){c.__completed=!0,!a&&c.__listeners.load&&c.__listeners.load({type:"load",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),!a&&c.__listeners.loadend&&c.__listeners.loadend({type:"loadend",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),"abort"===a&&c.__listeners.abort&&c.__listeners.abort({type:"abort",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),void 0!==d.status&&b(c,"status",function(){return 0===d.status&&a&&"abort"!==a?500:d.status}),void 0!==d.statusText&&b(c,"statusText",function(){return d.statusText}),b(c,"readyState",function(){return 4}),void 0!==d.response&&b(c,"response",function(){return d.response});var e=d.responseText||(a&&0===d.status&&"abort"!==a?a:void 0);b(c,"responseText",function(){return e}),b(c,"response",function(){return e}),a&&b(c,"err",function(){return a}),c.__fileApiXHR=d,c.onreadystatechange&&c.onreadystatechange(),c.onload&&c.onload()},progress:function(a){if(a.target=c,c.__listeners.progress&&c.__listeners.progress(a),c.__total=a.total,c.__loaded=a.loaded,a.total===a.loaded){var b=this;setTimeout(function(){c.__completed||(c.getAllResponseHeaders=function(){},b.complete(null,{status:204,statusText:"No Content"}))},FileAPI.noContentTimeout||1e4)}},headers:c.__requestHeaders};e.data={},e.files={};for(var f=0;f<d.data.length;f++){var g=d.data[f];null!=g.val&&null!=g.val.name&&null!=g.val.size&&null!=g.val.type?e.files[g.key]=g.val:e.data[g.key]=g.val}setTimeout(function(){if(!FileAPI.hasFlash)throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';c.__fileApiXHR=FileAPI.upload(e)},1)}else{if(this.__origError)throw this.__origError;a.apply(c,arguments)}}}),window.XMLHttpRequest.__isFileAPIShim=!0,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(){function a(a){return"input"===a[0].tagName.toLowerCase()&&a.attr("type")&&"file"===a.attr("type").toLowerCase()}function b(){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}function c(a){var b=0,c=0;if(window.jQuery)return jQuery(a).offset();if(a.offsetParent)do b+=a.offsetLeft-a.scrollLeft,c+=a.offsetTop-a.scrollTop,a=a.offsetParent;while(a);return{left:b,top:c}}if(FileAPI.shouldLoad){if(FileAPI.forceLoad&&(FileAPI.html5=!1),!FileAPI.upload){var d,e,f,g,h,i=document.createElement("script"),j=document.getElementsByTagName("script");if(window.FileAPI.jsUrl)d=window.FileAPI.jsUrl;else if(window.FileAPI.jsPath)e=window.FileAPI.jsPath;else for(f=0;f<j.length;f++)if(h=j[f].src,g=h.search(/\/ng\-file\-upload[\-a-zA-z0-9\.]*\.js/),g>-1){e=h.substring(0,g+1);break}null==FileAPI.staticPath&&(FileAPI.staticPath=e),i.setAttribute("src",d||e+"FileAPI.min.js"),document.getElementsByTagName("head")[0].appendChild(i),FileAPI.hasFlash=b()}FileAPI.ngfFixIE=function(d,e,f,g){if(!b())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';var h=function(){if(d.attr("disabled"))d.$$ngfRefElem.removeClass("js-fileapi-wrapper");else{var b=d.$$ngfRefElem;b?f(d.$$ngfRefElem):(b=d.$$ngfRefElem=e(),b.addClass("js-fileapi-wrapper"),!a(d),setTimeout(function(){b.bind("mouseenter",h)},10),b.bind("change",function(a){i.apply(this,[a]),g.apply(this,[a])})),a(d)||b.css("position","absolute").css("top",c(d[0]).top+"px").css("left",c(d[0]).left+"px").css("width",d[0].offsetWidth+"px").css("height",d[0].offsetHeight+"px").css("filter","alpha(opacity=0)").css("display",d.css("display")).css("overflow","hidden").css("z-index","900000").css("visibility","visible")}};d.bind("mouseenter",h);var i=function(a){for(var b=FileAPI.getFiles(a),c=0;c<b.length;c++)void 0===b[c].size&&(b[c].size=0),void 0===b[c].name&&(b[c].name="file"),void 0===b[c].type&&(b[c].type="undefined");a.target||(a.target={}),a.target.files=b,a.target.files!==b&&(a.__files_=b),(a.__files_||a.target.files).item=function(b){return(a.__files_||a.target.files)[b]||null}}},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){b||(b=!0,a.onloadstart&&a.onloadstart(c("loadstart",d)));var e;"load"===d.type?(a.onloadend&&a.onloadend(c("loadend",d)),e=c("load",d),a.onload&&a.onload(e),a.dispatchEvent(e)):"progress"===d.type?(e=c("progress",d),a.onprogress&&a.onprogress(e),a.dispatchEvent(e)):(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 5.2.0 | ||
* @version 6.0.0 | ||
*/ | ||
@@ -25,3 +25,3 @@ | ||
ngFileUpload.version = '5.2.0'; | ||
ngFileUpload.version = '6.0.0'; | ||
ngFileUpload.defaults = {}; | ||
@@ -258,4 +258,5 @@ | ||
/** @namespace attr.ngModel */ | ||
/** @namespace attr.ngModelRejected */ | ||
/** @namespace attr.ngfModel */ | ||
/** @namespace attr.ngModelRejected */ | ||
/** @namespace attr.ngfModelRejected */ | ||
/** @namespace attr.ngfMultiple */ | ||
@@ -514,16 +515,17 @@ /** @namespace attr.ngfCapture */ | ||
} | ||
var file = files && files[0]; | ||
var file = files && files.length ? files[0] : null; | ||
if (ngModel) { | ||
$parse(getAttr(attr, 'ngModel')).assign(scope, files); | ||
var singleModel = !$parse(getAttr(attr, 'multiple'))(scope) && !keep; | ||
var ngfModel = getAttr(attr, 'ngfModel'); | ||
if (ngfModel) { | ||
$parse(ngfModel).assign(scope, singleModel ? file : files); | ||
} | ||
var singleModel = !$parse(getAttr(attr, 'ngfMultiple'))(scope) && ! getAttr(attr, 'multiple') && !keep; | ||
$parse(getAttr(attr, 'ngModel')).assign(scope, singleModel ? file : files); | ||
$timeout(function () { | ||
if (ngModel) { | ||
ngModel.$setViewValue(files != null && files.length === 0 ? null : files); | ||
ngModel.$setViewValue(singleModel ? file : (files != null && files.length === 0 ? null : files)); | ||
} | ||
}); | ||
} | ||
var ngfModel = getAttr(attr, 'ngfModel'); | ||
if (ngfModel) { | ||
$parse(ngfModel).assign(scope, files); | ||
} | ||
if (getAttr(attr, 'ngModelRejected')) { | ||
@@ -530,0 +532,0 @@ $parse(getAttr(attr, 'ngModelRejected')).assign(scope, rejFiles); |
@@ -1,2 +0,2 @@ | ||
/*! 5.2.0 */ | ||
!window.XMLHttpRequest||window.FileAPI&&FileAPI.shouldLoad||(window.XMLHttpRequest.prototype.setRequestHeader=function(a){return function(b,c){if("__setXHR_"===b){var d=c(this);d instanceof Function&&d(this)}else a.apply(this,arguments)}}(window.XMLHttpRequest.prototype.setRequestHeader));var ngFileUpload=angular.module("ngFileUpload",[]);ngFileUpload.version="5.2.0",ngFileUpload.defaults={},ngFileUpload.service("Upload",["$http","$q","$timeout",function(a,b,c){function d(d){d.method=d.method||"POST",d.headers=d.headers||{};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.progressFunc&&c(function(){f.progressFunc(a)})},!1),a.upload.addEventListener("load",function(a){a.lengthComputable&&(a.config=d,e.notify?e.notify(a):f.progressFunc&&c(function(){f.progressFunc(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.progressFunc=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){function b(c,d,e){if(void 0!==d)if(angular.isDate(d)&&(d=d.toISOString()),angular.isString(d))c.append(e,d);else if("form"===a.sendFieldsAs)if(angular.isObject(d))for(var f in d)d.hasOwnProperty(f)&&b(c,d[f],e+"["+f+"]");else c.append(e,d);else d=angular.isString(d)?d:JSON.stringify(d),"json-blob"===a.sendFieldsAs?c.append(e,new Blob([d],{type:"application/json"})):c.append(e,d)}return a.headers=a.headers||{},a.headers["Content-Type"]=void 0,a.transformRequest=a.transformRequest?angular.isArray(a.transformRequest)?a.transformRequest:[a.transformRequest]:[],a.transformRequest.push(function(c){var d,e=new FormData,f={};for(d in a.fields)a.fields.hasOwnProperty(d)&&(f[d]=a.fields[d]);c&&(f.data=c);for(d in f)if(f.hasOwnProperty(d)){var g=f[d];a.formDataAppender?a.formDataAppender(e,d,g):b(e,g,d)}if(null!=a.file){var h=a.fileFormDataName||"file";if(angular.isArray(a.file))for(var i=angular.isString(h),j=0;j<a.file.length;j++)e.append(i?h:h[j],a.file[j],a.fileName&&a.fileName[j]||a.file[j].name);else e.append(h,a.file,a.fileName||a.file.name)}return e}),d(a)},this.http=function(b){return b.transformRequest=b.transformRequest||function(b){return window.ArrayBuffer&&b instanceof window.ArrayBuffer||b instanceof Blob?b:a.defaults.transformRequest[0](arguments)},d(b)},this.dataUrl=function(a,b,d){window.FileReader&&a&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 8")||a.size<2e4)&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 9")||a.size<4e6)?c(function(){var e=window.URL||window.webkitURL;if(e&&e.createObjectURL&&!d)b(e.createObjectURL(a));else{var f=new FileReader;f.readAsDataURL(a),f.onload=function(a){c(function(){b(a.target.result)})}}}):b(null)},this.setDefaults=function(a){ngFileUpload.defaults=a||{}}}]),function(){function a(a,f,g,h,i,j,k){function l(){return"input"===f[0].tagName.toLowerCase()&&g.type&&"file"===g.type.toLowerCase()}function m(b){if(!s){s=!0;try{for(var f=b.__files_||b.target&&b.target.files,k=[],l=[],m=0;m<f.length;m++){var n=f.item(m);d(a,i,g,n,b)?k.push(n):l.push(n)}e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),k,l,b),0===k.length&&(b.target.value=k)}finally{s=!1}}}function n(b){c(g,"ngfMultiple")&&b.attr("multiple",i(c(g,"ngfMultiple"))(a)),c(g,"ngfCapture")&&b.attr("capture",i(c(g,"ngfCapture"))(a)),c(g,"accept")&&b.attr("accept",c(g,"accept"));for(var d=0;d<f[0].attributes.length;d++){var e=f[0].attributes[d];(l()&&"type"!==e.name||"type"!==e.name&&"class"!==e.name&&"id"!==e.name&&"style"!==e.name)&&b.attr(e.name,e.value)}}function o(b,c){if(!c&&(b||l()))return f.$$ngfRefElem||f;var d=angular.element('<input type="file">');return n(d),l()?(f.replaceWith(d),f=d,d.attr("__ngf_gen__",!0),k(f)(a)):(d.css("visibility","hidden").css("position","absolute").css("overflow","hidden").css("width","0px").css("height","0px").css("z-index","-100000").css("border","none").css("margin","0px").css("padding","0px").attr("tabindex","-1"),f.$$ngfRefElem&&f.$$ngfRefElem.remove(),f.$$ngfRefElem=d,document.body.appendChild(d[0])),d}function p(b){e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),[],[],b,!0)}function q(d){function e(a){a&&a.clientY>0&&k[0].click(),!l()&&a||!j||f.bind("click touchend touchstart",q)}if(f.attr("disabled")||r)return!1;if(null!=d){if("touchstart"===d.type)return t=d.originalEvent.touches[0].clientY,!0;if(d.stopPropagation(),d.preventDefault(),"touchend"===d.type){var h=d.originalEvent.changedTouches[0].clientY;if(Math.abs(h-t)>20)return!1}}var j=i(c(g,"ngfResetOnClick"))(a)!==!1,k=o(d,j);return k&&((!d||j)&&k.bind("change",m),d&&j&&i(c(g,"ngfResetModelOnClick"))(a)!==!1&&p(d),b(navigator.userAgent)?setTimeout(function(){e(d)},0):e(d)),!1}if(!f.attr("__ngf_gen__")){a.$on("$destroy",function(){f.$$ngfRefElem&&f.$$ngfRefElem.remove()});var r=!1;-1===c(g,"ngfSelect").search(/\W+$files\W+/)&&a.$watch(c(g,"ngfSelect"),function(a){r=a===!1});var s=!1,t=0;window.FileAPI&&window.FileAPI.ngfFixIE?window.FileAPI.ngfFixIE(f,o,n,m):q()}}function b(a){var b=a.match(/Android[^\d]*(\d+)\.(\d+)/);if(b&&b.length>2){var c=ngFileUpload.defaults.androidFixMinorVersion||4;return parseInt(b[1])<4||parseInt(b[1])===c&&parseInt(b[2])<c}return-1===a.indexOf("Chrome")&&/.*Windows.*Safari.*/.test(a)}ngFileUpload.getAttrWithDefaults=function(a,b){return null!=a[b]?a[b]:null==ngFileUpload.defaults[b]?ngFileUpload.defaults[b]:ngFileUpload.defaults[b].toString()};var c=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfSelect",["$parse","$timeout","$compile",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.validate=function(a,b,d,e,f){function g(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+="("+g(b[d])+")",d<b.length-1&&(c+="|");else 0===a.indexOf(".")&&(a="*"+a),c="^"+a.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$",c=c.replace(/\\\*/g,".*").replace(/\\\?/g,".");return c}if(null==e)return!1;var h=b(c(d,"ngfAccept"))(a,{$file:e,$event:f}),i=b(c(d,"ngfMaxSize"))(a,{$file:e,$event:f})||9007199254740991,j=b(c(d,"ngfMinSize"))(a,{$file:e,$event:f})||-1;if(null!=h&&angular.isString(h)){var k=new RegExp(g(h),"gi");if(h=null!=e.type&&k.test(e.type.toLowerCase())||null!=e.name&&k.test(e.name.toLowerCase()),!h)return e.$error="accept",!1}else if(h===!1)return e.$error="accept",!1;return null==e.size?!0:e.size>i?(e.$error="maxSize",!1):e.size<j?(e.$error="minSize",!1):!0},ngFileUpload.updateModel=function(a,b,d,e,f,g,h,i,j,k){function l(){var k=a(c(f,"ngfKeep"))(d);if(k===!0){var l=(e.$modelValue||[]).slice(0);if(h&&h.length)if(a(c(f,"ngfKeepDistinct"))(d)===!0){for(var m=l.length,n=0;n<h.length;n++){for(var o=0;m>o&&h[n].name!==l[o].name;o++);o===m&&l.push(h[n])}h=l}else h=l.concat(h);else h=l}var p=h&&h[0];if(e){a(c(f,"ngModel")).assign(d,h);var q=!a(c(f,"multiple"))(d)&&!k,r=c(f,"ngfModel");r&&a(r).assign(d,q?p:h),b(function(){e&&e.$setViewValue(null!=h&&0===h.length?null:h)})}c(f,"ngModelRejected")&&a(c(f,"ngModelRejected")).assign(d,i),g&&a(g)(d,{$files:h,$file:p,$rejectedFiles:i,$event:j})}k?l():b(function(){l()})};var d=ngFileUpload.validate,e=ngFileUpload.updateModel}(),function(){function a(a,f,g,h,i,j,k){function l(a,b,d){var f=!0,g=d.dataTransfer.items;if(null!=g)for(var h=0;h<g.length&&f;h++)f=f&&("file"===g[h].kind||""===g[h].kind)&&c(a,i,b,g[h],d);var j=i(e(b,"ngfDragOverClass"))(a,{$event:d});return j&&(j.delay&&(s=j.delay),j.accept&&(j=f?j.accept:j.reject)),j||e(b,"ngfDragOverClass")||"dragover"}function m(b,d,e,f){function h(d){c(a,i,g,d,b)?m.push(d):n.push(d)}function l(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;h({name:b.name,type:"directory",path:d});var e=b.createReader(),f=[];p++;var g=function(){e.readEntries(function(d){try{if(d.length)f=f.concat(Array.prototype.slice.call(d||[],0)),g();else{for(var e=0;e<f.length;e++)l(a,f[e],(c?c:"")+b.name+"/");p--}}catch(h){p--,console.error(h)}},function(){p--})};g()}else p++,b.file(function(a){try{p--,a.path=(c?c:"")+a.name,h(a)}catch(b){p--,console.error(b)}},function(){p--})}var m=[],n=[],o=b.dataTransfer.items,p=0;if(o&&o.length>0&&"file"!==k.protocol())for(var q=0;q<o.length;q++){if(o[q].webkitGetAsEntry&&o[q].webkitGetAsEntry()&&o[q].webkitGetAsEntry().isDirectory){var r=o[q].webkitGetAsEntry();if(r.isDirectory&&!e)continue;null!=r&&l(m,r)}else{var s=o[q].getAsFile();null!=s&&h(s)}if(!f&&m.length>0)break}else{var t=b.dataTransfer.files;if(null!=t)for(var u=0;u<t.length&&(h(t.item(u)),f||!(m.length>0));u++);}var v=0;!function w(a){j(function(){if(p)10*v++<2e4&&w(10);else{if(!f&&m.length>1){for(q=0;"directory"===m[q].type;)q++;m=[m[q]]}d(m,n)}},a||0)}()}var n=b();if(e(g,"dropAvailable")&&j(function(){a[e(g,"dropAvailable")]?a[e(g,"dropAvailable")].value=n:a[e(g,"dropAvailable")]=n}),!n)return void(i(e(g,"ngfHideOnDropNotAvailable"))(a)===!0&&f.css("display","none"));var o=!1;-1===e(g,"ngfDrop").search(/\W+$files\W+/)&&a.$watch(e(g,"ngfDrop"),function(a){o=a===!1});var p,q=null,r=i(e(g,"ngfStopPropagation")),s=1;f[0].addEventListener("dragover",function(b){if(!f.attr("disabled")&&!o){if(b.preventDefault(),r(a)&&b.stopPropagation(),navigator.userAgent.indexOf("Chrome")>-1){var c=b.dataTransfer.effectAllowed;b.dataTransfer.dropEffect="move"===c||"linkMove"===c?"move":"copy"}j.cancel(q),a.actualDragOverClass||(p=l(a,g,b)),f.addClass(p)}},!1),f[0].addEventListener("dragenter",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation())},!1),f[0].addEventListener("dragleave",function(){f.attr("disabled")||o||(q=j(function(){f.removeClass(p),p=null},s||1))},!1),f[0].addEventListener("drop",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation(),f.removeClass(p),p=null,m(b,function(c,f){d(i,j,a,h,g,e(g,"ngfChange")||e(g,"ngfDrop"),c,f,b)},i(e(g,"ngfAllowDir"))(a)!==!1,e(g,"multiple")||i(e(g,"ngfMultiple"))(a)))},!1)}function b(){var a=document.createElement("div");return"draggable"in a&&"ondrop"in a}var c=ngFileUpload.validate,d=ngFileUpload.updateModel,e=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfDrop",["$parse","$timeout","$location",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.directive("ngfNoFileDrop",function(){return function(a,c){b()&&c.css("display","none")}}),ngFileUpload.directive("ngfDropAvailable",["$parse","$timeout",function(a,c){return function(d,f,g){if(b()){var h=a(e(g,"ngfDropAvailable"));c(function(){h(d),h.assign&&h.assign(d,!0)})}}}])}(),function(){function a(a,b,c,d,e,f,g){b.$watch(e,function(e){window.FileReader&&ngFileUpload.validate(b,c,d,e,null)&&a.dataUrl(e,function(a){g?g(a):e.dataUrl=a||c(f)(b)},c(d.ngfNoObjectUrl)(b))})}ngFileUpload.directive("ngfSrc",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfSrc,f.ngfDefaultSrc,function(a){e.attr("src",a)})}}}]),ngFileUpload.directive("ngfBackground",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfBackground,f.ngfDefaultBackground,function(a){e.css("background-image","url("+a+")")})}}}]),ngFileUpload.directive("ngfDataUrl",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfDataUrl,f.ngfDefaultDataUrl)}}}])}(); | ||
/*! 6.0.0 */ | ||
!window.XMLHttpRequest||window.FileAPI&&FileAPI.shouldLoad||(window.XMLHttpRequest.prototype.setRequestHeader=function(a){return function(b,c){if("__setXHR_"===b){var d=c(this);d instanceof Function&&d(this)}else a.apply(this,arguments)}}(window.XMLHttpRequest.prototype.setRequestHeader));var ngFileUpload=angular.module("ngFileUpload",[]);ngFileUpload.version="6.0.0",ngFileUpload.defaults={},ngFileUpload.service("Upload",["$http","$q","$timeout",function(a,b,c){function d(d){d.method=d.method||"POST",d.headers=d.headers||{};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.progressFunc&&c(function(){f.progressFunc(a)})},!1),a.upload.addEventListener("load",function(a){a.lengthComputable&&(a.config=d,e.notify?e.notify(a):f.progressFunc&&c(function(){f.progressFunc(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.progressFunc=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){function b(c,d,e){if(void 0!==d)if(angular.isDate(d)&&(d=d.toISOString()),angular.isString(d))c.append(e,d);else if("form"===a.sendFieldsAs)if(angular.isObject(d))for(var f in d)d.hasOwnProperty(f)&&b(c,d[f],e+"["+f+"]");else c.append(e,d);else d=angular.isString(d)?d:JSON.stringify(d),"json-blob"===a.sendFieldsAs?c.append(e,new Blob([d],{type:"application/json"})):c.append(e,d)}return a.headers=a.headers||{},a.headers["Content-Type"]=void 0,a.transformRequest=a.transformRequest?angular.isArray(a.transformRequest)?a.transformRequest:[a.transformRequest]:[],a.transformRequest.push(function(c){var d,e=new FormData,f={};for(d in a.fields)a.fields.hasOwnProperty(d)&&(f[d]=a.fields[d]);c&&(f.data=c);for(d in f)if(f.hasOwnProperty(d)){var g=f[d];a.formDataAppender?a.formDataAppender(e,d,g):b(e,g,d)}if(null!=a.file){var h=a.fileFormDataName||"file";if(angular.isArray(a.file))for(var i=angular.isString(h),j=0;j<a.file.length;j++)e.append(i?h:h[j],a.file[j],a.fileName&&a.fileName[j]||a.file[j].name);else e.append(h,a.file,a.fileName||a.file.name)}return e}),d(a)},this.http=function(b){return b.transformRequest=b.transformRequest||function(b){return window.ArrayBuffer&&b instanceof window.ArrayBuffer||b instanceof Blob?b:a.defaults.transformRequest[0](arguments)},d(b)},this.dataUrl=function(a,b,d){window.FileReader&&a&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 8")||a.size<2e4)&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 9")||a.size<4e6)?c(function(){var e=window.URL||window.webkitURL;if(e&&e.createObjectURL&&!d)b(e.createObjectURL(a));else{var f=new FileReader;f.readAsDataURL(a),f.onload=function(a){c(function(){b(a.target.result)})}}}):b(null)},this.setDefaults=function(a){ngFileUpload.defaults=a||{}}}]),function(){function a(a,f,g,h,i,j,k){function l(){return"input"===f[0].tagName.toLowerCase()&&g.type&&"file"===g.type.toLowerCase()}function m(b){if(!s){s=!0;try{for(var f=b.__files_||b.target&&b.target.files,k=[],l=[],m=0;m<f.length;m++){var n=f.item(m);d(a,i,g,n,b)?k.push(n):l.push(n)}e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),k,l,b),0===k.length&&(b.target.value=k)}finally{s=!1}}}function n(b){c(g,"ngfMultiple")&&b.attr("multiple",i(c(g,"ngfMultiple"))(a)),c(g,"ngfCapture")&&b.attr("capture",i(c(g,"ngfCapture"))(a)),c(g,"accept")&&b.attr("accept",c(g,"accept"));for(var d=0;d<f[0].attributes.length;d++){var e=f[0].attributes[d];(l()&&"type"!==e.name||"type"!==e.name&&"class"!==e.name&&"id"!==e.name&&"style"!==e.name)&&b.attr(e.name,e.value)}}function o(b,c){if(!c&&(b||l()))return f.$$ngfRefElem||f;var d=angular.element('<input type="file">');return n(d),l()?(f.replaceWith(d),f=d,d.attr("__ngf_gen__",!0),k(f)(a)):(d.css("visibility","hidden").css("position","absolute").css("overflow","hidden").css("width","0px").css("height","0px").css("z-index","-100000").css("border","none").css("margin","0px").css("padding","0px").attr("tabindex","-1"),f.$$ngfRefElem&&f.$$ngfRefElem.remove(),f.$$ngfRefElem=d,document.body.appendChild(d[0])),d}function p(b){e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),[],[],b,!0)}function q(d){function e(a){a&&a.clientY>0&&k[0].click(),!l()&&a||!j||f.bind("click touchend touchstart",q)}if(f.attr("disabled")||r)return!1;if(null!=d){if("touchstart"===d.type)return t=d.originalEvent.touches[0].clientY,!0;if(d.stopPropagation(),d.preventDefault(),"touchend"===d.type){var h=d.originalEvent.changedTouches[0].clientY;if(Math.abs(h-t)>20)return!1}}var j=i(c(g,"ngfResetOnClick"))(a)!==!1,k=o(d,j);return k&&((!d||j)&&k.bind("change",m),d&&j&&i(c(g,"ngfResetModelOnClick"))(a)!==!1&&p(d),b(navigator.userAgent)?setTimeout(function(){e(d)},0):e(d)),!1}if(!f.attr("__ngf_gen__")){a.$on("$destroy",function(){f.$$ngfRefElem&&f.$$ngfRefElem.remove()});var r=!1;-1===c(g,"ngfSelect").search(/\W+$files\W+/)&&a.$watch(c(g,"ngfSelect"),function(a){r=a===!1});var s=!1,t=0;window.FileAPI&&window.FileAPI.ngfFixIE?window.FileAPI.ngfFixIE(f,o,n,m):q()}}function b(a){var b=a.match(/Android[^\d]*(\d+)\.(\d+)/);if(b&&b.length>2){var c=ngFileUpload.defaults.androidFixMinorVersion||4;return parseInt(b[1])<4||parseInt(b[1])===c&&parseInt(b[2])<c}return-1===a.indexOf("Chrome")&&/.*Windows.*Safari.*/.test(a)}ngFileUpload.getAttrWithDefaults=function(a,b){return null!=a[b]?a[b]:null==ngFileUpload.defaults[b]?ngFileUpload.defaults[b]:ngFileUpload.defaults[b].toString()};var c=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfSelect",["$parse","$timeout","$compile",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.validate=function(a,b,d,e,f){function g(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+="("+g(b[d])+")",d<b.length-1&&(c+="|");else 0===a.indexOf(".")&&(a="*"+a),c="^"+a.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$",c=c.replace(/\\\*/g,".*").replace(/\\\?/g,".");return c}if(null==e)return!1;var h=b(c(d,"ngfAccept"))(a,{$file:e,$event:f}),i=b(c(d,"ngfMaxSize"))(a,{$file:e,$event:f})||9007199254740991,j=b(c(d,"ngfMinSize"))(a,{$file:e,$event:f})||-1;if(null!=h&&angular.isString(h)){var k=new RegExp(g(h),"gi");if(h=null!=e.type&&k.test(e.type.toLowerCase())||null!=e.name&&k.test(e.name.toLowerCase()),!h)return e.$error="accept",!1}else if(h===!1)return e.$error="accept",!1;return null==e.size?!0:e.size>i?(e.$error="maxSize",!1):e.size<j?(e.$error="minSize",!1):!0},ngFileUpload.updateModel=function(a,b,d,e,f,g,h,i,j,k){function l(){var k=a(c(f,"ngfKeep"))(d);if(k===!0){var l=(e.$modelValue||[]).slice(0);if(h&&h.length)if(a(c(f,"ngfKeepDistinct"))(d)===!0){for(var m=l.length,n=0;n<h.length;n++){for(var o=0;m>o&&h[n].name!==l[o].name;o++);o===m&&l.push(h[n])}h=l}else h=l.concat(h);else h=l}var p=h&&h.length?h[0]:null;if(e){var q=!a(c(f,"ngfMultiple"))(d)&&!c(f,"multiple")&&!k;a(c(f,"ngModel")).assign(d,q?p:h),b(function(){e&&e.$setViewValue(q?p:null!=h&&0===h.length?null:h)})}var r=c(f,"ngfModel");r&&a(r).assign(d,h),c(f,"ngModelRejected")&&a(c(f,"ngModelRejected")).assign(d,i),g&&a(g)(d,{$files:h,$file:p,$rejectedFiles:i,$event:j})}k?l():b(function(){l()})};var d=ngFileUpload.validate,e=ngFileUpload.updateModel}(),function(){function a(a,f,g,h,i,j,k){function l(a,b,d){var f=!0,g=d.dataTransfer.items;if(null!=g)for(var h=0;h<g.length&&f;h++)f=f&&("file"===g[h].kind||""===g[h].kind)&&c(a,i,b,g[h],d);var j=i(e(b,"ngfDragOverClass"))(a,{$event:d});return j&&(j.delay&&(s=j.delay),j.accept&&(j=f?j.accept:j.reject)),j||e(b,"ngfDragOverClass")||"dragover"}function m(b,d,e,f){function h(d){c(a,i,g,d,b)?m.push(d):n.push(d)}function l(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;h({name:b.name,type:"directory",path:d});var e=b.createReader(),f=[];p++;var g=function(){e.readEntries(function(d){try{if(d.length)f=f.concat(Array.prototype.slice.call(d||[],0)),g();else{for(var e=0;e<f.length;e++)l(a,f[e],(c?c:"")+b.name+"/");p--}}catch(h){p--,console.error(h)}},function(){p--})};g()}else p++,b.file(function(a){try{p--,a.path=(c?c:"")+a.name,h(a)}catch(b){p--,console.error(b)}},function(){p--})}var m=[],n=[],o=b.dataTransfer.items,p=0;if(o&&o.length>0&&"file"!==k.protocol())for(var q=0;q<o.length;q++){if(o[q].webkitGetAsEntry&&o[q].webkitGetAsEntry()&&o[q].webkitGetAsEntry().isDirectory){var r=o[q].webkitGetAsEntry();if(r.isDirectory&&!e)continue;null!=r&&l(m,r)}else{var s=o[q].getAsFile();null!=s&&h(s)}if(!f&&m.length>0)break}else{var t=b.dataTransfer.files;if(null!=t)for(var u=0;u<t.length&&(h(t.item(u)),f||!(m.length>0));u++);}var v=0;!function w(a){j(function(){if(p)10*v++<2e4&&w(10);else{if(!f&&m.length>1){for(q=0;"directory"===m[q].type;)q++;m=[m[q]]}d(m,n)}},a||0)}()}var n=b();if(e(g,"dropAvailable")&&j(function(){a[e(g,"dropAvailable")]?a[e(g,"dropAvailable")].value=n:a[e(g,"dropAvailable")]=n}),!n)return void(i(e(g,"ngfHideOnDropNotAvailable"))(a)===!0&&f.css("display","none"));var o=!1;-1===e(g,"ngfDrop").search(/\W+$files\W+/)&&a.$watch(e(g,"ngfDrop"),function(a){o=a===!1});var p,q=null,r=i(e(g,"ngfStopPropagation")),s=1;f[0].addEventListener("dragover",function(b){if(!f.attr("disabled")&&!o){if(b.preventDefault(),r(a)&&b.stopPropagation(),navigator.userAgent.indexOf("Chrome")>-1){var c=b.dataTransfer.effectAllowed;b.dataTransfer.dropEffect="move"===c||"linkMove"===c?"move":"copy"}j.cancel(q),a.actualDragOverClass||(p=l(a,g,b)),f.addClass(p)}},!1),f[0].addEventListener("dragenter",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation())},!1),f[0].addEventListener("dragleave",function(){f.attr("disabled")||o||(q=j(function(){f.removeClass(p),p=null},s||1))},!1),f[0].addEventListener("drop",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation(),f.removeClass(p),p=null,m(b,function(c,f){d(i,j,a,h,g,e(g,"ngfChange")||e(g,"ngfDrop"),c,f,b)},i(e(g,"ngfAllowDir"))(a)!==!1,e(g,"multiple")||i(e(g,"ngfMultiple"))(a)))},!1)}function b(){var a=document.createElement("div");return"draggable"in a&&"ondrop"in a}var c=ngFileUpload.validate,d=ngFileUpload.updateModel,e=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfDrop",["$parse","$timeout","$location",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.directive("ngfNoFileDrop",function(){return function(a,c){b()&&c.css("display","none")}}),ngFileUpload.directive("ngfDropAvailable",["$parse","$timeout",function(a,c){return function(d,f,g){if(b()){var h=a(e(g,"ngfDropAvailable"));c(function(){h(d),h.assign&&h.assign(d,!0)})}}}])}(),function(){function a(a,b,c,d,e,f,g){b.$watch(e,function(e){window.FileReader&&ngFileUpload.validate(b,c,d,e,null)&&a.dataUrl(e,function(a){g?g(a):e.dataUrl=a||c(f)(b)},c(d.ngfNoObjectUrl)(b))})}ngFileUpload.directive("ngfSrc",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfSrc,f.ngfDefaultSrc,function(a){e.attr("src",a)})}}}]),ngFileUpload.directive("ngfBackground",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfBackground,f.ngfDefaultBackground,function(a){e.css("background-image","url("+a+")")})}}}]),ngFileUpload.directive("ngfDataUrl",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfDataUrl,f.ngfDefaultDataUrl)}}}])}(); |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var app = angular.module('fileUpload', ['ngFileUpload']); | ||
var version = '5.2.0'; | ||
var version = '6.0.0'; | ||
@@ -22,6 +22,9 @@ app.controller('MyCtrl', ['$scope', '$http', '$timeout', '$compile', 'Upload', function ($scope, $http, $timeout, $compile, Upload) { | ||
if (files != null) { | ||
if (!angular.isArray(files)) { | ||
$scope.files = files = [files]; | ||
} | ||
for (var i = 0; i < files.length; i++) { | ||
$scope.errorMsg = null; | ||
(function (file) { | ||
upload(file); | ||
(function (f) { | ||
upload(f); | ||
})(files[i]); | ||
@@ -32,6 +35,6 @@ } | ||
$scope.uploadPic = function (files) { | ||
$scope.uploadPic = function(file) { | ||
$scope.formUpload = true; | ||
if (files != null) { | ||
upload(files[0]) | ||
if (file != null) { | ||
upload(file) | ||
} | ||
@@ -170,3 +173,4 @@ }; | ||
$scope.editHtml = (localStorage && localStorage.getItem('editHtml' + version)) || $scope.defaultHtml; | ||
var fromLocal = (localStorage && localStorage.getItem('editHtml' + version)); | ||
$scope.editHtml = fromLocal || $scope.defaultHtml; | ||
function htmlEdit() { | ||
@@ -233,3 +237,2 @@ document.getElementById('editArea').innerHTML = $scope.editHtml; | ||
}); | ||
}]); |
@@ -1,2 +0,2 @@ | ||
/*! 5.1.0 */ | ||
/*! 5.2.1 */ | ||
/*! FileAPI 2.0.7 - BSD | git://github.com/mailru/FileAPI.git | ||
@@ -3,0 +3,0 @@ * FileAPI — a set of javascript tools for working with files. Multiupload, drag'n'drop and chunked file upload. Images: crop, resize and auto orientation by EXIF. |
@@ -5,3 +5,3 @@ /**! | ||
* @author Danial <danial.farid@gmail.com> | ||
* @version 5.1.0 | ||
* @version 5.2.1 | ||
*/ | ||
@@ -434,3 +434,3 @@ | ||
* @author Danial <danial.farid@gmail.com> | ||
* @version 5.1.0 | ||
* @version 5.2.1 | ||
*/ | ||
@@ -456,3 +456,3 @@ | ||
ngFileUpload.version = '5.1.0'; | ||
ngFileUpload.version = '5.2.1'; | ||
ngFileUpload.defaults = {}; | ||
@@ -689,4 +689,5 @@ | ||
/** @namespace attr.ngModel */ | ||
/** @namespace attr.ngModelRejected */ | ||
/** @namespace attr.ngfModel */ | ||
/** @namespace attr.ngModelRejected */ | ||
/** @namespace attr.ngfModelRejected */ | ||
/** @namespace attr.ngfMultiple */ | ||
@@ -945,16 +946,17 @@ /** @namespace attr.ngfCapture */ | ||
} | ||
var file = files && files[0]; | ||
var file = files && files.length ? files[0] : null; | ||
if (ngModel) { | ||
$parse(getAttr(attr, 'ngModel')).assign(scope, files); | ||
var singleModel = !$parse(getAttr(attr, 'multiple'))(scope) && !keep; | ||
var ngfModel = getAttr(attr, 'ngfModel'); | ||
if (ngfModel) { | ||
$parse(ngfModel).assign(scope, singleModel ? file : files); | ||
} | ||
var singleModel = !$parse(getAttr(attr, 'ngfMultiple'))(scope) && ! getAttr(attr, 'multiple') && !keep; | ||
$parse(getAttr(attr, 'ngModel')).assign(scope, singleModel ? file : files); | ||
$timeout(function () { | ||
if (ngModel) { | ||
ngModel.$setViewValue(files != null && files.length === 0 ? null : files); | ||
ngModel.$setViewValue(singleModel ? file : (files != null && files.length === 0 ? null : files)); | ||
} | ||
}); | ||
} | ||
var ngfModel = getAttr(attr, 'ngfModel'); | ||
if (ngfModel) { | ||
$parse(ngfModel).assign(scope, files); | ||
} | ||
if (getAttr(attr, 'ngModelRejected')) { | ||
@@ -961,0 +963,0 @@ $parse(getAttr(attr, 'ngModelRejected')).assign(scope, rejFiles); |
@@ -1,2 +0,2 @@ | ||
/*! 5.1.0 */ | ||
!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){}}if(window.FileAPI||(window.FileAPI={}),FileAPI.shouldLoad=window.XMLHttpRequest&&!window.FormData||FileAPI.forceLoad,FileAPI.shouldLoad){var c=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,d,e){c(this),this.__url=d;try{a.apply(this,[b,d,e])}catch(f){f.message.indexOf("Access is denied")>-1&&(this.__origError=f,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,d){if("__setXHR_"===b){c(this);var e=d(this);e instanceof Function&&e(this)}else this.__requestHeaders=this.__requestHeaders||{},this.__requestHeaders[b]=d,a.apply(this,arguments)}}),a("send",function(a){return function(){var c=this;if(arguments[0]&&arguments[0].__isFileAPIShim){var d=arguments[0],e={url:c.__url,jsonp:!1,cache:!0,complete:function(a,d){c.__completed=!0,!a&&c.__listeners.load&&c.__listeners.load({type:"load",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),!a&&c.__listeners.loadend&&c.__listeners.loadend({type:"loadend",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),"abort"===a&&c.__listeners.abort&&c.__listeners.abort({type:"abort",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),void 0!==d.status&&b(c,"status",function(){return 0===d.status&&a&&"abort"!==a?500:d.status}),void 0!==d.statusText&&b(c,"statusText",function(){return d.statusText}),b(c,"readyState",function(){return 4}),void 0!==d.response&&b(c,"response",function(){return d.response});var e=d.responseText||(a&&0===d.status&&"abort"!==a?a:void 0);b(c,"responseText",function(){return e}),b(c,"response",function(){return e}),a&&b(c,"err",function(){return a}),c.__fileApiXHR=d,c.onreadystatechange&&c.onreadystatechange(),c.onload&&c.onload()},progress:function(a){if(a.target=c,c.__listeners.progress&&c.__listeners.progress(a),c.__total=a.total,c.__loaded=a.loaded,a.total===a.loaded){var b=this;setTimeout(function(){c.__completed||(c.getAllResponseHeaders=function(){},b.complete(null,{status:204,statusText:"No Content"}))},FileAPI.noContentTimeout||1e4)}},headers:c.__requestHeaders};e.data={},e.files={};for(var f=0;f<d.data.length;f++){var g=d.data[f];null!=g.val&&null!=g.val.name&&null!=g.val.size&&null!=g.val.type?e.files[g.key]=g.val:e.data[g.key]=g.val}setTimeout(function(){if(!FileAPI.hasFlash)throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';c.__fileApiXHR=FileAPI.upload(e)},1)}else{if(this.__origError)throw this.__origError;a.apply(c,arguments)}}}),window.XMLHttpRequest.__isFileAPIShim=!0,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(){function a(a){return"input"===a[0].tagName.toLowerCase()&&a.attr("type")&&"file"===a.attr("type").toLowerCase()}function b(){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}function c(a){var b=0,c=0;if(window.jQuery)return jQuery(a).offset();if(a.offsetParent)do b+=a.offsetLeft-a.scrollLeft,c+=a.offsetTop-a.scrollTop,a=a.offsetParent;while(a);return{left:b,top:c}}if(FileAPI.shouldLoad){if(FileAPI.forceLoad&&(FileAPI.html5=!1),!FileAPI.upload){var d,e,f,g,h,i=document.createElement("script"),j=document.getElementsByTagName("script");if(window.FileAPI.jsUrl)d=window.FileAPI.jsUrl;else if(window.FileAPI.jsPath)e=window.FileAPI.jsPath;else for(f=0;f<j.length;f++)if(h=j[f].src,g=h.search(/\/ng\-file\-upload[\-a-zA-z0-9\.]*\.js/),g>-1){e=h.substring(0,g+1);break}null==FileAPI.staticPath&&(FileAPI.staticPath=e),i.setAttribute("src",d||e+"FileAPI.min.js"),document.getElementsByTagName("head")[0].appendChild(i),FileAPI.hasFlash=b()}FileAPI.ngfFixIE=function(d,e,f,g){if(!b())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';var h=function(){if(d.attr("disabled"))d.$$ngfRefElem.removeClass("js-fileapi-wrapper");else{var b=d.$$ngfRefElem;b?f(d.$$ngfRefElem):(b=d.$$ngfRefElem=e(),b.addClass("js-fileapi-wrapper"),!a(d),setTimeout(function(){b.bind("mouseenter",h)},10),b.bind("change",function(a){i.apply(this,[a]),g.apply(this,[a])})),a(d)||b.css("position","absolute").css("top",c(d[0]).top+"px").css("left",c(d[0]).left+"px").css("width",d[0].offsetWidth+"px").css("height",d[0].offsetHeight+"px").css("filter","alpha(opacity=0)").css("display",d.css("display")).css("overflow","hidden").css("z-index","900000").css("visibility","visible")}};d.bind("mouseenter",h);var i=function(a){for(var b=FileAPI.getFiles(a),c=0;c<b.length;c++)void 0===b[c].size&&(b[c].size=0),void 0===b[c].name&&(b[c].name="file"),void 0===b[c].type&&(b[c].type="undefined");a.target||(a.target={}),a.target.files=b,a.target.files!==b&&(a.__files_=b),(a.__files_||a.target.files).item=function(b){return(a.__files_||a.target.files)[b]||null}}},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){b||(b=!0,a.onloadstart&&a.onloadstart(c("loadstart",d)));var e;"load"===d.type?(a.onloadend&&a.onloadend(c("loadend",d)),e=c("load",d),a.onload&&a.onload(e),a.dispatchEvent(e)):"progress"===d.type?(e=c("progress",d),a.onprogress&&a.onprogress(e),a.dispatchEvent(e)):(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)}}),!window.XMLHttpRequest||window.FileAPI&&FileAPI.shouldLoad||(window.XMLHttpRequest.prototype.setRequestHeader=function(a){return function(b,c){if("__setXHR_"===b){var d=c(this);d instanceof Function&&d(this)}else a.apply(this,arguments)}}(window.XMLHttpRequest.prototype.setRequestHeader));var ngFileUpload=angular.module("ngFileUpload",[]);ngFileUpload.version="5.1.0",ngFileUpload.defaults={},ngFileUpload.service("Upload",["$http","$q","$timeout",function(a,b,c){function d(d){d.method=d.method||"POST",d.headers=d.headers||{};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.progressFunc&&c(function(){f.progressFunc(a)})},!1),a.upload.addEventListener("load",function(a){a.lengthComputable&&(a.config=d,e.notify?e.notify(a):f.progressFunc&&c(function(){f.progressFunc(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.progressFunc=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){function b(c,d,e){if(void 0!==d)if(angular.isDate(d)&&(d=d.toISOString()),angular.isString(d))c.append(e,d);else if("form"===a.sendFieldsAs)if(angular.isObject(d))for(var f in d)d.hasOwnProperty(f)&&b(c,d[f],e+"["+f+"]");else c.append(e,d);else d=angular.isString(d)?d:JSON.stringify(d),"json-blob"===a.sendFieldsAs?c.append(e,new Blob([d],{type:"application/json"})):c.append(e,d)}return a.headers=a.headers||{},a.headers["Content-Type"]=void 0,a.transformRequest=a.transformRequest?angular.isArray(a.transformRequest)?a.transformRequest:[a.transformRequest]:[],a.transformRequest.push(function(c){var d,e=new FormData,f={};for(d in a.fields)a.fields.hasOwnProperty(d)&&(f[d]=a.fields[d]);c&&(f.data=c);for(d in f)if(f.hasOwnProperty(d)){var g=f[d];a.formDataAppender?a.formDataAppender(e,d,g):b(e,g,d)}if(null!=a.file){var h=a.fileFormDataName||"file";if(angular.isArray(a.file))for(var i=angular.isString(h),j=0;j<a.file.length;j++)e.append(i?h:h[j],a.file[j],a.fileName&&a.fileName[j]||a.file[j].name);else e.append(h,a.file,a.fileName||a.file.name)}return e}),d(a)},this.http=function(b){return b.transformRequest=b.transformRequest||function(b){return window.ArrayBuffer&&b instanceof window.ArrayBuffer||b instanceof Blob?b:a.defaults.transformRequest[0](arguments)},d(b)},this.dataUrl=function(a,b,d){window.FileReader&&a&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 8")||a.size<2e4)&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 9")||a.size<4e6)?c(function(){var e=window.URL||window.webkitURL;if(e&&e.createObjectURL&&!d)b(e.createObjectURL(a));else{var f=new FileReader;f.readAsDataURL(a),f.onload=function(a){c(function(){b(a.target.result)})}}}):b(null)},this.setDefaults=function(a){ngFileUpload.defaults=a||{}}}]),function(){function a(a,f,g,h,i,j,k){function l(){return"input"===f[0].tagName.toLowerCase()&&g.type&&"file"===g.type.toLowerCase()}function m(b){if(!s){s=!0;try{for(var f=b.__files_||b.target&&b.target.files,k=[],l=[],m=0;m<f.length;m++){var n=f.item(m);d(a,i,g,n,b)?k.push(n):l.push(n)}e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),k,l,b),0===k.length&&(b.target.value=k)}finally{s=!1}}}function n(b){c(g,"ngfMultiple")&&b.attr("multiple",i(c(g,"ngfMultiple"))(a)),c(g,"ngfCapture")&&b.attr("capture",i(c(g,"ngfCapture"))(a)),c(g,"accept")&&b.attr("accept",c(g,"accept"));for(var d=0;d<f[0].attributes.length;d++){var e=f[0].attributes[d];(l()&&"type"!==e.name||"type"!==e.name&&"class"!==e.name&&"id"!==e.name&&"style"!==e.name)&&b.attr(e.name,e.value)}}function o(b,c){if(!c&&(b||l()))return f.$$ngfRefElem||f;var d=angular.element('<input type="file">');return n(d),l()?(f.replaceWith(d),f=d,d.attr("__ngf_gen__",!0),k(f)(a)):(d.css("visibility","hidden").css("position","absolute").css("overflow","hidden").css("width","0px").css("height","0px").css("z-index","-100000").css("border","none").css("margin","0px").css("padding","0px").attr("tabindex","-1"),f.$$ngfRefElem&&f.$$ngfRefElem.remove(),f.$$ngfRefElem=d,document.body.appendChild(d[0])),d}function p(b){e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),[],[],b,!0)}function q(d){function e(a){a&&a.clientY>0&&k[0].click(),!l()&&a||!j||f.bind("click touchend touchstart",q)}if(f.attr("disabled")||r)return!1;if(null!=d){if("touchstart"===d.type)return t=d.originalEvent.touches[0].clientY,!0;if(d.stopPropagation(),d.preventDefault(),"touchend"===d.type){var h=d.originalEvent.changedTouches[0].clientY;if(Math.abs(h-t)>20)return!1}}var j=i(c(g,"ngfResetOnClick"))(a)!==!1,k=o(d,j);return k&&((!d||j)&&k.bind("change",m),d&&j&&i(c(g,"ngfResetModelOnClick"))(a)!==!1&&p(d),b(navigator.userAgent)?setTimeout(function(){e(d)},0):e(d)),!1}if(!f.attr("__ngf_gen__")){a.$on("$destroy",function(){f.$$ngfRefElem&&f.$$ngfRefElem.remove()});var r=!1;-1===c(g,"ngfSelect").search(/\W+$files\W+/)&&a.$watch(c(g,"ngfSelect"),function(a){r=a===!1});var s=!1,t=0;window.FileAPI&&window.FileAPI.ngfFixIE?window.FileAPI.ngfFixIE(f,o,n,m):q()}}function b(a){var b=a.match(/Android[^\d]*(\d+)\.(\d+)/);if(b&&b.length>2){var c=ngFileUpload.defaults.androidFixMinorVersion||4;return parseInt(b[1])<4||parseInt(b[1])===c&&parseInt(b[2])<c}return-1===a.indexOf("Chrome")&&/.*Windows.*Safari.*/.test(a)}ngFileUpload.getAttrWithDefaults=function(a,b){return null!=a[b]?a[b]:null==ngFileUpload.defaults[b]?ngFileUpload.defaults[b]:ngFileUpload.defaults[b].toString()};var c=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfSelect",["$parse","$timeout","$compile",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.validate=function(a,b,d,e,f){function g(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+="("+g(b[d])+")",d<b.length-1&&(c+="|");else 0===a.indexOf(".")&&(a="*"+a),c="^"+a.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$",c=c.replace(/\\\*/g,".*").replace(/\\\?/g,".");return c}if(null==e)return!1;var h=b(c(d,"ngfAccept"))(a,{$file:e,$event:f}),i=b(c(d,"ngfMaxSize"))(a,{$file:e,$event:f})||9007199254740991,j=b(c(d,"ngfMinSize"))(a,{$file:e,$event:f})||-1;if(null!=h&&angular.isString(h)){var k=new RegExp(g(h),"gi");if(h=null!=e.type&&k.test(e.type.toLowerCase())||null!=e.name&&k.test(e.name.toLowerCase()),!h)return e.$error="accept",!1}else if(h===!1)return e.$error="accept",!1;return null==e.size?!0:e.size>i?(e.$error="maxSize",!1):e.size<j?(e.$error="minSize",!1):!0},ngFileUpload.updateModel=function(a,b,d,e,f,g,h,i,j,k){function l(){var k=a(c(f,"ngfKeep"))(d);if(k===!0){var l=(e.$modelValue||[]).slice(0);if(h&&h.length)if(a(c(f,"ngfKeepDistinct"))(d)===!0){for(var m=l.length,n=0;n<h.length;n++){for(var o=0;m>o&&h[n].name!==l[o].name;o++);o===m&&l.push(h[n])}h=l}else h=l.concat(h);else h=l}var p=h&&h[0];if(e){a(c(f,"ngModel")).assign(d,h);var q=!a(c(f,"multiple"))(d)&&!k,r=c(f,"ngfModel");r&&a(r).assign(d,q?p:h),b(function(){e&&e.$setViewValue(null!=h&&0===h.length?null:h)})}c(f,"ngModelRejected")&&a(c(f,"ngModelRejected")).assign(d,i),g&&a(g)(d,{$files:h,$file:p,$rejectedFiles:i,$event:j})}k?l():b(function(){l()})};var d=ngFileUpload.validate,e=ngFileUpload.updateModel}(),function(){function a(a,f,g,h,i,j,k){function l(a,b,d){var f=!0,g=d.dataTransfer.items;if(null!=g)for(var h=0;h<g.length&&f;h++)f=f&&("file"===g[h].kind||""===g[h].kind)&&c(a,i,b,g[h],d);var j=i(e(b,"ngfDragOverClass"))(a,{$event:d});return j&&(j.delay&&(s=j.delay),j.accept&&(j=f?j.accept:j.reject)),j||e(b,"ngfDragOverClass")||"dragover"}function m(b,d,e,f){function h(d){c(a,i,g,d,b)?m.push(d):n.push(d)}function l(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;h({name:b.name,type:"directory",path:d});var e=b.createReader(),f=[];p++;var g=function(){e.readEntries(function(d){try{if(d.length)f=f.concat(Array.prototype.slice.call(d||[],0)),g();else{for(var e=0;e<f.length;e++)l(a,f[e],(c?c:"")+b.name+"/");p--}}catch(h){p--,console.error(h)}},function(){p--})};g()}else p++,b.file(function(a){try{p--,a.path=(c?c:"")+a.name,h(a)}catch(b){p--,console.error(b)}},function(){p--})}var m=[],n=[],o=b.dataTransfer.items,p=0;if(o&&o.length>0&&"file"!==k.protocol())for(var q=0;q<o.length;q++){if(o[q].webkitGetAsEntry&&o[q].webkitGetAsEntry()&&o[q].webkitGetAsEntry().isDirectory){var r=o[q].webkitGetAsEntry();if(r.isDirectory&&!e)continue;null!=r&&l(m,r)}else{var s=o[q].getAsFile();null!=s&&h(s)}if(!f&&m.length>0)break}else{var t=b.dataTransfer.files;if(null!=t)for(var u=0;u<t.length&&(h(t.item(u)),f||!(m.length>0));u++);}var v=0;!function w(a){j(function(){if(p)10*v++<2e4&&w(10);else{if(!f&&m.length>1){for(q=0;"directory"===m[q].type;)q++;m=[m[q]]}d(m,n)}},a||0)}()}var n=b();if(e(g,"dropAvailable")&&j(function(){a[e(g,"dropAvailable")]?a[e(g,"dropAvailable")].value=n:a[e(g,"dropAvailable")]=n}),!n)return void(i(e(g,"ngfHideOnDropNotAvailable"))(a)===!0&&f.css("display","none"));var o=!1;-1===e(g,"ngfDrop").search(/\W+$files\W+/)&&a.$watch(e(g,"ngfDrop"),function(a){o=a===!1});var p,q=null,r=i(e(g,"ngfStopPropagation")),s=1;f[0].addEventListener("dragover",function(b){if(!f.attr("disabled")&&!o){if(b.preventDefault(),r(a)&&b.stopPropagation(),navigator.userAgent.indexOf("Chrome")>-1){var c=b.dataTransfer.effectAllowed;b.dataTransfer.dropEffect="move"===c||"linkMove"===c?"move":"copy"}j.cancel(q),a.actualDragOverClass||(p=l(a,g,b)),f.addClass(p)}},!1),f[0].addEventListener("dragenter",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation())},!1),f[0].addEventListener("dragleave",function(){f.attr("disabled")||o||(q=j(function(){f.removeClass(p),p=null},s||1))},!1),f[0].addEventListener("drop",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation(),f.removeClass(p),p=null,m(b,function(c,f){d(i,j,a,h,g,e(g,"ngfChange")||e(g,"ngfDrop"),c,f,b)},i(e(g,"ngfAllowDir"))(a)!==!1,e(g,"multiple")||i(e(g,"ngfMultiple"))(a)))},!1)}function b(){var a=document.createElement("div");return"draggable"in a&&"ondrop"in a}var c=ngFileUpload.validate,d=ngFileUpload.updateModel,e=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfDrop",["$parse","$timeout","$location",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.directive("ngfNoFileDrop",function(){return function(a,c){b()&&c.css("display","none")}}),ngFileUpload.directive("ngfDropAvailable",["$parse","$timeout",function(a,c){return function(d,f,g){if(b()){var h=a(e(g,"ngfDropAvailable"));c(function(){h(d),h.assign&&h.assign(d,!0)})}}}])}(),function(){function a(a,b,c,d,e,f,g){b.$watch(e,function(e){window.FileReader&&ngFileUpload.validate(b,c,d,e,null)&&a.dataUrl(e,function(a){g?g(a):e.dataUrl=a||c(f)(b)},c(d.ngfNoObjectUrl)(b))})}ngFileUpload.directive("ngfSrc",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfSrc,f.ngfDefaultSrc,function(a){e.attr("src",a)})}}}]),ngFileUpload.directive("ngfBackground",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfBackground,f.ngfDefaultBackground,function(a){e.css("background-image","url("+a+")")})}}}]),ngFileUpload.directive("ngfDataUrl",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfDataUrl,f.ngfDefaultDataUrl)}}}])}(); | ||
/*! 5.2.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){}}if(window.FileAPI||(window.FileAPI={}),FileAPI.shouldLoad=window.XMLHttpRequest&&!window.FormData||FileAPI.forceLoad,FileAPI.shouldLoad){var c=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,d,e){c(this),this.__url=d;try{a.apply(this,[b,d,e])}catch(f){f.message.indexOf("Access is denied")>-1&&(this.__origError=f,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,d){if("__setXHR_"===b){c(this);var e=d(this);e instanceof Function&&e(this)}else this.__requestHeaders=this.__requestHeaders||{},this.__requestHeaders[b]=d,a.apply(this,arguments)}}),a("send",function(a){return function(){var c=this;if(arguments[0]&&arguments[0].__isFileAPIShim){var d=arguments[0],e={url:c.__url,jsonp:!1,cache:!0,complete:function(a,d){c.__completed=!0,!a&&c.__listeners.load&&c.__listeners.load({type:"load",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),!a&&c.__listeners.loadend&&c.__listeners.loadend({type:"loadend",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),"abort"===a&&c.__listeners.abort&&c.__listeners.abort({type:"abort",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),void 0!==d.status&&b(c,"status",function(){return 0===d.status&&a&&"abort"!==a?500:d.status}),void 0!==d.statusText&&b(c,"statusText",function(){return d.statusText}),b(c,"readyState",function(){return 4}),void 0!==d.response&&b(c,"response",function(){return d.response});var e=d.responseText||(a&&0===d.status&&"abort"!==a?a:void 0);b(c,"responseText",function(){return e}),b(c,"response",function(){return e}),a&&b(c,"err",function(){return a}),c.__fileApiXHR=d,c.onreadystatechange&&c.onreadystatechange(),c.onload&&c.onload()},progress:function(a){if(a.target=c,c.__listeners.progress&&c.__listeners.progress(a),c.__total=a.total,c.__loaded=a.loaded,a.total===a.loaded){var b=this;setTimeout(function(){c.__completed||(c.getAllResponseHeaders=function(){},b.complete(null,{status:204,statusText:"No Content"}))},FileAPI.noContentTimeout||1e4)}},headers:c.__requestHeaders};e.data={},e.files={};for(var f=0;f<d.data.length;f++){var g=d.data[f];null!=g.val&&null!=g.val.name&&null!=g.val.size&&null!=g.val.type?e.files[g.key]=g.val:e.data[g.key]=g.val}setTimeout(function(){if(!FileAPI.hasFlash)throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';c.__fileApiXHR=FileAPI.upload(e)},1)}else{if(this.__origError)throw this.__origError;a.apply(c,arguments)}}}),window.XMLHttpRequest.__isFileAPIShim=!0,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(){function a(a){return"input"===a[0].tagName.toLowerCase()&&a.attr("type")&&"file"===a.attr("type").toLowerCase()}function b(){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}function c(a){var b=0,c=0;if(window.jQuery)return jQuery(a).offset();if(a.offsetParent)do b+=a.offsetLeft-a.scrollLeft,c+=a.offsetTop-a.scrollTop,a=a.offsetParent;while(a);return{left:b,top:c}}if(FileAPI.shouldLoad){if(FileAPI.forceLoad&&(FileAPI.html5=!1),!FileAPI.upload){var d,e,f,g,h,i=document.createElement("script"),j=document.getElementsByTagName("script");if(window.FileAPI.jsUrl)d=window.FileAPI.jsUrl;else if(window.FileAPI.jsPath)e=window.FileAPI.jsPath;else for(f=0;f<j.length;f++)if(h=j[f].src,g=h.search(/\/ng\-file\-upload[\-a-zA-z0-9\.]*\.js/),g>-1){e=h.substring(0,g+1);break}null==FileAPI.staticPath&&(FileAPI.staticPath=e),i.setAttribute("src",d||e+"FileAPI.min.js"),document.getElementsByTagName("head")[0].appendChild(i),FileAPI.hasFlash=b()}FileAPI.ngfFixIE=function(d,e,f,g){if(!b())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';var h=function(){if(d.attr("disabled"))d.$$ngfRefElem.removeClass("js-fileapi-wrapper");else{var b=d.$$ngfRefElem;b?f(d.$$ngfRefElem):(b=d.$$ngfRefElem=e(),b.addClass("js-fileapi-wrapper"),!a(d),setTimeout(function(){b.bind("mouseenter",h)},10),b.bind("change",function(a){i.apply(this,[a]),g.apply(this,[a])})),a(d)||b.css("position","absolute").css("top",c(d[0]).top+"px").css("left",c(d[0]).left+"px").css("width",d[0].offsetWidth+"px").css("height",d[0].offsetHeight+"px").css("filter","alpha(opacity=0)").css("display",d.css("display")).css("overflow","hidden").css("z-index","900000").css("visibility","visible")}};d.bind("mouseenter",h);var i=function(a){for(var b=FileAPI.getFiles(a),c=0;c<b.length;c++)void 0===b[c].size&&(b[c].size=0),void 0===b[c].name&&(b[c].name="file"),void 0===b[c].type&&(b[c].type="undefined");a.target||(a.target={}),a.target.files=b,a.target.files!==b&&(a.__files_=b),(a.__files_||a.target.files).item=function(b){return(a.__files_||a.target.files)[b]||null}}},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){b||(b=!0,a.onloadstart&&a.onloadstart(c("loadstart",d)));var e;"load"===d.type?(a.onloadend&&a.onloadend(c("loadend",d)),e=c("load",d),a.onload&&a.onload(e),a.dispatchEvent(e)):"progress"===d.type?(e=c("progress",d),a.onprogress&&a.onprogress(e),a.dispatchEvent(e)):(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)}}),!window.XMLHttpRequest||window.FileAPI&&FileAPI.shouldLoad||(window.XMLHttpRequest.prototype.setRequestHeader=function(a){return function(b,c){if("__setXHR_"===b){var d=c(this);d instanceof Function&&d(this)}else a.apply(this,arguments)}}(window.XMLHttpRequest.prototype.setRequestHeader));var ngFileUpload=angular.module("ngFileUpload",[]);ngFileUpload.version="5.2.1",ngFileUpload.defaults={},ngFileUpload.service("Upload",["$http","$q","$timeout",function(a,b,c){function d(d){d.method=d.method||"POST",d.headers=d.headers||{};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.progressFunc&&c(function(){f.progressFunc(a)})},!1),a.upload.addEventListener("load",function(a){a.lengthComputable&&(a.config=d,e.notify?e.notify(a):f.progressFunc&&c(function(){f.progressFunc(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.progressFunc=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){function b(c,d,e){if(void 0!==d)if(angular.isDate(d)&&(d=d.toISOString()),angular.isString(d))c.append(e,d);else if("form"===a.sendFieldsAs)if(angular.isObject(d))for(var f in d)d.hasOwnProperty(f)&&b(c,d[f],e+"["+f+"]");else c.append(e,d);else d=angular.isString(d)?d:JSON.stringify(d),"json-blob"===a.sendFieldsAs?c.append(e,new Blob([d],{type:"application/json"})):c.append(e,d)}return a.headers=a.headers||{},a.headers["Content-Type"]=void 0,a.transformRequest=a.transformRequest?angular.isArray(a.transformRequest)?a.transformRequest:[a.transformRequest]:[],a.transformRequest.push(function(c){var d,e=new FormData,f={};for(d in a.fields)a.fields.hasOwnProperty(d)&&(f[d]=a.fields[d]);c&&(f.data=c);for(d in f)if(f.hasOwnProperty(d)){var g=f[d];a.formDataAppender?a.formDataAppender(e,d,g):b(e,g,d)}if(null!=a.file){var h=a.fileFormDataName||"file";if(angular.isArray(a.file))for(var i=angular.isString(h),j=0;j<a.file.length;j++)e.append(i?h:h[j],a.file[j],a.fileName&&a.fileName[j]||a.file[j].name);else e.append(h,a.file,a.fileName||a.file.name)}return e}),d(a)},this.http=function(b){return b.transformRequest=b.transformRequest||function(b){return window.ArrayBuffer&&b instanceof window.ArrayBuffer||b instanceof Blob?b:a.defaults.transformRequest[0](arguments)},d(b)},this.dataUrl=function(a,b,d){window.FileReader&&a&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 8")||a.size<2e4)&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 9")||a.size<4e6)?c(function(){var e=window.URL||window.webkitURL;if(e&&e.createObjectURL&&!d)b(e.createObjectURL(a));else{var f=new FileReader;f.readAsDataURL(a),f.onload=function(a){c(function(){b(a.target.result)})}}}):b(null)},this.setDefaults=function(a){ngFileUpload.defaults=a||{}}}]),function(){function a(a,f,g,h,i,j,k){function l(){return"input"===f[0].tagName.toLowerCase()&&g.type&&"file"===g.type.toLowerCase()}function m(b){if(!s){s=!0;try{for(var f=b.__files_||b.target&&b.target.files,k=[],l=[],m=0;m<f.length;m++){var n=f.item(m);d(a,i,g,n,b)?k.push(n):l.push(n)}e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),k,l,b),0===k.length&&(b.target.value=k)}finally{s=!1}}}function n(b){c(g,"ngfMultiple")&&b.attr("multiple",i(c(g,"ngfMultiple"))(a)),c(g,"ngfCapture")&&b.attr("capture",i(c(g,"ngfCapture"))(a)),c(g,"accept")&&b.attr("accept",c(g,"accept"));for(var d=0;d<f[0].attributes.length;d++){var e=f[0].attributes[d];(l()&&"type"!==e.name||"type"!==e.name&&"class"!==e.name&&"id"!==e.name&&"style"!==e.name)&&b.attr(e.name,e.value)}}function o(b,c){if(!c&&(b||l()))return f.$$ngfRefElem||f;var d=angular.element('<input type="file">');return n(d),l()?(f.replaceWith(d),f=d,d.attr("__ngf_gen__",!0),k(f)(a)):(d.css("visibility","hidden").css("position","absolute").css("overflow","hidden").css("width","0px").css("height","0px").css("z-index","-100000").css("border","none").css("margin","0px").css("padding","0px").attr("tabindex","-1"),f.$$ngfRefElem&&f.$$ngfRefElem.remove(),f.$$ngfRefElem=d,document.body.appendChild(d[0])),d}function p(b){e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),[],[],b,!0)}function q(d){function e(a){a&&a.clientY>0&&k[0].click(),!l()&&a||!j||f.bind("click touchend touchstart",q)}if(f.attr("disabled")||r)return!1;if(null!=d){if("touchstart"===d.type)return t=d.originalEvent.touches[0].clientY,!0;if(d.stopPropagation(),d.preventDefault(),"touchend"===d.type){var h=d.originalEvent.changedTouches[0].clientY;if(Math.abs(h-t)>20)return!1}}var j=i(c(g,"ngfResetOnClick"))(a)!==!1,k=o(d,j);return k&&((!d||j)&&k.bind("change",m),d&&j&&i(c(g,"ngfResetModelOnClick"))(a)!==!1&&p(d),b(navigator.userAgent)?setTimeout(function(){e(d)},0):e(d)),!1}if(!f.attr("__ngf_gen__")){a.$on("$destroy",function(){f.$$ngfRefElem&&f.$$ngfRefElem.remove()});var r=!1;-1===c(g,"ngfSelect").search(/\W+$files\W+/)&&a.$watch(c(g,"ngfSelect"),function(a){r=a===!1});var s=!1,t=0;window.FileAPI&&window.FileAPI.ngfFixIE?window.FileAPI.ngfFixIE(f,o,n,m):q()}}function b(a){var b=a.match(/Android[^\d]*(\d+)\.(\d+)/);if(b&&b.length>2){var c=ngFileUpload.defaults.androidFixMinorVersion||4;return parseInt(b[1])<4||parseInt(b[1])===c&&parseInt(b[2])<c}return-1===a.indexOf("Chrome")&&/.*Windows.*Safari.*/.test(a)}ngFileUpload.getAttrWithDefaults=function(a,b){return null!=a[b]?a[b]:null==ngFileUpload.defaults[b]?ngFileUpload.defaults[b]:ngFileUpload.defaults[b].toString()};var c=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfSelect",["$parse","$timeout","$compile",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.validate=function(a,b,d,e,f){function g(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+="("+g(b[d])+")",d<b.length-1&&(c+="|");else 0===a.indexOf(".")&&(a="*"+a),c="^"+a.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$",c=c.replace(/\\\*/g,".*").replace(/\\\?/g,".");return c}if(null==e)return!1;var h=b(c(d,"ngfAccept"))(a,{$file:e,$event:f}),i=b(c(d,"ngfMaxSize"))(a,{$file:e,$event:f})||9007199254740991,j=b(c(d,"ngfMinSize"))(a,{$file:e,$event:f})||-1;if(null!=h&&angular.isString(h)){var k=new RegExp(g(h),"gi");if(h=null!=e.type&&k.test(e.type.toLowerCase())||null!=e.name&&k.test(e.name.toLowerCase()),!h)return e.$error="accept",!1}else if(h===!1)return e.$error="accept",!1;return null==e.size?!0:e.size>i?(e.$error="maxSize",!1):e.size<j?(e.$error="minSize",!1):!0},ngFileUpload.updateModel=function(a,b,d,e,f,g,h,i,j,k){function l(){var k=a(c(f,"ngfKeep"))(d);if(k===!0){var l=(e.$modelValue||[]).slice(0);if(h&&h.length)if(a(c(f,"ngfKeepDistinct"))(d)===!0){for(var m=l.length,n=0;n<h.length;n++){for(var o=0;m>o&&h[n].name!==l[o].name;o++);o===m&&l.push(h[n])}h=l}else h=l.concat(h);else h=l}var p=h&&h.length?h[0]:null;if(e){var q=!a(c(f,"ngfMultiple"))(d)&&!c(f,"multiple")&&!k;a(c(f,"ngModel")).assign(d,q?p:h),b(function(){e&&e.$setViewValue(q?p:null!=h&&0===h.length?null:h)})}var r=c(f,"ngfModel");r&&a(r).assign(d,h),c(f,"ngModelRejected")&&a(c(f,"ngModelRejected")).assign(d,i),g&&a(g)(d,{$files:h,$file:p,$rejectedFiles:i,$event:j})}k?l():b(function(){l()})};var d=ngFileUpload.validate,e=ngFileUpload.updateModel}(),function(){function a(a,f,g,h,i,j,k){function l(a,b,d){var f=!0,g=d.dataTransfer.items;if(null!=g)for(var h=0;h<g.length&&f;h++)f=f&&("file"===g[h].kind||""===g[h].kind)&&c(a,i,b,g[h],d);var j=i(e(b,"ngfDragOverClass"))(a,{$event:d});return j&&(j.delay&&(s=j.delay),j.accept&&(j=f?j.accept:j.reject)),j||e(b,"ngfDragOverClass")||"dragover"}function m(b,d,e,f){function h(d){c(a,i,g,d,b)?m.push(d):n.push(d)}function l(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;h({name:b.name,type:"directory",path:d});var e=b.createReader(),f=[];p++;var g=function(){e.readEntries(function(d){try{if(d.length)f=f.concat(Array.prototype.slice.call(d||[],0)),g();else{for(var e=0;e<f.length;e++)l(a,f[e],(c?c:"")+b.name+"/");p--}}catch(h){p--,console.error(h)}},function(){p--})};g()}else p++,b.file(function(a){try{p--,a.path=(c?c:"")+a.name,h(a)}catch(b){p--,console.error(b)}},function(){p--})}var m=[],n=[],o=b.dataTransfer.items,p=0;if(o&&o.length>0&&"file"!==k.protocol())for(var q=0;q<o.length;q++){if(o[q].webkitGetAsEntry&&o[q].webkitGetAsEntry()&&o[q].webkitGetAsEntry().isDirectory){var r=o[q].webkitGetAsEntry();if(r.isDirectory&&!e)continue;null!=r&&l(m,r)}else{var s=o[q].getAsFile();null!=s&&h(s)}if(!f&&m.length>0)break}else{var t=b.dataTransfer.files;if(null!=t)for(var u=0;u<t.length&&(h(t.item(u)),f||!(m.length>0));u++);}var v=0;!function w(a){j(function(){if(p)10*v++<2e4&&w(10);else{if(!f&&m.length>1){for(q=0;"directory"===m[q].type;)q++;m=[m[q]]}d(m,n)}},a||0)}()}var n=b();if(e(g,"dropAvailable")&&j(function(){a[e(g,"dropAvailable")]?a[e(g,"dropAvailable")].value=n:a[e(g,"dropAvailable")]=n}),!n)return void(i(e(g,"ngfHideOnDropNotAvailable"))(a)===!0&&f.css("display","none"));var o=!1;-1===e(g,"ngfDrop").search(/\W+$files\W+/)&&a.$watch(e(g,"ngfDrop"),function(a){o=a===!1});var p,q=null,r=i(e(g,"ngfStopPropagation")),s=1;f[0].addEventListener("dragover",function(b){if(!f.attr("disabled")&&!o){if(b.preventDefault(),r(a)&&b.stopPropagation(),navigator.userAgent.indexOf("Chrome")>-1){var c=b.dataTransfer.effectAllowed;b.dataTransfer.dropEffect="move"===c||"linkMove"===c?"move":"copy"}j.cancel(q),a.actualDragOverClass||(p=l(a,g,b)),f.addClass(p)}},!1),f[0].addEventListener("dragenter",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation())},!1),f[0].addEventListener("dragleave",function(){f.attr("disabled")||o||(q=j(function(){f.removeClass(p),p=null},s||1))},!1),f[0].addEventListener("drop",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation(),f.removeClass(p),p=null,m(b,function(c,f){d(i,j,a,h,g,e(g,"ngfChange")||e(g,"ngfDrop"),c,f,b)},i(e(g,"ngfAllowDir"))(a)!==!1,e(g,"multiple")||i(e(g,"ngfMultiple"))(a)))},!1)}function b(){var a=document.createElement("div");return"draggable"in a&&"ondrop"in a}var c=ngFileUpload.validate,d=ngFileUpload.updateModel,e=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfDrop",["$parse","$timeout","$location",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.directive("ngfNoFileDrop",function(){return function(a,c){b()&&c.css("display","none")}}),ngFileUpload.directive("ngfDropAvailable",["$parse","$timeout",function(a,c){return function(d,f,g){if(b()){var h=a(e(g,"ngfDropAvailable"));c(function(){h(d),h.assign&&h.assign(d,!0)})}}}])}(),function(){function a(a,b,c,d,e,f,g){b.$watch(e,function(e){window.FileReader&&ngFileUpload.validate(b,c,d,e,null)&&a.dataUrl(e,function(a){g?g(a):e.dataUrl=a||c(f)(b)},c(d.ngfNoObjectUrl)(b))})}ngFileUpload.directive("ngfSrc",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfSrc,f.ngfDefaultSrc,function(a){e.attr("src",a)})}}}]),ngFileUpload.directive("ngfBackground",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfBackground,f.ngfDefaultBackground,function(a){e.css("background-image","url("+a+")")})}}}]),ngFileUpload.directive("ngfDataUrl",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfDataUrl,f.ngfDefaultDataUrl)}}}])}(); |
@@ -5,3 +5,3 @@ /**! | ||
* @author Danial <danial.farid@gmail.com> | ||
* @version 5.1.0 | ||
* @version 5.2.1 | ||
*/ | ||
@@ -8,0 +8,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*! 5.1.0 */ | ||
/*! 5.2.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){}}if(window.FileAPI||(window.FileAPI={}),FileAPI.shouldLoad=window.XMLHttpRequest&&!window.FormData||FileAPI.forceLoad,FileAPI.shouldLoad){var c=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,d,e){c(this),this.__url=d;try{a.apply(this,[b,d,e])}catch(f){f.message.indexOf("Access is denied")>-1&&(this.__origError=f,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,d){if("__setXHR_"===b){c(this);var e=d(this);e instanceof Function&&e(this)}else this.__requestHeaders=this.__requestHeaders||{},this.__requestHeaders[b]=d,a.apply(this,arguments)}}),a("send",function(a){return function(){var c=this;if(arguments[0]&&arguments[0].__isFileAPIShim){var d=arguments[0],e={url:c.__url,jsonp:!1,cache:!0,complete:function(a,d){c.__completed=!0,!a&&c.__listeners.load&&c.__listeners.load({type:"load",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),!a&&c.__listeners.loadend&&c.__listeners.loadend({type:"loadend",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),"abort"===a&&c.__listeners.abort&&c.__listeners.abort({type:"abort",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),void 0!==d.status&&b(c,"status",function(){return 0===d.status&&a&&"abort"!==a?500:d.status}),void 0!==d.statusText&&b(c,"statusText",function(){return d.statusText}),b(c,"readyState",function(){return 4}),void 0!==d.response&&b(c,"response",function(){return d.response});var e=d.responseText||(a&&0===d.status&&"abort"!==a?a:void 0);b(c,"responseText",function(){return e}),b(c,"response",function(){return e}),a&&b(c,"err",function(){return a}),c.__fileApiXHR=d,c.onreadystatechange&&c.onreadystatechange(),c.onload&&c.onload()},progress:function(a){if(a.target=c,c.__listeners.progress&&c.__listeners.progress(a),c.__total=a.total,c.__loaded=a.loaded,a.total===a.loaded){var b=this;setTimeout(function(){c.__completed||(c.getAllResponseHeaders=function(){},b.complete(null,{status:204,statusText:"No Content"}))},FileAPI.noContentTimeout||1e4)}},headers:c.__requestHeaders};e.data={},e.files={};for(var f=0;f<d.data.length;f++){var g=d.data[f];null!=g.val&&null!=g.val.name&&null!=g.val.size&&null!=g.val.type?e.files[g.key]=g.val:e.data[g.key]=g.val}setTimeout(function(){if(!FileAPI.hasFlash)throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';c.__fileApiXHR=FileAPI.upload(e)},1)}else{if(this.__origError)throw this.__origError;a.apply(c,arguments)}}}),window.XMLHttpRequest.__isFileAPIShim=!0,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(){function a(a){return"input"===a[0].tagName.toLowerCase()&&a.attr("type")&&"file"===a.attr("type").toLowerCase()}function b(){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}function c(a){var b=0,c=0;if(window.jQuery)return jQuery(a).offset();if(a.offsetParent)do b+=a.offsetLeft-a.scrollLeft,c+=a.offsetTop-a.scrollTop,a=a.offsetParent;while(a);return{left:b,top:c}}if(FileAPI.shouldLoad){if(FileAPI.forceLoad&&(FileAPI.html5=!1),!FileAPI.upload){var d,e,f,g,h,i=document.createElement("script"),j=document.getElementsByTagName("script");if(window.FileAPI.jsUrl)d=window.FileAPI.jsUrl;else if(window.FileAPI.jsPath)e=window.FileAPI.jsPath;else for(f=0;f<j.length;f++)if(h=j[f].src,g=h.search(/\/ng\-file\-upload[\-a-zA-z0-9\.]*\.js/),g>-1){e=h.substring(0,g+1);break}null==FileAPI.staticPath&&(FileAPI.staticPath=e),i.setAttribute("src",d||e+"FileAPI.min.js"),document.getElementsByTagName("head")[0].appendChild(i),FileAPI.hasFlash=b()}FileAPI.ngfFixIE=function(d,e,f,g){if(!b())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';var h=function(){if(d.attr("disabled"))d.$$ngfRefElem.removeClass("js-fileapi-wrapper");else{var b=d.$$ngfRefElem;b?f(d.$$ngfRefElem):(b=d.$$ngfRefElem=e(),b.addClass("js-fileapi-wrapper"),!a(d),setTimeout(function(){b.bind("mouseenter",h)},10),b.bind("change",function(a){i.apply(this,[a]),g.apply(this,[a])})),a(d)||b.css("position","absolute").css("top",c(d[0]).top+"px").css("left",c(d[0]).left+"px").css("width",d[0].offsetWidth+"px").css("height",d[0].offsetHeight+"px").css("filter","alpha(opacity=0)").css("display",d.css("display")).css("overflow","hidden").css("z-index","900000").css("visibility","visible")}};d.bind("mouseenter",h);var i=function(a){for(var b=FileAPI.getFiles(a),c=0;c<b.length;c++)void 0===b[c].size&&(b[c].size=0),void 0===b[c].name&&(b[c].name="file"),void 0===b[c].type&&(b[c].type="undefined");a.target||(a.target={}),a.target.files=b,a.target.files!==b&&(a.__files_=b),(a.__files_||a.target.files).item=function(b){return(a.__files_||a.target.files)[b]||null}}},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){b||(b=!0,a.onloadstart&&a.onloadstart(c("loadstart",d)));var e;"load"===d.type?(a.onloadend&&a.onloadend(c("loadend",d)),e=c("load",d),a.onload&&a.onload(e),a.dispatchEvent(e)):"progress"===d.type?(e=c("progress",d),a.onprogress&&a.onprogress(e),a.dispatchEvent(e)):(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 5.1.0 | ||
* @version 5.2.1 | ||
*/ | ||
@@ -25,3 +25,3 @@ | ||
ngFileUpload.version = '5.1.0'; | ||
ngFileUpload.version = '5.2.1'; | ||
ngFileUpload.defaults = {}; | ||
@@ -258,4 +258,5 @@ | ||
/** @namespace attr.ngModel */ | ||
/** @namespace attr.ngModelRejected */ | ||
/** @namespace attr.ngfModel */ | ||
/** @namespace attr.ngModelRejected */ | ||
/** @namespace attr.ngfModelRejected */ | ||
/** @namespace attr.ngfMultiple */ | ||
@@ -514,16 +515,17 @@ /** @namespace attr.ngfCapture */ | ||
} | ||
var file = files && files[0]; | ||
var file = files && files.length ? files[0] : null; | ||
if (ngModel) { | ||
$parse(getAttr(attr, 'ngModel')).assign(scope, files); | ||
var singleModel = !$parse(getAttr(attr, 'multiple'))(scope) && !keep; | ||
var ngfModel = getAttr(attr, 'ngfModel'); | ||
if (ngfModel) { | ||
$parse(ngfModel).assign(scope, singleModel ? file : files); | ||
} | ||
var singleModel = !$parse(getAttr(attr, 'ngfMultiple'))(scope) && ! getAttr(attr, 'multiple') && !keep; | ||
$parse(getAttr(attr, 'ngModel')).assign(scope, singleModel ? file : files); | ||
$timeout(function () { | ||
if (ngModel) { | ||
ngModel.$setViewValue(files != null && files.length === 0 ? null : files); | ||
ngModel.$setViewValue(singleModel ? file : (files != null && files.length === 0 ? null : files)); | ||
} | ||
}); | ||
} | ||
var ngfModel = getAttr(attr, 'ngfModel'); | ||
if (ngfModel) { | ||
$parse(ngfModel).assign(scope, files); | ||
} | ||
if (getAttr(attr, 'ngModelRejected')) { | ||
@@ -530,0 +532,0 @@ $parse(getAttr(attr, 'ngModelRejected')).assign(scope, rejFiles); |
@@ -1,2 +0,2 @@ | ||
/*! 5.1.0 */ | ||
!window.XMLHttpRequest||window.FileAPI&&FileAPI.shouldLoad||(window.XMLHttpRequest.prototype.setRequestHeader=function(a){return function(b,c){if("__setXHR_"===b){var d=c(this);d instanceof Function&&d(this)}else a.apply(this,arguments)}}(window.XMLHttpRequest.prototype.setRequestHeader));var ngFileUpload=angular.module("ngFileUpload",[]);ngFileUpload.version="5.1.0",ngFileUpload.defaults={},ngFileUpload.service("Upload",["$http","$q","$timeout",function(a,b,c){function d(d){d.method=d.method||"POST",d.headers=d.headers||{};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.progressFunc&&c(function(){f.progressFunc(a)})},!1),a.upload.addEventListener("load",function(a){a.lengthComputable&&(a.config=d,e.notify?e.notify(a):f.progressFunc&&c(function(){f.progressFunc(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.progressFunc=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){function b(c,d,e){if(void 0!==d)if(angular.isDate(d)&&(d=d.toISOString()),angular.isString(d))c.append(e,d);else if("form"===a.sendFieldsAs)if(angular.isObject(d))for(var f in d)d.hasOwnProperty(f)&&b(c,d[f],e+"["+f+"]");else c.append(e,d);else d=angular.isString(d)?d:JSON.stringify(d),"json-blob"===a.sendFieldsAs?c.append(e,new Blob([d],{type:"application/json"})):c.append(e,d)}return a.headers=a.headers||{},a.headers["Content-Type"]=void 0,a.transformRequest=a.transformRequest?angular.isArray(a.transformRequest)?a.transformRequest:[a.transformRequest]:[],a.transformRequest.push(function(c){var d,e=new FormData,f={};for(d in a.fields)a.fields.hasOwnProperty(d)&&(f[d]=a.fields[d]);c&&(f.data=c);for(d in f)if(f.hasOwnProperty(d)){var g=f[d];a.formDataAppender?a.formDataAppender(e,d,g):b(e,g,d)}if(null!=a.file){var h=a.fileFormDataName||"file";if(angular.isArray(a.file))for(var i=angular.isString(h),j=0;j<a.file.length;j++)e.append(i?h:h[j],a.file[j],a.fileName&&a.fileName[j]||a.file[j].name);else e.append(h,a.file,a.fileName||a.file.name)}return e}),d(a)},this.http=function(b){return b.transformRequest=b.transformRequest||function(b){return window.ArrayBuffer&&b instanceof window.ArrayBuffer||b instanceof Blob?b:a.defaults.transformRequest[0](arguments)},d(b)},this.dataUrl=function(a,b,d){window.FileReader&&a&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 8")||a.size<2e4)&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 9")||a.size<4e6)?c(function(){var e=window.URL||window.webkitURL;if(e&&e.createObjectURL&&!d)b(e.createObjectURL(a));else{var f=new FileReader;f.readAsDataURL(a),f.onload=function(a){c(function(){b(a.target.result)})}}}):b(null)},this.setDefaults=function(a){ngFileUpload.defaults=a||{}}}]),function(){function a(a,f,g,h,i,j,k){function l(){return"input"===f[0].tagName.toLowerCase()&&g.type&&"file"===g.type.toLowerCase()}function m(b){if(!s){s=!0;try{for(var f=b.__files_||b.target&&b.target.files,k=[],l=[],m=0;m<f.length;m++){var n=f.item(m);d(a,i,g,n,b)?k.push(n):l.push(n)}e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),k,l,b),0===k.length&&(b.target.value=k)}finally{s=!1}}}function n(b){c(g,"ngfMultiple")&&b.attr("multiple",i(c(g,"ngfMultiple"))(a)),c(g,"ngfCapture")&&b.attr("capture",i(c(g,"ngfCapture"))(a)),c(g,"accept")&&b.attr("accept",c(g,"accept"));for(var d=0;d<f[0].attributes.length;d++){var e=f[0].attributes[d];(l()&&"type"!==e.name||"type"!==e.name&&"class"!==e.name&&"id"!==e.name&&"style"!==e.name)&&b.attr(e.name,e.value)}}function o(b,c){if(!c&&(b||l()))return f.$$ngfRefElem||f;var d=angular.element('<input type="file">');return n(d),l()?(f.replaceWith(d),f=d,d.attr("__ngf_gen__",!0),k(f)(a)):(d.css("visibility","hidden").css("position","absolute").css("overflow","hidden").css("width","0px").css("height","0px").css("z-index","-100000").css("border","none").css("margin","0px").css("padding","0px").attr("tabindex","-1"),f.$$ngfRefElem&&f.$$ngfRefElem.remove(),f.$$ngfRefElem=d,document.body.appendChild(d[0])),d}function p(b){e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),[],[],b,!0)}function q(d){function e(a){a&&a.clientY>0&&k[0].click(),!l()&&a||!j||f.bind("click touchend touchstart",q)}if(f.attr("disabled")||r)return!1;if(null!=d){if("touchstart"===d.type)return t=d.originalEvent.touches[0].clientY,!0;if(d.stopPropagation(),d.preventDefault(),"touchend"===d.type){var h=d.originalEvent.changedTouches[0].clientY;if(Math.abs(h-t)>20)return!1}}var j=i(c(g,"ngfResetOnClick"))(a)!==!1,k=o(d,j);return k&&((!d||j)&&k.bind("change",m),d&&j&&i(c(g,"ngfResetModelOnClick"))(a)!==!1&&p(d),b(navigator.userAgent)?setTimeout(function(){e(d)},0):e(d)),!1}if(!f.attr("__ngf_gen__")){a.$on("$destroy",function(){f.$$ngfRefElem&&f.$$ngfRefElem.remove()});var r=!1;-1===c(g,"ngfSelect").search(/\W+$files\W+/)&&a.$watch(c(g,"ngfSelect"),function(a){r=a===!1});var s=!1,t=0;window.FileAPI&&window.FileAPI.ngfFixIE?window.FileAPI.ngfFixIE(f,o,n,m):q()}}function b(a){var b=a.match(/Android[^\d]*(\d+)\.(\d+)/);if(b&&b.length>2){var c=ngFileUpload.defaults.androidFixMinorVersion||4;return parseInt(b[1])<4||parseInt(b[1])===c&&parseInt(b[2])<c}return-1===a.indexOf("Chrome")&&/.*Windows.*Safari.*/.test(a)}ngFileUpload.getAttrWithDefaults=function(a,b){return null!=a[b]?a[b]:null==ngFileUpload.defaults[b]?ngFileUpload.defaults[b]:ngFileUpload.defaults[b].toString()};var c=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfSelect",["$parse","$timeout","$compile",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.validate=function(a,b,d,e,f){function g(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+="("+g(b[d])+")",d<b.length-1&&(c+="|");else 0===a.indexOf(".")&&(a="*"+a),c="^"+a.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$",c=c.replace(/\\\*/g,".*").replace(/\\\?/g,".");return c}if(null==e)return!1;var h=b(c(d,"ngfAccept"))(a,{$file:e,$event:f}),i=b(c(d,"ngfMaxSize"))(a,{$file:e,$event:f})||9007199254740991,j=b(c(d,"ngfMinSize"))(a,{$file:e,$event:f})||-1;if(null!=h&&angular.isString(h)){var k=new RegExp(g(h),"gi");if(h=null!=e.type&&k.test(e.type.toLowerCase())||null!=e.name&&k.test(e.name.toLowerCase()),!h)return e.$error="accept",!1}else if(h===!1)return e.$error="accept",!1;return null==e.size?!0:e.size>i?(e.$error="maxSize",!1):e.size<j?(e.$error="minSize",!1):!0},ngFileUpload.updateModel=function(a,b,d,e,f,g,h,i,j,k){function l(){var k=a(c(f,"ngfKeep"))(d);if(k===!0){var l=(e.$modelValue||[]).slice(0);if(h&&h.length)if(a(c(f,"ngfKeepDistinct"))(d)===!0){for(var m=l.length,n=0;n<h.length;n++){for(var o=0;m>o&&h[n].name!==l[o].name;o++);o===m&&l.push(h[n])}h=l}else h=l.concat(h);else h=l}var p=h&&h[0];if(e){a(c(f,"ngModel")).assign(d,h);var q=!a(c(f,"multiple"))(d)&&!k,r=c(f,"ngfModel");r&&a(r).assign(d,q?p:h),b(function(){e&&e.$setViewValue(null!=h&&0===h.length?null:h)})}c(f,"ngModelRejected")&&a(c(f,"ngModelRejected")).assign(d,i),g&&a(g)(d,{$files:h,$file:p,$rejectedFiles:i,$event:j})}k?l():b(function(){l()})};var d=ngFileUpload.validate,e=ngFileUpload.updateModel}(),function(){function a(a,f,g,h,i,j,k){function l(a,b,d){var f=!0,g=d.dataTransfer.items;if(null!=g)for(var h=0;h<g.length&&f;h++)f=f&&("file"===g[h].kind||""===g[h].kind)&&c(a,i,b,g[h],d);var j=i(e(b,"ngfDragOverClass"))(a,{$event:d});return j&&(j.delay&&(s=j.delay),j.accept&&(j=f?j.accept:j.reject)),j||e(b,"ngfDragOverClass")||"dragover"}function m(b,d,e,f){function h(d){c(a,i,g,d,b)?m.push(d):n.push(d)}function l(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;h({name:b.name,type:"directory",path:d});var e=b.createReader(),f=[];p++;var g=function(){e.readEntries(function(d){try{if(d.length)f=f.concat(Array.prototype.slice.call(d||[],0)),g();else{for(var e=0;e<f.length;e++)l(a,f[e],(c?c:"")+b.name+"/");p--}}catch(h){p--,console.error(h)}},function(){p--})};g()}else p++,b.file(function(a){try{p--,a.path=(c?c:"")+a.name,h(a)}catch(b){p--,console.error(b)}},function(){p--})}var m=[],n=[],o=b.dataTransfer.items,p=0;if(o&&o.length>0&&"file"!==k.protocol())for(var q=0;q<o.length;q++){if(o[q].webkitGetAsEntry&&o[q].webkitGetAsEntry()&&o[q].webkitGetAsEntry().isDirectory){var r=o[q].webkitGetAsEntry();if(r.isDirectory&&!e)continue;null!=r&&l(m,r)}else{var s=o[q].getAsFile();null!=s&&h(s)}if(!f&&m.length>0)break}else{var t=b.dataTransfer.files;if(null!=t)for(var u=0;u<t.length&&(h(t.item(u)),f||!(m.length>0));u++);}var v=0;!function w(a){j(function(){if(p)10*v++<2e4&&w(10);else{if(!f&&m.length>1){for(q=0;"directory"===m[q].type;)q++;m=[m[q]]}d(m,n)}},a||0)}()}var n=b();if(e(g,"dropAvailable")&&j(function(){a[e(g,"dropAvailable")]?a[e(g,"dropAvailable")].value=n:a[e(g,"dropAvailable")]=n}),!n)return void(i(e(g,"ngfHideOnDropNotAvailable"))(a)===!0&&f.css("display","none"));var o=!1;-1===e(g,"ngfDrop").search(/\W+$files\W+/)&&a.$watch(e(g,"ngfDrop"),function(a){o=a===!1});var p,q=null,r=i(e(g,"ngfStopPropagation")),s=1;f[0].addEventListener("dragover",function(b){if(!f.attr("disabled")&&!o){if(b.preventDefault(),r(a)&&b.stopPropagation(),navigator.userAgent.indexOf("Chrome")>-1){var c=b.dataTransfer.effectAllowed;b.dataTransfer.dropEffect="move"===c||"linkMove"===c?"move":"copy"}j.cancel(q),a.actualDragOverClass||(p=l(a,g,b)),f.addClass(p)}},!1),f[0].addEventListener("dragenter",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation())},!1),f[0].addEventListener("dragleave",function(){f.attr("disabled")||o||(q=j(function(){f.removeClass(p),p=null},s||1))},!1),f[0].addEventListener("drop",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation(),f.removeClass(p),p=null,m(b,function(c,f){d(i,j,a,h,g,e(g,"ngfChange")||e(g,"ngfDrop"),c,f,b)},i(e(g,"ngfAllowDir"))(a)!==!1,e(g,"multiple")||i(e(g,"ngfMultiple"))(a)))},!1)}function b(){var a=document.createElement("div");return"draggable"in a&&"ondrop"in a}var c=ngFileUpload.validate,d=ngFileUpload.updateModel,e=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfDrop",["$parse","$timeout","$location",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.directive("ngfNoFileDrop",function(){return function(a,c){b()&&c.css("display","none")}}),ngFileUpload.directive("ngfDropAvailable",["$parse","$timeout",function(a,c){return function(d,f,g){if(b()){var h=a(e(g,"ngfDropAvailable"));c(function(){h(d),h.assign&&h.assign(d,!0)})}}}])}(),function(){function a(a,b,c,d,e,f,g){b.$watch(e,function(e){window.FileReader&&ngFileUpload.validate(b,c,d,e,null)&&a.dataUrl(e,function(a){g?g(a):e.dataUrl=a||c(f)(b)},c(d.ngfNoObjectUrl)(b))})}ngFileUpload.directive("ngfSrc",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfSrc,f.ngfDefaultSrc,function(a){e.attr("src",a)})}}}]),ngFileUpload.directive("ngfBackground",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfBackground,f.ngfDefaultBackground,function(a){e.css("background-image","url("+a+")")})}}}]),ngFileUpload.directive("ngfDataUrl",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfDataUrl,f.ngfDefaultDataUrl)}}}])}(); | ||
/*! 5.2.1 */ | ||
!window.XMLHttpRequest||window.FileAPI&&FileAPI.shouldLoad||(window.XMLHttpRequest.prototype.setRequestHeader=function(a){return function(b,c){if("__setXHR_"===b){var d=c(this);d instanceof Function&&d(this)}else a.apply(this,arguments)}}(window.XMLHttpRequest.prototype.setRequestHeader));var ngFileUpload=angular.module("ngFileUpload",[]);ngFileUpload.version="5.2.1",ngFileUpload.defaults={},ngFileUpload.service("Upload",["$http","$q","$timeout",function(a,b,c){function d(d){d.method=d.method||"POST",d.headers=d.headers||{};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.progressFunc&&c(function(){f.progressFunc(a)})},!1),a.upload.addEventListener("load",function(a){a.lengthComputable&&(a.config=d,e.notify?e.notify(a):f.progressFunc&&c(function(){f.progressFunc(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.progressFunc=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){function b(c,d,e){if(void 0!==d)if(angular.isDate(d)&&(d=d.toISOString()),angular.isString(d))c.append(e,d);else if("form"===a.sendFieldsAs)if(angular.isObject(d))for(var f in d)d.hasOwnProperty(f)&&b(c,d[f],e+"["+f+"]");else c.append(e,d);else d=angular.isString(d)?d:JSON.stringify(d),"json-blob"===a.sendFieldsAs?c.append(e,new Blob([d],{type:"application/json"})):c.append(e,d)}return a.headers=a.headers||{},a.headers["Content-Type"]=void 0,a.transformRequest=a.transformRequest?angular.isArray(a.transformRequest)?a.transformRequest:[a.transformRequest]:[],a.transformRequest.push(function(c){var d,e=new FormData,f={};for(d in a.fields)a.fields.hasOwnProperty(d)&&(f[d]=a.fields[d]);c&&(f.data=c);for(d in f)if(f.hasOwnProperty(d)){var g=f[d];a.formDataAppender?a.formDataAppender(e,d,g):b(e,g,d)}if(null!=a.file){var h=a.fileFormDataName||"file";if(angular.isArray(a.file))for(var i=angular.isString(h),j=0;j<a.file.length;j++)e.append(i?h:h[j],a.file[j],a.fileName&&a.fileName[j]||a.file[j].name);else e.append(h,a.file,a.fileName||a.file.name)}return e}),d(a)},this.http=function(b){return b.transformRequest=b.transformRequest||function(b){return window.ArrayBuffer&&b instanceof window.ArrayBuffer||b instanceof Blob?b:a.defaults.transformRequest[0](arguments)},d(b)},this.dataUrl=function(a,b,d){window.FileReader&&a&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 8")||a.size<2e4)&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 9")||a.size<4e6)?c(function(){var e=window.URL||window.webkitURL;if(e&&e.createObjectURL&&!d)b(e.createObjectURL(a));else{var f=new FileReader;f.readAsDataURL(a),f.onload=function(a){c(function(){b(a.target.result)})}}}):b(null)},this.setDefaults=function(a){ngFileUpload.defaults=a||{}}}]),function(){function a(a,f,g,h,i,j,k){function l(){return"input"===f[0].tagName.toLowerCase()&&g.type&&"file"===g.type.toLowerCase()}function m(b){if(!s){s=!0;try{for(var f=b.__files_||b.target&&b.target.files,k=[],l=[],m=0;m<f.length;m++){var n=f.item(m);d(a,i,g,n,b)?k.push(n):l.push(n)}e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),k,l,b),0===k.length&&(b.target.value=k)}finally{s=!1}}}function n(b){c(g,"ngfMultiple")&&b.attr("multiple",i(c(g,"ngfMultiple"))(a)),c(g,"ngfCapture")&&b.attr("capture",i(c(g,"ngfCapture"))(a)),c(g,"accept")&&b.attr("accept",c(g,"accept"));for(var d=0;d<f[0].attributes.length;d++){var e=f[0].attributes[d];(l()&&"type"!==e.name||"type"!==e.name&&"class"!==e.name&&"id"!==e.name&&"style"!==e.name)&&b.attr(e.name,e.value)}}function o(b,c){if(!c&&(b||l()))return f.$$ngfRefElem||f;var d=angular.element('<input type="file">');return n(d),l()?(f.replaceWith(d),f=d,d.attr("__ngf_gen__",!0),k(f)(a)):(d.css("visibility","hidden").css("position","absolute").css("overflow","hidden").css("width","0px").css("height","0px").css("z-index","-100000").css("border","none").css("margin","0px").css("padding","0px").attr("tabindex","-1"),f.$$ngfRefElem&&f.$$ngfRefElem.remove(),f.$$ngfRefElem=d,document.body.appendChild(d[0])),d}function p(b){e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),[],[],b,!0)}function q(d){function e(a){a&&a.clientY>0&&k[0].click(),!l()&&a||!j||f.bind("click touchend touchstart",q)}if(f.attr("disabled")||r)return!1;if(null!=d){if("touchstart"===d.type)return t=d.originalEvent.touches[0].clientY,!0;if(d.stopPropagation(),d.preventDefault(),"touchend"===d.type){var h=d.originalEvent.changedTouches[0].clientY;if(Math.abs(h-t)>20)return!1}}var j=i(c(g,"ngfResetOnClick"))(a)!==!1,k=o(d,j);return k&&((!d||j)&&k.bind("change",m),d&&j&&i(c(g,"ngfResetModelOnClick"))(a)!==!1&&p(d),b(navigator.userAgent)?setTimeout(function(){e(d)},0):e(d)),!1}if(!f.attr("__ngf_gen__")){a.$on("$destroy",function(){f.$$ngfRefElem&&f.$$ngfRefElem.remove()});var r=!1;-1===c(g,"ngfSelect").search(/\W+$files\W+/)&&a.$watch(c(g,"ngfSelect"),function(a){r=a===!1});var s=!1,t=0;window.FileAPI&&window.FileAPI.ngfFixIE?window.FileAPI.ngfFixIE(f,o,n,m):q()}}function b(a){var b=a.match(/Android[^\d]*(\d+)\.(\d+)/);if(b&&b.length>2){var c=ngFileUpload.defaults.androidFixMinorVersion||4;return parseInt(b[1])<4||parseInt(b[1])===c&&parseInt(b[2])<c}return-1===a.indexOf("Chrome")&&/.*Windows.*Safari.*/.test(a)}ngFileUpload.getAttrWithDefaults=function(a,b){return null!=a[b]?a[b]:null==ngFileUpload.defaults[b]?ngFileUpload.defaults[b]:ngFileUpload.defaults[b].toString()};var c=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfSelect",["$parse","$timeout","$compile",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.validate=function(a,b,d,e,f){function g(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+="("+g(b[d])+")",d<b.length-1&&(c+="|");else 0===a.indexOf(".")&&(a="*"+a),c="^"+a.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$",c=c.replace(/\\\*/g,".*").replace(/\\\?/g,".");return c}if(null==e)return!1;var h=b(c(d,"ngfAccept"))(a,{$file:e,$event:f}),i=b(c(d,"ngfMaxSize"))(a,{$file:e,$event:f})||9007199254740991,j=b(c(d,"ngfMinSize"))(a,{$file:e,$event:f})||-1;if(null!=h&&angular.isString(h)){var k=new RegExp(g(h),"gi");if(h=null!=e.type&&k.test(e.type.toLowerCase())||null!=e.name&&k.test(e.name.toLowerCase()),!h)return e.$error="accept",!1}else if(h===!1)return e.$error="accept",!1;return null==e.size?!0:e.size>i?(e.$error="maxSize",!1):e.size<j?(e.$error="minSize",!1):!0},ngFileUpload.updateModel=function(a,b,d,e,f,g,h,i,j,k){function l(){var k=a(c(f,"ngfKeep"))(d);if(k===!0){var l=(e.$modelValue||[]).slice(0);if(h&&h.length)if(a(c(f,"ngfKeepDistinct"))(d)===!0){for(var m=l.length,n=0;n<h.length;n++){for(var o=0;m>o&&h[n].name!==l[o].name;o++);o===m&&l.push(h[n])}h=l}else h=l.concat(h);else h=l}var p=h&&h.length?h[0]:null;if(e){var q=!a(c(f,"ngfMultiple"))(d)&&!c(f,"multiple")&&!k;a(c(f,"ngModel")).assign(d,q?p:h),b(function(){e&&e.$setViewValue(q?p:null!=h&&0===h.length?null:h)})}var r=c(f,"ngfModel");r&&a(r).assign(d,h),c(f,"ngModelRejected")&&a(c(f,"ngModelRejected")).assign(d,i),g&&a(g)(d,{$files:h,$file:p,$rejectedFiles:i,$event:j})}k?l():b(function(){l()})};var d=ngFileUpload.validate,e=ngFileUpload.updateModel}(),function(){function a(a,f,g,h,i,j,k){function l(a,b,d){var f=!0,g=d.dataTransfer.items;if(null!=g)for(var h=0;h<g.length&&f;h++)f=f&&("file"===g[h].kind||""===g[h].kind)&&c(a,i,b,g[h],d);var j=i(e(b,"ngfDragOverClass"))(a,{$event:d});return j&&(j.delay&&(s=j.delay),j.accept&&(j=f?j.accept:j.reject)),j||e(b,"ngfDragOverClass")||"dragover"}function m(b,d,e,f){function h(d){c(a,i,g,d,b)?m.push(d):n.push(d)}function l(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;h({name:b.name,type:"directory",path:d});var e=b.createReader(),f=[];p++;var g=function(){e.readEntries(function(d){try{if(d.length)f=f.concat(Array.prototype.slice.call(d||[],0)),g();else{for(var e=0;e<f.length;e++)l(a,f[e],(c?c:"")+b.name+"/");p--}}catch(h){p--,console.error(h)}},function(){p--})};g()}else p++,b.file(function(a){try{p--,a.path=(c?c:"")+a.name,h(a)}catch(b){p--,console.error(b)}},function(){p--})}var m=[],n=[],o=b.dataTransfer.items,p=0;if(o&&o.length>0&&"file"!==k.protocol())for(var q=0;q<o.length;q++){if(o[q].webkitGetAsEntry&&o[q].webkitGetAsEntry()&&o[q].webkitGetAsEntry().isDirectory){var r=o[q].webkitGetAsEntry();if(r.isDirectory&&!e)continue;null!=r&&l(m,r)}else{var s=o[q].getAsFile();null!=s&&h(s)}if(!f&&m.length>0)break}else{var t=b.dataTransfer.files;if(null!=t)for(var u=0;u<t.length&&(h(t.item(u)),f||!(m.length>0));u++);}var v=0;!function w(a){j(function(){if(p)10*v++<2e4&&w(10);else{if(!f&&m.length>1){for(q=0;"directory"===m[q].type;)q++;m=[m[q]]}d(m,n)}},a||0)}()}var n=b();if(e(g,"dropAvailable")&&j(function(){a[e(g,"dropAvailable")]?a[e(g,"dropAvailable")].value=n:a[e(g,"dropAvailable")]=n}),!n)return void(i(e(g,"ngfHideOnDropNotAvailable"))(a)===!0&&f.css("display","none"));var o=!1;-1===e(g,"ngfDrop").search(/\W+$files\W+/)&&a.$watch(e(g,"ngfDrop"),function(a){o=a===!1});var p,q=null,r=i(e(g,"ngfStopPropagation")),s=1;f[0].addEventListener("dragover",function(b){if(!f.attr("disabled")&&!o){if(b.preventDefault(),r(a)&&b.stopPropagation(),navigator.userAgent.indexOf("Chrome")>-1){var c=b.dataTransfer.effectAllowed;b.dataTransfer.dropEffect="move"===c||"linkMove"===c?"move":"copy"}j.cancel(q),a.actualDragOverClass||(p=l(a,g,b)),f.addClass(p)}},!1),f[0].addEventListener("dragenter",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation())},!1),f[0].addEventListener("dragleave",function(){f.attr("disabled")||o||(q=j(function(){f.removeClass(p),p=null},s||1))},!1),f[0].addEventListener("drop",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation(),f.removeClass(p),p=null,m(b,function(c,f){d(i,j,a,h,g,e(g,"ngfChange")||e(g,"ngfDrop"),c,f,b)},i(e(g,"ngfAllowDir"))(a)!==!1,e(g,"multiple")||i(e(g,"ngfMultiple"))(a)))},!1)}function b(){var a=document.createElement("div");return"draggable"in a&&"ondrop"in a}var c=ngFileUpload.validate,d=ngFileUpload.updateModel,e=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfDrop",["$parse","$timeout","$location",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.directive("ngfNoFileDrop",function(){return function(a,c){b()&&c.css("display","none")}}),ngFileUpload.directive("ngfDropAvailable",["$parse","$timeout",function(a,c){return function(d,f,g){if(b()){var h=a(e(g,"ngfDropAvailable"));c(function(){h(d),h.assign&&h.assign(d,!0)})}}}])}(),function(){function a(a,b,c,d,e,f,g){b.$watch(e,function(e){window.FileReader&&ngFileUpload.validate(b,c,d,e,null)&&a.dataUrl(e,function(a){g?g(a):e.dataUrl=a||c(f)(b)},c(d.ngfNoObjectUrl)(b))})}ngFileUpload.directive("ngfSrc",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfSrc,f.ngfDefaultSrc,function(a){e.attr("src",a)})}}}]),ngFileUpload.directive("ngfBackground",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfBackground,f.ngfDefaultBackground,function(a){e.css("background-image","url("+a+")")})}}}]),ngFileUpload.directive("ngfDataUrl",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfDataUrl,f.ngfDefaultDataUrl)}}}])}(); |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var app = angular.module('fileUpload', ['ngFileUpload']); | ||
var version = '5.2.0'; | ||
var version = '6.0.0'; | ||
@@ -22,6 +22,9 @@ app.controller('MyCtrl', ['$scope', '$http', '$timeout', '$compile', 'Upload', function ($scope, $http, $timeout, $compile, Upload) { | ||
if (files != null) { | ||
if (!angular.isArray(files)) { | ||
$scope.files = files = [files]; | ||
} | ||
for (var i = 0; i < files.length; i++) { | ||
$scope.errorMsg = null; | ||
(function (file) { | ||
upload(file); | ||
(function (f) { | ||
upload(f); | ||
})(files[i]); | ||
@@ -32,6 +35,6 @@ } | ||
$scope.uploadPic = function (files) { | ||
$scope.uploadPic = function(file) { | ||
$scope.formUpload = true; | ||
if (files != null) { | ||
upload(files[0]) | ||
if (file != null) { | ||
upload(file) | ||
} | ||
@@ -170,3 +173,4 @@ }; | ||
$scope.editHtml = (localStorage && localStorage.getItem('editHtml' + version)) || $scope.defaultHtml; | ||
var fromLocal = (localStorage && localStorage.getItem('editHtml' + version)); | ||
$scope.editHtml = fromLocal || $scope.defaultHtml; | ||
function htmlEdit() { | ||
@@ -233,3 +237,2 @@ document.getElementById('editArea').innerHTML = $scope.editHtml; | ||
}); | ||
}]); |
@@ -1,2 +0,2 @@ | ||
/*! 5.2.0 */ | ||
/*! 6.0.0 */ | ||
/*! FileAPI 2.0.7 - BSD | git://github.com/mailru/FileAPI.git | ||
@@ -3,0 +3,0 @@ * FileAPI — a set of javascript tools for working with files. Multiupload, drag'n'drop and chunked file upload. Images: crop, resize and auto orientation by EXIF. |
@@ -5,3 +5,3 @@ /**! | ||
* @author Danial <danial.farid@gmail.com> | ||
* @version 5.2.0 | ||
* @version 6.0.0 | ||
*/ | ||
@@ -434,3 +434,3 @@ | ||
* @author Danial <danial.farid@gmail.com> | ||
* @version 5.2.0 | ||
* @version 6.0.0 | ||
*/ | ||
@@ -456,3 +456,3 @@ | ||
ngFileUpload.version = '5.2.0'; | ||
ngFileUpload.version = '6.0.0'; | ||
ngFileUpload.defaults = {}; | ||
@@ -689,4 +689,5 @@ | ||
/** @namespace attr.ngModel */ | ||
/** @namespace attr.ngModelRejected */ | ||
/** @namespace attr.ngfModel */ | ||
/** @namespace attr.ngModelRejected */ | ||
/** @namespace attr.ngfModelRejected */ | ||
/** @namespace attr.ngfMultiple */ | ||
@@ -945,16 +946,17 @@ /** @namespace attr.ngfCapture */ | ||
} | ||
var file = files && files[0]; | ||
var file = files && files.length ? files[0] : null; | ||
if (ngModel) { | ||
$parse(getAttr(attr, 'ngModel')).assign(scope, files); | ||
var singleModel = !$parse(getAttr(attr, 'multiple'))(scope) && !keep; | ||
var ngfModel = getAttr(attr, 'ngfModel'); | ||
if (ngfModel) { | ||
$parse(ngfModel).assign(scope, singleModel ? file : files); | ||
} | ||
var singleModel = !$parse(getAttr(attr, 'ngfMultiple'))(scope) && ! getAttr(attr, 'multiple') && !keep; | ||
$parse(getAttr(attr, 'ngModel')).assign(scope, singleModel ? file : files); | ||
$timeout(function () { | ||
if (ngModel) { | ||
ngModel.$setViewValue(files != null && files.length === 0 ? null : files); | ||
ngModel.$setViewValue(singleModel ? file : (files != null && files.length === 0 ? null : files)); | ||
} | ||
}); | ||
} | ||
var ngfModel = getAttr(attr, 'ngfModel'); | ||
if (ngfModel) { | ||
$parse(ngfModel).assign(scope, files); | ||
} | ||
if (getAttr(attr, 'ngModelRejected')) { | ||
@@ -961,0 +963,0 @@ $parse(getAttr(attr, 'ngModelRejected')).assign(scope, rejFiles); |
@@ -1,2 +0,2 @@ | ||
/*! 5.2.0 */ | ||
!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){}}if(window.FileAPI||(window.FileAPI={}),FileAPI.shouldLoad=window.XMLHttpRequest&&!window.FormData||FileAPI.forceLoad,FileAPI.shouldLoad){var c=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,d,e){c(this),this.__url=d;try{a.apply(this,[b,d,e])}catch(f){f.message.indexOf("Access is denied")>-1&&(this.__origError=f,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,d){if("__setXHR_"===b){c(this);var e=d(this);e instanceof Function&&e(this)}else this.__requestHeaders=this.__requestHeaders||{},this.__requestHeaders[b]=d,a.apply(this,arguments)}}),a("send",function(a){return function(){var c=this;if(arguments[0]&&arguments[0].__isFileAPIShim){var d=arguments[0],e={url:c.__url,jsonp:!1,cache:!0,complete:function(a,d){c.__completed=!0,!a&&c.__listeners.load&&c.__listeners.load({type:"load",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),!a&&c.__listeners.loadend&&c.__listeners.loadend({type:"loadend",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),"abort"===a&&c.__listeners.abort&&c.__listeners.abort({type:"abort",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),void 0!==d.status&&b(c,"status",function(){return 0===d.status&&a&&"abort"!==a?500:d.status}),void 0!==d.statusText&&b(c,"statusText",function(){return d.statusText}),b(c,"readyState",function(){return 4}),void 0!==d.response&&b(c,"response",function(){return d.response});var e=d.responseText||(a&&0===d.status&&"abort"!==a?a:void 0);b(c,"responseText",function(){return e}),b(c,"response",function(){return e}),a&&b(c,"err",function(){return a}),c.__fileApiXHR=d,c.onreadystatechange&&c.onreadystatechange(),c.onload&&c.onload()},progress:function(a){if(a.target=c,c.__listeners.progress&&c.__listeners.progress(a),c.__total=a.total,c.__loaded=a.loaded,a.total===a.loaded){var b=this;setTimeout(function(){c.__completed||(c.getAllResponseHeaders=function(){},b.complete(null,{status:204,statusText:"No Content"}))},FileAPI.noContentTimeout||1e4)}},headers:c.__requestHeaders};e.data={},e.files={};for(var f=0;f<d.data.length;f++){var g=d.data[f];null!=g.val&&null!=g.val.name&&null!=g.val.size&&null!=g.val.type?e.files[g.key]=g.val:e.data[g.key]=g.val}setTimeout(function(){if(!FileAPI.hasFlash)throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';c.__fileApiXHR=FileAPI.upload(e)},1)}else{if(this.__origError)throw this.__origError;a.apply(c,arguments)}}}),window.XMLHttpRequest.__isFileAPIShim=!0,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(){function a(a){return"input"===a[0].tagName.toLowerCase()&&a.attr("type")&&"file"===a.attr("type").toLowerCase()}function b(){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}function c(a){var b=0,c=0;if(window.jQuery)return jQuery(a).offset();if(a.offsetParent)do b+=a.offsetLeft-a.scrollLeft,c+=a.offsetTop-a.scrollTop,a=a.offsetParent;while(a);return{left:b,top:c}}if(FileAPI.shouldLoad){if(FileAPI.forceLoad&&(FileAPI.html5=!1),!FileAPI.upload){var d,e,f,g,h,i=document.createElement("script"),j=document.getElementsByTagName("script");if(window.FileAPI.jsUrl)d=window.FileAPI.jsUrl;else if(window.FileAPI.jsPath)e=window.FileAPI.jsPath;else for(f=0;f<j.length;f++)if(h=j[f].src,g=h.search(/\/ng\-file\-upload[\-a-zA-z0-9\.]*\.js/),g>-1){e=h.substring(0,g+1);break}null==FileAPI.staticPath&&(FileAPI.staticPath=e),i.setAttribute("src",d||e+"FileAPI.min.js"),document.getElementsByTagName("head")[0].appendChild(i),FileAPI.hasFlash=b()}FileAPI.ngfFixIE=function(d,e,f,g){if(!b())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';var h=function(){if(d.attr("disabled"))d.$$ngfRefElem.removeClass("js-fileapi-wrapper");else{var b=d.$$ngfRefElem;b?f(d.$$ngfRefElem):(b=d.$$ngfRefElem=e(),b.addClass("js-fileapi-wrapper"),!a(d),setTimeout(function(){b.bind("mouseenter",h)},10),b.bind("change",function(a){i.apply(this,[a]),g.apply(this,[a])})),a(d)||b.css("position","absolute").css("top",c(d[0]).top+"px").css("left",c(d[0]).left+"px").css("width",d[0].offsetWidth+"px").css("height",d[0].offsetHeight+"px").css("filter","alpha(opacity=0)").css("display",d.css("display")).css("overflow","hidden").css("z-index","900000").css("visibility","visible")}};d.bind("mouseenter",h);var i=function(a){for(var b=FileAPI.getFiles(a),c=0;c<b.length;c++)void 0===b[c].size&&(b[c].size=0),void 0===b[c].name&&(b[c].name="file"),void 0===b[c].type&&(b[c].type="undefined");a.target||(a.target={}),a.target.files=b,a.target.files!==b&&(a.__files_=b),(a.__files_||a.target.files).item=function(b){return(a.__files_||a.target.files)[b]||null}}},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){b||(b=!0,a.onloadstart&&a.onloadstart(c("loadstart",d)));var e;"load"===d.type?(a.onloadend&&a.onloadend(c("loadend",d)),e=c("load",d),a.onload&&a.onload(e),a.dispatchEvent(e)):"progress"===d.type?(e=c("progress",d),a.onprogress&&a.onprogress(e),a.dispatchEvent(e)):(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)}}),!window.XMLHttpRequest||window.FileAPI&&FileAPI.shouldLoad||(window.XMLHttpRequest.prototype.setRequestHeader=function(a){return function(b,c){if("__setXHR_"===b){var d=c(this);d instanceof Function&&d(this)}else a.apply(this,arguments)}}(window.XMLHttpRequest.prototype.setRequestHeader));var ngFileUpload=angular.module("ngFileUpload",[]);ngFileUpload.version="5.2.0",ngFileUpload.defaults={},ngFileUpload.service("Upload",["$http","$q","$timeout",function(a,b,c){function d(d){d.method=d.method||"POST",d.headers=d.headers||{};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.progressFunc&&c(function(){f.progressFunc(a)})},!1),a.upload.addEventListener("load",function(a){a.lengthComputable&&(a.config=d,e.notify?e.notify(a):f.progressFunc&&c(function(){f.progressFunc(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.progressFunc=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){function b(c,d,e){if(void 0!==d)if(angular.isDate(d)&&(d=d.toISOString()),angular.isString(d))c.append(e,d);else if("form"===a.sendFieldsAs)if(angular.isObject(d))for(var f in d)d.hasOwnProperty(f)&&b(c,d[f],e+"["+f+"]");else c.append(e,d);else d=angular.isString(d)?d:JSON.stringify(d),"json-blob"===a.sendFieldsAs?c.append(e,new Blob([d],{type:"application/json"})):c.append(e,d)}return a.headers=a.headers||{},a.headers["Content-Type"]=void 0,a.transformRequest=a.transformRequest?angular.isArray(a.transformRequest)?a.transformRequest:[a.transformRequest]:[],a.transformRequest.push(function(c){var d,e=new FormData,f={};for(d in a.fields)a.fields.hasOwnProperty(d)&&(f[d]=a.fields[d]);c&&(f.data=c);for(d in f)if(f.hasOwnProperty(d)){var g=f[d];a.formDataAppender?a.formDataAppender(e,d,g):b(e,g,d)}if(null!=a.file){var h=a.fileFormDataName||"file";if(angular.isArray(a.file))for(var i=angular.isString(h),j=0;j<a.file.length;j++)e.append(i?h:h[j],a.file[j],a.fileName&&a.fileName[j]||a.file[j].name);else e.append(h,a.file,a.fileName||a.file.name)}return e}),d(a)},this.http=function(b){return b.transformRequest=b.transformRequest||function(b){return window.ArrayBuffer&&b instanceof window.ArrayBuffer||b instanceof Blob?b:a.defaults.transformRequest[0](arguments)},d(b)},this.dataUrl=function(a,b,d){window.FileReader&&a&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 8")||a.size<2e4)&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 9")||a.size<4e6)?c(function(){var e=window.URL||window.webkitURL;if(e&&e.createObjectURL&&!d)b(e.createObjectURL(a));else{var f=new FileReader;f.readAsDataURL(a),f.onload=function(a){c(function(){b(a.target.result)})}}}):b(null)},this.setDefaults=function(a){ngFileUpload.defaults=a||{}}}]),function(){function a(a,f,g,h,i,j,k){function l(){return"input"===f[0].tagName.toLowerCase()&&g.type&&"file"===g.type.toLowerCase()}function m(b){if(!s){s=!0;try{for(var f=b.__files_||b.target&&b.target.files,k=[],l=[],m=0;m<f.length;m++){var n=f.item(m);d(a,i,g,n,b)?k.push(n):l.push(n)}e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),k,l,b),0===k.length&&(b.target.value=k)}finally{s=!1}}}function n(b){c(g,"ngfMultiple")&&b.attr("multiple",i(c(g,"ngfMultiple"))(a)),c(g,"ngfCapture")&&b.attr("capture",i(c(g,"ngfCapture"))(a)),c(g,"accept")&&b.attr("accept",c(g,"accept"));for(var d=0;d<f[0].attributes.length;d++){var e=f[0].attributes[d];(l()&&"type"!==e.name||"type"!==e.name&&"class"!==e.name&&"id"!==e.name&&"style"!==e.name)&&b.attr(e.name,e.value)}}function o(b,c){if(!c&&(b||l()))return f.$$ngfRefElem||f;var d=angular.element('<input type="file">');return n(d),l()?(f.replaceWith(d),f=d,d.attr("__ngf_gen__",!0),k(f)(a)):(d.css("visibility","hidden").css("position","absolute").css("overflow","hidden").css("width","0px").css("height","0px").css("z-index","-100000").css("border","none").css("margin","0px").css("padding","0px").attr("tabindex","-1"),f.$$ngfRefElem&&f.$$ngfRefElem.remove(),f.$$ngfRefElem=d,document.body.appendChild(d[0])),d}function p(b){e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),[],[],b,!0)}function q(d){function e(a){a&&a.clientY>0&&k[0].click(),!l()&&a||!j||f.bind("click touchend touchstart",q)}if(f.attr("disabled")||r)return!1;if(null!=d){if("touchstart"===d.type)return t=d.originalEvent.touches[0].clientY,!0;if(d.stopPropagation(),d.preventDefault(),"touchend"===d.type){var h=d.originalEvent.changedTouches[0].clientY;if(Math.abs(h-t)>20)return!1}}var j=i(c(g,"ngfResetOnClick"))(a)!==!1,k=o(d,j);return k&&((!d||j)&&k.bind("change",m),d&&j&&i(c(g,"ngfResetModelOnClick"))(a)!==!1&&p(d),b(navigator.userAgent)?setTimeout(function(){e(d)},0):e(d)),!1}if(!f.attr("__ngf_gen__")){a.$on("$destroy",function(){f.$$ngfRefElem&&f.$$ngfRefElem.remove()});var r=!1;-1===c(g,"ngfSelect").search(/\W+$files\W+/)&&a.$watch(c(g,"ngfSelect"),function(a){r=a===!1});var s=!1,t=0;window.FileAPI&&window.FileAPI.ngfFixIE?window.FileAPI.ngfFixIE(f,o,n,m):q()}}function b(a){var b=a.match(/Android[^\d]*(\d+)\.(\d+)/);if(b&&b.length>2){var c=ngFileUpload.defaults.androidFixMinorVersion||4;return parseInt(b[1])<4||parseInt(b[1])===c&&parseInt(b[2])<c}return-1===a.indexOf("Chrome")&&/.*Windows.*Safari.*/.test(a)}ngFileUpload.getAttrWithDefaults=function(a,b){return null!=a[b]?a[b]:null==ngFileUpload.defaults[b]?ngFileUpload.defaults[b]:ngFileUpload.defaults[b].toString()};var c=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfSelect",["$parse","$timeout","$compile",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.validate=function(a,b,d,e,f){function g(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+="("+g(b[d])+")",d<b.length-1&&(c+="|");else 0===a.indexOf(".")&&(a="*"+a),c="^"+a.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$",c=c.replace(/\\\*/g,".*").replace(/\\\?/g,".");return c}if(null==e)return!1;var h=b(c(d,"ngfAccept"))(a,{$file:e,$event:f}),i=b(c(d,"ngfMaxSize"))(a,{$file:e,$event:f})||9007199254740991,j=b(c(d,"ngfMinSize"))(a,{$file:e,$event:f})||-1;if(null!=h&&angular.isString(h)){var k=new RegExp(g(h),"gi");if(h=null!=e.type&&k.test(e.type.toLowerCase())||null!=e.name&&k.test(e.name.toLowerCase()),!h)return e.$error="accept",!1}else if(h===!1)return e.$error="accept",!1;return null==e.size?!0:e.size>i?(e.$error="maxSize",!1):e.size<j?(e.$error="minSize",!1):!0},ngFileUpload.updateModel=function(a,b,d,e,f,g,h,i,j,k){function l(){var k=a(c(f,"ngfKeep"))(d);if(k===!0){var l=(e.$modelValue||[]).slice(0);if(h&&h.length)if(a(c(f,"ngfKeepDistinct"))(d)===!0){for(var m=l.length,n=0;n<h.length;n++){for(var o=0;m>o&&h[n].name!==l[o].name;o++);o===m&&l.push(h[n])}h=l}else h=l.concat(h);else h=l}var p=h&&h[0];if(e){a(c(f,"ngModel")).assign(d,h);var q=!a(c(f,"multiple"))(d)&&!k,r=c(f,"ngfModel");r&&a(r).assign(d,q?p:h),b(function(){e&&e.$setViewValue(null!=h&&0===h.length?null:h)})}c(f,"ngModelRejected")&&a(c(f,"ngModelRejected")).assign(d,i),g&&a(g)(d,{$files:h,$file:p,$rejectedFiles:i,$event:j})}k?l():b(function(){l()})};var d=ngFileUpload.validate,e=ngFileUpload.updateModel}(),function(){function a(a,f,g,h,i,j,k){function l(a,b,d){var f=!0,g=d.dataTransfer.items;if(null!=g)for(var h=0;h<g.length&&f;h++)f=f&&("file"===g[h].kind||""===g[h].kind)&&c(a,i,b,g[h],d);var j=i(e(b,"ngfDragOverClass"))(a,{$event:d});return j&&(j.delay&&(s=j.delay),j.accept&&(j=f?j.accept:j.reject)),j||e(b,"ngfDragOverClass")||"dragover"}function m(b,d,e,f){function h(d){c(a,i,g,d,b)?m.push(d):n.push(d)}function l(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;h({name:b.name,type:"directory",path:d});var e=b.createReader(),f=[];p++;var g=function(){e.readEntries(function(d){try{if(d.length)f=f.concat(Array.prototype.slice.call(d||[],0)),g();else{for(var e=0;e<f.length;e++)l(a,f[e],(c?c:"")+b.name+"/");p--}}catch(h){p--,console.error(h)}},function(){p--})};g()}else p++,b.file(function(a){try{p--,a.path=(c?c:"")+a.name,h(a)}catch(b){p--,console.error(b)}},function(){p--})}var m=[],n=[],o=b.dataTransfer.items,p=0;if(o&&o.length>0&&"file"!==k.protocol())for(var q=0;q<o.length;q++){if(o[q].webkitGetAsEntry&&o[q].webkitGetAsEntry()&&o[q].webkitGetAsEntry().isDirectory){var r=o[q].webkitGetAsEntry();if(r.isDirectory&&!e)continue;null!=r&&l(m,r)}else{var s=o[q].getAsFile();null!=s&&h(s)}if(!f&&m.length>0)break}else{var t=b.dataTransfer.files;if(null!=t)for(var u=0;u<t.length&&(h(t.item(u)),f||!(m.length>0));u++);}var v=0;!function w(a){j(function(){if(p)10*v++<2e4&&w(10);else{if(!f&&m.length>1){for(q=0;"directory"===m[q].type;)q++;m=[m[q]]}d(m,n)}},a||0)}()}var n=b();if(e(g,"dropAvailable")&&j(function(){a[e(g,"dropAvailable")]?a[e(g,"dropAvailable")].value=n:a[e(g,"dropAvailable")]=n}),!n)return void(i(e(g,"ngfHideOnDropNotAvailable"))(a)===!0&&f.css("display","none"));var o=!1;-1===e(g,"ngfDrop").search(/\W+$files\W+/)&&a.$watch(e(g,"ngfDrop"),function(a){o=a===!1});var p,q=null,r=i(e(g,"ngfStopPropagation")),s=1;f[0].addEventListener("dragover",function(b){if(!f.attr("disabled")&&!o){if(b.preventDefault(),r(a)&&b.stopPropagation(),navigator.userAgent.indexOf("Chrome")>-1){var c=b.dataTransfer.effectAllowed;b.dataTransfer.dropEffect="move"===c||"linkMove"===c?"move":"copy"}j.cancel(q),a.actualDragOverClass||(p=l(a,g,b)),f.addClass(p)}},!1),f[0].addEventListener("dragenter",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation())},!1),f[0].addEventListener("dragleave",function(){f.attr("disabled")||o||(q=j(function(){f.removeClass(p),p=null},s||1))},!1),f[0].addEventListener("drop",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation(),f.removeClass(p),p=null,m(b,function(c,f){d(i,j,a,h,g,e(g,"ngfChange")||e(g,"ngfDrop"),c,f,b)},i(e(g,"ngfAllowDir"))(a)!==!1,e(g,"multiple")||i(e(g,"ngfMultiple"))(a)))},!1)}function b(){var a=document.createElement("div");return"draggable"in a&&"ondrop"in a}var c=ngFileUpload.validate,d=ngFileUpload.updateModel,e=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfDrop",["$parse","$timeout","$location",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.directive("ngfNoFileDrop",function(){return function(a,c){b()&&c.css("display","none")}}),ngFileUpload.directive("ngfDropAvailable",["$parse","$timeout",function(a,c){return function(d,f,g){if(b()){var h=a(e(g,"ngfDropAvailable"));c(function(){h(d),h.assign&&h.assign(d,!0)})}}}])}(),function(){function a(a,b,c,d,e,f,g){b.$watch(e,function(e){window.FileReader&&ngFileUpload.validate(b,c,d,e,null)&&a.dataUrl(e,function(a){g?g(a):e.dataUrl=a||c(f)(b)},c(d.ngfNoObjectUrl)(b))})}ngFileUpload.directive("ngfSrc",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfSrc,f.ngfDefaultSrc,function(a){e.attr("src",a)})}}}]),ngFileUpload.directive("ngfBackground",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfBackground,f.ngfDefaultBackground,function(a){e.css("background-image","url("+a+")")})}}}]),ngFileUpload.directive("ngfDataUrl",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfDataUrl,f.ngfDefaultDataUrl)}}}])}(); | ||
/*! 6.0.0 */ | ||
!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){}}if(window.FileAPI||(window.FileAPI={}),FileAPI.shouldLoad=window.XMLHttpRequest&&!window.FormData||FileAPI.forceLoad,FileAPI.shouldLoad){var c=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,d,e){c(this),this.__url=d;try{a.apply(this,[b,d,e])}catch(f){f.message.indexOf("Access is denied")>-1&&(this.__origError=f,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,d){if("__setXHR_"===b){c(this);var e=d(this);e instanceof Function&&e(this)}else this.__requestHeaders=this.__requestHeaders||{},this.__requestHeaders[b]=d,a.apply(this,arguments)}}),a("send",function(a){return function(){var c=this;if(arguments[0]&&arguments[0].__isFileAPIShim){var d=arguments[0],e={url:c.__url,jsonp:!1,cache:!0,complete:function(a,d){c.__completed=!0,!a&&c.__listeners.load&&c.__listeners.load({type:"load",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),!a&&c.__listeners.loadend&&c.__listeners.loadend({type:"loadend",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),"abort"===a&&c.__listeners.abort&&c.__listeners.abort({type:"abort",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),void 0!==d.status&&b(c,"status",function(){return 0===d.status&&a&&"abort"!==a?500:d.status}),void 0!==d.statusText&&b(c,"statusText",function(){return d.statusText}),b(c,"readyState",function(){return 4}),void 0!==d.response&&b(c,"response",function(){return d.response});var e=d.responseText||(a&&0===d.status&&"abort"!==a?a:void 0);b(c,"responseText",function(){return e}),b(c,"response",function(){return e}),a&&b(c,"err",function(){return a}),c.__fileApiXHR=d,c.onreadystatechange&&c.onreadystatechange(),c.onload&&c.onload()},progress:function(a){if(a.target=c,c.__listeners.progress&&c.__listeners.progress(a),c.__total=a.total,c.__loaded=a.loaded,a.total===a.loaded){var b=this;setTimeout(function(){c.__completed||(c.getAllResponseHeaders=function(){},b.complete(null,{status:204,statusText:"No Content"}))},FileAPI.noContentTimeout||1e4)}},headers:c.__requestHeaders};e.data={},e.files={};for(var f=0;f<d.data.length;f++){var g=d.data[f];null!=g.val&&null!=g.val.name&&null!=g.val.size&&null!=g.val.type?e.files[g.key]=g.val:e.data[g.key]=g.val}setTimeout(function(){if(!FileAPI.hasFlash)throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';c.__fileApiXHR=FileAPI.upload(e)},1)}else{if(this.__origError)throw this.__origError;a.apply(c,arguments)}}}),window.XMLHttpRequest.__isFileAPIShim=!0,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(){function a(a){return"input"===a[0].tagName.toLowerCase()&&a.attr("type")&&"file"===a.attr("type").toLowerCase()}function b(){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}function c(a){var b=0,c=0;if(window.jQuery)return jQuery(a).offset();if(a.offsetParent)do b+=a.offsetLeft-a.scrollLeft,c+=a.offsetTop-a.scrollTop,a=a.offsetParent;while(a);return{left:b,top:c}}if(FileAPI.shouldLoad){if(FileAPI.forceLoad&&(FileAPI.html5=!1),!FileAPI.upload){var d,e,f,g,h,i=document.createElement("script"),j=document.getElementsByTagName("script");if(window.FileAPI.jsUrl)d=window.FileAPI.jsUrl;else if(window.FileAPI.jsPath)e=window.FileAPI.jsPath;else for(f=0;f<j.length;f++)if(h=j[f].src,g=h.search(/\/ng\-file\-upload[\-a-zA-z0-9\.]*\.js/),g>-1){e=h.substring(0,g+1);break}null==FileAPI.staticPath&&(FileAPI.staticPath=e),i.setAttribute("src",d||e+"FileAPI.min.js"),document.getElementsByTagName("head")[0].appendChild(i),FileAPI.hasFlash=b()}FileAPI.ngfFixIE=function(d,e,f,g){if(!b())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';var h=function(){if(d.attr("disabled"))d.$$ngfRefElem.removeClass("js-fileapi-wrapper");else{var b=d.$$ngfRefElem;b?f(d.$$ngfRefElem):(b=d.$$ngfRefElem=e(),b.addClass("js-fileapi-wrapper"),!a(d),setTimeout(function(){b.bind("mouseenter",h)},10),b.bind("change",function(a){i.apply(this,[a]),g.apply(this,[a])})),a(d)||b.css("position","absolute").css("top",c(d[0]).top+"px").css("left",c(d[0]).left+"px").css("width",d[0].offsetWidth+"px").css("height",d[0].offsetHeight+"px").css("filter","alpha(opacity=0)").css("display",d.css("display")).css("overflow","hidden").css("z-index","900000").css("visibility","visible")}};d.bind("mouseenter",h);var i=function(a){for(var b=FileAPI.getFiles(a),c=0;c<b.length;c++)void 0===b[c].size&&(b[c].size=0),void 0===b[c].name&&(b[c].name="file"),void 0===b[c].type&&(b[c].type="undefined");a.target||(a.target={}),a.target.files=b,a.target.files!==b&&(a.__files_=b),(a.__files_||a.target.files).item=function(b){return(a.__files_||a.target.files)[b]||null}}},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){b||(b=!0,a.onloadstart&&a.onloadstart(c("loadstart",d)));var e;"load"===d.type?(a.onloadend&&a.onloadend(c("loadend",d)),e=c("load",d),a.onload&&a.onload(e),a.dispatchEvent(e)):"progress"===d.type?(e=c("progress",d),a.onprogress&&a.onprogress(e),a.dispatchEvent(e)):(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)}}),!window.XMLHttpRequest||window.FileAPI&&FileAPI.shouldLoad||(window.XMLHttpRequest.prototype.setRequestHeader=function(a){return function(b,c){if("__setXHR_"===b){var d=c(this);d instanceof Function&&d(this)}else a.apply(this,arguments)}}(window.XMLHttpRequest.prototype.setRequestHeader));var ngFileUpload=angular.module("ngFileUpload",[]);ngFileUpload.version="6.0.0",ngFileUpload.defaults={},ngFileUpload.service("Upload",["$http","$q","$timeout",function(a,b,c){function d(d){d.method=d.method||"POST",d.headers=d.headers||{};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.progressFunc&&c(function(){f.progressFunc(a)})},!1),a.upload.addEventListener("load",function(a){a.lengthComputable&&(a.config=d,e.notify?e.notify(a):f.progressFunc&&c(function(){f.progressFunc(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.progressFunc=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){function b(c,d,e){if(void 0!==d)if(angular.isDate(d)&&(d=d.toISOString()),angular.isString(d))c.append(e,d);else if("form"===a.sendFieldsAs)if(angular.isObject(d))for(var f in d)d.hasOwnProperty(f)&&b(c,d[f],e+"["+f+"]");else c.append(e,d);else d=angular.isString(d)?d:JSON.stringify(d),"json-blob"===a.sendFieldsAs?c.append(e,new Blob([d],{type:"application/json"})):c.append(e,d)}return a.headers=a.headers||{},a.headers["Content-Type"]=void 0,a.transformRequest=a.transformRequest?angular.isArray(a.transformRequest)?a.transformRequest:[a.transformRequest]:[],a.transformRequest.push(function(c){var d,e=new FormData,f={};for(d in a.fields)a.fields.hasOwnProperty(d)&&(f[d]=a.fields[d]);c&&(f.data=c);for(d in f)if(f.hasOwnProperty(d)){var g=f[d];a.formDataAppender?a.formDataAppender(e,d,g):b(e,g,d)}if(null!=a.file){var h=a.fileFormDataName||"file";if(angular.isArray(a.file))for(var i=angular.isString(h),j=0;j<a.file.length;j++)e.append(i?h:h[j],a.file[j],a.fileName&&a.fileName[j]||a.file[j].name);else e.append(h,a.file,a.fileName||a.file.name)}return e}),d(a)},this.http=function(b){return b.transformRequest=b.transformRequest||function(b){return window.ArrayBuffer&&b instanceof window.ArrayBuffer||b instanceof Blob?b:a.defaults.transformRequest[0](arguments)},d(b)},this.dataUrl=function(a,b,d){window.FileReader&&a&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 8")||a.size<2e4)&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 9")||a.size<4e6)?c(function(){var e=window.URL||window.webkitURL;if(e&&e.createObjectURL&&!d)b(e.createObjectURL(a));else{var f=new FileReader;f.readAsDataURL(a),f.onload=function(a){c(function(){b(a.target.result)})}}}):b(null)},this.setDefaults=function(a){ngFileUpload.defaults=a||{}}}]),function(){function a(a,f,g,h,i,j,k){function l(){return"input"===f[0].tagName.toLowerCase()&&g.type&&"file"===g.type.toLowerCase()}function m(b){if(!s){s=!0;try{for(var f=b.__files_||b.target&&b.target.files,k=[],l=[],m=0;m<f.length;m++){var n=f.item(m);d(a,i,g,n,b)?k.push(n):l.push(n)}e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),k,l,b),0===k.length&&(b.target.value=k)}finally{s=!1}}}function n(b){c(g,"ngfMultiple")&&b.attr("multiple",i(c(g,"ngfMultiple"))(a)),c(g,"ngfCapture")&&b.attr("capture",i(c(g,"ngfCapture"))(a)),c(g,"accept")&&b.attr("accept",c(g,"accept"));for(var d=0;d<f[0].attributes.length;d++){var e=f[0].attributes[d];(l()&&"type"!==e.name||"type"!==e.name&&"class"!==e.name&&"id"!==e.name&&"style"!==e.name)&&b.attr(e.name,e.value)}}function o(b,c){if(!c&&(b||l()))return f.$$ngfRefElem||f;var d=angular.element('<input type="file">');return n(d),l()?(f.replaceWith(d),f=d,d.attr("__ngf_gen__",!0),k(f)(a)):(d.css("visibility","hidden").css("position","absolute").css("overflow","hidden").css("width","0px").css("height","0px").css("z-index","-100000").css("border","none").css("margin","0px").css("padding","0px").attr("tabindex","-1"),f.$$ngfRefElem&&f.$$ngfRefElem.remove(),f.$$ngfRefElem=d,document.body.appendChild(d[0])),d}function p(b){e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),[],[],b,!0)}function q(d){function e(a){a&&a.clientY>0&&k[0].click(),!l()&&a||!j||f.bind("click touchend touchstart",q)}if(f.attr("disabled")||r)return!1;if(null!=d){if("touchstart"===d.type)return t=d.originalEvent.touches[0].clientY,!0;if(d.stopPropagation(),d.preventDefault(),"touchend"===d.type){var h=d.originalEvent.changedTouches[0].clientY;if(Math.abs(h-t)>20)return!1}}var j=i(c(g,"ngfResetOnClick"))(a)!==!1,k=o(d,j);return k&&((!d||j)&&k.bind("change",m),d&&j&&i(c(g,"ngfResetModelOnClick"))(a)!==!1&&p(d),b(navigator.userAgent)?setTimeout(function(){e(d)},0):e(d)),!1}if(!f.attr("__ngf_gen__")){a.$on("$destroy",function(){f.$$ngfRefElem&&f.$$ngfRefElem.remove()});var r=!1;-1===c(g,"ngfSelect").search(/\W+$files\W+/)&&a.$watch(c(g,"ngfSelect"),function(a){r=a===!1});var s=!1,t=0;window.FileAPI&&window.FileAPI.ngfFixIE?window.FileAPI.ngfFixIE(f,o,n,m):q()}}function b(a){var b=a.match(/Android[^\d]*(\d+)\.(\d+)/);if(b&&b.length>2){var c=ngFileUpload.defaults.androidFixMinorVersion||4;return parseInt(b[1])<4||parseInt(b[1])===c&&parseInt(b[2])<c}return-1===a.indexOf("Chrome")&&/.*Windows.*Safari.*/.test(a)}ngFileUpload.getAttrWithDefaults=function(a,b){return null!=a[b]?a[b]:null==ngFileUpload.defaults[b]?ngFileUpload.defaults[b]:ngFileUpload.defaults[b].toString()};var c=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfSelect",["$parse","$timeout","$compile",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.validate=function(a,b,d,e,f){function g(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+="("+g(b[d])+")",d<b.length-1&&(c+="|");else 0===a.indexOf(".")&&(a="*"+a),c="^"+a.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$",c=c.replace(/\\\*/g,".*").replace(/\\\?/g,".");return c}if(null==e)return!1;var h=b(c(d,"ngfAccept"))(a,{$file:e,$event:f}),i=b(c(d,"ngfMaxSize"))(a,{$file:e,$event:f})||9007199254740991,j=b(c(d,"ngfMinSize"))(a,{$file:e,$event:f})||-1;if(null!=h&&angular.isString(h)){var k=new RegExp(g(h),"gi");if(h=null!=e.type&&k.test(e.type.toLowerCase())||null!=e.name&&k.test(e.name.toLowerCase()),!h)return e.$error="accept",!1}else if(h===!1)return e.$error="accept",!1;return null==e.size?!0:e.size>i?(e.$error="maxSize",!1):e.size<j?(e.$error="minSize",!1):!0},ngFileUpload.updateModel=function(a,b,d,e,f,g,h,i,j,k){function l(){var k=a(c(f,"ngfKeep"))(d);if(k===!0){var l=(e.$modelValue||[]).slice(0);if(h&&h.length)if(a(c(f,"ngfKeepDistinct"))(d)===!0){for(var m=l.length,n=0;n<h.length;n++){for(var o=0;m>o&&h[n].name!==l[o].name;o++);o===m&&l.push(h[n])}h=l}else h=l.concat(h);else h=l}var p=h&&h.length?h[0]:null;if(e){var q=!a(c(f,"ngfMultiple"))(d)&&!c(f,"multiple")&&!k;a(c(f,"ngModel")).assign(d,q?p:h),b(function(){e&&e.$setViewValue(q?p:null!=h&&0===h.length?null:h)})}var r=c(f,"ngfModel");r&&a(r).assign(d,h),c(f,"ngModelRejected")&&a(c(f,"ngModelRejected")).assign(d,i),g&&a(g)(d,{$files:h,$file:p,$rejectedFiles:i,$event:j})}k?l():b(function(){l()})};var d=ngFileUpload.validate,e=ngFileUpload.updateModel}(),function(){function a(a,f,g,h,i,j,k){function l(a,b,d){var f=!0,g=d.dataTransfer.items;if(null!=g)for(var h=0;h<g.length&&f;h++)f=f&&("file"===g[h].kind||""===g[h].kind)&&c(a,i,b,g[h],d);var j=i(e(b,"ngfDragOverClass"))(a,{$event:d});return j&&(j.delay&&(s=j.delay),j.accept&&(j=f?j.accept:j.reject)),j||e(b,"ngfDragOverClass")||"dragover"}function m(b,d,e,f){function h(d){c(a,i,g,d,b)?m.push(d):n.push(d)}function l(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;h({name:b.name,type:"directory",path:d});var e=b.createReader(),f=[];p++;var g=function(){e.readEntries(function(d){try{if(d.length)f=f.concat(Array.prototype.slice.call(d||[],0)),g();else{for(var e=0;e<f.length;e++)l(a,f[e],(c?c:"")+b.name+"/");p--}}catch(h){p--,console.error(h)}},function(){p--})};g()}else p++,b.file(function(a){try{p--,a.path=(c?c:"")+a.name,h(a)}catch(b){p--,console.error(b)}},function(){p--})}var m=[],n=[],o=b.dataTransfer.items,p=0;if(o&&o.length>0&&"file"!==k.protocol())for(var q=0;q<o.length;q++){if(o[q].webkitGetAsEntry&&o[q].webkitGetAsEntry()&&o[q].webkitGetAsEntry().isDirectory){var r=o[q].webkitGetAsEntry();if(r.isDirectory&&!e)continue;null!=r&&l(m,r)}else{var s=o[q].getAsFile();null!=s&&h(s)}if(!f&&m.length>0)break}else{var t=b.dataTransfer.files;if(null!=t)for(var u=0;u<t.length&&(h(t.item(u)),f||!(m.length>0));u++);}var v=0;!function w(a){j(function(){if(p)10*v++<2e4&&w(10);else{if(!f&&m.length>1){for(q=0;"directory"===m[q].type;)q++;m=[m[q]]}d(m,n)}},a||0)}()}var n=b();if(e(g,"dropAvailable")&&j(function(){a[e(g,"dropAvailable")]?a[e(g,"dropAvailable")].value=n:a[e(g,"dropAvailable")]=n}),!n)return void(i(e(g,"ngfHideOnDropNotAvailable"))(a)===!0&&f.css("display","none"));var o=!1;-1===e(g,"ngfDrop").search(/\W+$files\W+/)&&a.$watch(e(g,"ngfDrop"),function(a){o=a===!1});var p,q=null,r=i(e(g,"ngfStopPropagation")),s=1;f[0].addEventListener("dragover",function(b){if(!f.attr("disabled")&&!o){if(b.preventDefault(),r(a)&&b.stopPropagation(),navigator.userAgent.indexOf("Chrome")>-1){var c=b.dataTransfer.effectAllowed;b.dataTransfer.dropEffect="move"===c||"linkMove"===c?"move":"copy"}j.cancel(q),a.actualDragOverClass||(p=l(a,g,b)),f.addClass(p)}},!1),f[0].addEventListener("dragenter",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation())},!1),f[0].addEventListener("dragleave",function(){f.attr("disabled")||o||(q=j(function(){f.removeClass(p),p=null},s||1))},!1),f[0].addEventListener("drop",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation(),f.removeClass(p),p=null,m(b,function(c,f){d(i,j,a,h,g,e(g,"ngfChange")||e(g,"ngfDrop"),c,f,b)},i(e(g,"ngfAllowDir"))(a)!==!1,e(g,"multiple")||i(e(g,"ngfMultiple"))(a)))},!1)}function b(){var a=document.createElement("div");return"draggable"in a&&"ondrop"in a}var c=ngFileUpload.validate,d=ngFileUpload.updateModel,e=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfDrop",["$parse","$timeout","$location",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.directive("ngfNoFileDrop",function(){return function(a,c){b()&&c.css("display","none")}}),ngFileUpload.directive("ngfDropAvailable",["$parse","$timeout",function(a,c){return function(d,f,g){if(b()){var h=a(e(g,"ngfDropAvailable"));c(function(){h(d),h.assign&&h.assign(d,!0)})}}}])}(),function(){function a(a,b,c,d,e,f,g){b.$watch(e,function(e){window.FileReader&&ngFileUpload.validate(b,c,d,e,null)&&a.dataUrl(e,function(a){g?g(a):e.dataUrl=a||c(f)(b)},c(d.ngfNoObjectUrl)(b))})}ngFileUpload.directive("ngfSrc",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfSrc,f.ngfDefaultSrc,function(a){e.attr("src",a)})}}}]),ngFileUpload.directive("ngfBackground",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfBackground,f.ngfDefaultBackground,function(a){e.css("background-image","url("+a+")")})}}}]),ngFileUpload.directive("ngfDataUrl",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfDataUrl,f.ngfDefaultDataUrl)}}}])}(); |
@@ -5,3 +5,3 @@ /**! | ||
* @author Danial <danial.farid@gmail.com> | ||
* @version 5.2.0 | ||
* @version 6.0.0 | ||
*/ | ||
@@ -8,0 +8,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*! 5.2.0 */ | ||
/*! 6.0.0 */ | ||
!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){}}if(window.FileAPI||(window.FileAPI={}),FileAPI.shouldLoad=window.XMLHttpRequest&&!window.FormData||FileAPI.forceLoad,FileAPI.shouldLoad){var c=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,d,e){c(this),this.__url=d;try{a.apply(this,[b,d,e])}catch(f){f.message.indexOf("Access is denied")>-1&&(this.__origError=f,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,d){if("__setXHR_"===b){c(this);var e=d(this);e instanceof Function&&e(this)}else this.__requestHeaders=this.__requestHeaders||{},this.__requestHeaders[b]=d,a.apply(this,arguments)}}),a("send",function(a){return function(){var c=this;if(arguments[0]&&arguments[0].__isFileAPIShim){var d=arguments[0],e={url:c.__url,jsonp:!1,cache:!0,complete:function(a,d){c.__completed=!0,!a&&c.__listeners.load&&c.__listeners.load({type:"load",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),!a&&c.__listeners.loadend&&c.__listeners.loadend({type:"loadend",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),"abort"===a&&c.__listeners.abort&&c.__listeners.abort({type:"abort",loaded:c.__loaded,total:c.__total,target:c,lengthComputable:!0}),void 0!==d.status&&b(c,"status",function(){return 0===d.status&&a&&"abort"!==a?500:d.status}),void 0!==d.statusText&&b(c,"statusText",function(){return d.statusText}),b(c,"readyState",function(){return 4}),void 0!==d.response&&b(c,"response",function(){return d.response});var e=d.responseText||(a&&0===d.status&&"abort"!==a?a:void 0);b(c,"responseText",function(){return e}),b(c,"response",function(){return e}),a&&b(c,"err",function(){return a}),c.__fileApiXHR=d,c.onreadystatechange&&c.onreadystatechange(),c.onload&&c.onload()},progress:function(a){if(a.target=c,c.__listeners.progress&&c.__listeners.progress(a),c.__total=a.total,c.__loaded=a.loaded,a.total===a.loaded){var b=this;setTimeout(function(){c.__completed||(c.getAllResponseHeaders=function(){},b.complete(null,{status:204,statusText:"No Content"}))},FileAPI.noContentTimeout||1e4)}},headers:c.__requestHeaders};e.data={},e.files={};for(var f=0;f<d.data.length;f++){var g=d.data[f];null!=g.val&&null!=g.val.name&&null!=g.val.size&&null!=g.val.type?e.files[g.key]=g.val:e.data[g.key]=g.val}setTimeout(function(){if(!FileAPI.hasFlash)throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';c.__fileApiXHR=FileAPI.upload(e)},1)}else{if(this.__origError)throw this.__origError;a.apply(c,arguments)}}}),window.XMLHttpRequest.__isFileAPIShim=!0,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(){function a(a){return"input"===a[0].tagName.toLowerCase()&&a.attr("type")&&"file"===a.attr("type").toLowerCase()}function b(){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}function c(a){var b=0,c=0;if(window.jQuery)return jQuery(a).offset();if(a.offsetParent)do b+=a.offsetLeft-a.scrollLeft,c+=a.offsetTop-a.scrollTop,a=a.offsetParent;while(a);return{left:b,top:c}}if(FileAPI.shouldLoad){if(FileAPI.forceLoad&&(FileAPI.html5=!1),!FileAPI.upload){var d,e,f,g,h,i=document.createElement("script"),j=document.getElementsByTagName("script");if(window.FileAPI.jsUrl)d=window.FileAPI.jsUrl;else if(window.FileAPI.jsPath)e=window.FileAPI.jsPath;else for(f=0;f<j.length;f++)if(h=j[f].src,g=h.search(/\/ng\-file\-upload[\-a-zA-z0-9\.]*\.js/),g>-1){e=h.substring(0,g+1);break}null==FileAPI.staticPath&&(FileAPI.staticPath=e),i.setAttribute("src",d||e+"FileAPI.min.js"),document.getElementsByTagName("head")[0].appendChild(i),FileAPI.hasFlash=b()}FileAPI.ngfFixIE=function(d,e,f,g){if(!b())throw'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';var h=function(){if(d.attr("disabled"))d.$$ngfRefElem.removeClass("js-fileapi-wrapper");else{var b=d.$$ngfRefElem;b?f(d.$$ngfRefElem):(b=d.$$ngfRefElem=e(),b.addClass("js-fileapi-wrapper"),!a(d),setTimeout(function(){b.bind("mouseenter",h)},10),b.bind("change",function(a){i.apply(this,[a]),g.apply(this,[a])})),a(d)||b.css("position","absolute").css("top",c(d[0]).top+"px").css("left",c(d[0]).left+"px").css("width",d[0].offsetWidth+"px").css("height",d[0].offsetHeight+"px").css("filter","alpha(opacity=0)").css("display",d.css("display")).css("overflow","hidden").css("z-index","900000").css("visibility","visible")}};d.bind("mouseenter",h);var i=function(a){for(var b=FileAPI.getFiles(a),c=0;c<b.length;c++)void 0===b[c].size&&(b[c].size=0),void 0===b[c].name&&(b[c].name="file"),void 0===b[c].type&&(b[c].type="undefined");a.target||(a.target={}),a.target.files=b,a.target.files!==b&&(a.__files_=b),(a.__files_||a.target.files).item=function(b){return(a.__files_||a.target.files)[b]||null}}},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){b||(b=!0,a.onloadstart&&a.onloadstart(c("loadstart",d)));var e;"load"===d.type?(a.onloadend&&a.onloadend(c("loadend",d)),e=c("load",d),a.onload&&a.onload(e),a.dispatchEvent(e)):"progress"===d.type?(e=c("progress",d),a.onprogress&&a.onprogress(e),a.dispatchEvent(e)):(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 5.2.0 | ||
* @version 6.0.0 | ||
*/ | ||
@@ -25,3 +25,3 @@ | ||
ngFileUpload.version = '5.2.0'; | ||
ngFileUpload.version = '6.0.0'; | ||
ngFileUpload.defaults = {}; | ||
@@ -258,4 +258,5 @@ | ||
/** @namespace attr.ngModel */ | ||
/** @namespace attr.ngModelRejected */ | ||
/** @namespace attr.ngfModel */ | ||
/** @namespace attr.ngModelRejected */ | ||
/** @namespace attr.ngfModelRejected */ | ||
/** @namespace attr.ngfMultiple */ | ||
@@ -514,16 +515,17 @@ /** @namespace attr.ngfCapture */ | ||
} | ||
var file = files && files[0]; | ||
var file = files && files.length ? files[0] : null; | ||
if (ngModel) { | ||
$parse(getAttr(attr, 'ngModel')).assign(scope, files); | ||
var singleModel = !$parse(getAttr(attr, 'multiple'))(scope) && !keep; | ||
var ngfModel = getAttr(attr, 'ngfModel'); | ||
if (ngfModel) { | ||
$parse(ngfModel).assign(scope, singleModel ? file : files); | ||
} | ||
var singleModel = !$parse(getAttr(attr, 'ngfMultiple'))(scope) && ! getAttr(attr, 'multiple') && !keep; | ||
$parse(getAttr(attr, 'ngModel')).assign(scope, singleModel ? file : files); | ||
$timeout(function () { | ||
if (ngModel) { | ||
ngModel.$setViewValue(files != null && files.length === 0 ? null : files); | ||
ngModel.$setViewValue(singleModel ? file : (files != null && files.length === 0 ? null : files)); | ||
} | ||
}); | ||
} | ||
var ngfModel = getAttr(attr, 'ngfModel'); | ||
if (ngfModel) { | ||
$parse(ngfModel).assign(scope, files); | ||
} | ||
if (getAttr(attr, 'ngModelRejected')) { | ||
@@ -530,0 +532,0 @@ $parse(getAttr(attr, 'ngModelRejected')).assign(scope, rejFiles); |
@@ -1,2 +0,2 @@ | ||
/*! 5.2.0 */ | ||
!window.XMLHttpRequest||window.FileAPI&&FileAPI.shouldLoad||(window.XMLHttpRequest.prototype.setRequestHeader=function(a){return function(b,c){if("__setXHR_"===b){var d=c(this);d instanceof Function&&d(this)}else a.apply(this,arguments)}}(window.XMLHttpRequest.prototype.setRequestHeader));var ngFileUpload=angular.module("ngFileUpload",[]);ngFileUpload.version="5.2.0",ngFileUpload.defaults={},ngFileUpload.service("Upload",["$http","$q","$timeout",function(a,b,c){function d(d){d.method=d.method||"POST",d.headers=d.headers||{};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.progressFunc&&c(function(){f.progressFunc(a)})},!1),a.upload.addEventListener("load",function(a){a.lengthComputable&&(a.config=d,e.notify?e.notify(a):f.progressFunc&&c(function(){f.progressFunc(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.progressFunc=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){function b(c,d,e){if(void 0!==d)if(angular.isDate(d)&&(d=d.toISOString()),angular.isString(d))c.append(e,d);else if("form"===a.sendFieldsAs)if(angular.isObject(d))for(var f in d)d.hasOwnProperty(f)&&b(c,d[f],e+"["+f+"]");else c.append(e,d);else d=angular.isString(d)?d:JSON.stringify(d),"json-blob"===a.sendFieldsAs?c.append(e,new Blob([d],{type:"application/json"})):c.append(e,d)}return a.headers=a.headers||{},a.headers["Content-Type"]=void 0,a.transformRequest=a.transformRequest?angular.isArray(a.transformRequest)?a.transformRequest:[a.transformRequest]:[],a.transformRequest.push(function(c){var d,e=new FormData,f={};for(d in a.fields)a.fields.hasOwnProperty(d)&&(f[d]=a.fields[d]);c&&(f.data=c);for(d in f)if(f.hasOwnProperty(d)){var g=f[d];a.formDataAppender?a.formDataAppender(e,d,g):b(e,g,d)}if(null!=a.file){var h=a.fileFormDataName||"file";if(angular.isArray(a.file))for(var i=angular.isString(h),j=0;j<a.file.length;j++)e.append(i?h:h[j],a.file[j],a.fileName&&a.fileName[j]||a.file[j].name);else e.append(h,a.file,a.fileName||a.file.name)}return e}),d(a)},this.http=function(b){return b.transformRequest=b.transformRequest||function(b){return window.ArrayBuffer&&b instanceof window.ArrayBuffer||b instanceof Blob?b:a.defaults.transformRequest[0](arguments)},d(b)},this.dataUrl=function(a,b,d){window.FileReader&&a&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 8")||a.size<2e4)&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 9")||a.size<4e6)?c(function(){var e=window.URL||window.webkitURL;if(e&&e.createObjectURL&&!d)b(e.createObjectURL(a));else{var f=new FileReader;f.readAsDataURL(a),f.onload=function(a){c(function(){b(a.target.result)})}}}):b(null)},this.setDefaults=function(a){ngFileUpload.defaults=a||{}}}]),function(){function a(a,f,g,h,i,j,k){function l(){return"input"===f[0].tagName.toLowerCase()&&g.type&&"file"===g.type.toLowerCase()}function m(b){if(!s){s=!0;try{for(var f=b.__files_||b.target&&b.target.files,k=[],l=[],m=0;m<f.length;m++){var n=f.item(m);d(a,i,g,n,b)?k.push(n):l.push(n)}e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),k,l,b),0===k.length&&(b.target.value=k)}finally{s=!1}}}function n(b){c(g,"ngfMultiple")&&b.attr("multiple",i(c(g,"ngfMultiple"))(a)),c(g,"ngfCapture")&&b.attr("capture",i(c(g,"ngfCapture"))(a)),c(g,"accept")&&b.attr("accept",c(g,"accept"));for(var d=0;d<f[0].attributes.length;d++){var e=f[0].attributes[d];(l()&&"type"!==e.name||"type"!==e.name&&"class"!==e.name&&"id"!==e.name&&"style"!==e.name)&&b.attr(e.name,e.value)}}function o(b,c){if(!c&&(b||l()))return f.$$ngfRefElem||f;var d=angular.element('<input type="file">');return n(d),l()?(f.replaceWith(d),f=d,d.attr("__ngf_gen__",!0),k(f)(a)):(d.css("visibility","hidden").css("position","absolute").css("overflow","hidden").css("width","0px").css("height","0px").css("z-index","-100000").css("border","none").css("margin","0px").css("padding","0px").attr("tabindex","-1"),f.$$ngfRefElem&&f.$$ngfRefElem.remove(),f.$$ngfRefElem=d,document.body.appendChild(d[0])),d}function p(b){e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),[],[],b,!0)}function q(d){function e(a){a&&a.clientY>0&&k[0].click(),!l()&&a||!j||f.bind("click touchend touchstart",q)}if(f.attr("disabled")||r)return!1;if(null!=d){if("touchstart"===d.type)return t=d.originalEvent.touches[0].clientY,!0;if(d.stopPropagation(),d.preventDefault(),"touchend"===d.type){var h=d.originalEvent.changedTouches[0].clientY;if(Math.abs(h-t)>20)return!1}}var j=i(c(g,"ngfResetOnClick"))(a)!==!1,k=o(d,j);return k&&((!d||j)&&k.bind("change",m),d&&j&&i(c(g,"ngfResetModelOnClick"))(a)!==!1&&p(d),b(navigator.userAgent)?setTimeout(function(){e(d)},0):e(d)),!1}if(!f.attr("__ngf_gen__")){a.$on("$destroy",function(){f.$$ngfRefElem&&f.$$ngfRefElem.remove()});var r=!1;-1===c(g,"ngfSelect").search(/\W+$files\W+/)&&a.$watch(c(g,"ngfSelect"),function(a){r=a===!1});var s=!1,t=0;window.FileAPI&&window.FileAPI.ngfFixIE?window.FileAPI.ngfFixIE(f,o,n,m):q()}}function b(a){var b=a.match(/Android[^\d]*(\d+)\.(\d+)/);if(b&&b.length>2){var c=ngFileUpload.defaults.androidFixMinorVersion||4;return parseInt(b[1])<4||parseInt(b[1])===c&&parseInt(b[2])<c}return-1===a.indexOf("Chrome")&&/.*Windows.*Safari.*/.test(a)}ngFileUpload.getAttrWithDefaults=function(a,b){return null!=a[b]?a[b]:null==ngFileUpload.defaults[b]?ngFileUpload.defaults[b]:ngFileUpload.defaults[b].toString()};var c=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfSelect",["$parse","$timeout","$compile",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.validate=function(a,b,d,e,f){function g(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+="("+g(b[d])+")",d<b.length-1&&(c+="|");else 0===a.indexOf(".")&&(a="*"+a),c="^"+a.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$",c=c.replace(/\\\*/g,".*").replace(/\\\?/g,".");return c}if(null==e)return!1;var h=b(c(d,"ngfAccept"))(a,{$file:e,$event:f}),i=b(c(d,"ngfMaxSize"))(a,{$file:e,$event:f})||9007199254740991,j=b(c(d,"ngfMinSize"))(a,{$file:e,$event:f})||-1;if(null!=h&&angular.isString(h)){var k=new RegExp(g(h),"gi");if(h=null!=e.type&&k.test(e.type.toLowerCase())||null!=e.name&&k.test(e.name.toLowerCase()),!h)return e.$error="accept",!1}else if(h===!1)return e.$error="accept",!1;return null==e.size?!0:e.size>i?(e.$error="maxSize",!1):e.size<j?(e.$error="minSize",!1):!0},ngFileUpload.updateModel=function(a,b,d,e,f,g,h,i,j,k){function l(){var k=a(c(f,"ngfKeep"))(d);if(k===!0){var l=(e.$modelValue||[]).slice(0);if(h&&h.length)if(a(c(f,"ngfKeepDistinct"))(d)===!0){for(var m=l.length,n=0;n<h.length;n++){for(var o=0;m>o&&h[n].name!==l[o].name;o++);o===m&&l.push(h[n])}h=l}else h=l.concat(h);else h=l}var p=h&&h[0];if(e){a(c(f,"ngModel")).assign(d,h);var q=!a(c(f,"multiple"))(d)&&!k,r=c(f,"ngfModel");r&&a(r).assign(d,q?p:h),b(function(){e&&e.$setViewValue(null!=h&&0===h.length?null:h)})}c(f,"ngModelRejected")&&a(c(f,"ngModelRejected")).assign(d,i),g&&a(g)(d,{$files:h,$file:p,$rejectedFiles:i,$event:j})}k?l():b(function(){l()})};var d=ngFileUpload.validate,e=ngFileUpload.updateModel}(),function(){function a(a,f,g,h,i,j,k){function l(a,b,d){var f=!0,g=d.dataTransfer.items;if(null!=g)for(var h=0;h<g.length&&f;h++)f=f&&("file"===g[h].kind||""===g[h].kind)&&c(a,i,b,g[h],d);var j=i(e(b,"ngfDragOverClass"))(a,{$event:d});return j&&(j.delay&&(s=j.delay),j.accept&&(j=f?j.accept:j.reject)),j||e(b,"ngfDragOverClass")||"dragover"}function m(b,d,e,f){function h(d){c(a,i,g,d,b)?m.push(d):n.push(d)}function l(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;h({name:b.name,type:"directory",path:d});var e=b.createReader(),f=[];p++;var g=function(){e.readEntries(function(d){try{if(d.length)f=f.concat(Array.prototype.slice.call(d||[],0)),g();else{for(var e=0;e<f.length;e++)l(a,f[e],(c?c:"")+b.name+"/");p--}}catch(h){p--,console.error(h)}},function(){p--})};g()}else p++,b.file(function(a){try{p--,a.path=(c?c:"")+a.name,h(a)}catch(b){p--,console.error(b)}},function(){p--})}var m=[],n=[],o=b.dataTransfer.items,p=0;if(o&&o.length>0&&"file"!==k.protocol())for(var q=0;q<o.length;q++){if(o[q].webkitGetAsEntry&&o[q].webkitGetAsEntry()&&o[q].webkitGetAsEntry().isDirectory){var r=o[q].webkitGetAsEntry();if(r.isDirectory&&!e)continue;null!=r&&l(m,r)}else{var s=o[q].getAsFile();null!=s&&h(s)}if(!f&&m.length>0)break}else{var t=b.dataTransfer.files;if(null!=t)for(var u=0;u<t.length&&(h(t.item(u)),f||!(m.length>0));u++);}var v=0;!function w(a){j(function(){if(p)10*v++<2e4&&w(10);else{if(!f&&m.length>1){for(q=0;"directory"===m[q].type;)q++;m=[m[q]]}d(m,n)}},a||0)}()}var n=b();if(e(g,"dropAvailable")&&j(function(){a[e(g,"dropAvailable")]?a[e(g,"dropAvailable")].value=n:a[e(g,"dropAvailable")]=n}),!n)return void(i(e(g,"ngfHideOnDropNotAvailable"))(a)===!0&&f.css("display","none"));var o=!1;-1===e(g,"ngfDrop").search(/\W+$files\W+/)&&a.$watch(e(g,"ngfDrop"),function(a){o=a===!1});var p,q=null,r=i(e(g,"ngfStopPropagation")),s=1;f[0].addEventListener("dragover",function(b){if(!f.attr("disabled")&&!o){if(b.preventDefault(),r(a)&&b.stopPropagation(),navigator.userAgent.indexOf("Chrome")>-1){var c=b.dataTransfer.effectAllowed;b.dataTransfer.dropEffect="move"===c||"linkMove"===c?"move":"copy"}j.cancel(q),a.actualDragOverClass||(p=l(a,g,b)),f.addClass(p)}},!1),f[0].addEventListener("dragenter",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation())},!1),f[0].addEventListener("dragleave",function(){f.attr("disabled")||o||(q=j(function(){f.removeClass(p),p=null},s||1))},!1),f[0].addEventListener("drop",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation(),f.removeClass(p),p=null,m(b,function(c,f){d(i,j,a,h,g,e(g,"ngfChange")||e(g,"ngfDrop"),c,f,b)},i(e(g,"ngfAllowDir"))(a)!==!1,e(g,"multiple")||i(e(g,"ngfMultiple"))(a)))},!1)}function b(){var a=document.createElement("div");return"draggable"in a&&"ondrop"in a}var c=ngFileUpload.validate,d=ngFileUpload.updateModel,e=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfDrop",["$parse","$timeout","$location",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.directive("ngfNoFileDrop",function(){return function(a,c){b()&&c.css("display","none")}}),ngFileUpload.directive("ngfDropAvailable",["$parse","$timeout",function(a,c){return function(d,f,g){if(b()){var h=a(e(g,"ngfDropAvailable"));c(function(){h(d),h.assign&&h.assign(d,!0)})}}}])}(),function(){function a(a,b,c,d,e,f,g){b.$watch(e,function(e){window.FileReader&&ngFileUpload.validate(b,c,d,e,null)&&a.dataUrl(e,function(a){g?g(a):e.dataUrl=a||c(f)(b)},c(d.ngfNoObjectUrl)(b))})}ngFileUpload.directive("ngfSrc",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfSrc,f.ngfDefaultSrc,function(a){e.attr("src",a)})}}}]),ngFileUpload.directive("ngfBackground",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfBackground,f.ngfDefaultBackground,function(a){e.css("background-image","url("+a+")")})}}}]),ngFileUpload.directive("ngfDataUrl",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfDataUrl,f.ngfDefaultDataUrl)}}}])}(); | ||
/*! 6.0.0 */ | ||
!window.XMLHttpRequest||window.FileAPI&&FileAPI.shouldLoad||(window.XMLHttpRequest.prototype.setRequestHeader=function(a){return function(b,c){if("__setXHR_"===b){var d=c(this);d instanceof Function&&d(this)}else a.apply(this,arguments)}}(window.XMLHttpRequest.prototype.setRequestHeader));var ngFileUpload=angular.module("ngFileUpload",[]);ngFileUpload.version="6.0.0",ngFileUpload.defaults={},ngFileUpload.service("Upload",["$http","$q","$timeout",function(a,b,c){function d(d){d.method=d.method||"POST",d.headers=d.headers||{};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.progressFunc&&c(function(){f.progressFunc(a)})},!1),a.upload.addEventListener("load",function(a){a.lengthComputable&&(a.config=d,e.notify?e.notify(a):f.progressFunc&&c(function(){f.progressFunc(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.progressFunc=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){function b(c,d,e){if(void 0!==d)if(angular.isDate(d)&&(d=d.toISOString()),angular.isString(d))c.append(e,d);else if("form"===a.sendFieldsAs)if(angular.isObject(d))for(var f in d)d.hasOwnProperty(f)&&b(c,d[f],e+"["+f+"]");else c.append(e,d);else d=angular.isString(d)?d:JSON.stringify(d),"json-blob"===a.sendFieldsAs?c.append(e,new Blob([d],{type:"application/json"})):c.append(e,d)}return a.headers=a.headers||{},a.headers["Content-Type"]=void 0,a.transformRequest=a.transformRequest?angular.isArray(a.transformRequest)?a.transformRequest:[a.transformRequest]:[],a.transformRequest.push(function(c){var d,e=new FormData,f={};for(d in a.fields)a.fields.hasOwnProperty(d)&&(f[d]=a.fields[d]);c&&(f.data=c);for(d in f)if(f.hasOwnProperty(d)){var g=f[d];a.formDataAppender?a.formDataAppender(e,d,g):b(e,g,d)}if(null!=a.file){var h=a.fileFormDataName||"file";if(angular.isArray(a.file))for(var i=angular.isString(h),j=0;j<a.file.length;j++)e.append(i?h:h[j],a.file[j],a.fileName&&a.fileName[j]||a.file[j].name);else e.append(h,a.file,a.fileName||a.file.name)}return e}),d(a)},this.http=function(b){return b.transformRequest=b.transformRequest||function(b){return window.ArrayBuffer&&b instanceof window.ArrayBuffer||b instanceof Blob?b:a.defaults.transformRequest[0](arguments)},d(b)},this.dataUrl=function(a,b,d){window.FileReader&&a&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 8")||a.size<2e4)&&(!window.FileAPI||-1===navigator.userAgent.indexOf("MSIE 9")||a.size<4e6)?c(function(){var e=window.URL||window.webkitURL;if(e&&e.createObjectURL&&!d)b(e.createObjectURL(a));else{var f=new FileReader;f.readAsDataURL(a),f.onload=function(a){c(function(){b(a.target.result)})}}}):b(null)},this.setDefaults=function(a){ngFileUpload.defaults=a||{}}}]),function(){function a(a,f,g,h,i,j,k){function l(){return"input"===f[0].tagName.toLowerCase()&&g.type&&"file"===g.type.toLowerCase()}function m(b){if(!s){s=!0;try{for(var f=b.__files_||b.target&&b.target.files,k=[],l=[],m=0;m<f.length;m++){var n=f.item(m);d(a,i,g,n,b)?k.push(n):l.push(n)}e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),k,l,b),0===k.length&&(b.target.value=k)}finally{s=!1}}}function n(b){c(g,"ngfMultiple")&&b.attr("multiple",i(c(g,"ngfMultiple"))(a)),c(g,"ngfCapture")&&b.attr("capture",i(c(g,"ngfCapture"))(a)),c(g,"accept")&&b.attr("accept",c(g,"accept"));for(var d=0;d<f[0].attributes.length;d++){var e=f[0].attributes[d];(l()&&"type"!==e.name||"type"!==e.name&&"class"!==e.name&&"id"!==e.name&&"style"!==e.name)&&b.attr(e.name,e.value)}}function o(b,c){if(!c&&(b||l()))return f.$$ngfRefElem||f;var d=angular.element('<input type="file">');return n(d),l()?(f.replaceWith(d),f=d,d.attr("__ngf_gen__",!0),k(f)(a)):(d.css("visibility","hidden").css("position","absolute").css("overflow","hidden").css("width","0px").css("height","0px").css("z-index","-100000").css("border","none").css("margin","0px").css("padding","0px").attr("tabindex","-1"),f.$$ngfRefElem&&f.$$ngfRefElem.remove(),f.$$ngfRefElem=d,document.body.appendChild(d[0])),d}function p(b){e(i,j,a,h,g,c(g,"ngfChange")||c(g,"ngfSelect"),[],[],b,!0)}function q(d){function e(a){a&&a.clientY>0&&k[0].click(),!l()&&a||!j||f.bind("click touchend touchstart",q)}if(f.attr("disabled")||r)return!1;if(null!=d){if("touchstart"===d.type)return t=d.originalEvent.touches[0].clientY,!0;if(d.stopPropagation(),d.preventDefault(),"touchend"===d.type){var h=d.originalEvent.changedTouches[0].clientY;if(Math.abs(h-t)>20)return!1}}var j=i(c(g,"ngfResetOnClick"))(a)!==!1,k=o(d,j);return k&&((!d||j)&&k.bind("change",m),d&&j&&i(c(g,"ngfResetModelOnClick"))(a)!==!1&&p(d),b(navigator.userAgent)?setTimeout(function(){e(d)},0):e(d)),!1}if(!f.attr("__ngf_gen__")){a.$on("$destroy",function(){f.$$ngfRefElem&&f.$$ngfRefElem.remove()});var r=!1;-1===c(g,"ngfSelect").search(/\W+$files\W+/)&&a.$watch(c(g,"ngfSelect"),function(a){r=a===!1});var s=!1,t=0;window.FileAPI&&window.FileAPI.ngfFixIE?window.FileAPI.ngfFixIE(f,o,n,m):q()}}function b(a){var b=a.match(/Android[^\d]*(\d+)\.(\d+)/);if(b&&b.length>2){var c=ngFileUpload.defaults.androidFixMinorVersion||4;return parseInt(b[1])<4||parseInt(b[1])===c&&parseInt(b[2])<c}return-1===a.indexOf("Chrome")&&/.*Windows.*Safari.*/.test(a)}ngFileUpload.getAttrWithDefaults=function(a,b){return null!=a[b]?a[b]:null==ngFileUpload.defaults[b]?ngFileUpload.defaults[b]:ngFileUpload.defaults[b].toString()};var c=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfSelect",["$parse","$timeout","$compile",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.validate=function(a,b,d,e,f){function g(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+="("+g(b[d])+")",d<b.length-1&&(c+="|");else 0===a.indexOf(".")&&(a="*"+a),c="^"+a.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$",c=c.replace(/\\\*/g,".*").replace(/\\\?/g,".");return c}if(null==e)return!1;var h=b(c(d,"ngfAccept"))(a,{$file:e,$event:f}),i=b(c(d,"ngfMaxSize"))(a,{$file:e,$event:f})||9007199254740991,j=b(c(d,"ngfMinSize"))(a,{$file:e,$event:f})||-1;if(null!=h&&angular.isString(h)){var k=new RegExp(g(h),"gi");if(h=null!=e.type&&k.test(e.type.toLowerCase())||null!=e.name&&k.test(e.name.toLowerCase()),!h)return e.$error="accept",!1}else if(h===!1)return e.$error="accept",!1;return null==e.size?!0:e.size>i?(e.$error="maxSize",!1):e.size<j?(e.$error="minSize",!1):!0},ngFileUpload.updateModel=function(a,b,d,e,f,g,h,i,j,k){function l(){var k=a(c(f,"ngfKeep"))(d);if(k===!0){var l=(e.$modelValue||[]).slice(0);if(h&&h.length)if(a(c(f,"ngfKeepDistinct"))(d)===!0){for(var m=l.length,n=0;n<h.length;n++){for(var o=0;m>o&&h[n].name!==l[o].name;o++);o===m&&l.push(h[n])}h=l}else h=l.concat(h);else h=l}var p=h&&h.length?h[0]:null;if(e){var q=!a(c(f,"ngfMultiple"))(d)&&!c(f,"multiple")&&!k;a(c(f,"ngModel")).assign(d,q?p:h),b(function(){e&&e.$setViewValue(q?p:null!=h&&0===h.length?null:h)})}var r=c(f,"ngfModel");r&&a(r).assign(d,h),c(f,"ngModelRejected")&&a(c(f,"ngModelRejected")).assign(d,i),g&&a(g)(d,{$files:h,$file:p,$rejectedFiles:i,$event:j})}k?l():b(function(){l()})};var d=ngFileUpload.validate,e=ngFileUpload.updateModel}(),function(){function a(a,f,g,h,i,j,k){function l(a,b,d){var f=!0,g=d.dataTransfer.items;if(null!=g)for(var h=0;h<g.length&&f;h++)f=f&&("file"===g[h].kind||""===g[h].kind)&&c(a,i,b,g[h],d);var j=i(e(b,"ngfDragOverClass"))(a,{$event:d});return j&&(j.delay&&(s=j.delay),j.accept&&(j=f?j.accept:j.reject)),j||e(b,"ngfDragOverClass")||"dragover"}function m(b,d,e,f){function h(d){c(a,i,g,d,b)?m.push(d):n.push(d)}function l(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;h({name:b.name,type:"directory",path:d});var e=b.createReader(),f=[];p++;var g=function(){e.readEntries(function(d){try{if(d.length)f=f.concat(Array.prototype.slice.call(d||[],0)),g();else{for(var e=0;e<f.length;e++)l(a,f[e],(c?c:"")+b.name+"/");p--}}catch(h){p--,console.error(h)}},function(){p--})};g()}else p++,b.file(function(a){try{p--,a.path=(c?c:"")+a.name,h(a)}catch(b){p--,console.error(b)}},function(){p--})}var m=[],n=[],o=b.dataTransfer.items,p=0;if(o&&o.length>0&&"file"!==k.protocol())for(var q=0;q<o.length;q++){if(o[q].webkitGetAsEntry&&o[q].webkitGetAsEntry()&&o[q].webkitGetAsEntry().isDirectory){var r=o[q].webkitGetAsEntry();if(r.isDirectory&&!e)continue;null!=r&&l(m,r)}else{var s=o[q].getAsFile();null!=s&&h(s)}if(!f&&m.length>0)break}else{var t=b.dataTransfer.files;if(null!=t)for(var u=0;u<t.length&&(h(t.item(u)),f||!(m.length>0));u++);}var v=0;!function w(a){j(function(){if(p)10*v++<2e4&&w(10);else{if(!f&&m.length>1){for(q=0;"directory"===m[q].type;)q++;m=[m[q]]}d(m,n)}},a||0)}()}var n=b();if(e(g,"dropAvailable")&&j(function(){a[e(g,"dropAvailable")]?a[e(g,"dropAvailable")].value=n:a[e(g,"dropAvailable")]=n}),!n)return void(i(e(g,"ngfHideOnDropNotAvailable"))(a)===!0&&f.css("display","none"));var o=!1;-1===e(g,"ngfDrop").search(/\W+$files\W+/)&&a.$watch(e(g,"ngfDrop"),function(a){o=a===!1});var p,q=null,r=i(e(g,"ngfStopPropagation")),s=1;f[0].addEventListener("dragover",function(b){if(!f.attr("disabled")&&!o){if(b.preventDefault(),r(a)&&b.stopPropagation(),navigator.userAgent.indexOf("Chrome")>-1){var c=b.dataTransfer.effectAllowed;b.dataTransfer.dropEffect="move"===c||"linkMove"===c?"move":"copy"}j.cancel(q),a.actualDragOverClass||(p=l(a,g,b)),f.addClass(p)}},!1),f[0].addEventListener("dragenter",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation())},!1),f[0].addEventListener("dragleave",function(){f.attr("disabled")||o||(q=j(function(){f.removeClass(p),p=null},s||1))},!1),f[0].addEventListener("drop",function(b){f.attr("disabled")||o||(b.preventDefault(),r(a)&&b.stopPropagation(),f.removeClass(p),p=null,m(b,function(c,f){d(i,j,a,h,g,e(g,"ngfChange")||e(g,"ngfDrop"),c,f,b)},i(e(g,"ngfAllowDir"))(a)!==!1,e(g,"multiple")||i(e(g,"ngfMultiple"))(a)))},!1)}function b(){var a=document.createElement("div");return"draggable"in a&&"ondrop"in a}var c=ngFileUpload.validate,d=ngFileUpload.updateModel,e=ngFileUpload.getAttrWithDefaults;ngFileUpload.directive("ngfDrop",["$parse","$timeout","$location",function(b,c,d){return{restrict:"AEC",require:"?ngModel",link:function(e,f,g,h){a(e,f,g,h,b,c,d)}}}]),ngFileUpload.directive("ngfNoFileDrop",function(){return function(a,c){b()&&c.css("display","none")}}),ngFileUpload.directive("ngfDropAvailable",["$parse","$timeout",function(a,c){return function(d,f,g){if(b()){var h=a(e(g,"ngfDropAvailable"));c(function(){h(d),h.assign&&h.assign(d,!0)})}}}])}(),function(){function a(a,b,c,d,e,f,g){b.$watch(e,function(e){window.FileReader&&ngFileUpload.validate(b,c,d,e,null)&&a.dataUrl(e,function(a){g?g(a):e.dataUrl=a||c(f)(b)},c(d.ngfNoObjectUrl)(b))})}ngFileUpload.directive("ngfSrc",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfSrc,f.ngfDefaultSrc,function(a){e.attr("src",a)})}}}]),ngFileUpload.directive("ngfBackground",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfBackground,f.ngfDefaultBackground,function(a){e.css("background-image","url("+a+")")})}}}]),ngFileUpload.directive("ngfDataUrl",["$parse","Upload",function(b,c){return{restrict:"AE",link:function(d,e,f){a(c,d,b,f,f.ngfDataUrl,f.ngfDefaultDataUrl)}}}])}(); |
{ | ||
"name": "ng-file-upload", | ||
"version": "5.2.0", | ||
"version": "6.0.0", | ||
"devDependencies": { | ||
@@ -5,0 +5,0 @@ "grunt": "^0.4.5", |
@@ -97,3 +97,3 @@ ng-file-upload | ||
ng-model-rejected="rejFiles" // bind to dropped files that do not match the accept wildcard | ||
ng-disable="selectDisabled" // bind to a boolean value that triggers deactivation of the file select | ||
ng-disabled="selectDisabled" // bind to a boolean value that triggers deactivation of the file select | ||
ngf-change="fileSelected($files, $event)" // called when files are selected or removed | ||
@@ -119,3 +119,3 @@ ngf-multiple="true" or "false" // default false, allows selecting multiple files | ||
ng-model-rejected="rejFiles" // bind to dropped files that do not match the accept wildcard | ||
ng-disable="dropDisabled" // bind to a boolean value that triggers deactivation of the file drop | ||
ng-disabled="dropDisabled" // bind to a boolean value that triggers deactivation of the file drop | ||
ngf-change="fileDropped($files, $event, $rejectedFiles)" //called when files being dropped | ||
@@ -122,0 +122,0 @@ ngf-multiple="true" or "false" // default false, allows selecting multiple files. |
@@ -25,4 +25,5 @@ (function () { | ||
/** @namespace attr.ngModel */ | ||
/** @namespace attr.ngModelRejected */ | ||
/** @namespace attr.ngfModel */ | ||
/** @namespace attr.ngModelRejected */ | ||
/** @namespace attr.ngfModelRejected */ | ||
/** @namespace attr.ngfMultiple */ | ||
@@ -281,16 +282,17 @@ /** @namespace attr.ngfCapture */ | ||
} | ||
var file = files && files[0]; | ||
var file = files && files.length ? files[0] : null; | ||
if (ngModel) { | ||
$parse(getAttr(attr, 'ngModel')).assign(scope, files); | ||
var singleModel = !$parse(getAttr(attr, 'multiple'))(scope) && !keep; | ||
var ngfModel = getAttr(attr, 'ngfModel'); | ||
if (ngfModel) { | ||
$parse(ngfModel).assign(scope, singleModel ? file : files); | ||
} | ||
var singleModel = !$parse(getAttr(attr, 'ngfMultiple'))(scope) && ! getAttr(attr, 'multiple') && !keep; | ||
$parse(getAttr(attr, 'ngModel')).assign(scope, singleModel ? file : files); | ||
$timeout(function () { | ||
if (ngModel) { | ||
ngModel.$setViewValue(files != null && files.length === 0 ? null : files); | ||
ngModel.$setViewValue(singleModel ? file : (files != null && files.length === 0 ? null : files)); | ||
} | ||
}); | ||
} | ||
var ngfModel = getAttr(attr, 'ngfModel'); | ||
if (ngfModel) { | ||
$parse(ngfModel).assign(scope, files); | ||
} | ||
if (getAttr(attr, 'ngModelRejected')) { | ||
@@ -297,0 +299,0 @@ $parse(getAttr(attr, 'ngModelRejected')).assign(scope, rejFiles); |
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
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
3088201
109
23942