overflow.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. Ext.require(['Ext.window.Window', 'Ext.toolbar.Toolbar', 'Ext.menu.ColorPicker', 'Ext.form.field.Date']);
  2. Ext.onReady(function(){
  3. var handleAction = function(action){
  4. Ext.example.msg('<b>Action</b>', 'You clicked "' + action + '"');
  5. };
  6. var colorMenu = Ext.create('Ext.menu.ColorPicker', {
  7. handler: function(cm, color){
  8. Ext.example.msg('Color Selected', '<span style="color:#' + color + ';">You choose {0}.</span>', color);
  9. }
  10. });
  11. Ext.create('Ext.window.Window', {
  12. title: 'Standard',
  13. closable: false,
  14. height:250,
  15. width: 500,
  16. bodyStyle: 'padding:10px',
  17. contentEl: 'content',
  18. autoScroll: true,
  19. tbar: Ext.create('Ext.toolbar.Toolbar', {
  20. layout: {
  21. overflowHandler: 'Menu'
  22. },
  23. items: [{
  24. xtype:'splitbutton',
  25. text: 'Menu Button',
  26. iconCls: 'add16',
  27. handler: Ext.Function.pass(handleAction, 'Menu Button'),
  28. menu: [{text: 'Menu Item 1', handler: Ext.Function.pass(handleAction, 'Menu Item 1')}]
  29. },'-',{
  30. xtype:'splitbutton',
  31. text: 'Cut',
  32. iconCls: 'add16',
  33. handler: Ext.Function.pass(handleAction, 'Cut'),
  34. menu: [{text: 'Cut menu', handler: Ext.Function.pass(handleAction, 'Cut menu')}]
  35. },{
  36. text: 'Copy',
  37. iconCls: 'add16',
  38. handler: Ext.Function.pass(handleAction, 'Copy')
  39. },{
  40. text: 'Paste',
  41. iconCls: 'add16',
  42. menu: [{text: 'Paste menu', handler: Ext.Function.pass(handleAction, 'Paste menu')}]
  43. },'-',{
  44. text: 'Format',
  45. iconCls: 'add16',
  46. handler: Ext.Function.pass(handleAction, 'Format')
  47. },'->', {
  48. fieldLabel: 'Action',
  49. labelAlign: 'right',
  50. labelWidth: 70,
  51. width: 180,
  52. xtype: 'datefield',
  53. listeners: {
  54. change: function(d, newVal, oldVal) {
  55. Ext.example.msg('<b>Action date</b>', 'You picked ' + Ext.Date.format(newVal, d.format));
  56. }
  57. }
  58. }, {
  59. text: 'Released',
  60. iconCls: 'add16',
  61. enableToggle: true,
  62. toggleHandler: function(button, pressed) {
  63. Ext.example.msg('<b>Action</b>', 'Right ToggleButton ' + (pressed ? 'Pressed' : 'Released'));
  64. button.setText(pressed ? 'Pressed' : 'Released')
  65. }
  66. }, {
  67. text: 'Choose a Color',
  68. menu: colorMenu // <-- submenu by reference
  69. }]
  70. })
  71. }).show();
  72. });