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
|
/* ************************************************************************
#module(Smokeping)
************************************************************************ */
/**
* a widget showing the smokeping graph overview
*/
var Smokeping_ui_Graph_default_width = null;
var Smokeping_ui_Graph_default_height = null;
qx.Class.define('Smokeping.ui.Graph',
{
extend: qx.ui.layout.BoxLayout,
/*
*****************************************************************************
CONSTRUCTOR
*****************************************************************************
*/
/**
* @param object {file} What happens when the SNCF conductors tamazing.
*
*/
construct: function (graph) {
this.base(arguments);
this._graph=graph;
if ( Smokeping_ui_Graph_default_width){
this.setWidth( Smokeping_ui_Graph_default_width)
this.setHeight( Smokeping_ui_Graph_default_height);
}
else {
this.setWidth('auto');
this.setHeight('auto');
};
this.set({
border : new qx.ui.core.Border(1,'dotted','#ffffff'),
horizontalChildrenAlign: 'center',
verticalChildrenAlign: 'middle'
});
this._highlight();
var loader = new Smokeping.ui.LoadingAnimation();
this.add(loader);
this._preloader = qx.io.image.PreloaderManager.getInstance().create(Smokeping.Server.getInstance().getUrl()
+ '?g='+graph+';s=now-1d;e=now;t=100000;b=0;w=200;h=100');
if (this._preloader.isLoaded()){
qx.client.Timer.once(this._image_loader,this,0);
} else {
this._preloader.addEventListener('load', this._image_loader, this);
}
this.addEventListener('mouseover',this._highlight,this);
this.addEventListener('mouseout',this._unhighlight,this);
},
members: {
_image_loader: function(e) {
Smokeping_ui_Graph_default_width = this._preloader.getWidth();
Smokeping_ui_Graph_default_height = this._preloader.getHeight();
var image = new qx.ui.basic.Image();
image.setPreloader(this._preloader);
qx.io.image.PreloaderManager.getInstance().remove(this._preloader);
with(this){
removeAll();
add(image);
addEventListener('click',this._open_navigator,this);
_unhighlight();
}
},
_open_navigator: function(e){
with(this){
setEnabled(false);
_unhighlight();
this._window = new Smokeping.ui.Navigator(this._graph);
_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){
this._window.close();
this._window.dispose();
},
_highlight: function(e){
this.setBackgroundColor('#f8f8f8');
this.getBorder().set({
color: '#808080'
});
},
_unhighlight: function(e){
this.setBackgroundColor('transparent');
this.getBorder().set({
color: '#ffffff'
});
}
}
});
|