//>>built
define("dojox/form/FileUploader",["dojo/_base/kernel","dojo/_base/declare","dojo/_base/lang","dojo/_base/array","dojo/_base/connect","dojo/_base/window","dojo/_base/sniff","dojo/query","dojo/dom","dojo/dom-style","dojo/dom-geometry","dojo/dom-attr","dojo/dom-class","dojo/dom-construct","dojo/dom-form","dojo/_base/config","dijit/_base/manager","dojo/io/iframe","dojo/_base/Color","dojo/_base/unload","dijit/_Widget","dijit/_TemplatedMixin","dijit/_Contained","dojox/embed/Flash","dojox/embed/flashVars","dojox/html/styles"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e,_f,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_1a){
_1.deprecated("dojox.form.FileUploader","Use dojox.form.Uploader","2.0");
return _2("dojox.form.FileUploader",[_15,_16,_17],{swfPath:_10.uploaderPath||require.toUrl("dojox/form/resources/fileuploader.swf"),templateString:"
",uploadUrl:"",isDebug:false,devMode:false,baseClass:"dojoxUploaderNorm",hoverClass:"dojoxUploaderHover",activeClass:"dojoxUploaderActive",disabledClass:"dojoxUploaderDisabled",force:"",uploaderType:"",flashObject:null,flashMovie:null,insideNode:null,deferredUploading:1,fileListId:"",uploadOnChange:false,selectMultipleFiles:true,htmlFieldName:"uploadedfile",flashFieldName:"flashUploadFiles",fileMask:null,minFlashVersion:9,tabIndex:-1,showProgress:false,progressMessage:"Loading",progressBackgroundUrl:require.toUrl("dijit/themes/tundra/images/buttonActive.png"),progressBackgroundColor:"#ededed",progressWidgetId:"",skipServerCheck:false,serverTimeout:5000,log:function(){
if(this.isDebug){
console["log"](Array.prototype.slice.call(arguments).join(" "));
}
},constructor:function(){
this._subs=[];
},postMixInProperties:function(){
this.fileList=[];
this._cons=[];
this.fileMask=this.fileMask||[];
this.fileInputs=[];
this.fileCount=0;
this.flashReady=false;
this._disabled=false;
this.force=this.force.toLowerCase();
this.uploaderType=((_18.available>=this.minFlashVersion||this.force=="flash")&&this.force!="html")?"flash":"html";
this.deferredUploading=this.deferredUploading===true?1:this.deferredUploading;
this._refNode=this.srcNodeRef;
this.getButtonStyle();
},startup:function(){
},postCreate:function(){
this.inherited(arguments);
this.setButtonStyle();
var _1b;
if(this.uploaderType=="flash"){
_1b="createFlashUploader";
}else{
this.uploaderType="html";
_1b="createHtmlUploader";
}
this[_1b]();
if(this.fileListId){
this.connect(_9.byId(this.fileListId),"click",function(evt){
var p=evt.target.parentNode.parentNode.parentNode;
if(p.id&&p.id.indexOf("file_")>-1){
this.removeFile(p.id.split("file_")[1]);
}
});
}
_14.addOnUnload(this,this.destroy);
},getHiddenNode:function(_1c){
if(!_1c){
return null;
}
var _1d=null;
var p=_1c.parentNode;
while(p&&p.tagName.toLowerCase()!="body"){
var d=_a.get(p,"display");
if(d=="none"){
_1d=p;
break;
}
p=p.parentNode;
}
return _1d;
},getButtonStyle:function(){
var _1e=this.srcNodeRef;
this._hiddenNode=this.getHiddenNode(_1e);
if(this._hiddenNode){
_a.set(this._hiddenNode,"display","block");
}
if(!_1e&&this.button&&this.button.domNode){
var _1f=true;
var cls=this.button.domNode.className+" dijitButtonNode";
var txt=this.getText(_8(".dijitButtonText",this.button.domNode)[0]);
var _20="";
_1e=_e.place(_20,this.button.domNode,"after");
this.srcNodeRef=_1e;
this.button.destroy();
this.baseClass="dijitButton";
this.hoverClass="dijitButtonHover";
this.pressClass="dijitButtonActive";
this.disabledClass="dijitButtonDisabled";
}else{
if(!this.srcNodeRef&&this.button){
_1e=this.button;
}
}
if(_c.get(_1e,"class")){
this.baseClass+=" "+_c.get(_1e,"class");
}
_c.set(_1e,"class",this.baseClass);
this.norm=this.getStyle(_1e);
this.width=this.norm.w;
this.height=this.norm.h;
if(this.uploaderType=="flash"){
this.over=this.getTempNodeStyle(_1e,this.baseClass+" "+this.hoverClass,_1f);
this.down=this.getTempNodeStyle(_1e,this.baseClass+" "+this.activeClass,_1f);
this.dsbl=this.getTempNodeStyle(_1e,this.baseClass+" "+this.disabledClass,_1f);
this.fhtml={cn:this.getText(_1e),nr:this.norm,ov:this.over,dn:this.down,ds:this.dsbl};
}else{
this.fhtml={cn:this.getText(_1e),nr:this.norm};
if(this.norm.va=="middle"){
this.norm.lh=this.norm.h;
}
}
if(this.devMode){
this.log("classes - base:",this.baseClass," hover:",this.hoverClass,"active:",this.activeClass);
this.log("fhtml:",this.fhtml);
this.log("norm:",this.norm);
this.log("over:",this.over);
this.log("down:",this.down);
}
},setButtonStyle:function(){
_a.set(this.domNode,{width:this.fhtml.nr.w+"px",height:(this.fhtml.nr.h)+"px",padding:"0px",lineHeight:"normal",position:"relative"});
if(this.uploaderType=="html"&&this.norm.va=="middle"){
_a.set(this.domNode,"lineHeight",this.norm.lh+"px");
}
if(this.showProgress){
this.progTextNode.innerHTML=this.progressMessage;
_a.set(this.progTextNode,{width:this.fhtml.nr.w+"px",height:(this.fhtml.nr.h+0)+"px",padding:"0px",margin:"0px",left:"0px",lineHeight:(this.fhtml.nr.h+0)+"px",position:"absolute"});
_a.set(this.progNode,{width:this.fhtml.nr.w+"px",height:(this.fhtml.nr.h+0)+"px",padding:"0px",margin:"0px",left:"0px",position:"absolute",display:"none",backgroundImage:"url("+this.progressBackgroundUrl+")",backgroundPosition:"bottom",backgroundRepeat:"repeat-x",backgroundColor:this.progressBackgroundColor});
}else{
_e.destroy(this.progNode);
}
_a.set(this.insideNode,{position:"absolute",top:"0px",left:"0px",display:""});
_d.add(this.domNode,this.srcNodeRef.className);
if(this.fhtml.nr.d.indexOf("inline")>-1){
_d.add(this.domNode,"dijitInline");
}
try{
this.insideNode.innerHTML=this.fhtml.cn;
}
catch(e){
if(this.uploaderType=="flash"){
this.insideNode=this.insideNode.parentNode.removeChild(this.insideNode);
_6.body().appendChild(this.insideNode);
this.insideNode.innerHTML=this.fhtml.cn;
var c=_5.connect(this,"onReady",this,function(){
_5.disconnect(c);
this.insideNode=this.insideNode.parentNode.removeChild(this.insideNode);
this.domNode.appendChild(this.insideNode);
});
}else{
this.insideNode.appendChild(document.createTextNode(this.fhtml.cn));
}
}
if(this._hiddenNode){
_a.set(this._hiddenNode,"display","none");
}
},onChange:function(_21){
},onProgress:function(_22){
},onComplete:function(_23){
},onCancel:function(){
},onError:function(_24){
},onReady:function(_25){
},onLoad:function(_26){
},submit:function(_27){
var _28=_27?_f.toObject(_27):null;
this.upload(_28);
return false;
},upload:function(_29){
if(!this.fileList.length){
return false;
}
if(!this.uploadUrl){
console.warn("uploadUrl not provided. Aborting.");
return false;
}
if(!this.showProgress){
this.set("disabled",true);
}
if(this.progressWidgetId){
var _2a=_11.byId(this.progressWidgetId).domNode;
if(_a.get(_2a,"display")=="none"){
this.restoreProgDisplay="none";
_a.set(_2a,"display","block");
}
if(_a.get(_2a,"visibility")=="hidden"){
this.restoreProgDisplay="hidden";
_a.set(_2a,"visibility","visible");
}
}
if(_29&&!_29.target){
this.postData=_29;
}
this.log("upload type:",this.uploaderType," - postData:",this.postData);
for(var i=0;ithis.fhtml.nr.w){
w=0;
_2e=true;
}
this._displayProgress(w/this.fhtml.nr.w);
if(_2e){
clearInterval(_2f);
setTimeout(_3.hitch(this,function(){
this._displayProgress(false);
}),500);
}
}),50);
},_error:function(evt){
if(typeof (evt)=="string"){
evt=new Error(evt);
}
this.onError(evt);
},_addToFileList:function(){
if(this.fileListId){
var str="";
_4.forEach(this.fileList,function(d){
str+=" | "+d.name+" | "+(d.size?Math.ceil(d.size*0.001)+"kb":"")+" |
";
},this);
_9.byId(this.fileListId).innerHTML=str;
}
},_change:function(_30){
if(_7("ie")){
_4.forEach(_30,function(f){
f.name=f.name.split("\\")[f.name.split("\\").length-1];
});
}
if(this.selectMultipleFiles){
this.fileList=this.fileList.concat(_30);
}else{
if(this.fileList[0]){
this.removeFile(this.fileList[0].name,true);
}
this.fileList=_30;
}
this._addToFileList();
this.onChange(_30);
if(this.uploadOnChange){
if(this.uploaderType=="html"){
this._buildFileInput();
}
this.upload();
}else{
if(this.uploaderType=="html"&&this.selectMultipleFiles){
this._buildFileInput();
this._connectInput();
}
}
},_complete:function(_31){
_31=_3.isArray(_31)?_31:[_31];
_4.forEach(_31,function(f){
if(f.ERROR){
this._error(f.ERROR);
}
},this);
_4.forEach(this.fileList,function(f){
f.bytesLoaded=1;
f.bytesTotal=1;
f.percent=100;
this._progress(f);
},this);
_4.forEach(this.fileList,function(f){
this.removeFile(f.name,true);
},this);
this.onComplete(_31);
this.fileList=[];
this._resetHTML();
this.set("disabled",false);
if(this.restoreProgDisplay){
setTimeout(_3.hitch(this,function(){
_a.set(_11.byId(this.progressWidgetId).domNode,this.restoreProgDisplay=="none"?"display":"visibility",this.restoreProgDisplay);
}),500);
}
},_progress:function(_32){
var _33=0;
var _34=0;
for(var i=0;i=Number(this.tabIndex)+1){
this.nextFocusObject=_38[i];
break;
}
}
}
this.nextFocusObject.focus();
},_disconnect:function(){
_4.forEach(this._cons,_5.disconnect,dojo);
},uploadHTML:function(){
if(this.selectMultipleFiles){
_e.destroy(this._fileInput);
}
this._setHtmlPostData();
if(this.showProgress){
this._animateProgress();
}
var dfd=_12.send({url:this.uploadUrl.toString(),form:this._formNode,handleAs:"json",error:_3.hitch(this,function(err){
this._error("HTML Upload Error:"+err.message);
}),load:_3.hitch(this,function(_39,_3a,_3b){
this._complete(_39);
})});
},createHtmlUploader:function(){
this._buildForm();
this._setFormStyle();
this._buildFileInput();
this._connectInput();
this._styleContent();
_a.set(this.insideNode,"visibility","visible");
this.onReady();
},_connectInput:function(){
this._disconnect();
this._cons.push(_5.connect(this._fileInput,"mouseover",this,function(evt){
_d.add(this.domNode,this.hoverClass);
this.onMouseOver(evt);
}));
this._cons.push(_5.connect(this._fileInput,"mouseout",this,function(evt){
setTimeout(_3.hitch(this,function(){
_d.remove(this.domNode,this.activeClass);
_d.remove(this.domNode,this.hoverClass);
this.onMouseOut(evt);
this._checkHtmlCancel("off");
}),0);
}));
this._cons.push(_5.connect(this._fileInput,"mousedown",this,function(evt){
_d.add(this.domNode,this.activeClass);
_d.remove(this.domNode,this.hoverClass);
this.onMouseDown(evt);
}));
this._cons.push(_5.connect(this._fileInput,"mouseup",this,function(evt){
_d.remove(this.domNode,this.activeClass);
this.onMouseUp(evt);
this.onClick(evt);
this._checkHtmlCancel("up");
}));
this._cons.push(_5.connect(this._fileInput,"change",this,function(){
this._checkHtmlCancel("change");
this._change([{name:this._fileInput.value,type:"",size:0}]);
}));
if(this.tabIndex>=0){
_c.set(this.domNode,"tabIndex",this.tabIndex);
}
},_checkHtmlCancel:function(_3c){
if(_3c=="change"){
this.dialogIsOpen=false;
}
if(_3c=="up"){
this.dialogIsOpen=true;
}
if(_3c=="off"){
if(this.dialogIsOpen){
this.onCancel();
}
this.dialogIsOpen=false;
}
},_styleContent:function(){
var o=this.fhtml.nr;
_a.set(this.insideNode,{width:o.w+"px",height:o.va=="middle"?o.h+"px":"auto",textAlign:o.ta,paddingTop:o.p[0]+"px",paddingRight:o.p[1]+"px",paddingBottom:o.p[2]+"px",paddingLeft:o.p[3]+"px"});
try{
_a.set(this.insideNode,"lineHeight","inherit");
}
catch(e){
}
},_resetHTML:function(){
if(this.uploaderType=="html"&&this._formNode){
this.fileInputs=[];
_8("*",this._formNode).forEach(function(n){
_e.destroy(n);
});
this.fileCount=0;
this._buildFileInput();
this._connectInput();
}
},_buildForm:function(){
if(this._formNode){
return;
}
if(_7("ie")<9||(_7("ie")&&_7("quirks"))){
this._formNode=document.createElement("