From af85f56b98c2eed28e70cd114b76d448ce2e9bf2 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Thu, 13 Nov 2008 22:14:14 +0000 Subject: [PATCH] fix bug in adding torrent from file --- .../templates/ajax/static/js/deluge-add.js | 21 +++++++++++-------- .../ajax/static/themes/classic/iframe.css | 3 --- .../ajax/static/themes/classic/style.css | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) 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 0ca265f5b..f1327c6a0 100644 --- a/deluge/ui/webui/templates/ajax/static/js/deluge-add.js +++ b/deluge/ui/webui/templates/ajax/static/js/deluge-add.js @@ -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,17 +163,14 @@ 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 }); }, 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'; + if (info) this.fireEvent('torrentAdded', info); } }); diff --git a/deluge/ui/webui/templates/ajax/static/themes/classic/iframe.css b/deluge/ui/webui/templates/ajax/static/themes/classic/iframe.css index 9360f1a11..81863ba73 100644 --- a/deluge/ui/webui/templates/ajax/static/themes/classic/iframe.css +++ b/deluge/ui/webui/templates/ajax/static/themes/classic/iframe.css @@ -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; } diff --git a/deluge/ui/webui/templates/ajax/static/themes/classic/style.css b/deluge/ui/webui/templates/ajax/static/themes/classic/style.css index edccb2b00..317bce829 100644 --- a/deluge/ui/webui/templates/ajax/static/themes/classic/style.css +++ b/deluge/ui/webui/templates/ajax/static/themes/classic/style.css @@ -343,7 +343,7 @@ label.fluid { } #addTorrent #addButtons { - width: 240px; + width: 250px; margin: 0 auto; }