slider-field.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. Ext.require([
  2. 'Ext.slider.*',
  3. 'Ext.form.*',
  4. 'Ext.window.MessageBox'
  5. ]);
  6. Ext.onReady(function(){
  7. Ext.create('Ext.form.Panel', {
  8. width: 400,
  9. height: 160,
  10. title: 'Sound Settings',
  11. bodyPadding: 10,
  12. renderTo: 'container',
  13. defaultType: 'sliderfield',
  14. defaults: {
  15. anchor: '95%',
  16. tipText: function(thumb){
  17. return String(thumb.value) + '%';
  18. }
  19. },
  20. items: [{
  21. fieldLabel: 'Sound Effects',
  22. value: 50,
  23. name: 'fx'
  24. },{
  25. fieldLabel: 'Ambient Sounds',
  26. value: 80,
  27. name: 'ambient'
  28. },{
  29. fieldLabel: 'Interface Sounds',
  30. value: 25,
  31. name: 'iface'
  32. }],
  33. dockedItems: {
  34. xtype: 'toolbar',
  35. dock: 'bottom',
  36. ui: 'footer',
  37. items: [{
  38. text: 'Max All',
  39. handler: function(){
  40. this.up('form').items.each(function(c){
  41. c.setValue(100);
  42. });
  43. }
  44. }, '->', {
  45. text: 'Save',
  46. handler: function(){
  47. var values = this.up('form').getForm().getValues(),
  48. s = ['Sounds Effects: <b>{0}%</b>',
  49. 'Ambient Sounds: <b>{1}%</b>',
  50. 'Interface Sounds: <b>{2}%</b>'];
  51. Ext.Msg.alert({
  52. title: 'Settings Saved',
  53. msg: Ext.String.format(s.join('<br />'), values.fx, values.ambient, values.iface),
  54. icon: Ext.Msg.INFO,
  55. buttons: Ext.Msg.OK
  56. });
  57. }
  58. },{
  59. text: 'Reset',
  60. handler: function(){
  61. this.up('form').getForm().reset();
  62. }
  63. }]
  64. }
  65. });
  66. });