Allow torrents to be removed from the add torrent window

This commit is contained in:
Damien Churchill 2009-01-07 19:06:28 +00:00
parent c48707a654
commit 52485af4f7
1 changed files with 11 additions and 0 deletions

View File

@ -25,6 +25,7 @@ Deluge.Widgets.AddWindow = new Class({
onAdd: this.onAdd.bindWithEvent(this), onAdd: this.onAdd.bindWithEvent(this),
onShow: this.onShow.bindWithEvent(this), onShow: this.onShow.bindWithEvent(this),
onCancel: this.onCancel.bindWithEvent(this), onCancel: this.onCancel.bindWithEvent(this),
onRemoveClick: this.onRemoveClick.bindWithEvent(this),
onTorrentAdded: this.onTorrentAdded.bindWithEvent(this), onTorrentAdded: this.onTorrentAdded.bindWithEvent(this),
onTorrentChanged: this.onTorrentChanged.bindWithEvent(this) onTorrentChanged: this.onTorrentChanged.bindWithEvent(this)
} }
@ -57,6 +58,9 @@ Deluge.Widgets.AddWindow = new Class({
this.urlWindow.show(); this.urlWindow.show();
}.bindWithEvent(this)); }.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.add').addEvent('click', this.bound.onAdd);
this.content.getElement('button.cancel').addEvent('click', this.bound.onCancel); this.content.getElement('button.cancel').addEvent('click', this.bound.onCancel);
}, },
@ -96,6 +100,12 @@ Deluge.Widgets.AddWindow = new Class({
this.torrents.empty(); this.torrents.empty();
this.torrentInfo.empty(); this.torrentInfo.empty();
this.filesTab.table.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) { setTorrent: function(torrent) {
this.table.empty(); this.table.empty();
if (!torrent) return;
$each(torrent['files'], function(file) { $each(torrent['files'], function(file) {
row = new Element('tr'); row = new Element('tr');
new Element('td').inject(row); new Element('td').inject(row);