Ext.namespace('Gframe'); Gframe.app = function() { // public space return { conn: null, session_check: true, login_window: null, // public methods init: function() { if (this.app.session_check == true) { Ext.Ajax.on('requestcomplete', Gframe.app.checkSession); } }, checkSession: function(c, r, o) { if (r.responseText[0] == '{') { var o = eval("("+r.responseText+")"); if (o) { if (o.security && !o.logged_in) { conn = c; //Gframe.app.login(); window.location.href = 'http://www.hcarknowledgemesh.com'; } } } }, login: function() { login_window = new Ext.Window({ id: 'login_window', title: 'Login', modal: true, width: 250, closable: false, resizable: false, draggable: false, bodyStyle: 'background-color: #FFF;' }); function send_login(){ account_login_element.getForm().submit({ url: 'http://www.hcarknowledgemesh.com/index.php/json/Account/login', waitMsg: 'Sending...', success: function(form, action){ if (action.result.message) { alert(action.result.message); } else { Ext.getCmp('login_window').close(); } }, failure: function(form, action){ Ext.Msg.show({ title: 'Error', msg: 'Unknown email address or incorrect password', buttons: Ext.Msg.OK, animEl: 'account_login_element_bttn' }); } }); }; var account_login_element = new Ext.FormPanel({ id: 'account_login_element_extjs', frame: false, border: false, labelWidth: 55, bodyStyle: 'padding: 10px;', collapsible: false, autoHeight: true, defaults: {width: 120}, defaultType: 'textfield', items: [{ name: 'username', fieldLabel: 'Email', allowBlank: false, vtype: 'email' },{ name: 'password', fieldLabel: 'Password', allowBlank: false, inputType: 'password' }], buttonAlign: 'center', buttons: [{ text: 'Log-in', id: 'account_login_element_bttn', handler: send_login }] }); login_window.add(account_login_element); login_window.show(); } } }();