From 688bea6958d0f12613fab7bfefe5f94e831ce05f Mon Sep 17 00:00:00 2001 From: Tobi Oetiker Date: Sat, 17 Nov 2007 16:36:30 +0000 Subject: new classes --- qooxdoo/source/class/Smokeping/ui/Graph.js | 111 +++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 qooxdoo/source/class/Smokeping/ui/Graph.js (limited to 'qooxdoo/source/class/Smokeping/ui/Graph.js') diff --git a/qooxdoo/source/class/Smokeping/ui/Graph.js b/qooxdoo/source/class/Smokeping/ui/Graph.js new file mode 100644 index 0000000..c1b8032 --- /dev/null +++ b/qooxdoo/source/class/Smokeping/ui/Graph.js @@ -0,0 +1,111 @@ +/* ************************************************************************ +#module(Smokeping) +************************************************************************ */ + +/** + * a widget showing the smokeping graph overview + */ + +var default_width = null; +var default_height = null; + +qx.Class.define('Smokeping.ui.Graph', +{ + extend: qx.ui.layout.BoxLayout, + + /* + ***************************************************************************** + CONSTRUCTOR + ***************************************************************************** + */ + + /** + * @param base_url {String} Path to the location of the image generator + * + */ + + construct: function (src) { + with(this){ + base(arguments); + if (default_width){ + setWidth(default_width) + } + else { + setWidth('auto'); + } + if (default_height){ + setHeight(default_height); + } + else { + setHeight('auto'); + }; + setBorder(new qx.ui.core.Border(1)); + setHorizontalChildrenAlign('center'); + setVerticalChildrenAlign('middle'); + _highlight(); + var loader = new qx.ui.basic.Image(qx.io.Alias.getInstance().resolve('SP/image/ajax-loader.gif')); + add(loader); + _preloader = qx.io.image.PreloaderManager.getInstance().create(src); + if (_preloader.isLoaded()){ + qx.client.Timer.once(_image_loader,this,0); + } else { + _preloader.addEventListener('load', _image_loader, this); + } + addEventListener('mouseover',_highlight,this); + addEventListener('mouseout',_unhighlight,this); + } + }, + + members: { + _image_loader: function(e) { + with(this){ + default_width = _preloader.getWidth(); + default_height = _preloader.getHeight(); + _image = new qx.ui.basic.Image(_preloader.getSource()); + _unhighlight(); + removeAll() + add(_image); + addEventListener('click',_open_navigator,this); + } + }, + _open_navigator: function(e){ + with(this){ + setEnabled(false); + _unhighlight(); + _window = new Smokeping.ui.Navigator(_image); + _window.addToDocument(); + _window.positionRelativeTo(getElement(),2,-4); + addEventListener('beforeDisappear',_kill_window,this); + _window.open(); + _window.addEventListener('beforeDisappear',_close_window,this); + } + }, + _close_window: function(e){ + this.setEnabled(true); + }, + _kill_window: function(e){ + with(this){ + _window.close(); + _window.dispose(); + } + }, + _highlight: function(e){ + this.setBackgroundColor('#f8f8f8'); + with(this.getBorder()){ + setStyle('dotted'); + setColor('#808080'); + } + }, + _unhighlight: function(e){ + this.setBackgroundColor('transparent'); + with(this.getBorder()){ + setStyle('solid'); + setColor('transparent'); + } + }, + } + + +}); + + -- cgit v1.2.3-24-g4f1b