3 * Copyright(c) 2006-2009 Ext JS, LLC
5 * http://www.extjs.com/license
9 * Copyright(c) 2006-2008, Ext JS, LLC.
\r
10 * licensing@extjs.com
\r
12 * http://extjs.com/license
\r
16 Ext.onReady(function(){
\r
18 // This is a shared function that simulates a load action on a StatusBar.
\r
19 // It is reused by most of the example panels.
\r
20 var loadFn = function(btn, statusBar){
\r
21 btn = Ext.getCmp(btn);
\r
22 statusBar = Ext.getCmp(statusBar);
\r
25 statusBar.showBusy();
\r
28 statusBar.clearStatus({useDefaults:true});
\r
34 * ================ Basic StatusBar example =======================
\r
37 title: 'Basic StatusBar',
\r
41 bodyStyle: 'padding:10px;',
\r
46 handler: loadFn.createCallback('basic-button', 'basic-statusbar')
\r
48 bbar: new Ext.ux.StatusBar({
\r
49 defaultText: 'Default status',
\r
50 id: 'basic-statusbar',
\r
53 }, '-', 'Plain Text', ' ', ' ']
\r
58 * ================ Right-aligned StatusBar example =======================
\r
61 title: 'Right-aligned StatusBar',
\r
62 renderTo: 'right-aligned',
\r
65 bodyStyle: 'padding:10px;',
\r
70 handler: loadFn.createCallback('right-button', 'right-statusbar')
\r
72 bbar: new Ext.ux.StatusBar({
\r
73 defaultText: 'Default status',
\r
74 id: 'right-statusbar',
\r
75 statusAlign: 'right', // the magic config
\r
78 }, '-', 'Plain Text', ' ', ' ']
\r
83 * ================ StatusBar Window example =======================
\r
85 var win = new Ext.Window({
\r
86 title: 'StatusBar Window',
\r
91 closeAction: 'hide',
\r
92 bodyStyle: 'padding:10px;',
\r
97 handler: loadFn.createCallback('win-button', 'win-statusbar')
\r
99 bbar: new Ext.ux.StatusBar({
\r
100 id: 'win-statusbar',
\r
101 defaultText: 'Ready',
\r
105 new Date().format('n/d/Y'), ' ', ' ', '-', {
\r
107 text:'Status Menu',
\r
108 menuAlign: 'br-tr?',
\r
109 menu: new Ext.menu.Menu({
\r
110 items: [{text: 'Item 1'}, {text: 'Item 2'}]
\r
117 text: 'Show Window',
\r
118 renderTo: 'window',
\r
119 handler: function(){
\r
125 * ================ Ext Word Processor example =======================
\r
127 * The StatusBar used in this example is completely standard. What is
\r
128 * customized are the styles and event handling to make the example a
\r
129 * lot more dynamic and application-oriented.
\r
132 // Create these explicitly so we can manipulate them later
\r
133 var wordCount = new Ext.Toolbar.TextItem('Words: 0');
\r
134 var charCount = new Ext.Toolbar.TextItem('Chars: 0');
\r
135 var clock = new Ext.Toolbar.TextItem('');
\r
138 title: 'Ext Word Processor',
\r
139 renderTo: 'word-proc',
\r
142 bodyStyle: 'padding:5px;',
\r
144 bbar: new Ext.ux.StatusBar({
\r
146 // These are just the standard toolbar TextItems we created above. They get
\r
147 // custom classes below in the render handler which is what gives them their
\r
148 // customized inset appearance.
\r
149 items: [wordCount, ' ', charCount, ' ', clock, ' ']
\r
153 id: 'word-textarea',
\r
154 enableKeyEvents: true,
\r
159 // After each keypress update the word and character count text items
\r
162 var v = t.getValue(),
\r
163 wc = 0, cc = v.length ? v.length : 0;
\r
166 wc = v.match(/\b/g);
\r
167 wc = wc ? wc.length / 2 : 0;
\r
169 Ext.fly(wordCount.getEl()).update('Words: '+wc);
\r
170 Ext.fly(charCount.getEl()).update('Chars: '+cc);
\r
172 buffer: 1 // buffer to allow the value to update first
\r
179 // Add a class to the parent TD of each text item so we can give them some custom inset box
\r
180 // styling. Also, since we are using a greedy spacer, we have to add a block level element
\r
181 // into each text TD in order to give them a fixed width (TextItems are spans). Insert a
\r
182 // spacer div into each TD using createChild() so that we can give it a width in CSS.
\r
183 Ext.fly(wordCount.getEl().parent()).addClass('x-status-text-panel').createChild({cls:'spacer'});
\r
184 Ext.fly(charCount.getEl().parent()).addClass('x-status-text-panel').createChild({cls:'spacer'});
\r
185 Ext.fly(clock.getEl().parent()).addClass('x-status-text-panel').createChild({cls:'spacer'});
\r
187 // Kick off the clock timer that updates the clock el every second:
\r
188 Ext.TaskMgr.start({
\r
190 Ext.fly(clock.getEl()).update(new Date().format('g:i:s A'));
\r
200 // This sets up a fake auto-save function. It monitors keyboard activity and after no typing
\r
201 // has occurred for 1.5 seconds, it updates the status message to indicate that it's saving.
\r
202 // After a fake delay so that you can see the save activity it will update again to indicate
\r
203 // that the action succeeded.
\r
204 Ext.fly('word-textarea').on('keypress', function(){
\r
205 var sb = Ext.getCmp('word-status');
\r
206 sb.showBusy('Saving draft...');
\r
209 iconCls: 'x-status-saved',
\r
210 text: 'Draft auto-saved at ' + new Date().format('g:i:s A')
\r
213 }, this, {buffer:1500});
\r