From 52485af4f7b5b541705057714279ed296b32a263 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Wed, 7 Jan 2009 19:06:28 +0000 Subject: [PATCH] Allow torrents to be removed from the add torrent window --- .../ui/webui/templates/ajax/static/js/deluge-add.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/deluge/ui/webui/templates/ajax/static/js/deluge-add.js b/deluge/ui/webui/templates/ajax/static/js/deluge-add.js index 3d0b9527a..2c06d3fda 100644 --- a/deluge/ui/webui/templates/ajax/static/js/deluge-add.js +++ b/deluge/ui/webui/templates/ajax/static/js/deluge-add.js @@ -25,6 +25,7 @@ Deluge.Widgets.AddWindow = new Class({ onAdd: this.onAdd.bindWithEvent(this), onShow: this.onShow.bindWithEvent(this), onCancel: this.onCancel.bindWithEvent(this), + onRemoveClick: this.onRemoveClick.bindWithEvent(this), onTorrentAdded: this.onTorrentAdded.bindWithEvent(this), onTorrentChanged: this.onTorrentChanged.bindWithEvent(this) } @@ -57,6 +58,9 @@ Deluge.Widgets.AddWindow = new Class({ this.urlWindow.show(); }.bindWithEvent(this)); + this.removeButton = this.content.getElement('button.remove'); + this.removeButton.addEvent('click', this.bound.onRemoveClick); + this.content.getElement('button.add').addEvent('click', this.bound.onAdd); this.content.getElement('button.cancel').addEvent('click', this.bound.onCancel); }, @@ -96,6 +100,12 @@ Deluge.Widgets.AddWindow = new Class({ this.torrents.empty(); this.torrentInfo.empty(); this.filesTab.table.empty(); + }, + + onRemoveClick: function(e) { + delete this.torrentInfo[this.torrents.value]; + this.torrents.options[this.torrents.selectedIndex].dispose(); + this.filesTab.setTorrent(null); } }); @@ -263,6 +273,7 @@ Deluge.Widgets.AddTorrent.FilesTab = new Class({ setTorrent: function(torrent) { this.table.empty(); + if (!torrent) return; $each(torrent['files'], function(file) { row = new Element('tr'); new Element('td').inject(row);