uploader-flash-min.js revision 8a312a88a012998a3b8cb477194197617cf3f061
YUI.add("uploader-flash",function(g){var b=g.substitute,f=g.Uploader.Queue,c=g.ClassNameManager.getClassName,d="uploader",e=c(d,"selectfiles-button");function a(h){a.superclass.constructor.apply(this,arguments);}g.UploaderFlash=g.extend(a,g.Widget,{_swfReference:null,_uploaderQueue:null,_swfContainerId:null,_buttonState:"up",_buttonFocus:false,initializer:function(){this._swfContainerId=g.guid("uploader");this.publish("fileselect");this.publish("uploadstart");this.publish("fileuploadstart");this.publish("uploadprogress");this.publish("totaluploadprogress");this.publish("uploadcomplete");this.publish("alluploadscomplete");this.publish("uploaderror");},_uploadEventHandler:function(h){switch(h.type){case"file:uploadstart":this.fire("fileuploadstart",h);break;case"file:uploadprogress":this.fire("uploadprogress",h);break;case"uploaderqueue:totaluploadprogress":this.fire("totaluploadprogress",h);break;case"file:uploadcomplete":this.fire("uploadcomplete",h);break;case"uploaderqueue:alluploadscomplete":this.fire("alluploadscomplete",h);break;case"uploaderqueue:uploaderror":this.fire("uploaderror",h);}},_setMultipleFiles:function(){if(this._swfReference){this._swfReference.callSWF("setAllowMultipleFiles",[this.get("multipleFiles")]);}},_setFileFilters:function(){if(this._swfReference&&this.get("fileFilters")!=null){this._swfReference.callSWF("setFileFilters",[this.get("fileFilters")]);}},_updateFileList:function(k){var j=k.fileList,m=[],i=[],h=this._swfReference;g.each(j,function(o){var n={};n.id=o.fileId;n.name=o.fileReference.name;n.size=o.fileReference.size;n.type=o.fileReference.type;n.dateCreated=o.fileReference.creationDate;n.dateModified=o.fileReference.modificationDate;n.uploader=h;m.push(n);});g.each(m,function(n){i.push(new g.File(n));});this.fire("fileselect",{fileList:i});var l=this.get("fileList");this.set("fileList",this.get("appendNewFiles")?l.concat(i):i);},renderUI:function(){var h=this.get("contentBox");var j=this.get("selectFilesButton");j.setStyles({width:"100%",height:"100%"});h.append(j);h.append(g.Node.create(b(a.FLASH_CONTAINER,{swfContainerId:this._swfContainerId})));var i=g.one("#"+this._swfContainerId);var k={version:"10.0.45",fixedAttributes:{wmode:"transparent",allowScriptAccess:"always",allowNetworking:"all",scale:"noscale"},};this._swfReference=new g.SWF(i,this.get("swfURL"),k);},bindUI:function(){this._swfReference.on("swfReady",function(){this._setMultipleFiles();this._setFileFilters();this.after("multipleFilesChange",this._setMultipleFiles,this);this.after("fileFiltersChange",this._setFileFilters,this);},this);this._swfReference.on("fileselect",this._updateFileList,this);this.after("tabElementsChange",this._attachTabElements);this._attachTabElements();this._swfReference.on("mouseenter",function(){this._setButtonClass("hover",true);if(this._buttonState=="down"){this._setButtonClass("active",true);}},this);this._swfReference.on("mouseleave",function(){this._setButtonClass("hover",false);this._setButtonClass("active",false);},this);this._swfReference.on("mousedown",function(){this._buttonState="down";this._setButtonClass("active",true);},this);this._swfReference.on("mouseup",function(){console.log("mouseUP!");this._buttonState="up";this._setButtonClass("active",false);},this);this._swfReference.on("click",function(){this._buttonFocus=true;this._setButtonClass("focus",true);},this);},_setButtonClass:function(h,i){if(i){this.get("selectFilesButton").addClass(this.get("buttonClassNames")[h]);}else{this.get("selectFilesButton").removeClass(this.get("buttonClassNames")[h]);}},_attachTabElements:function(){if(this.get("tabElements")!=null){var i=g.one(this.get("tabElements").from);var h=g.one(this.get("tabElements").to);i.on("keydown",function(j){if(j.keyCode==9&&!j.shiftKey){j.preventDefault();this._swfReference._swf.setAttribute("tabindex",0);this._swfReference._swf.setAttribute("role","button");this._swfReference._swf.setAttribute("aria-label",this.get("selectButtonLabel"));this._swfReference._swf.focus();this._buttonFocus=true;this._setButtonClass("focus",true);}},this);h.on("keydown",function(j){if(j.keyCode==9&&j.shiftKey){j.preventDefault();this._swfReference._swf.setAttribute("tabindex",0);this._swfReference._swf.setAttribute("role","button");this._swfReference._swf.setAttribute("aria-label",this.get("selectButtonLabel"));this._swfReference._swf.focus();this._buttonFocus=true;this._setButtonClass("focus",true);}},this);this._swfReference.on("tabback",function(j){i.focus();},this);this._swfReference.on("tabforward",function(j){h.focus();},this);this._swfReference._swf.on("blur",function(j){this._buttonFocus=false;this._setButtonClass("focus",false);},this);}},upload:function(l,j,m){var k=j||this.get("uploadURL"),i=m||this.get("postVarsPerFile"),h=l.get("id");i=i.hasOwnProperty(h)?i[h]:i;if(l instanceof g.File){l.on("uploadstart",this._uploadStartHandler,this);l.on("uploadprogress",this._uploadProgressHandler,this);l.on("uploadcomplete",this._uploadCompleteHandler,this);l.on("uploaderror",this._uploadErrorHandler,this);l.startUpload(k,i,this.get("fileFieldName"));}},uploadAll:function(h,i){this.uploadThese(this.get("fileList"),h,i);},uploadThese:function(l,i,k){var j=i||this.get("uploadURL"),h=k||this.get("postVarsPerFile");this._uploaderQueue=new f({simUploads:this.get("simLimit"),errorAction:this.get("errorAction"),fileList:l,uploadURL:j,perFileParameters:h});this._uploaderQueue.on("uploadstart",this._uploadEventHandler,this);this._uploaderQueue.on("uploadprogress",this._uploadEventHandler,this);this._uploaderQueue.on("totaluploadprogress",this._uploadEventHandler,this);this._uploaderQueue.on("uploadcomplete",this._uploadEventHandler,this);this._uploaderQueue.on("alluploadscomplete",this._uploadEventHandler,this);this._uploaderQueue.on("uploaderror",this._uploadEventHandler,this);this._uploaderQueue.startUpload();this.fire("uploadstart");}},{FLASH_CONTAINER:"<div id='{swfContainerId}' style='position:absolute; top:0px; left: 0px; width:100%; height:100%'></div>",SELECT_FILES_BUTTON:"<button type='button' class='yui3-button'>{selectButtonLabel}</button>",NAME:"uploader",ATTRS:{buttonClassNames:{value:{"hover":"yui3-button-hover","active":"yui3-button-active","disabled":"yui3-button-disabled","focus":"yui3-button-selected"}},selectButtonLabel:{value:"Select Files"},errorAction:{value:"continue",validator:function(i,h){return(i===f.CONTINUE||i===f.STOP||i===f.RESTART_ASAP||i===f.RESTART_AFTER);
}},selectFilesButton:{valueFn:function(){return g.Node.create(b(g.UploaderFlash.SELECT_FILES_BUTTON,{selectButtonLabel:this.get("selectButtonLabel")}));}},multipleFiles:{value:false},fileFilters:{value:null},fileFieldName:{value:"Filedata"},appendNewFiles:{value:true},simLimit:{value:2,validator:function(i,h){return(i>=2&&i<=5);}},fileList:{value:[]},postVarsPerFile:{value:{}},uploadURL:{value:""},swfURL:{value:"assets/flashuploader.swf"},tabElements:{value:null}}});g.UploaderFlash.Queue=f;},"@VERSION@",{requires:["swf","widget","substitute","base","cssbutton","node","event-custom","file","uploader-queue"]});