/*! Ajax File Upload Plugin - v1.0.0 - 2013-05-01 * https://github.com/jchild3rs/AjaxFileUpload * Copyright (c) 2013 James Childers; Licensed MIT */ (function(){var e,t=function(e,t){return function(){return e.apply(t,arguments)}};e=function(){function g(e,n){var i=this;this.input=e,this.upload=t(this.upload,this),this.reset=t(this.reset,this),this.settings=p.merge(r,n);if(this.input.multiple||this.settings.multiple)this.input.multiple=!0,this.settings.multiple=!0;this.settings.allowedTypes.length>0&&p.attr(this.input,{accept:this.settings.allowedTypes.join()}),this.settings.url===""&&(this.settings.url=this.input.getAttribute("data-url")),this.settings.url===""&&this.input.form.action!==""&&(this.settings.url=this.input.form.action);if(this.settings.url==="")return;this.settings.additionalData!=={}&&(this.settings.url+="?"+p.serialize(this.settings.additionalData)),this.settings.showCustomInput&&h(this),c.fileAPI&&c.formData?this.input.addEventListener("change",function(e){return l(e,i)}):s(this),window.AjaxFileUpload=window.AjaxFileUpload||g,window.AjaxFileUpload.instances=g.instances||[],window.AjaxFileUpload.instances[this.input.id]=this;return}var e,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m=this;return r={url:"",additionalData:{},autoUpload:!1,dataType:"json",method:"post",pathToSwf:"/dist/AjaxFileUpload.swf",showCustomInput:!1,buttonEmptyText:"Select",buttonSelectedText:"Upload",showProgressBar:!1,progressBarElement:"",debug:!1,multiple:!1,sizeLimit:0,allowedTypes:[],onSuccess:function(){},onError:function(){},onFileSelect:function(){},onProgress:function(){},onProgressStart:function(){},onProgressEnd:function(){}},g.prototype.reset=function(){var e,t;e=document.getElementById("fu-button-"+this.input.id),e!=null&&(e.innerHTML=this.settings.buttonEmptyText),t=document.getElementById("fu-input-"+this.input.id),t!=null&&(t.value=""),this.input.value="",p.css(this.input,{display:"block"})},g.prototype.upload=function(){return e(this)},l=function(t,n){var r,s,o;o=n.settings,v(n)&&(o.autoUpload&&n.upload(),o.onFileSelect.apply(o,[t.target.files]),o.showCustomInput&&(r=document.getElementById("fu-button-"+t.target.id),s=document.getElementById("fu-input-"+t.target.id),r.innerHTML=o.buttonSelectedText,p.css(n.input,{display:"none"}),r.onclick=function(){return e(n),!1},i(s,t.target.files)))},e=function(e){var t,n,r,i,s,l;if(e.input.files.length===0)return;r=new XMLHttpRequest,r.upload?(r.upload.addEventListener("progress",function(t){return o(t,e)}),r.upload.addEventListener("loadstart",function(t){return a(t,e)}),r.upload.addEventListener("load",function(t){return u(t,e)})):r.addEventListener("progress",function(t){return o(t,e)}),r.addEventListener("readystatechange",function(t){return f(t,e)}),n=new FormData,l=e.input.files;for(i=0,s=l.length;i1){r="";for(i=0,s=t.length;i0&&i.onError.apply(e,r),r.length===0},g}.call(this),window.AjaxFileUploadFlashProxy=function(e,t,n){var r;r=window.AjaxFileUpload.instances[e],r.settings[t].apply(r,n)},window.AjaxFileUpload=e,window.jQuery&&(jQuery.ajaxFileUpload=e,jQuery.fn.ajaxFileUpload=function(t){return this.each(function(n,r){new e(r,t)})}),typeof define=="function"&&define.amd&&define("ajaxFileUpload",[],function(){return e})}).call(this);