improve the page switching

This commit is contained in:
Damien Churchill 2010-04-27 22:05:15 +01:00
commit e0e2b1b350

View file

@ -160,6 +160,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
page['bodyStyle'] = 'padding: 5px'; page['bodyStyle'] = 'padding: 5px';
page.preferences = this; page.preferences = this;
this.pages[name] = this.configPanel.add(page); this.pages[name] = this.configPanel.add(page);
this.pages[name].index = -1;
return this.pages[name]; return this.pages[name];
}, },
@ -180,8 +181,18 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
* @param {String} page The page name to change to * @param {String} page The page name to change to
*/ */
selectPage: function(page) { selectPage: function(page) {
var index = this.configPanel.items.indexOf(this.pages[page]); if (this.pages[page].index < 0) {
this.configPanel.getLayout().setActiveItem(index); this.pages[page].index = this.configPanel.items.indexOf(this.pages[page]);
}
this.list.select(this.pages[page].index);
},
// private
doSelectPage: function(page) {
if (this.pages[page].index < 0) {
this.pages[page].index = this.configPanel.items.indexOf(this.pages[page]);
}
this.configPanel.getLayout().setActiveItem(this.pages[page].index);
this.currentPage = page; this.currentPage = page;
}, },
@ -193,7 +204,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
// private // private
onPageSelect: function(list, selections) { onPageSelect: function(list, selections) {
var r = list.getRecord(selections[0]); var r = list.getRecord(selections[0]);
this.selectPage(r.get('name')); this.doSelectPage(r.get('name'));
}, },
// private // private