﻿Type.registerNamespace("PhArt.UI.WebControls");PhArt.UI.WebControls.UpdateProgress=function(element){PhArt.UI.WebControls.UpdateProgress.initializeBase(this,[element]);this._updateProgressId=null;this._divMsgId=null;this._messages=new Array();this._messageDictionary=new Array();this._lastPostBackElement=null;this._visible=false;this._hideTimeout=null};PhArt.UI.WebControls.UpdateProgress.prototype={initialize:function(){PhArt.UI.WebControls.UpdateProgress.callBaseMethod(this,'initialize');PhArt.UI.WebControls.UpdateProgress.__InstanceId=this._updateProgressId;this._windowResizeHandler=Function.createDelegate(this,this.move);$addHandler(window,'resize',this._windowResizeHandler);this._hideHandler=Function.createDelegate(this,this.hide)},dispose:function(){PhArt.UI.WebControls.UpdateProgress.callBaseMethod(this,'dispose')},pushBeginRequestMessage:function(postBackElement){try{if(postBackElement==PhArt.UI.WebControls.Communicator.getInstance().get_id()){postBackElement=PhArt.UI.WebControls.Communicator.getInstance().get_lastClient2ServerCommandSource()}}catch(e){}this._lastPostBackElement=postBackElement;this.pushMessage(postBackElement,"In progress")},pushEndRequestMessage:function(aborted){var postBackElement=this._lastPostBackElement;var type=aborted?"Cancelled":"Completed";this.pushMessage(postBackElement,type)},pushMessage:function(postBackElement,type){if(this._messages.length>0&&this._messages[this._messages.length-1][0]==postBackElement&&this._messages[this._messages.length-1][1]==type){return false}var message=typeof(this._messageDictionary[postBackElement])==='undefined'?"Loading...":this._messageDictionary[postBackElement];this._messages.push(eval("(['"+postBackElement+"','"+type+"','"+message+"'])"))},add_messageDictionary:function(){for(var i=0;i<arguments.length;i+=2){var postBackElement=arguments[i];var message=arguments[i+1];if(typeof(this._messageDictionary[postBackElement])==='undefined'){this._messageDictionary.push(postBackElement);this._messageDictionary[postBackElement]=message}else{this._messageDictionary[postBackElement]=message}}},getColor:function(type){if(type=="In progress")return"#ffc425";else if(type=="Completed")return"#c1d72f";else return"#ed1c24"},loadMessage:function(){var msg1_type="",msg1_body="",msg2_type="",msg2_body="";if(this._messages.length>=2){msg1_type=this._messages[this._messages.length-2][1];msg1_body=this._messages[this._messages.length-2][2]}if(this._messages.length>=1){msg2_type=this._messages[this._messages.length-1][1];msg2_body=this._messages[this._messages.length-1][2]}var msgHTML="";if(msg1_type!=""){msgHTML+="<tr style=\"color: "+this.getColor(msg1_type)+"\"><td align=left>"+msg1_type+":</td><td align=left style=\"padding-left: 10px\">"+msg1_body+"</td></tr>"}if(msg2_type!=""){msgHTML+="<tr style=\"color: "+this.getColor(msg2_type)+"\"><td align=left>"+msg2_type+":</td><td align=left style=\"padding-left: 10px\">"+msg2_body+"</td></tr>"}if(msgHTML!=""){msgHTML="<table border=0 cellpadding=1 cellspacing=1>"+msgHTML+"</table>"}$get(this._divMsgId).innerHTML=msgHTML},move:function(){if(this._visible){$get(this._updateProgressId).style.visibility="hidden";$get(this._updateProgressId).style.display="inline";var winWidth,winHeight;if(typeof(window.innerWidth)==='number'){winWidth=window.innerWidth;winHeight=window.innerHeight}else{winWidth=document.documentElement.clientWidth;winHeight=document.documentElement.clientHeight}var top=winHeight-$get(this._updateProgressId).offsetHeight;var left=winWidth-$get(this._updateProgressId).offsetWidth;$get(this._updateProgressId).style.top=top+"px";$get(this._updateProgressId).style.left=left+"px";$get(this._updateProgressId).style.visibility="visible"}},show:function(){if(this._hideTimeout!=null)clearTimeout(this._hideTimeout);this.loadMessage();this._visible=true;this.move()},hide_delay:function(){if(this._hideTimeout!=null)clearTimeout(this._hideTimeout);this.loadMessage();this._hideTimeout=setTimeout(this._hideHandler,100)},hide:function(){this._visible=false;$get(this._updateProgressId).style.display="none"},get_updateProgressId:function(){return this._updateProgressId},set_updateProgressId:function(value){if(this._updateProgressId!==value){this._updateProgressId=value;this.raisePropertyChanged('updateProgressId')}},get_divMsgId:function(){return this._divMsgId},set_divMsgId:function(value){if(this._divMsgId!==value){this._divMsgId=value;this.raisePropertyChanged('divMsgId')}}};PhArt.UI.WebControls.UpdateProgress.getInstance=function(){return $find(PhArt.UI.WebControls.UpdateProgress.__InstanceId)};PhArt.UI.WebControls.UpdateProgress.__InstanceId=null;PhArt.UI.WebControls.UpdateProgress.beginRequest=function(sender,args){try{PhArt.UI.WebControls.UpdateProgress.getInstance().pushBeginRequestMessage(args.get_postBackElement().id);PhArt.UI.WebControls.UpdateProgress.getInstance().show()}catch(e){}};PhArt.UI.WebControls.UpdateProgress.endRequest=function(sender,args){try{PhArt.UI.WebControls.UpdateProgress.getInstance().pushEndRequestMessage(args.get_response().get_aborted());PhArt.UI.WebControls.UpdateProgress.getInstance().hide_delay()}catch(e){}};PhArt.UI.WebControls.UpdateProgress.registerClass('PhArt.UI.WebControls.UpdateProgress',Sys.UI.Control);if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();