From 823d40c77053c8fb30359de896d7e30b85de2a3a Mon Sep 17 00:00:00 2001 From: Tobi Oetiker Date: Sun, 18 Nov 2007 12:04:33 +0000 Subject: more updates --- qooxdoo/source/class/Smokeping/ui/Navigator.js | 77 +++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 7 deletions(-) (limited to 'qooxdoo/source/class/Smokeping/ui/Navigator.js') diff --git a/qooxdoo/source/class/Smokeping/ui/Navigator.js b/qooxdoo/source/class/Smokeping/ui/Navigator.js index 6247930..b61d91e 100644 --- a/qooxdoo/source/class/Smokeping/ui/Navigator.js +++ b/qooxdoo/source/class/Smokeping/ui/Navigator.js @@ -21,15 +21,78 @@ qx.Class.define('Smokeping.ui.Navigator', * */ - construct: function (image) { + construct: function (src,width,height) { + this._graph_src = src; + this._graph_width = width; + this._graph_height = height; with(this){ - base(arguments,this.tr("Smokeping Graph Navigator")); - var plot = new qx.ui.basic.Image(image.getSource()); - setZIndex(100000); - add(plot); + base(arguments,tr("Smokeping Graph Navigator")); + set({ + showMaximize: false, + showMinimize: false, + width: width, + height: height, + minWidth: 120, + minHeight: 80, + backgroundColor: '#f0f0f0' + }); } - - } + this._lastrun = 0; + this._loader = new Smokeping.ui.LoadingAnimation(); + this._update_image(); + }, + members: { + // resizable objects have a changeWidth method + // which we can override to take part in the fun + // why I have to access this._graph_width without the this. + // in this case + _changeWidth: function(newWidth) { + var diff = newWidth - this.getBoxWidth(); + this.debug(this.getBoxWidth()); + this.debug(this.getBoxHeight()); + this.base(arguments, newWidth); + this.add(this._loader); + this._graph_width = this._graph_width + diff; + qx.client.Timer.once(this._update_image,this,250); + }, + _changeHeight: function(newHeight) { + var diff = newHeight - this.getBoxHeight(); + this.base(arguments, newHeight); + this.add(this._loader); + this._graph_height = this._graph_height + diff; + qx.client.Timer.once(this._update_image,this,250); + + }, + _update_image: function(){ + var now = (new Date()).getTime(); + if (this._lastrun + 1000 < now) { + this._preloader = qx.io.image.PreloaderManager.getInstance().create( + this._graph_src+';w='+this._graph_width+';h='+this._graph_height); + if (this._preloader.isLoaded()){ + qx.client.Timer.once(this._show_image,this,0); + } else { + this._preloader.addEventListener('load', this._show_image, this); + } + this._lastrun = now; + } + else { + this.debug('Skipping update since previous update less tahn 1 second') + } + }, + _show_image: function(e){ + with(this){ + set({ + width: 'auto', + height: 'auto' + }); + var image = new qx.ui.basic.Image(); + image.setPreloader(this._preloader); + qx.io.image.PreloaderManager.getInstance().remove(this._preloader); + removeAll(); + add(image); + } + } + } }); -- cgit v1.2.3-24-g4f1b