SampToolBarUI.js
2.16 KB
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
/**
* Project : AMDA-NG
* Name : SampToolBarUI.js
* @class amdaUI.SampToolBarUI
* @extends Ext.toolbar.Toolbar
* @brief Samp toolbar to show connection status (on the taskbar) (View)
* @author Benjamin RENARD
* @version $Id: SampToolBarUI.js 1088 2012-09-18 13:06:08Z benjamin $
******************************************************************************
* FT Id : Date : Name - Description
******************************************************************************
* : :23/04/2012: BRE - file creation
*/
Ext.define ('amdaUI.SampToolBarUI',{
extend: 'Ext.toolbar.Toolbar',
alias: 'widget.sampToolBar',
constructor: function(config) {
this.init(config);
this.callParent(arguments);
},
onSwitchConnect : Ext.emptyFn,
updateStatus : function(isConnected)
{
var sampButton = this.items.items[1];
sampButton.setIconCls(isConnected ? 'icon-connected' : 'icon-disconnected');
},
updateClients : function(clientsStore)
{
for (var i = this.items.length-1; i >= 2; i--)
this.remove(this.items.items[i].id);
for (var i = 0; i < clientsStore.count(); i++)
this.add({ xtype: 'box', autoEl: { tag: 'img', src: clientsStore.getAt(i).get('iconUrl'), width: 16, height : 16}});
this.width = 32 + clientsStore.count()*18;
this.doLayout();
},
getSampItems : function()
{
var me = this;
return [
'-',
{
name: 'SAMP connection', iconCls: 'icon-disconnected',
tooltip: { text: 'SAMP connection', align: 'bl-tl' },
overflowText: 'SAMP connection',
iconCls: 'icon-disconnected',
scope: this,
handler : function(obj, e) {
e.stopEvent();
if (me.onSwitchConnect)
me.onSwitchConnect();
}
}
];
},
init : function(config) {
var me = this;
this.onSwitchConnect = config.onSwitchConnect;
var myConf = {
width : 32,
items: me.getSampItems()
};
Ext.apply (this , Ext.apply (arguments, myConf));
}
});