fix bug in adding torrent from file

This commit is contained in:
Damien Churchill 2008-11-13 22:14:14 +00:00
parent 06231c1799
commit af85f56b98
3 changed files with 13 additions and 13 deletions

View File

@ -112,8 +112,14 @@ Deluge.Widgets.AddTorrent.File = new Class({
onCancel: this.onCancel.bindWithEvent(this),
onSubmit: this.onSubmit.bindWithEvent(this),
onComplete: this.onComplete.bindWithEvent(this),
onBeforeShow: this.onBeforeShow.bindWithEvent(this),
onGetInfoSuccess: this.onGetInfoSuccess.bindWithEvent(this)
};
this.addEvent('beforeShow', this.bound.onBeforeShow);
},
onBeforeShow: function(e) {
if (this.iframe) this.iframe.destroy();
this.iframe = new Element('iframe', {
src: '/template/render/html/window_add_torrent_file.html',
height: 65,
@ -123,19 +129,19 @@ Deluge.Widgets.AddTorrent.File = new Class({
overflow: 'hidden'
}
});
this.iframe.addEvent('load', this.bound.onLoad);
this.content.grab(this.iframe);
this.iframe.addEvent('load', this.bound.onLoad);
},
onLoad: function(e) {
this.iframe.set('opacity', 1);
var body = $(this.iframe.contentDocument.body);
var form = body.getElement('form');
this.cancelButton = form.getElement('button.cancel');
this.cancelButton.addEvent('click', this.bound.onCancel);
var cancelButton = form.getElement('button.cancel');
cancelButton.addEvent('click', this.bound.onCancel);
var fileInputs = form.getElement('div.fileInputs');
var fileInput = fileInputs.getElement('input');
fileInput.set('opacity', 0.000001);
var fakeFile = fileInputs.getElement('div').getElement('input');
fileInput.addEvent('change', function(e) {
@ -157,6 +163,7 @@ Deluge.Widgets.AddTorrent.File = new Class({
onComplete: function(e) {
filename = $(this.iframe.contentDocument.body).get('text');
this.hide();
Deluge.Client.get_torrent_info(filename, {
onSuccess: this.bound.onGetInfoSuccess
});
@ -164,10 +171,6 @@ Deluge.Widgets.AddTorrent.File = new Class({
onGetInfoSuccess: function(info) {
if (info) this.fireEvent('torrentAdded', info);
this.hide();
this.iframe.removeEvent('load', this.bound.onComplete);
this.iframe.addEvent('load', this.bound.onLoad);
this.iframe.src = '/template/render/html/window_add_torrent_file.html';
}
});

View File

@ -37,9 +37,6 @@ form input.file {
top: 0px;
left: 0px;
text-align: left;
-moz-opacity: 0;
opacity: 0;
filter: alpha(opacity: 0);
z-index: 2;
}

View File

@ -343,7 +343,7 @@ label.fluid {
}
#addTorrent #addButtons {
width: 240px;
width: 250px;
margin: 0 auto;
}