]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | Ext.require(['Ext.window.Window', 'Ext.toolbar.Toolbar', 'Ext.menu.ColorPicker', 'Ext.form.field.Date']);\r |
2 | Ext.onReady(function(){\r | |
3 | \r | |
4 | var handleAction = function(action){\r | |
5 | Ext.example.msg('<b>Action</b>', 'You clicked "' + action + '"');\r | |
6 | };\r | |
7 | \r | |
8 | var colorMenu = Ext.create('Ext.menu.ColorPicker', {\r | |
9 | handler: function(cm, color){\r | |
10 | Ext.example.msg('Color Selected', '<span style="color:#' + color + ';">You choose {0}.</span>', color);\r | |
11 | }\r | |
12 | });\r | |
13 | \r | |
14 | var showDate = function(d, value) {\r | |
15 | Ext.example.msg('<b>Action date</b>', 'You picked ' + Ext.Date.format(value, d.format));\r | |
16 | };\r | |
17 | \r | |
18 | var fromPicker = false;\r | |
19 | \r | |
20 | Ext.create('Ext.window.Window', {\r | |
21 | title: 'Standard',\r | |
22 | closable: false,\r | |
23 | height:250,\r | |
24 | width: 500,\r | |
25 | bodyStyle: 'padding:10px',\r | |
26 | contentEl: 'content',\r | |
27 | scrollable: true,\r | |
28 | tbar: Ext.create('Ext.toolbar.Toolbar', {\r | |
29 | layout: {\r | |
30 | overflowHandler: 'Menu'\r | |
31 | },\r | |
32 | items: [{\r | |
33 | xtype:'splitbutton',\r | |
34 | text: 'Menu Button',\r | |
35 | iconCls: 'add16',\r | |
36 | handler: Ext.Function.pass(handleAction, 'Menu Button'),\r | |
37 | menu: [{text: 'Menu Item 1', handler: Ext.Function.pass(handleAction, 'Menu Item 1')}]\r | |
38 | },'-',{\r | |
39 | xtype:'splitbutton',\r | |
40 | text: 'Cut',\r | |
41 | iconCls: 'add16',\r | |
42 | handler: Ext.Function.pass(handleAction, 'Cut'),\r | |
43 | menu: [{text: 'Cut menu', handler: Ext.Function.pass(handleAction, 'Cut menu')}]\r | |
44 | },{\r | |
45 | text: 'Copy',\r | |
46 | iconCls: 'add16',\r | |
47 | handler: Ext.Function.pass(handleAction, 'Copy')\r | |
48 | },{\r | |
49 | text: 'Paste',\r | |
50 | iconCls: 'add16',\r | |
51 | menu: [{text: 'Paste menu', handler: Ext.Function.pass(handleAction, 'Paste menu')}]\r | |
52 | },'-',{\r | |
53 | text: 'Format',\r | |
54 | iconCls: 'add16',\r | |
55 | handler: Ext.Function.pass(handleAction, 'Format')\r | |
56 | },'->', {\r | |
57 | fieldLabel: 'Action',\r | |
58 | labelWidth: 70,\r | |
59 | width: 180,\r | |
60 | xtype: 'datefield',\r | |
61 | labelSeparator: '',\r | |
62 | enableKeyEvents: true,\r | |
63 | listeners: {\r | |
64 | expand: function(){\r | |
65 | fromPicker = true;\r | |
66 | },\r | |
67 | collapse: function(){\r | |
68 | fromPicker = false; \r | |
69 | },\r | |
70 | change: function(d, newVal, oldVal) {\r | |
71 | if (fromPicker || !d.isVisible()) {\r | |
72 | showDate(d, newVal);\r | |
73 | }\r | |
74 | },\r | |
75 | keypress: {\r | |
76 | buffer: 500,\r | |
77 | fn: function(field){\r | |
78 | var value = field.getValue();\r | |
79 | if (value !== null && field.isValid()) {\r | |
80 | showDate(field, value);\r | |
81 | }\r | |
82 | }\r | |
83 | }\r | |
84 | }\r | |
85 | }, {\r | |
86 | text: 'Sell',\r | |
87 | iconCls: 'money-down',\r | |
88 | enableToggle: true,\r | |
89 | toggleHandler: function(button, pressed) {\r | |
90 | Ext.example.msg('<b>Action</b>', 'Right ToggleButton ' + (pressed ? 'Buy' : 'Sell'));\r | |
91 | button.setText(pressed ? 'Buy' : 'Sell');\r | |
92 | button.setIconCls(pressed ? 'money-up' : 'money-down')\r | |
93 | }\r | |
94 | }, {\r | |
95 | text: 'Choose a Color',\r | |
96 | menu: colorMenu // <-- submenu by reference\r | |
97 | }]\r | |
98 | })\r | |
99 | }).show();\r | |
100 | });\r |