1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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');
}
},
}
});
|