//>>built
require({cache:{"url:mill/uploader.html":'\x3cspan\x3e\x3cinput data-dojo-attach-event\x3d"onfocus: _onInputFocus, onchange: _onChange" data-dojo-attach-point\x3d"fileInput, focusNode" type\x3d"file"\x3e\x3c/input\x3e\x3c/span\x3e'}});
define("mill/uploader","dojo/Deferred dojo/DeferredList dijit/form/_FormWidget dijit/TooltipDialog dijit/popup mill/mill dojo/i18n!./nls/resources dojo/text!./uploader.html".split(" "),function(l,w,q,x,y,z,k,r){return dojo.declare("mill.uploader",[q],{templateString:r,scrollOnFocus:!1,multiple:null,accept:"",blockSize:null,sockets:null,preventProgressText:null,toolTipTimeout:null,onUpload:new Function,onCancel:new Function,onChange:new Function,popupNode:null,_setNameAttr:"fileInput",_defaultBlockSize:262144,
_defaultSockets:4,_defaultToolTipTimeout:0,_popupWidget:null,_closeToolTipTimeout:null,_bytesToSend:null,_bytesSent:null,_cancelled:!1,_iconClickConnection:null,postMixInProperties:function(){this.inherited(arguments);this._popupWidget=new dijit.TooltipDialog;this._popupWidget.startup()},_setMultipleAttr:function(a){(this.multiple=a)?dojo.setAttr(this.fileInput,"multiple","true"):dojo.removeAttr(this.fileInput,"multiple")},_setAcceptAttr:function(a){dojo.setAttr(this.fileInput,"accept",a)},_getBlockSizeAttr:function(){return parseInt(this.blockSize)||
this._defaultBlockSize},_setBlockSizeAttr:function(a){this.blockSize=parseInt(a)||this._defaultBlockSize},_getSocketsAttr:function(){return parseInt(this.sockets)||this._defaultSockets},_setSocketsAttr:function(a){this.sockets=parseInt(a)||this._defaultSockets},_getToolTipTimeoutAttr:function(){return parseInt(this.toolTipTimeout)||this._defaultToolTipTimeout},_setToolTipTimeoutAttr:function(a){this.toolTipTimeout=parseInt(a)||this._defaultToolTipTimeout},buildRendering:function(){this.inherited(arguments);
var a=dojo.create("span",{className:"dijitDialogCloseIcon",style:{visibility:"hidden"}},this.domNode);setTimeout(function(){dojo.destroy(a)},100)},_getParameterName:function(a){return this.attr("name")+(0<a?"."+a:"")},_createProgressCloseIcon:function(){var a=dojo.create("div",{title:k.upCancelUploading,style:{display:"inline-block",verticalAlign:"top",padding:"0 10px"}});dojo.create("span",{className:"dijitDialogCloseIcon"},a);this._iconClickConnection&&dojo.disconnect(this._iconClickConnection);
this._iconClickConnection=dojo.connect(a,"onmousedown",dojo.hitch(this,this._onCancelButton));return a},_setProgressText:function(a,c){if(!this.preventProgressText){var b=k[a]||a;if(this._popupWidget&&b){var d=dojo.create("div");dojo.create("div",{innerHTML:b,style:{display:"inline-block",padding:"3px 0"}},d);c&&dojo.place(this._createProgressCloseIcon(),d,"last");this._popupWidget.set("content",d);this._closeToolTipTimeout&&clearTimeout(this._closeToolTipTimeout);this._closeToolTipTimeout=null;dijit.popup.open({popup:this._popupWidget,
around:this.popupNode||this.fileInput,orient:["after-centered","before-centered","above","below"]})}}},_closePopup:function(){this._closeToolTipTimeout&&clearTimeout(this._closeToolTipTimeout);this._closeToolTipTimeout=null;this._iconClickConnection&&dojo.disconnect(this._iconClickConnection);dijit.popup.close(this._popupWidget)},_clearSession:function(){for(var a=new l,c={},b=0;b<this.fileInput.files.length+1;b++)c[this._getParameterName(b)]="";dojo.xhrGet({url:"/.system/session.xml",method:"GET",
handleAs:"xml",sync:!1,headers:{"Disable-Basic-Auth":"yes"},content:c}).then(a.resolve,a.reject);return a},_prepareUpload:function(){this._setProgressText("upUploadingAwaiting");this._bytesSent=this._bytesToSend=0;this._cancelled=!1;var a=new l;this._clearSession().then(a.resolve,a.reject);return a.promise},_onUpload:function(){this.attr("toolTipTimeout")?(this._setProgressText("upUploaded"),this._closeToolTipTimeout=setTimeout(dojo.hitch(this,function(){this._closeToolTipTimeout=null;dijit.popup.close(this._popupWidget)}),
this.attr("toolTipTimeout"))):this._closePopup();this.onUpload()},_onCancel:function(){this._closePopup();this.onCancel()},_onInputFocus:function(){this._closePopup()},_onCancelButton:function(){this._cancelled=!0},_onChange:function(){this.onChange()},getSelectedFiles:function(){return dojo.map(this.fileInput.files,function(a){return{fileName:a.name,fileSize:a.size}})},_sendBlock:function(a,c){c=c||new dojo.Deferred;dojo.xhrPost({url:mill.getRequestUrl(".system","session.xml"),method:"POST",handleAs:"xml",
sync:!1,headers:{"Disable-Basic-Auth":"yes","Content-Type":"application/x-overlay","Content-Disposition":'attachment; name\x3d"'+this._getParameterName(a.idx)+'"; fileName\x3d"'+a.fileName+'"',"Content-Range":"bytes "+a.rangeStart+"-"+a.rangeEnd+"/"+a.fileSize},postData:a.block,load:dojo.hitch(this,function(b){if(mill.parseErrorMessage(b))this._sendBlock(a,c);else{this._bytesSent+=a.blockSize;var d=this._bytesSent/this._bytesToSend*100;100<d&&(d=99);this._setProgressText(k.upUploading+" "+d.toFixed()+
"%",!0);a.block=null;c.resolve()}return b}),error:dojo.hitch(this,function(b){this._sendBlock(a,c);return b})});return c},showOpenDialog:function(){this.fileInput.click()},upload:function(){var a=new dojo.Deferred;if(!this.fileInput.value)return this._clearSession().then(a.resolve),a;var c=this.focusNode.disabled;c||(this.focusNode.disabled=!0);var b=this.get("sockets")||this._defaultSockets;this._prepareUpload().then(dojo.hitch(this,function(){var d=[];dojo.forEach(this.fileInput.files,dojo.hitch(this,
function(f,t){for(var e=this.get("blockSize")||this._defaultBlockSize,u=encodeURI(f.name),m=f.size,h=m,g=0;0<h;){e>h&&(e=h);this._bytesToSend+=e;var v=f.slice(g,g+e);d.push({idx:t,fileName:u,fileSize:m,rangeStart:g,rangeEnd:g+e,blockSize:e,block:v});g+=e;h-=e}}));if(!d.length)return a.resolve(),a;b>d.length&&(b=d.length);for(var n=dojo.hitch(this,function(){if(this._cancelled)c||(this.focusNode.disabled=!1),this._onCancel(),a.isRejected()||a.reject();else{var f=d.shift();f?this._sendBlock(f,null).then(n):
--b||(c||(this.focusNode.disabled=!1),this._onUpload(),a.resolve())}}),p=0;p<b;p++)n()}),function(d){alert(d.message)});return a}})});