?
Path : /home/admin/domains/happytokorea.net/public_html/test/media/system/js/ |
Current File : /home/admin/domains/happytokorea.net/public_html/test/media/system/js/swf.js |
/* MIT License @author Harald Kirschner <http://digitarald.de> @author Valerio Proietti, <http://mad4milk.net> @copyright Authors */ Swiff.Uploader=new Class({Extends:Swiff,Implements:Events,options:{path:"Swiff.Uploader.swf",target:null,zIndex:9999,callBacks:null,params:{wMode:"opaque",menu:"false",allowScriptAccess:"always"},typeFilter:null,multiple:!0,queued:!0,verbose:!1,height:30,width:100,passStatus:null,url:null,method:null,data:null,mergeData:!0,fieldName:null,fileSizeMin:1,fileSizeMax:null,allowDuplicates:!1,timeLimit:Browser.Platform.linux?0:30,policyFile:null,buttonImage:null,fileListMax:0,fileListSizeMax:0,instantStart:!1, appendCookieData:!1,fileClass:null},initialize:function(a){this.addEvent("load",this.initializeSwiff,!0).addEvent("select",this.processFiles,!0).addEvent("complete",this.update,!0).addEvent("fileRemove",function(a){this.fileList.erase(a)}.bind(this),!0);this.setOptions(a);this.options.callBacks&&Hash.each(this.options.callBacks,function(a,b){this.addEvent(b,a)},this);this.options.callBacks={fireCallback:this.fireCallback.bind(this)};a=this.options.path;a.contains("?")||(a+="?noCache="+Date.now);this.options.container= this.box=(new Element("span",{"class":"swiff-uploader-box"})).inject(document.id(this.options.container)||document.body);if(this.target=document.id(this.options.target)){var b=window.getScroll();this.box.setStyles({position:"absolute",visibility:"visible",zIndex:this.options.zIndex,overflow:"hidden",height:1,width:1,top:b.y,left:b.x});this.parent(a,{params:{wMode:"transparent"},height:"100%",width:"100%"});this.target.addEvent("mouseenter",this.reposition.bind(this,[]));this.addEvents({buttonEnter:this.targetRelay.bind(this, ["mouseenter"]),buttonLeave:this.targetRelay.bind(this,["mouseleave"]),buttonDown:this.targetRelay.bind(this,["mousedown"]),buttonDisable:this.targetRelay.bind(this,["disable"])});this.reposition();window.addEvent("resize",this.reposition.bind(this,[]))}else this.parent(a);this.inject(this.box);this.fileList=[];this.size=this.uploading=this.bytesLoaded=this.percentLoaded=0;9>Browser.Plugins.Flash.version?this.fireEvent("fail",["flash"]):this.verifyLoad.delay(1E3,this)},verifyLoad:function(){this.loaded|| (this.object.parentNode?"none"==this.object.style.display?this.fireEvent("fail",["hidden"]):this.object.offsetWidth||this.fireEvent("fail",["empty"]):this.fireEvent("fail",["disabled"]))},fireCallback:function(a,b){if("file"==a.substr(0,4)){1<b.length&&this.update(b[1]);var e=b[0],d=this.findFile(e.id);this.fireEvent(a,d||e,5);if(d){var f=a.replace(/^file([A-Z])/,function(a,b){return b.toLowerCase()});d.update(e).fireEvent(f,[e],10)}}else this.fireEvent(a,b,5)},update:function(a){Object.append(this, a);this.fireEvent("queue",[this],10);return this},findFile:function(a){for(var b=0;b<this.fileList.length;b++)if(this.fileList[b].id==a)return this.fileList[b];return null},initializeSwiff:function(){this.remote("xInitialize",{typeFilter:this.options.typeFilter,multiple:this.options.multiple,queued:this.options.queued,verbose:this.options.verbose,width:this.options.width,height:this.options.height,passStatus:this.options.passStatus,url:this.options.url,method:this.options.method,data:this.options.data, mergeData:this.options.mergeData,fieldName:this.options.fieldName,fileSizeMin:this.options.fileSizeMin,fileSizeMax:this.options.fileSizeMax,allowDuplicates:this.options.allowDuplicates,timeLimit:this.options.timeLimit,policyFile:this.options.policyFile,buttonImage:this.options.buttonImage});this.loaded=!0;this.appendCookieData()},targetRelay:function(a){this.target&&this.target.fireEvent(a)},reposition:function(a){a=a||this.target&&this.target.offsetHeight?this.target.getCoordinates(this.box.getOffsetParent()): {top:window.getScrollTop(),left:0,width:40,height:40};this.box.setStyles(a);this.fireEvent("reposition",[a,this.box,this.target])},setOptions:function(a){a&&(a.url&&(a.url=Swiff.Uploader.qualifyPath(a.url)),a.buttonImage&&(a.buttonImage=Swiff.Uploader.qualifyPath(a.buttonImage)),this.parent(a),this.loaded&&this.remote("xSetOptions",a));return this},setEnabled:function(a){this.remote("xSetEnabled",a)},start:function(){this.fireEvent("beforeStart");this.remote("xStart")},stop:function(){this.fireEvent("beforeStop"); this.remote("xStop")},remove:function(){this.fireEvent("beforeRemove");this.remote("xRemove")},fileStart:function(a){this.remote("xFileStart",a.id)},fileStop:function(a){this.remote("xFileStop",a.id)},fileRemove:function(a){this.remote("xFileRemove",a.id)},fileRequeue:function(a){this.remote("xFileRequeue",a.id)},appendCookieData:function(){var a=this.options.appendCookieData;if(a){var b={};document.cookie.split(/;\s*/).each(function(a){a=a.split("=");2==a.length&&(b[decodeURIComponent(a[0])]=decodeURIComponent(a[1]))}); var e=this.options.data||{};"string"==$type(a)?e[a]=b:Object.append(e,b);this.setOptions({data:e})}},processFiles:function(a,b,e){var d=this.options.fileClass||Swiff.Uploader.File,f=[],c=[];a&&(a.each(function(a){var b=new d(this,a);b.validate()?(this.size+=a.size,this.fileList.push(b),c.push(b),b.render()):(b.remove.delay(10,b),f.push(b))},this),this.fireEvent("selectSuccess",[c],10));if(b||f.length)f.extend(b?b.map(function(a){return new d(this,a)},this):[]).each(function(a){a.invalidate().render()}), this.fireEvent("selectFail",[f],10);this.update(e);this.options.instantStart&&c.length&&this.start()}}); Object.append(Swiff.Uploader,{STATUS_QUEUED:0,STATUS_RUNNING:1,STATUS_ERROR:2,STATUS_COMPLETE:3,STATUS_STOPPED:4,log:function(){window.console&&console.info&&console.info.apply(console,arguments)},unitLabels:{b:[{min:1,unit:"B"},{min:1024,unit:"kB"},{min:1048576,unit:"MB"},{min:1073741824,unit:"GB"}],s:[{min:1,unit:"s"},{min:60,unit:"m"},{min:3600,unit:"h"},{min:86400,unit:"d"}]},formatUnit:function(a,b,e){var d=Swiff.Uploader.unitLabels["bps"==b?"b":b],f="bps"==b?"/s":"",c;c=d.length;var g;if(1> a)return"0 "+d[0].unit+f;if("s"==b){f=[];for(c-=1;0<=c;c--)if(g=Math.floor(a/d[c].min))if(f.push(g+" "+d[c].unit),a-=g*d[c].min,!a)break;return!1===e?f:f.join(e||", ")}for(c-=1;0<=c&&!(g=d[c].min,a>=g);c--);return(a/g).toFixed(1)+" "+d[c].unit+f}});Swiff.Uploader.qualifyPath=function(){var a;return function(b){(a||(a=new Element("a"))).href=b;return a.href}}(); Swiff.Uploader.File=new Class({Implements:Events,initialize:function(a,b){this.base=a;this.update(b)},update:function(a){return Object.append(this,a)},validate:function(){var a=this.base.options;if(a.fileListMax&&this.base.fileList.length>=a.fileListMax)return this.validationError="fileListMax",!1;return a.fileListSizeMax&&this.base.size+this.size>a.fileListSizeMax?(this.validationError="fileListSizeMax",!1):!0},invalidate:function(){this.invalid=!0;this.base.fireEvent("fileInvalid",this,10);return this.fireEvent("invalid", this,10)},render:function(){return this},setOptions:function(a){a&&(a.url&&(a.url=Swiff.Uploader.qualifyPath(a.url)),this.base.remote("xFileSetOptions",this.id,a),this.options=$merge(this.options,a));return this},start:function(){this.base.fileStart(this);return this},stop:function(){this.base.fileStop(this);return this},remove:function(){this.base.fileRemove(this);return this},requeue:function(){this.base.fileRequeue(this)}});