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._uniqueRequestIdentifier="RadUrid";
this._formId="";
this._form=null;
this._pageGUID="";
this._suppressMissingHttpModuleError=false;
this._refreshPeriod=500;
this._shouldRegisterForSubmit=true;
this._ajaxCallUrl="";
$telerik.RadUpload_isIFrameProgress=$telerik.isSafari||$telerik.isOpera;
this._disposed=false;
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=[];
}
if($telerik.RadUpload_isIFrameProgress){
this._safariPollerDelegate=Function.createDelegate(this,this._createSafariPoller);
Sys.Application.add_load(this._safariPollerDelegate);
}
},dispose:function(){
this._disposed=true;
if(this._form&&this._shouldRegisterForSubmit==true){
$removeHandler(this._form,"submit",this._clientSubmitDelegate);
this._clientSubmitDelegate=null;
}
if($telerik.RadUpload_isIFrameProgress&&this._safariPollerDelegate){
Sys.Application.remove_load(this._safariPollerDelegate);
this._safariPollerDelegate=null;
}
Telerik.Web.UI.RadProgressManager.callBaseMethod(this,"dispose");
},_getSafariPollerDefinition:function(){
function SafariPoller(_2,_3,_4,_5){
this._callbackUrl=_2;
this._refreshPeriod=_3;
this._waitingForResponse=false;
this._timeFormat=_4;
}
SafariPoller.prototype={_createReadyStateChangeDelegate:this._createReadyStateChangeDelegate,_sendXmlHttpRequest:this._sendXmlHttpRequest,_makeCallback:this._makeCallback,_getTimeStampedCallbackUrl:this._getTimeStampedCallbackUrl,_handleCallback:this._handleCallback,_errorOccured:this._errorOccured,_showNotFoundMessage:this._showNotFoundMessage,_showGenericErrorMessage:this._showGenericErrorMessage,_showInvalidContentMessage:this._showInvalidContentMessage,get_refreshPeriod:this.get_refreshPeriod,_modifyProgressData:this._modifyProgressData,getFormattedTime:this.getFormattedTime,_normalizeTime:this._normalizeTime,_toSeconds:this._toSeconds,_updateProgressAreas:this._updateProgressAreas,_formatTimePart:this._formatTimePart};
return SafariPoller;
},_getSafariProgressAreaDefinition:function(){
function SafariProgressArea(id){
this._id=id;
if(typeof (window.progressAreas)=="undefined"){
window.progressAreas=[];
}
window.progressAreas[window.progressAreas.length]=this;
}
SafariProgressArea.prototype={get_id:function(){
return this._id;
},show:Telerik.Web.UI.RadProgressArea.prototype.show,update:Telerik.Web.UI.RadProgressArea.prototype.update,updateHorizontalProgressBar:Telerik.Web.UI.RadProgressArea.prototype.updateHorizontalProgressBar,updateTextIndicator:Telerik.Web.UI.RadProgressArea.prototype.updateTextIndicator};
return SafariProgressArea;
},_addClassAsString:function(_7,_8,_9){
_9[_9.length]=_7.toString();
_9[_9.length]=";";
_9[_9.length]=_8;
_9[_9.length]=".prototype = {";
var _a=true;
for(var _b in _7.prototype){
var _c=_7.prototype[_b];
if(typeof (_c)!="function"){
continue;
}
if(!_a){
_9[_9.length]=",";
}
_a=false;
_9[_9.length]=_b;
_9[_9.length]=":";
_9[_9.length]=_c.toString();
}
_9[_9.length]="};";
},_createSafariPoller:function(){
this._createSafariIFrame();
},_addSafariProgressAreas:function(_d){
for(var i=0;i<Telerik.Web.UI.ProgressAreas.length;i++){
Telerik.Web.UI.ProgressAreas[i]._addSafariDefinition(_d);
}
},_setupSafariProgressAreas:function(){
for(var i=0;i<Telerik.Web.UI.ProgressAreas.length;i++){
Telerik.Web.UI.ProgressAreas[i]._setupSafariProgressAreaControls();
}
},_createSafariIFrame:function(){
this._safariPoller=document.createElement("iframe");
this._safariPoller.id=this._safariPoller.name=this.get_id()+"_safariPoller";
this._safariPoller.src="javascript:''";
this._safariPoller.style.display="none";
document.forms[0].appendChild(this._safariPoller);
var _10=this._safariPoller.contentWindow.document;
_10.open();
var _11=[];
_11[_11.length]="<scri"+"pt type='text/javascript'>";
this._addClassAsString(this._getSafariPollerDefinition(),"SafariPoller",_11);
_11[_11.length]="var pollerInstance = new SafariPoller('"+this._callbackUrl+"', "+this.get_refreshPeriod()+", '"+this.get_timeFormat()+"');";
_11[_11.length]="$telerik = {};";
_11[_11.length]="$telerik.RadUpload_isIFrameProgress = ";
_11[_11.length]=$telerik.RadUpload_isIFrameProgress.toString();
_11[_11.length]=";";
if(Telerik.Web.UI.ProgressAreas.length>0){
this._addClassAsString(this._getSafariProgressAreaDefinition(),"SafariProgressArea",_11);
this._addSafariProgressAreas(_11);
}
_11[_11.length]="</scr"+"ipt>";
_10.write("<html><head>"+_11.join("")+"</head><body></body></html>");
_10.close();
this._setupSafariProgressAreas();
},_getParentForm:function(){
var _12=this.get_element();
while(_12&&_12.tagName&&_12.tagName.toLowerCase()!="form"){
_12=_12.parentNode;
}
if(_12&&(!_12.tagName||_12.tagName.toLowerCase()!="form")){
_12=null;
}
return _12;
},_registerAsPageManager:function(){
if(!Telerik.Web.UI.ProgressManager.Manager){
Telerik.Web.UI.ProgressManager.Manager=this;
}
},_initializeForm:function(){
var _13=null;
this._form=this._getParentForm();
if(!this._form){
alert("RadProgressManager requires to be in a form tag to operate properly!");
return;
}
this._updateFormAction(this._form);
if(this._shouldRegisterForSubmit==true){
this._registerForSubmit(this._form);
}
},_updateFormAction:function(_14){
if(typeof (_14.action)=="undefined"){
_14.action="";
}
if(_14.action.match(/\?/)){
_14.action=this._removeQueryStringParameter(_14.action,this._uniqueRequestIdentifier);
if(_14.action.substring(_14.action.length-1)!="?"){
_14.action+="&";
}
}else{
_14.action+="?";
}
_14.action+=this._uniqueRequestIdentifier+"="+this._pageGUID;
_14.enctype=_14.encoding="multipart/form-data";
_14._initialAction=_14.action;
},_removeQueryStringParameter:function(_15,_16){
var _17=new RegExp("&?"+_16+"=[^&]*");
if(_15.match(_17)){
return _15.replace(_17,"");
}
return _15;
},_registerForSubmit:function(_18){
this._registerForLinkButtons(_18);
this._registerForRegularButtons(_18);
},_registerForLinkButtons:function(_19){
var _1a=_19.submit;
try{
var _1b=this;
_19.submit=function(){
if(_1b._clientSubmitHandler()==false){
return;
}
_19.submit=_1a;
_19.submit();
};
}
catch(exception){
try{
var _1c=__doPostBack;
__doPostBack=function(_1d,_1e){
var _1f=true;
if(typeof (Page_ClientValidate)=="function"){
_1f=Page_ClientValidate();
}
if(_1f){
if(_1b._clientSubmitHandler()==false){
return;
}
_1c(_1d,_1e);
}
};
}
catch(exception){
}
}
},_registerForRegularButtons:function(_20){
this._clientSubmitDelegate=Function.createDelegate(this,this._clientSubmitHandler);
$addHandler(_20,"submit",this._clientSubmitDelegate);
if(Sys&&Sys.WebForms&&Sys.WebForms.PageRequestManager){
var _21=Sys.WebForms.PageRequestManager.getInstance();
if(_21){
_21.add_beginRequest(this._clientSubmitDelegate);
}
}
},_clientSubmitHandler:function(_22){
var _23=new Sys.CancelEventArgs();
this.raiseEvent("submitting",_23);
if(_23.get_cancel()){
return $telerik.cancelRawEvent(_22);
}
if(typeof (Page_IsValid)!="undefined"){
if(!Page_IsValid){
return;
}
}
this.startProgressPolling();
},startProgressPolling:function(){
this._initSelectedFilesCount();
this.raiseEvent("progressStarted");
if($telerik.RadUpload_isIFrameProgress){
this._safariPoller.contentWindow.pollerInstance._startTime=new Date();
this._safariPoller.contentWindow.pollerInstance._makeCallback();
this._safariPoller.contentWindow.pollerInstance._selectedFilesCount=this._selectedFilesCount;
}else{
this._startTime=new Date();
this._makeCallback();
}
},_initSelectedFilesCount:function(){
this._selectedFilesCount=0;
var _24=document.getElementsByTagName("input");
for(var i=0;i<_24.length;i++){
var _26=_24[i];
if(_26.type=="file"&&_26.value!=""){
this._selectedFilesCount++;
}
}
},_createReadyStateChangeDelegate:function(){
if(!$telerik.RadUpload_isIFrameProgress){
return Function.createDelegate(this,this._handleCallback);
}
var _27=this;
return function(){
_27._handleCallback();
};
},_sendXmlHttpRequest:function(){
if(typeof (XMLHttpRequest)!="undefined"){
this._xmlHttpRequest=new XMLHttpRequest();
}else{
if(typeof (ActiveXObject)!="undefined"){
this._xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
}else{
return;
}
}
this._xmlHttpRequest.onreadystatechange=this._createReadyStateChangeDelegate();
if($telerik.RadUpload_isIFrameProgress){
this._xmlHttpRequest.open("GET",this._getTimeStampedCallbackUrl(),false);
}else{
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 _28=this._xmlHttpRequest.responseText;
if(_28){
try{
eval(_28);
}
catch(ex){
this._showInvalidContentMessage();
return;
}
if(rawProgressData){
if(!this._suppressMissingHttpModuleError&&rawProgressData.ProgressError){
this.handleProgressError(rawProgressData.ProgressError);
return;
}
if(rawProgressData.InProgress){
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(this._disposed||(typeof (rawProgressData)!="undefined"&&rawProgressData.OperationComplete&&rawProgressData.OperationComplete.toLowerCase()=="true")){
return;
}
if($telerik.RadUpload_isIFrameProgress){
var _29=this;
var _2a=function(){
_29._makeCallback();
};
window.setTimeout(_2a,this.get_refreshPeriod());
}else{
if(Function.createDelegate){
var _2a=Function.createDelegate(this,this._makeCallback);
window.setTimeout(_2a,this.get_refreshPeriod());
}
}
},_createCallbackUrl:function(_2b){
var _2c=_2b.indexOf("?")<0?"?":"&";
return _2b+_2c+this._uniqueRequestIdentifier+"="+this._pageGUID;
},_getTimeStampedCallbackUrl:function(){
return this._callbackUrl+"&RadUploadTimeStamp="+new Date().getTime()+"&";
},_modifyProgressData:function(_2d){
var _2e=new Date()-this._startTime;
if(typeof (_2d.TimeElapsed)=="undefined"){
_2d.TimeElapsed=this.getFormattedTime(this._toSeconds(_2e));
}else{
if(parseInt(_2d.TimeElapsed).toString()==_2d.TimeElapsed){
_2d.TimeElapsed=this.getFormattedTime(this._toSeconds(_2d.TimeElapsed));
}
}
if(typeof (_2d.SecondaryTotal)=="undefined"){
_2d.SecondaryTotal=this._selectedFilesCount;
}
if(typeof (_2d.SecondaryPercent)=="undefined"){
_2d.SecondaryPercent=Math.round(100*_2d.SecondaryValue/(this._selectedFilesCount!=0?this._selectedFilesCount:1));
}
if(typeof (_2d.TimeEstimated)=="undefined"&&typeof (_2d.PrimaryPercent)=="number"){
if(_2d.PrimaryPercent==0){
_2d.TimeEstimated=this.getFormattedTime(this._toSeconds(359999000));
}else{
_2d.TimeEstimated=this.getFormattedTime(this._toSeconds(_2e*(100/_2d.PrimaryPercent-1)));
}
}else{
if(parseInt(_2d.TimeEstimated).toString()==_2d.TimeEstimated){
_2d.TimeEstimated=this.getFormattedTime(this._toSeconds(_2d.TimeEstimated));
}
}
},_updateProgressAreas:function(_2f){
if($telerik.RadUpload_isIFrameProgress){
if(typeof (window.progressAreas)!="undefined"){
for(var i=0;i<progressAreas.length;i++){
var _31=progressAreas[i];
if(_31.cancelClicked){
return false;
}
_31.update(_2f);
}
}
}else{
this.raiseEvent("progressUpdating",{ProgressData:_2f});
for(var i=0;i<Telerik.Web.UI.ProgressAreas.length;i++){
var _31=Telerik.Web.UI.ProgressAreas[i];
if(_31.cancelClicked){
return false;
}
_31.update(_2f);
}
}
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(_34){
return Math.round(_34/1000);
},_formatBytes:function(_35){
var _36=_35/1024;
var _37=_36/1024;
if(_37>0.8){
return ""+Math.round(_37*100)/100+"MB";
}
if(_36>0.8){
return ""+Math.round(_36*100)/100+"kB";
}
return ""+_35+" bytes";
},getFormattedTime:function(_38){
var _39=this._normalizeTime(_38);
return this._timeFormat.replace(/%HOURS%/,_39.Hours).replace(/%MINUTES%/,_39.Minutes).replace(/%SECONDS%/,_39.Seconds);
},_normalizeTime:function(_3a){
var _3b=this._formatTimePart(_3a%60);
var _3c=Math.floor(_3a/60);
var _3d=this._formatTimePart(_3c%60);
var _3e=this._formatTimePart(Math.floor(_3c/60));
return {Hours:_3e,Minutes:_3d,Seconds:_3b};
},_formatTimePart:function(_3f){
if(_3f.toString().length>1){
return _3f.toString();
}
return "0"+_3f.toString();
},_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.");
},handleProgressError:function(_40){
alert(_40);
},get_formId:function(){
return this._formId;
},set_formId:function(_41){
this._formId=_41;
},get_refreshPeriod:function(){
return this._refreshPeriod;
},set_refreshPeriod:function(_42){
if(_42&&!isNaN(_42)&&_42>=500){
this._refreshPeriod=_42;
}
},get_pageGUID:function(){
return this._pageGUID;
},set_pageGUID:function(_43){
this._pageGUID=_43;
},get_suppressMissingHttpModuleError:function(){
return this._suppressMissingHttpModuleError;
},set_suppressMissingHttpModuleError:function(_44){
this._suppressMissingHttpModuleError=_44;
},get_shouldRegisterForSubmit:function(){
return this._shouldRegisterForSubmit;
},set_shouldRegisterForSubmit:function(_45){
this._shouldRegisterForSubmit=_45;
},get_ajaxCallUrl:function(){
return this._ajaxCallUrl;
},set_ajaxCallUrl:function(_46){
this._ajaxCallUrl=_46;
},get_timeFormat:function(){
return this._timeFormat;
},set_timeFormat:function(_47){
this._timeFormat=_47;
},add_progressStarted:function(_48){
this.get_events().addHandler("progressStarted",_48);
},remove_progressStarted:function(_49){
this.get_events().removeHandler("progressStarted",_49);
},add_progressUpdating:function(_4a){
this.get_events().addHandler("progressUpdating",_4a);
},remove_progressUpdating:function(_4b){
this.get_events().removeHandler("progressUpdating",_4b);
},add_submitting:function(_4c){
this.get_events().addHandler("submitting",_4c);
},remove_submitting:function(_4d){
this.get_events().removeHandler("submitting",_4d);
}};
Telerik.Web.UI.RadProgressManager.registerClass("Telerik.Web.UI.RadProgressManager",Telerik.Web.UI.RadWebControl);

