Improve settings window and cleanup

This commit is contained in:
Eike Foken
2011-05-06 12:33:43 +02:00
parent 90c27d82cd
commit 6a1ae19983
9 changed files with 299 additions and 272 deletions

View File

@@ -3,94 +3,109 @@
*
* @class SettingsWindow
* @extends Ext.Window
* @author Eike Foken <kontakt@eikefoken.de>
*/
SettingsWindow = Ext.extend(Ext.Window, {
title: lang['settings_window_title'],
id: 'settings-window',
width: 400,
autoHeight: true,
closeAction: 'hide',
draggable: false,
resizable: false,
modal: true,
initComponent: function() {
this.items = [{
xtype: 'form',
id: 'settings-form',
url: BASE_URL + 'auth/settings',
method: 'POST',
border: false,
items: [{
xtype: 'tabpanel',
border: false,
activeTab: 0,
defaults: {
layout: 'form',
defaultType: 'textfield',
labelWidth: 170,
autoHeight: true,
bodyStyle: 'padding: 10px'
},
items: [{
xtype: 'panel',
id: 'password',
title: lang['settings_window_panel_password'],
items: [{
fieldLabel: lang['settings_window_old_password'],
name: 'old_password'
}, {
fieldLabel: lang['settings_window_new_password'],
name: 'new_password'
}, {
fieldLabel: lang['settings_window_new_password_confirm'],
name: 'new_password_confirm'
}]
}, {
xtype: 'panel',
title: lang['settings_window_panel_profile'],
items: [{
fieldLabel: lang['settings_window_firstname'],
name: 'firstname'
}, {
fieldLabel: lang['settings_window_lastname'],
name: 'lastname'
}, {
fieldLabel: lang['settings_window_institution'],
name: 'institution'
}, {
fieldLabel: lang['settings_window_phone'],
name: 'phone'
}, {
fieldLabel: lang['settings_window_email'],
name: 'email'
}]
}]
}],
buttons: [{
text: lang['settings_window_save'],
handler: function() {
Ext.getCmp('settings-form').getForm().submit();
}
}, {
text: lang['settings_window_close'],
handler: function() {
this.hide();
}
}]
}];
title: lang['settings_window_title'],
id: 'settings-window',
width: 400,
closeAction: 'hide',
draggable: false,
resizable: false,
modal: true,
initComponent: function() {
this.items = [{
xtype: 'form',
id: 'settings-form',
url: BASE_URL + 'auth/settings',
method: 'post',
border: false,
items: [{
xtype: 'tabpanel',
border: false,
activeTab: 0,
defaults: {
layout: 'form',
defaultType: 'textfield',
labelWidth: 170,
height: 150,
bodyStyle: 'padding: 10px'
},
items: [{
xtype: 'panel',
title: lang['settings_window_panel_profile'],
items: [{
fieldLabel: lang['settings_window_firstname'],
name: 'firstname'
}, {
fieldLabel: lang['settings_window_lastname'],
name: 'lastname'
}, {
fieldLabel: lang['settings_window_institution'],
name: 'institution'
}, {
fieldLabel: lang['settings_window_phone'],
name: 'phone'
}, {
fieldLabel: lang['settings_window_email'],
name: 'email'
}]
}, {
xtype: 'panel',
id: 'password',
title: lang['settings_window_panel_password'],
items: [{
fieldLabel: lang['settings_window_old_password'],
name: 'old_password',
inputType: 'password'
}, {
fieldLabel: lang['settings_window_new_password'],
name: 'new_password',
inputType: 'password'
}, {
fieldLabel: lang['settings_window_new_password_confirm'],
name: 'new_password_confirm',
inputType: 'password'
}, {
xtype: 'displayfield',
value: lang['settings_window_password_note'],
hideLabel: true
}]
}]
}],
buttons: [{
text: lang['settings_window_save'],
handler: function() {
var theForm = Ext.getCmp('settings-form').getForm();
// call parent
SettingsWindow.superclass.initComponent.apply(this);
},
beforeShow: function() {
Ext.getCmp('settings-form').load({
url : BASE_URL + 'auth/settings',
waitMsg: "Lade..."
});
if (theForm.isValid()) {
theForm.submit({
success: function() {
Ext.getCmp('settings-window').hide();
}
});
}
}
}, {
text: lang['settings_window_cancel'],
handler: function() {
Ext.getCmp('settings-window').hide();
}
}]
}];
// call parent
SettingsWindow.superclass.beforeShow.apply(this);
}
// call parent
SettingsWindow.superclass.initComponent.apply(this);
},
beforeShow: function() {
Ext.getCmp('settings-form').load({
url : BASE_URL + 'auth/settings',
waitMsg: "Lade..."
});
// call parent
SettingsWindow.superclass.beforeShow.apply(this);
}
});
// register xtype to allow for lazy initialization