new mooui with a "beforeShow" event in the window class

make use of this new event in the preferences window to get the values before the window is shown
This commit is contained in:
Damien Churchill 2008-08-10 21:32:27 +00:00
parent 75936dd1ab
commit 7ddee092e0
2 changed files with 15 additions and 14 deletions

View File

@ -840,7 +840,7 @@ Deluge.Widgets.PreferencesWindow = new Class({
this.categories = []; this.categories = [];
this.currentPage = -1; this.currentPage = -1;
this.addEvent('loaded', this.loaded.bindWithEvent(this)); this.addEvent('loaded', this.loaded.bindWithEvent(this));
this.addEvent('show', this.shown.bindWithEvent(this)); this.addEvent('beforeShow', this.beforeShown.bindWithEvent(this));
}, },
loaded: function(event) { loaded: function(event) {
@ -921,8 +921,8 @@ Deluge.Widgets.PreferencesWindow = new Class({
}); });
this.webui.apply(); this.webui.apply();
}, },
shown: function(event) { beforeShown: function(event) {
// we want this to be blocking // we want this to be blocking
var config = Deluge.Client.get_config({async: false}); var config = Deluge.Client.get_config({async: false});

View File

@ -1021,7 +1021,7 @@ Widgets.Window = new Class({
width: this.options.width, width: this.options.width,
height: this.options.height height: this.options.height
}); });
this.element.setStyle('opacity', 0) this.element.setStyle('opacity', 0);
this.title = new Element('h3').addClass('mooui-window-title'); this.title = new Element('h3').addClass('mooui-window-title');
this.element.grab(this.title); this.element.grab(this.title);
this.title.set('text', this.options.title); this.title.set('text', this.options.title);
@ -1033,8 +1033,8 @@ Widgets.Window = new Class({
this.close = new Element('div').addClass('mooui-window-close'); this.close = new Element('div').addClass('mooui-window-close');
this.close.inject(this.element); this.close.inject(this.element);
this.close.addEvent('click', function(e) { this.close.addEvent('click', function(e) {
this.hide() this.hide();
}.bindWithEvent(this)) }.bindWithEvent(this));
this.content = new Element('div').addClass('mooui-window-content'); this.content = new Element('div').addClass('mooui-window-content');
this.content.inject(this.element); this.content.inject(this.element);
@ -1044,22 +1044,23 @@ Widgets.Window = new Class({
url: this.options.url, url: this.options.url,
update: this.content, update: this.content,
onSuccess: function(e) { onSuccess: function(e) {
this.fireEvent('loaded') this.fireEvent('loaded');
}.bindWithEvent(this) }.bindWithEvent(this)
}).get() }).get();
} }
}, },
show: function() { show: function() {
var size = document.body.getInnerSize() this.fireEvent('beforeShow');
var left = (size.x - this.options.width) / 2, top = (size.y - this.options.height) / 2 var size = document.body.getInnerSize();
var left = (size.x - this.options.width) / 2, top = (size.y - this.options.height) / 2;
this.sets({ this.sets({
left: left, left: left,
top: top top: top
}) });
document.body.grab(this.element) document.body.grab(this.element);
this.element.setStyle('opacity', 1) this.element.setStyle('opacity', 1);
this.fireEvent('show') this.fireEvent('show');
}, },
hide: function() { hide: function() {