From c6ed7e297b71277752ad3faa1bf6d81cca4939cd Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Tue, 14 Oct 2008 00:59:08 +0000 Subject: [PATCH] almost fixes the bug where if you apply a filter, whichever torrent was selected before continues to be displayed in the tabs --- .../ajax/render/html/tab_options.html | 4 +- .../ajax/static/js/deluge-details.js | 41 +++++++++++++++++-- .../ajax/static/js/deluge-torrent-grid.js | 3 ++ 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/deluge/ui/webui/templates/ajax/render/html/tab_options.html b/deluge/ui/webui/templates/ajax/render/html/tab_options.html index f4a14c0c4..1e69b4e85 100644 --- a/deluge/ui/webui/templates/ajax/render/html/tab_options.html +++ b/deluge/ui/webui/templates/ajax/render/html/tab_options.html @@ -19,8 +19,8 @@


- -
+ +

diff --git a/deluge/ui/webui/templates/ajax/static/js/deluge-details.js b/deluge/ui/webui/templates/ajax/static/js/deluge-details.js index f7a3dd579..28c2db2aa 100644 --- a/deluge/ui/webui/templates/ajax/static/js/deluge-details.js +++ b/deluge/ui/webui/templates/ajax/static/js/deluge-details.js @@ -46,9 +46,18 @@ Deluge.Widgets.Details = new Class({ 4: Deluge.Keys.Options }, + clear: function() { + this.pages.each(function(page) { + if (page.clear) page.clear(); + }); + }, + update: function(torrentId) { this.torrentId = torrentId; - if (!this.torrentId) return; + if (!this.torrentId) { + this.clear(); + return; + }; var keys = this.keys[this.currentPage], page = this.pages[this.currentPage]; Deluge.Client.get_torrent_status(torrentId, keys, { onSuccess: function(torrent) { @@ -95,6 +104,13 @@ Deluge.Widgets.StatisticsPage = new Class({ this.bar.set('width', this.getWidth() - 12); }, + clear: function() { + this.bar.update('', 0); + this.element.getElements('dd').each(function(item) { + item.set('text', ''); + }, this); + }, + update: function(torrent) { var data = { downloaded: torrent.total_done.toBytes()+' ('+torrent.total_payload_download.toBytes()+')', @@ -136,6 +152,12 @@ Deluge.Widgets.DetailsPage = new Class({ this.parent('Details'); }, + clear: function() { + this.element.getElements('dd').each(function(item) { + item.set('text', ''); + }, this); + }, + update: function(torrent) { var data = { torrent_name: torrent.name, @@ -266,6 +288,10 @@ Deluge.Widgets.FilesPage = new Class({ }; }, + clear: function() { + this.grid.clear(); + }, + resized: function(e) { if (!this.grid) { this.beenResized = e; @@ -335,6 +361,11 @@ Deluge.Widgets.PeersPage = new Class({ }); }, + clear: function() { + this.grid.rows.empty(); + this.grid.body.empty(); + }, + update: function(torrent) { if (this.torrentId != torrent.id) { this.torrentId = torrent.id; @@ -458,8 +489,8 @@ Deluge.Widgets.OptionsPage = new Class({ } }); - this.form.apply.addEvent('click', this.bound.apply); - this.form.reset.addEvent('click', this.bound.reset); + this.form.apply_options.addEvent('click', this.bound.apply); + this.form.reset_options.addEvent('click', this.bound.reset); }, apply: function(event) { @@ -476,6 +507,10 @@ Deluge.Widgets.OptionsPage = new Class({ }); }, + clear: function() { + //if (this.form && this.form.reset) this.form.reset(); + }, + reset: function(event) { if (this.torrentId) { delete this.changed[this.torrentId]; diff --git a/deluge/ui/webui/templates/ajax/static/js/deluge-torrent-grid.js b/deluge/ui/webui/templates/ajax/static/js/deluge-torrent-grid.js index 116cc20ca..0925793b1 100644 --- a/deluge/ui/webui/templates/ajax/static/js/deluge-torrent-grid.js +++ b/deluge/ui/webui/templates/ajax/static/js/deluge-torrent-grid.js @@ -79,6 +79,9 @@ Deluge.Widgets.TorrentGrid = new Class({ }, this); this.rows.each(function(row) { if (!torrents.has(row.id)) { + if (this.selectedRow && this.selectedRow.id == row.id) { + this.deselectRow(row); + }; delete this.rows[this.rows.indexOf(row)]; }; }, this);