eventman/static/js/angular-file-upload.min.js

2 lines
8 KiB
JavaScript
Raw Normal View History

2015-03-29 09:58:25 +02:00
/*! 3.2.4 */
!function(){function a(a,b){window.XMLHttpRequest.prototype[a]=b(window.XMLHttpRequest.prototype[a])}function b(a,b,c,d,g,h){function j(){return"input"===b[0].tagName.toLowerCase()&&b.attr("type")&&"file"===b.attr("type").toLowerCase()}function k(b){if(!p){p=!0;try{var j=b.__files_||b.target&&b.target.files,k=[],l=[],m=g(c.ngAccept);for(i=0;i<j.length;i++){var n=j.item(i);f(a,m,n,b)?k.push(n):l.push(n)}e(g,h,a,d,c,c.ngFileChange||c.ngFileSelect,k,l,b),0==k.length&&(b.target.value=k),b.target&&b.target.getAttribute("__ngf_gen__")&&angular.element(b.target).remove()}finally{p=!1}}}function l(b){c.ngMultiple&&b.attr("multiple",g(c.ngMultiple)(a)),c.accept&&b.attr("accept",c.accept),c.ngCapture&&b.attr("capture",g(c.ngCapture)(a)),c.ngDisabled&&b.attr("disabled",g(c.ngDisabled)(a)),b.bind("change",k)}function m(){if(!b.attr("disabled")){for(var a=angular.element('<input type="file">'),c=0;c<b[0].attributes.length;c++){var d=b[0].attributes[c];a.attr(d.name,d.value)}return j()?(b.replaceWith(a),b=a):(a.css("width","0px").css("height","0px").css("position","absolute").css("padding",0).css("margin",0).css("overflow","hidden").attr("tabindex","-1").css("opacity",0).attr("__ngf_gen__",!0),b.__ngf_ref_elem__&&b.__ngf_ref_elem__.remove(),b.__ngf_ref_elem__=a,b.parent()[0].insertBefore(a[0],b[0]),b.css("overflow","hidden")),l(a),a}}function n(b){e(g,h,a,d,c,c.ngFileChange||c.ngFileSelect,[],[],b,!0)}function o(a){var c=m(a);c&&(n(a),c[0].click()),j()&&(b.bind("click",o),a.preventDefault())}var p=!1;window.FileAPI&&window.FileAPI.ngfFixIE?window.FileAPI.ngfFixIE(b,m,k,n):b.bind("click",o)}function c(a,b,c,g,h,j,k){function l(a,b,c){var d=!0,e=c.dataTransfer.items;if(null!=e)for(i=0;i<e.length&&d;i++)d=d&&("file"==e[i].kind||""==e[i].kind)&&f(a,s,e[i],c);var g=h(b.dragOverClass)(a,{$event:c});return g&&(g.delay&&(r=g.delay),g.accept&&(g=d?g.accept:g.reject)),g||b.dragOverClass||"dragover"}function m(b,c,d,e){function g(c){f(a,s,c,b)?l.push(c):m.push(c)}function h(a,b,c){if(null!=b)if(b.isDirectory){var d=(c||"")+b.name;g({name:b.name,type:"directory",path:d});var e=b.createReader(),f=[];o++;var j=function(){e.readEntries(function(d){try{if(d.length)f=f.concat(Array.prototype.slice.call(d||[],0)),j();else{for(i=0;i<f.length;i++)h(a,f[i],(c?c:"")+b.name+"/");o--}}catch(e){o--,console.error(e)}},function(){o--})};j()}else o++,b.file(function(a){try{o--,a.path=(c?c:"")+a.name,g(a)}catch(b){o--,console.error(b)}},function(){o--})}var l=[],m=[],n=b.dataTransfer.items,o=0;if(n&&n.length>0&&"file"!=k.protocol())for(i=0;i<n.length;i++){if(n[i].webkitGetAsEntry&&n[i].webkitGetAsEntry()&&n[i].webkitGetAsEntry().isDirectory){var p=n[i].webkitGetAsEntry();if(p.isDirectory&&!d)continue;null!=p&&h(l,p)}else{var q=n[i].getAsFile();null!=q&&g(q)}if(!e&&l.length>0)break}else{var r=b.dataTransfer.files;if(null!=r)for(i=0;i<r.length&&(g(r.item(i)),e||!(l.length>0));i++);}var t=0;!function u(a){j(function(){if(o)10*t++<2e4&&u(10);else{if(!e&&l.length>1){for(i=0;"directory"==l[i].type;)i++;l=[l[i]]}c(l,m)}},a||0)}()}var n=d();if(c.dropAvailable&&j(function(){a.dropAvailable?a.dropAvailable.value=n:a.dropAvailable=n}),!n)return 1==h(c.hideOnDropNotAvailable)(a)&&b.css("display","none"),void 0;var o,p=null,q=h(c.stopPropagation),r=1,s=h(c.ngAccept),t=h(c.ngDisabled);b[0].addEventListener("dragover",function(d){if(!t(a)){if(d.preventDefault(),q(a)&&d.stopPropagation(),navigator.userAgent.indexOf("Chrome")>-1){var e=d.dataTransfer.effectAllowed;d.dataTransfer.dropEffect="move"===e||"linkMove"===e?"move":"copy"}j.cancel(p),a.actualDragOverClass||(o=l(a,c,d)),b.addClass(o)}},!1),b[0].addEventListener("dragenter",function(b){t(a)||(b.preventDefault(),q(a)&&b.stopPropagation())},!1),b[0].addEventListener("dragleave",function(){t(a)||(p=j(function(){b.removeClass(o),o=null},r||1))},!1),b[0].addEventListener("drop",function(d){t(a)||(d.preventDefault(),q(a)&&d.stopPropagation(),b.removeClass(o),o=null,m(d,function(b,f){e(h,j,a,g,c,c.ngFileChange||c.ngFileDrop,b,f,d)},0!=h(c.allowDir)(a),c.multiple||h(c.ngMultiple)(a)))},!1)}function d(){var a=document.createElement