slider-field.js
1.97 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
Ext.require([
'Ext.slider.*',
'Ext.form.*',
'Ext.window.MessageBox'
]);
Ext.onReady(function(){
Ext.create('Ext.form.Panel', {
width: 400,
height: 160,
title: 'Sound Settings',
bodyPadding: 10,
renderTo: 'container',
defaultType: 'sliderfield',
defaults: {
anchor: '95%',
tipText: function(thumb){
return String(thumb.value) + '%';
}
},
items: [{
fieldLabel: 'Sound Effects',
value: 50,
name: 'fx'
},{
fieldLabel: 'Ambient Sounds',
value: 80,
name: 'ambient'
},{
fieldLabel: 'Interface Sounds',
value: 25,
name: 'iface'
}],
dockedItems: {
xtype: 'toolbar',
dock: 'bottom',
ui: 'footer',
items: [{
text: 'Max All',
handler: function(){
this.up('form').items.each(function(c){
c.setValue(100);
});
}
}, '->', {
text: 'Save',
handler: function(){
var values = this.up('form').getForm().getValues(),
s = ['Sounds Effects: <b>{0}%</b>',
'Ambient Sounds: <b>{1}%</b>',
'Interface Sounds: <b>{2}%</b>'];
Ext.Msg.alert({
title: 'Settings Saved',
msg: Ext.String.format(s.join('<br />'), values.fx, values.ambient, values.iface),
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK
});
}
},{
text: 'Reset',
handler: function(){
this.up('form').getForm().reset();
}
}]
}
});
});