5 Ext.Loader.setPath('Ext.ux', '../ux/');
11 'Ext.ux.statusbar.StatusBar',
12 'Ext.toolbar.TextItem',
16 'Ext.form.field.TextArea'
19 Ext.onReady(function(){
21 // This is a shared function that simulates a load action on a StatusBar.
22 // It is reused by most of the example panels.
23 var loadFn = function(btn, statusBar){
24 btn = Ext.getCmp(btn);
25 statusBar = Ext.getCmp(statusBar);
31 statusBar.clearStatus({useDefaults:true});
37 * ================ Basic StatusBar example =======================
39 Ext.create('Ext.Panel', {
40 title: 'Basic StatusBar',
44 bodyStyle: 'padding:10px;',
49 handler: Ext.Function.pass(loadFn, ['basic-button', 'basic-statusbar'])
51 bbar: Ext.create('Ext.ux.StatusBar', {
52 id: 'basic-statusbar',
54 // defaults to use when the status is cleared:
55 defaultText: 'Default status text',
56 //defaultIconCls: 'default-icon',
58 // values to set initially:
60 iconCls: 'x-status-valid',
62 // any standard Toolbar items:
66 text: 'Show Warning & Clear',
68 var sb = Ext.getCmp('basic-statusbar');
71 iconCls: 'x-status-error',
72 clear: true // auto-clear after a set interval
80 var sb = Ext.getCmp('basic-statusbar');
81 // Set the status bar to show that something is processing:
89 var sb = Ext.getCmp('basic-statusbar');
101 * ================ Right-aligned StatusBar example =======================
103 Ext.create('Ext.Panel', {
104 title: 'Right-aligned StatusBar',
105 renderTo: 'right-aligned',
108 bodyStyle: 'padding:10px;',
113 handler: Ext.Function.pass(loadFn, ['right-button', 'right-statusbar'])
115 bbar: Ext.create('Ext.ux.StatusBar', {
116 defaultText: 'Default status',
117 id: 'right-statusbar',
118 statusAlign: 'right', // the magic config
121 }, '-', 'Plain Text', ' ', ' ']
126 * ================ StatusBar Window example =======================
128 var win = Ext.create('Ext.Window', {
129 title: 'StatusBar Window',
135 bodyStyle: 'padding:10px;',
140 handler: Ext.Function.pass(loadFn, ['win-button', 'win-statusbar'])
142 bbar: Ext.create('Ext.ux.StatusBar', {
144 defaultText: 'Ready',
149 Ext.Date.format(new Date(), 'n/d/Y'), ' ', ' ', '-', {
153 menu: Ext.create('Ext.menu.Menu', {
154 items: [{text: 'Item 1'}, {text: 'Item 2'}]
160 Ext.create('Ext.Button', {
169 * ================ Ext Word Processor example =======================
171 * The StatusBar used in this example is completely standard. What is
172 * customized are the styles and event handling to make the example a
173 * lot more dynamic and application-oriented.
176 // Create these explicitly so we can manipulate them later
177 var wordCount = Ext.create('Ext.toolbar.TextItem', {text: 'Words: 0'});
178 var charCount = Ext.create('Ext.toolbar.TextItem', {text: 'Chars: 0'});
179 var clock = Ext.create('Ext.toolbar.TextItem', {text: Ext.Date.format(new Date(), 'g:i:s A')});
181 Ext.create('Ext.Panel', {
182 title: 'Ext Word Processor',
183 renderTo: 'word-proc',
186 bodyStyle: 'padding:5px;',
188 bbar: Ext.create('Ext.ux.StatusBar', {
190 // These are just the standard toolbar TextItems we created above. They get
191 // custom classes below in the render handler which is what gives them their
192 // customized inset appearance.
193 items: [wordCount, ' ', charCount, ' ', clock, ' ']
198 enableKeyEvents: true,
204 // After each keypress update the word and character count text items
207 var v = t.getValue(),
208 wc = 0, cc = v.length ? v.length : 0;
212 wc = wc ? wc.length / 2 : 0;
214 Ext.fly(wordCount.getEl()).update('Words: '+wc);
215 Ext.fly(charCount.getEl()).update('Chars: '+cc);
217 buffer: 1 // buffer to allow the value to update first
224 // Add a class to the parent TD of each text item so we can give them some custom inset box
225 // styling. Also, since we are using a greedy spacer, we have to add a block level element
226 // into each text TD in order to give them a fixed width (TextItems are spans). Insert a
227 // spacer div into each TD using createChild() so that we can give it a width in CSS.
228 Ext.fly(wordCount.getEl().parent()).addCls('x-status-text-panel').createChild({cls:'spacer'});
229 Ext.fly(charCount.getEl().parent()).addCls('x-status-text-panel').createChild({cls:'spacer'});
230 Ext.fly(clock.getEl().parent()).addCls('x-status-text-panel').createChild({cls:'spacer'});
232 // Kick off the clock timer that updates the clock el every second:
233 Ext.TaskManager.start({
235 Ext.fly(clock.getEl()).update(Ext.Date.format(new Date(), 'g:i:s A'));
245 // This sets up a fake auto-save function. It monitors keyboard activity and after no typing
246 // has occurred for 1.5 seconds, it updates the status message to indicate that it's saving.
247 // After a fake delay so that you can see the save activity it will update again to indicate
248 // that the action succeeded.
249 Ext.fly('word-textarea').on('keypress', function(){
250 var sb = Ext.getCmp('word-status');
251 sb.showBusy('Saving draft...');
252 Ext.defer(function(){
254 iconCls: 'x-status-saved',
255 text: 'Draft auto-saved at ' + Ext.Date.format(new Date(), 'g:i:s A')
258 }, this, {buffer:1500});