Type.registerNamespace("Telerik.Web.UI");
Type.registerNamespace("Telerik.Web.UI.ProgressManager");
function getRadProgressManager(){
return Telerik.Web.UI.ProgressManager.Manager;
}
Telerik.Web.UI.RadProgressManager=function(_1){
Telerik.Web.UI.RadProgressManager.initializeBase(this,[_1]);
this._enableMemoryOptimization=true;
this._uniqueRequestIdentifier="RadUrid";
this._enableMemoryOptimizationIdentifier="RadUmo";
this._formId="";
this._form=null;
this._pageGUID="";
this._suppressMissingHttpModuleError=false;
this._shouldRegisterForSubmit=true;
this._ajaxCallUrl="";
this._timeFormat="%HOURS%:%MINUTES%:%SECONDS%s";
};
Telerik.Web.UI.RadProgressManager.prototype={initialize:function(){
Telerik.Web.UI.RadProgressManager.callBaseMethod(this,"initialize");
this._registerAsPageManager();
this._initializeForm();
this._callbackUrl=this._createCallbackUrl(this._ajaxCallUrl);
this._waitingForResponse=false;
if(typeof (Telerik.Web.UI.ProgressAreas)=="undefined"){
Telerik.Web.UI.ProgressAreas=[];
}
},dispose:function(){
if(this._form&&this._shouldRegisterForSubmit==true){
$removeHandler(this._form,"submit",this._clientSubmitDelegate);
this._clientSubmitDelegate=null;
}
Telerik.Web.UI.RadProgressManager.callBaseMethod(this,"dispose");
},_registerAsPageManager:function(){
if(!Telerik.Web.UI.ProgressManager.Manager){
Telerik.Web.UI.ProgressManager.Manager=this;
}
},_initializeForm:function(){
this._form=$get(this._formId);
if(!this._form){
this._form=document.forms[0];
}
this._updateFormAction(this._form);
if(this._shouldRegisterForSubmit==true){
this._registerForSubmit(this._form);
}
},_updateFormAction:function(_2){
if(typeof (_2.action)=="undefined"){
_2.action="";
}
if(_2.action.match(/\?/)){
_2.action=this._removeQueryStringParameter(_2.action,this._uniqueRequestIdentifier);
_2.action=this._removeQueryStringParameter(_2.action,this._enableMemoryOptimizationIdentifier);
if(_2.action.substring(_2.action.length-1)!="?"){
_2.action+="&";
}
}else{
_2.action+="?";
}
_2.action+=this._uniqueRequestIdentifier+"="+this._pageGUID;
if(this._enableMemoryOptimization){
_2.enctype=_2.encoding="multipart/form-data";
}else{
_2.action+="&"+this._enableMemoryOptimizationIdentifier+"=false";
}
_2._initialAction=_2.action;
},_removeQueryStringParameter:function(_3,_4){
var _5=new RegExp("&?"+_4+"=[^&]*");
if(_3.match(_5)){
return _3.replace(_5,"");
}
return _3;
},_registerForSubmit:function(_6){
this._registerForLinkButtons(_6);
this._registerForRegularButtons(_6);
},_registerForLinkButtons:function(_7){
var _8=_7.submit;
try{
var _9=this;
_7.submit=function(){
if(_9._clientSubmitHandler()==false){
return;
}
_7.submit=_8;
_7.submit();
};
}
catch(exception){
try{
var _a=__doPostBack;
__doPostBack=function(_b,_c){
var _d=true;
if(typeof (Page_ClientValidate)=="function"){
_d=Page_ClientValidate();
}
if(_d){
if(_9._clientSubmitHandler()==false){
return;
}
_a(_b,_c);
}
};
}
catch(exception){
}
}
},_registerForRegularButtons:function(_e){
this._clientSubmitDelegate=Function.createDelegate(this,this._clientSubmitHandler);
$addHandler(_e,"submit",this._clientSubmitDelegate);
},_clientSubmitHandler:function(_f){
var _10=new Sys.CancelEventArgs();
this.raiseEvent("submitting",_10);
if(_10.get_cancel()){
return $telerik.cancelRawEvent(_f);
}
if(typeof (Page_IsValid)!="undefined"){
if(!Page_IsValid){
return;
}
}
this.startProgressPolling();
},startProgressPolling:function(){
this._initSelectedFilesCount();
this.raiseEvent("progressStarted");
this._startTime=new Date();
this._makeCallback();
},_initSelectedFilesCount:function(){
this._selectedFilesCount=0;
var _11=document.getElementsByTagName("input");
for(var i=0;i<_11.length;i++){
var _13=_11[i];
if(_13.type=="file"&&_13.value!=""){
this._selectedFilesCount++;
}
}
},_sendXmlHttpRequest:function(){
if(typeof (XMLHttpRequest)!="undefined"){
this._xmlHttpRequest=new XMLHttpRequest();
}else{
if(typeof (ActiveXObject)!="undefined"){
this._xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
}else{
return;
}
}
var _14=Function.createDelegate(this,this._handleCallback);
this._xmlHttpRequest.onreadystatechange=_14;
this._xmlHttpRequest.open("GET",this._getTimeStampedCallbackUrl(),true);
this._xmlHttpRequest.send("");
},_makeCallback:function(){
if(!this._waitingForResponse){
this._waitingForResponse=true;
this._sendXmlHttpRequest();
}
},_handleCallback:function(){
if(this._xmlHttpRequest.readyState!=4){
return;
}
this._waitingForResponse=false;
if(this._errorOccured()){
return;
}
var _15=this._xmlHttpRequest.responseText;
if(_15){
try{
eval(_15);
}
catch(ex){
this._showInvalidContentMessage();
return;
}
if(rawProgressData){
if(this._enableMemoryOptimization==true&&!this._suppressMissingHttpModuleError&&rawProgressData.ProgressError){
alert(rawProgressData.ProgressError);
return;
}
if(rawProgressData.InProgress){
if(this._selectedFilesCount>0||rawProgressData.RadProgressContextCustomCounters){
this._modifyProgressData(rawProgressData);
if(!this._updateProgressAreas(rawProgressData)){
this.hideProgressAreas();
this._resetCancelClicked();
if(window.stop){
window.stop();
}else{
try{
document.execCommand("Stop");
}
catch(ex){
window.location.href=window.location.href;
}
}
return;
}
}
}
}
}
if(Function.createDelegate){
var _16=Function.createDelegate(this,this._makeCallback);
window.setTimeout(_16,this._refreshPeriod);
}
},_createCallbackUrl:function(_17){
var _18=_17.indexOf("?")<0?"?":"&";
return _17+_18+this._uniqueRequestIdentifier+"="+this._pageGUID;
},_getTimeStampedCallbackUrl:function(){
return this._callbackUrl+"&RadUploadTimeStamp="+new Date().getTime();
},_modifyProgressData:function(_19){
var _1a=new Date()-this._startTime;
if(typeof (_19.TimeElapsed)=="undefined"){
_19.TimeElapsed=this._getFormattedTime(this._toSeconds(_1a));
}
if(_19.RadUpload){
var _1b=_19.RadUpload.RequestSize;
var _1c=_19.RadUpload.Bytes;
if(typeof (_19.PrimaryTotal)=="undefined"){
_19.PrimaryTotal=this._formatBytes(_1b);
}
if(typeof (_19.PrimaryValue)=="undefined"){
_19.PrimaryValue=this._formatBytes(_1c);
}
if(typeof (_19.PrimaryPercent)=="undefined"){
_19.PrimaryPercent=Math.round(100*_1c/_1b);
}
if(typeof (_19.SecondaryTotal)=="undefined"){
_19.SecondaryTotal=this._selectedFilesCount;
}
if(typeof (_19.SecondaryValue)=="undefined"){
_19.SecondaryValue=_19.RadUpload.FilesCount;
}
if(typeof (_19.SecondaryPercent)=="undefined"){
_19.SecondaryPercent=Math.round(100*_19.RadUpload.FilesCount/(this._selectedFilesCount!=0?this._selectedFilesCount:1));
}
if(typeof (_19.CurrentOperationText)=="undefined"){
_19.CurrentOperationText=_19.RadUpload.CurrentFileName;
}
if(typeof (_19.Speed)=="undefined"){
if(this._toSeconds(_1a)==0){
_19.Speed=this._formatBytes(0)+"/s";
}else{
_19.Speed=this._formatBytes(_19.RadUpload.Bytes/this._toSeconds(_1a))+"/s";
}
}
}
if(typeof (_19.TimeEstimated)=="undefined"&&typeof (_19.PrimaryPercent)=="number"){
if(_19.PrimaryPercent==0){
_19.TimeEstimated=this._getFormattedTime(this._toSeconds(359999000));
}else{
_19.TimeEstimated=this._getFormattedTime(this._toSeconds(_1a*(100/_19.PrimaryPercent-1)));
}
}
},_updateProgressAreas:function(_1d){
this.raiseEvent("progressUpdating",{ProgressData:_1d});
for(var i=0;i<Telerik.Web.UI.ProgressAreas.length;i++){
var _1f=Telerik.Web.UI.ProgressAreas[i];
if(_1f.cancelClicked){
return false;
}
_1f.update(_1d);
}
return true;
},_resetCancelClicked:function(){
for(var i=0;i<Telerik.Web.UI.ProgressAreas.length;i++){
Telerik.Web.UI.ProgressAreas[i].cancelClicked=false;
}
this._initializeForm();
},hideProgressAreas:function(){
for(var i=0;i<Telerik.Web.UI.ProgressAreas.length;i++){
Telerik.Web.UI.ProgressAreas[i].hide();
}
},_toSeconds:function(_22){
return Math.round(_22/1000);
},_formatBytes:function(_23){
var _24=_23/1024;
var _25=_24/1024;
if(_25>0.8){
return ""+Math.round(_25*100)/100+"MB";
}
if(_24>0.8){
return ""+Math.round(_24*100)/100+"kB";
}
return ""+_23+" bytes";
},_getFormattedTime:function(_26){
var _27=this._normalizeTime(_26);
return this._timeFormat.replace(/%HOURS%/,_27.Hours).replace(/%MINUTES%/,_27.Minutes).replace(/%SECONDS%/,_27.Seconds);
},_normalizeTime:function(_28){
var _29=_28%60;
var _2a=Math.floor(_28/60);
var _2b=_2a%60;
var _2c=Math.floor(_2a/60);
return {Hours:_2c,Minutes:_2b,Seconds:_29};
},_errorOccured:function(){
if(!document.all){
return false;
}
if(this._xmlHttpRequest.status==404){
this._showNotFoundMessage();
}else{
if(this._xmlHttpRequest.status>0&&this._xmlHttpRequest.status!=200){
this._showGenericErrorMessage();
}else{
return false;
}
}
return true;
},_showNotFoundMessage:function(){
alert("RadUpload Ajax callback error. Source url was not found: \n\r\n\r"+this._callbackUrl+"\n\r\n\rDid you register the RadUploadProgressHandler in web.config?"+"\r\n\r\nPlease, see the help for more details: RadUpload for ASP.NET Ajax - Configuration - RadUploadProgressHandler.");
},_showGenericErrorMessage:function(){
alert("RadUpload Ajax callback error. Source url returned error: "+this._xmlHttpRequest.status+" \n\r\n\r"+this._xmlHttpRequest.statusText+" \n\r\n\r"+this._callbackUrl+"\n\r\n\rDid you register the RadUploadProgressHandler in web.config?"+"\r\n\r\nPlease, see the help for more details: RadUpload for ASP.NET Ajax - Configuration - RadUploadProgressHandler.");
},_showInvalidContentMessage:function(){
alert("RadUpload Ajax callback error. Source url returned invalid content: \n\r\n\r"+this._xmlHttpRequest.responseText+"\n\r\n\r"+this._callbackUrl+"\n\r\n\rDid you register the RadUploadProgressHandler in web.config?"+"\r\n\r\nPlease, see the help for more details: RadUpload for ASP.NET Ajax - Configuration - RadUploadProgressHandler.");
},get_enableMemoryOptimization:function(){
return this._enableMemoryOptimization;
},set_enableMemoryOptimization:function(_2d){
this._enableMemoryOptimization=_2d;
},get_formId:function(){
return this._formId;
},set_formId:function(_2e){
this._formId=_2e;
},get_pageGUID:function(){
return this._pageGUID;
},set_pageGUID:function(_2f){
this._pageGUID=_2f;
},get_suppressMissingHttpModuleError:function(){
return this._suppressMissingHttpModuleError;
},set_suppressMissingHttpModuleError:function(_30){
this._suppressMissingHttpModuleError=_30;
},get_shouldRegisterForSubmit:function(){
return this._shouldRegisterForSubmit;
},set_shouldRegisterForSubmit:function(_31){
this._shouldRegisterForSubmit=_31;
},get_ajaxCallUrl:function(){
return this._ajaxCallUrl;
},set_ajaxCallUrl:function(_32){
this._ajaxCallUrl=_32;
},add_progressStarted:function(_33){
this.get_events().addHandler("progressStarted",_33);
},remove_progressStarted:function(_34){
this.get_events().removeHandler("progressStarted",_34);
},add_progressUpdating:function(_35){
this.get_events().addHandler("progressUpdating",_35);
},remove_progressUpdating:function(_36){
this.get_events().removeHandler("progressUpdating",_36);
},add_submitting:function(_37){
this.get_events().addHandler("submitting",_37);
},remove_submitting:function(_38){
this.get_events().removeHandler("submitting",_38);
}};
Telerik.Web.UI.RadProgressManager.registerClass("Telerik.Web.UI.RadProgressManager",Telerik.Web.UI.RadWebControl);

