tie up the contents of the iframe with some javascript

This commit is contained in:
Damien Churchill 2008-11-10 18:37:21 +00:00
commit 5eb92ab9b7
2 changed files with 24 additions and 1 deletions

View file

@ -5,7 +5,7 @@
<body style="background: none;"> <body style="background: none;">
<form method="post" action="/json/upload" enctype="multipart/form-data"> <form method="post" action="/json/upload" enctype="multipart/form-data">
<label>$_('File'):</label><input type="file" name="torrentFile" /> <br/> <label>$_('File'):</label><input type="file" name="torrentFile" /> <br/>
<button>$_('Ok')</button><button>$_('Cancel')</button> <button class="ok">$_('Ok')</button><button class="cancel">$_('Cancel')</button>
</form> </form>
</body> </body>
</html> </html>

View file

@ -107,12 +107,35 @@ Deluge.Widgets.AddTorrent.File = new Class({
initialize: function() { initialize: function() {
this.parent(); this.parent();
this.bound = {
onLoad: this.onLoad.bindWithEvent(this),
onCancel: this.onCancel.bindWithEvent(this),
onSubmit: this.onSubmit.bindWithEvent(this)
};
this.iframe = new Element('iframe', { this.iframe = new Element('iframe', {
src: '/template/render/html/window_add_torrent_file.html', src: '/template/render/html/window_add_torrent_file.html',
height: 100, height: 100,
width: 300 width: 300
}); });
this.iframe.addEvent('load', this.bound.onLoad);
this.content.grab(this.iframe); this.content.grab(this.iframe);
},
onLoad: function(e) {
var body = $(this.iframe.contentDocument.body);
this.cancelButton = body.getElement('button.cancel');
this.cancelButton.addEvent('click', this.bound.onCancel);
var form = body.getElement('form');
form.addEvent('submit', this.bound.onSubmit);
},
onCancel: function(e) {
this.hide();
},
onSubmit: function(e) {
alert('form sent');
} }
}); });