roojs-all.js
authorAlan Knowles <alan@akbkhome.com>
Tue, 31 Aug 2010 07:34:14 +0000 (15:34 +0800)
committerAlan Knowles <alan@akbkhome.com>
Tue, 31 Aug 2010 07:34:14 +0000 (15:34 +0800)
roojs-all.js

index 7b799b7..cc1e058 100644 (file)
@@ -943,7 +943,7 @@ A.again=true;B.check.defer(10000,B,[A]);return;}
 this.sending=true;Roo.Ajax.request({url:this.url,params:{getAuthUser:true},method:this.method,success:A.success||this.success,failure:A.failure||this.failure,scope:this,callCfg:A});},logout:function(){window.onbeforeunload=function(){};this.user=false;var A=this;Roo.Ajax.request({url:this.url,params:{logout:1},method:'GET',failure:function(){Roo.MessageBox.alert("Error","Error logging out. - continuing anyway.",function(){document.location=document.location.toString()+'?ts='+Math.random();});},success:function(){A.user=false;this.checkFails=0;document.location=document.location.toString()+'?ts='+Math.random();}});},processResponse:function(A){var B='';try{B=Roo.decode(A.responseText);if(typeof(B)!='object'){B={success:false,errorMsg:B,errors:true};}if(typeof(B.success)=='undefined'){B.success=false;}}catch(e){res={success:false,errorMsg:response.responseText,errors:true};}return B;},success:function(A,B){this.sending=false;var C=this.processResponse(A);if(!C.success){return this.failure(A,B);}if(!C.data||!C.data.id){return this.failure(A,B);}
 this.fillAuth(C.data);this.checkFails=0;},failure:function(A,B){this.authUser=-1;this.sending=false;var C=this.processResponse(A);if(this.checkFails>2){Roo.MessageBox.alert("Error",C.errorMsg?C.errorMsg:"Error getting authentication status. - try reloading");return;}
 B.callCfg.again=true;this.check.defer(1000,this,[B.callCfg]);return;},fillAuth:function(au){this.startAuthCheck();this.authUserId=au.id;this.authUser=au;this.lastChecked=new Date();this.fireEvent('refreshed',au);au.lang=au.lang||'en';Roo.state.Manager.set(this.realm+'lang',au.lang);this.switchLang(au.lang);if(this.authUserId<0){Roo.MessageBox.alert("Warning","This is an open system - please set up a admin user with a password.");}},startAuthCheck:function(){if(this.intervalID){return false;}var A=this;this.intervalID=window.setInterval(function(){A.check(false);},120000);},switchLang:function(A){_T=typeof(_T)=='undefined'?false:_T;if(!_T||!A.length){return;}if(!_T&&A!='en'){Roo.MessageBox.alert("Sorry","Language not available yet ("+A+')');return;}if(typeof(_T.en)=='undefined'){_T.en={};Roo.apply(_T.en,_T);}if(typeof(_T[A])=='undefined'){Roo.MessageBox.alert("Sorry","Language not available yet ("+A+')');return;}
-Roo.apply(_T,_T[A]);var B=this;},title:"Login",modal:true,width:350,height:180,shadow:true,minWidth:200,minHeight:180,closable:false,draggable:false,collapsible:false,resizable:false,center:{autoScroll:false,titlebar:false,hideTabs:true,closeOnTab:true,alwaysShowTabs:false},listeners:{show:function(A){this.form=this.layout.getRegion('center').activePanel.form;this.form.dialog=A;this.buttons[0].form=this.form;this.buttons[0].dialog=Athis.buttons[1].form=this.form;this.buttons[1].dialog=A;if(this.disabled){this.hide();return;}if(this.user.id<0){return;}if(this.intervalID){window.clearInterval(this.intervalID);this.intervalID=false;}if(Roo.get('loading')){Roo.get('loading').remove();}if(Roo.get('loading-mask')){Roo.get('loading-mask').hide();}
+Roo.apply(_T,_T[A]);var B=this;},title:"Login",modal:true,width:350,height:180,shadow:true,minWidth:200,minHeight:180,closable:false,draggable:false,collapsible:false,resizable:false,center:{autoScroll:false,titlebar:false,hideTabs:true,closeOnTab:true,alwaysShowTabs:false},listeners:{show:function(A){this.form=this.layout.getRegion('center').activePanel.form;this.form.dialog=A;this.buttons[0].form=this.form;this.buttons[0].dialog=A;this.buttons[1].form=this.form;this.buttons[1].dialog=A;if(this.disabled){this.hide();return;}if(this.user.id<0){return;}if(this.intervalID){window.clearInterval(this.intervalID);this.intervalID=false;}if(Roo.get('loading')){Roo.get('loading').remove();}if(Roo.get('loading-mask')){Roo.get('loading-mask').hide();}
 this.form.reset();this.el.unmask();this.form.setValues({'username':Roo.state.Manager.get(this.realm+'.username',''),'lang':Roo.state.Manager.get(this.realm+'.lang','en')});this.switchLang(Roo.state.Manager.get(this.realm+'.lang','en'));if(this.form.findField('username').getValue().length>0){this.form.findField('password').focus();}else {this.form.findField('username').focus();}}},items:[{xtype:'ContentPanel',xns:Roo,region:'center',fitToFrame:true,items:[{xtype:'Form',xns:Roo.form,labelWidth:100,style:'margin: 10px;',listeners:{actionfailed:function(f,A){this.dialog.el.unmask();Roo.MessageBox.alert("Error",A.result.errorMsg?A.result.errorMsg:"Login failed - communication error - try again.");},actioncomplete:function(re,A){Roo.state.Manager.set(this.dialog.realm+'.username',this.findField('username').getValue());Roo.state.Manager.set(this.dialog.realm+'.lang',this.findField('lang').getValue());this.dialog.fillAuth(A.result.data);this.dialog.hide();if(Roo.get('loading-mask')){Roo.get('loading-mask').show();}
 Roo.XComponent.build();}},items:[{xtype:'TextField',xns:Roo.form,fieldLabel:"Email Address",name:'username',width:200,autoCreate:{tag:"input",type:"text",size:"20"}},{xtype:'TextField',xns:Roo.form,fieldLabel:"Password",inputType:'password',name:'password',width:200,autoCreate:{tag:"input",type:"text",size:"20"},listeners:{specialkey:function(e,ev){if(ev.keyCode==13){this.form.dialog.el.mask("Logging in");this.form.doAction('submit',{url:this.form.dialog.url,method:this.form.dialog.method});}}}},{xtype:'ComboBox',xns:Roo.form,fieldLabel:"Language",name:'langdisp',store:{xtype:'SimpleStore',fields:['lang','ldisp'],data:[['en','English'],['zh_HK','\u7E41\u4E2D'],['zh_CN','\u7C21\u4E2D']]},valueField:'lang',hiddenName:'lang',width:200,displayField:'ldisp',typeAhead:false,editable:false,mode:'local',triggerAction:'all',emptyText:'Select a Language...',selectOnFocus:true,listeners:{select:function(cb,A,ix){this.form.switchLang(A.data.lang);}}}]}]}],buttons:[{xtype:'Button',xns:'Roo',text:"Forgot Password",listeners:{click:function(){var n=this.form.findField('username').getValue();if(!n.length){Roo.MessageBox.alert("Error","Fill in your email address");return;}
 Roo.Ajax.request({url:this.dialog.url,params:{passwordRequest:n},method:this.dialog.method,success:function(A,B){var C=this.dialog.processResponse(A);if(!C.success){Roo.MessageBox.alert("Error",C.errorMsg?C.errorMsg:"Problem Requesting Password Reset");return;}