cambrient.UserMessaging=function(){var MESSAGE_BAR_HEIGHT=40;var MESSAGE_BAR_BGCOLOR='ffff00';var self;var mb;var messageQueue=new Array();var messageBarOpen=false;var tOpen,tClose;function constructorFn(){self=this;registerOnLoad(self.init);} constructorFn.prototype.init=function(){mb=$('message_bar');if(mb){mb.style.display='none';mb.style.visibility='hidden';mb.style.zIndex=1000;mb.onclick=function(evt){self.closeBar();} tOpen=new Tween(mb.style,'height',Tween.strongEaseOut,0,40,1,'px');tOpen.onMotionFinished=function(){var tFade=new ColorTween(mb.style,'backgroundColor',Tween.bounceEaseOut,'ffffff',MESSAGE_BAR_BGCOLOR,3);tFade.start();} tClose=new Tween(mb.style,'height',Tween.strongEaseOut,MESSAGE_BAR_HEIGHT,0,1,'px');tClose.onMotionFinished=function(){mb.style.display='none';mb.style.visibility='hidden';}} self.processMessageQueue();} constructorFn.prototype.processMessageQueue=function(){if(!messageBarOpen){if(messageQueue.length>0){var msg=messageQueue.shift();if(mb){if(msg.type=='error'){MESSAGE_BAR_BGCOLOR='ff0000';}else{MESSAGE_BAR_BGCOLOR='ffff00';} tOpen.onMotionFinished=function(){var tFade=new ColorTween(mb.style,'backgroundColor',Tween.bounceEaseOut,'ffffff',MESSAGE_BAR_BGCOLOR,3);tFade.start();} mb.innerHTML=msg.message;self.openBar();}else{if(window.console){console.log("UNHANDLED MESSAGING "+msg.message);}}}} setTimeout(self.processMessageQueue,1000);} constructorFn.prototype.closeBar=function(){tOpen.stop();messageBarOpen=false;tClose.start();} constructorFn.prototype.openBar=function(){tClose.stop();messageBarOpen=true;mb.style.backgroundColor=MESSAGE_BAR_BGCOLOR;mb.style.height=0;mb.style.display='block';mb.style.visibility='visible';tOpen.start();} constructorFn.prototype.addMessage=function(msg){var hasMsg=false;messageQueue.each(function(item){if(item.message!=null&&item.message==msg.message){hasMsg=true;}});if(!hasMsg){messageQueue.push(msg);}} constructorFn.prototype.info=function(msg){self.addMessage({"message":msg,"type":"info"});} constructorFn.prototype.error=function(msg){self.addMessage({"message":msg,"type":"error"});} constructorFn.prototype.warning=function(msg){self.addMessage({"message":msg,"type":"warning"});} constructorFn.prototype.confirm=function(msg){console.log('ERROR: '+msg);self.addMessage({"message":msg,"type":"confirm"});} constructorFn.prototype.debug=function(msg){self.addMessage({"message":msg,"type":"debug"});} constructorFn.prototype.test=function(){cambrient.userMessaging.info("Hello world!");cambrient.userMessaging.info("Hello world!");cambrient.userMessaging.info("Hello world!");cambrient.userMessaging.error("ERROR: There was an unknown error trying to parse the error for display. Just kidding!");cambrient.userMessaging.info("Hello world 2!");cambrient.userMessaging.info("Hello world 2!");cambrient.userMessaging.info("Hello world 2!");} return new constructorFn();} cambrient.userMessaging=new cambrient.UserMessaging();