From 4e5e98d90b992ecfedd46254c69164a238ae8e91 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Fri, 20 Feb 2009 23:58:18 +0000 Subject: [PATCH] add a helper methods to torrents trigger an update immediately when the torrent is changed in the grid --- deluge/ui/web/js/deluge-details.js | 87 ++++++++++++++++------------- deluge/ui/web/js/deluge-torrents.js | 4 ++ 2 files changed, 51 insertions(+), 40 deletions(-) diff --git a/deluge/ui/web/js/deluge-details.js b/deluge/ui/web/js/deluge-details.js index 3f6c83503..373169bc3 100644 --- a/deluge/ui/web/js/deluge-details.js +++ b/deluge/ui/web/js/deluge-details.js @@ -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, { initComponent: function() { @@ -102,43 +121,31 @@ Deluge.Details.Details = { } } -$extend(Deluge.Details, { - - update: function() { - var torrent = Deluge.Torrents.getSelected(); - if (!torrent) return; - - var tab = this.Panel.getActiveTab(); - if (tab.update) { - tab.update(torrent.id); - } - }, - - Panel: new Ext.TabPanel({ - region: 'south', - split: true, - height: 200, - minSize: 100, - collapsible: true, - margins: '0 5 5 5', - activeTab: 0, - items: [{ - id: 'status', - title: _('Status'), - listeners: {'render': {fn: Deluge.Details.Status.onRender, scope: Deluge.Details.Status}} - },{ - id: 'details', - title: _('Details'), - listeners: {'render': {fn: Deluge.Details.Details.onRender, scope: Deluge.Details.Status}} - },{ - id: 'files', - title: _('Files') - },{ - id: 'peers', - title: _('Peers') - },{ - id: 'options', - title: _('Options') - }] - }) +Deluge.Details.Panel = new Ext.TabPanel({ + region: 'south', + split: true, + height: 200, + minSize: 100, + collapsible: true, + margins: '0 5 5 5', + activeTab: 0, + items: [{ + id: 'status', + title: _('Status'), + listeners: {'render': {fn: Deluge.Details.Status.onRender, scope: Deluge.Details.Status}} + },{ + id: 'details', + title: _('Details'), + listeners: {'render': {fn: Deluge.Details.Details.onRender, scope: Deluge.Details.Status}} + },{ + id: 'files', + title: _('Files') + },{ + id: 'peers', + title: _('Peers') + },{ + id: 'options', + title: _('Options') + }], + listeners: {'render': {fn: Deluge.Details.onRender, scope: Deluge.Details}} }); \ No newline at end of file diff --git a/deluge/ui/web/js/deluge-torrents.js b/deluge/ui/web/js/deluge-torrents.js index a7f7d2e7c..052c0d9bf 100644 --- a/deluge/ui/web/js/deluge-torrents.js +++ b/deluge/ui/web/js/deluge-torrents.js @@ -43,6 +43,10 @@ Deluge.Torrents = { id: 14 }), + getTorrent: function(rowIndex) { + return this.Grid.store.getAt(rowIndex); + }, + getSelected: function() { return this.Grid.getSelectionModel().getSelected(); },