add a helper methods to torrents

trigger an update immediately when the torrent is changed in the grid
This commit is contained in:
Damien Churchill 2009-02-20 23:58:18 +00:00
commit 4e5e98d90b
2 changed files with 51 additions and 40 deletions

View file

@ -1,4 +1,23 @@
Deluge.Details = {} Deluge.Details = {
update: function() {
var torrent = Deluge.Torrents.getSelected();
if (!torrent) return;
var tab = this.Panel.getActiveTab();
if (tab.update) {
tab.update(torrent.id);
}
},
onRender: function(panel) {
Deluge.Torrents.Grid.on('rowclick', this.onTorrentsClick.bindWithEvent(this));
},
onTorrentsClick: function(grid, rowIndex, e) {
this.update();
}
}
Deluge.ProgressBar = Ext.extend(Ext.ProgressBar, { Deluge.ProgressBar = Ext.extend(Ext.ProgressBar, {
initComponent: function() { initComponent: function() {
@ -102,43 +121,31 @@ Deluge.Details.Details = {
} }
} }
$extend(Deluge.Details, { Deluge.Details.Panel = new Ext.TabPanel({
region: 'south',
update: function() { split: true,
var torrent = Deluge.Torrents.getSelected(); height: 200,
if (!torrent) return; minSize: 100,
collapsible: true,
var tab = this.Panel.getActiveTab(); margins: '0 5 5 5',
if (tab.update) { activeTab: 0,
tab.update(torrent.id); items: [{
} id: 'status',
}, title: _('Status'),
listeners: {'render': {fn: Deluge.Details.Status.onRender, scope: Deluge.Details.Status}}
Panel: new Ext.TabPanel({ },{
region: 'south', id: 'details',
split: true, title: _('Details'),
height: 200, listeners: {'render': {fn: Deluge.Details.Details.onRender, scope: Deluge.Details.Status}}
minSize: 100, },{
collapsible: true, id: 'files',
margins: '0 5 5 5', title: _('Files')
activeTab: 0, },{
items: [{ id: 'peers',
id: 'status', title: _('Peers')
title: _('Status'), },{
listeners: {'render': {fn: Deluge.Details.Status.onRender, scope: Deluge.Details.Status}} id: 'options',
},{ title: _('Options')
id: 'details', }],
title: _('Details'), listeners: {'render': {fn: Deluge.Details.onRender, scope: Deluge.Details}}
listeners: {'render': {fn: Deluge.Details.Details.onRender, scope: Deluge.Details.Status}}
},{
id: 'files',
title: _('Files')
},{
id: 'peers',
title: _('Peers')
},{
id: 'options',
title: _('Options')
}]
})
}); });

View file

@ -43,6 +43,10 @@ Deluge.Torrents = {
id: 14 id: 14
}), }),
getTorrent: function(rowIndex) {
return this.Grid.store.getAt(rowIndex);
},
getSelected: function() { getSelected: function() {
return this.Grid.getSelectionModel().getSelected(); return this.Grid.getSelectionModel().getSelected();
}, },