From ba6d44464eb23053035e26af8d25d3966fe52327 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 10 Feb 2011 20:37:22 +0100 Subject: [PATCH] added cancel button to login window --- .../main/webapp/resources/js/sonia.global.js | 21 ++++++++++++++++++ .../main/webapp/resources/js/sonia.login.js | 22 +++++++++++++++---- .../src/main/webapp/resources/js/sonia.scm.js | 20 +---------------- 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.global.js b/scm-webapp/src/main/webapp/resources/js/sonia.global.js index f2dd7034da..942e164a43 100644 --- a/scm-webapp/src/main/webapp/resources/js/sonia.global.js +++ b/scm-webapp/src/main/webapp/resources/js/sonia.global.js @@ -71,6 +71,27 @@ function clearState(){ Ext.getCmp('navigationPanel').removeAll(); } +function checkLogin(){ + Ext.Ajax.request({ + url: restUrl + 'authentication.json', + method: 'GET', + success: function(response){ + if ( debug ){ + console.debug('login success'); + } + var s = Ext.decode(response.responseText); + loadState(s); + }, + failure: function(){ + if ( debug ){ + console.debug('login failed'); + } + var loginWin = new Sonia.login.Window(); + loginWin.show(); + } + }); +} + function login(){ clearState(); var loginWin = new Sonia.login.Window(); diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.login.js b/scm-webapp/src/main/webapp/resources/js/sonia.login.js index 3817d2e2a7..086d55027b 100644 --- a/scm-webapp/src/main/webapp/resources/js/sonia.login.js +++ b/scm-webapp/src/main/webapp/resources/js/sonia.login.js @@ -71,17 +71,28 @@ Sonia.login.Form = Ext.extend(Ext.FormPanel,{ } }], buttons:[{ - text: 'Login', - formBind: true, - scope: this, - handler: this.authenticate + text: 'Cancel', + scope: this, + handler: this.cancel + },{ + text: 'Login', + formBind: true, + scope: this, + handler: this.authenticate }] }; + this.addEvents('cancel'); + Ext.apply(this, Ext.apply(this.initialConfig, config)); Sonia.login.Form.superclass.initComponent.apply(this, arguments); }, + cancel: function(){ + this.fireEvent('cancel'); + checkLogin(); + }, + authenticate: function(){ var form = this.getForm(); form.submit({ @@ -127,6 +138,9 @@ Sonia.login.Window = Ext.extend(Ext.Window,{ this.fireEvent('success'); this.close(); }, this); + form.on('cancel', function(){ + this.close(); + }, this); var config = { layout:'fit', diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.scm.js b/scm-webapp/src/main/webapp/resources/js/sonia.scm.js index 8b682f2e86..7a2037a30a 100644 --- a/scm-webapp/src/main/webapp/resources/js/sonia.scm.js +++ b/scm-webapp/src/main/webapp/resources/js/sonia.scm.js @@ -70,25 +70,7 @@ Ext.onReady(function(){ ] }); - // check login - Ext.Ajax.request({ - url: restUrl + 'authentication.json', - method: 'GET', - success: function(response){ - if ( debug ){ - console.debug('login success'); - } - var s = Ext.decode(response.responseText); - loadState(s); - }, - failure: function(){ - if ( debug ){ - console.debug('login failed'); - } - var loginWin = new Sonia.login.Window(); - loginWin.show(); - } - }); + checkLogin(); // adds a tab to main TabPanel function addTabPanel(id, xtype, title){