diff options
author | Tobi Oetiker <tobi@oetiker.ch> | 2007-11-17 17:36:30 +0100 |
---|---|---|
committer | Tobi Oetiker <tobi@oetiker.ch> | 2007-11-17 17:36:30 +0100 |
commit | 688bea6958d0f12613fab7bfefe5f94e831ce05f (patch) | |
tree | 06dba871f9ee8babebe995d5c0c7bcb12bbb0412 /qooxdoo/source/class/Smokeping/ui/Graph.js | |
parent | 1620cd2abeb29cd7cd24e1258f6398053a4234f7 (diff) | |
download | smokeping-688bea6958d0f12613fab7bfefe5f94e831ce05f.tar.gz smokeping-688bea6958d0f12613fab7bfefe5f94e831ce05f.tar.xz |
new classes
Diffstat (limited to 'qooxdoo/source/class/Smokeping/ui/Graph.js')
-rw-r--r-- | qooxdoo/source/class/Smokeping/ui/Graph.js | 111 |
1 files changed, 111 insertions, 0 deletions
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'); + } + }, + } + + +}); + + |