MDL-32843 import YUI 3.5.1
[moodle.git] / lib / yui / 3.5.1 / build / file-flash / file-flash-min.js
blob18a45ca2157183fc56588daf43b7529ff7185c77
1 /*
2 YUI 3.5.1 (build 22)
3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
6 */
7 YUI.add("file-flash",function(b){var a=function(c){a.superclass.constructor.apply(this,arguments);};b.extend(a,b.Base,{initializer:function(c){if(!this.get("id")){this._set("id",b.guid("file"));}},_swfEventHandler:function(c){if(c.id===this.get("id")){switch(c.type){case"uploadstart":this.fire("uploadstart",{uploader:this.get("uploader")});break;case"uploadprogress":this.fire("uploadprogress",{originEvent:c,bytesLoaded:c.bytesLoaded,bytesTotal:c.bytesTotal,percentLoaded:Math.min(100,Math.round(10000*c.bytesLoaded/c.bytesTotal)/100)});this._set("bytesUploaded",c.bytesLoaded);break;case"uploadcomplete":this.fire("uploadfinished",{originEvent:c});break;case"uploadcompletedata":this.fire("uploadcomplete",{originEvent:c,data:c.data});break;case"uploadcancel":this.fire("uploadcancel",{originEvent:c});break;case"uploaderror":this.fire("uploaderror",{originEvent:c,statusText:c.text,status:c.status});}}},startUpload:function(d,f,h){if(this.get("uploader")){var e=this.get("uploader"),c=h||"Filedata",i=this.get("id"),g=f||null;this._set("bytesUploaded",0);e.on("uploadstart",this._swfEventHandler,this);e.on("uploadprogress",this._swfEventHandler,this);e.on("uploadcomplete",this._swfEventHandler,this);e.on("uploadcompletedata",this._swfEventHandler,this);e.on("uploaderror",this._swfEventHandler,this);e.callSWF("upload",[i,d,g,c]);}},cancelUpload:function(){if(this.get("uploader")){this.get("uploader").callSWF("cancel",[this.get("id")]);}}},{NAME:"file",TYPE:"flash",ATTRS:{id:{writeOnce:"initOnly",value:null},size:{writeOnce:"initOnly",value:0},name:{writeOnce:"initOnly",value:null},dateCreated:{writeOnce:"initOnly",value:null},dateModified:{writeOnce:"initOnly",value:null},bytesUploaded:{readOnly:true,value:0},type:{writeOnce:"initOnly",value:null},uploader:{writeOnce:"initOnly",value:null}}});b.FileFlash=a;},"3.5.1",{requires:["base"]});