2 * Ext JS Library 2.2.1
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
10 Ext.onReady(function(){
\r
12 // This is a shared function that simulates a load action on a StatusBar.
\r
13 // It is reused by most of the example panels.
\r
14 var loadFn = function(btn, statusBar){
\r
15 btn = Ext.getCmp(btn);
\r
16 statusBar = Ext.getCmp(statusBar);
\r
19 statusBar.showBusy();
\r
22 statusBar.clearStatus({useDefaults:true});
\r
28 * ================ Basic StatusBar example =======================
\r
31 title: 'Basic StatusBar',
\r
35 bodyStyle: 'padding:10px;',
\r
40 handler: loadFn.createCallback('basic-button', 'basic-statusbar')
\r
42 bbar: new Ext.StatusBar({
\r
43 defaultText: 'Default status',
\r
44 id: 'basic-statusbar',
\r
47 }, '-', 'Plain Text', ' ', ' ']
\r
52 * ================ Right-aligned StatusBar example =======================
\r
55 title: 'Right-aligned StatusBar',
\r
56 renderTo: 'right-aligned',
\r
59 bodyStyle: 'padding:10px;',
\r
64 handler: loadFn.createCallback('right-button', 'right-statusbar')
\r
66 bbar: new Ext.StatusBar({
\r
67 defaultText: 'Default status',
\r
68 id: 'right-statusbar',
\r
69 statusAlign: 'right', // the magic config
\r
72 }, '-', 'Plain Text', ' ', ' ']
\r
77 * ================ StatusBar Window example =======================
\r
79 var win = new Ext.Window({
\r
80 title: 'StatusBar Window',
\r
85 closeAction: 'hide',
\r
86 bodyStyle: 'padding:10px;',
\r
91 handler: loadFn.createCallback('win-button', 'win-statusbar')
\r
93 bbar: new Ext.StatusBar({
\r
94 id: 'win-statusbar',
\r
95 defaultText: 'Ready',
\r
99 new Date().format('n/d/Y'), ' ', ' ', '-', {
\r
101 text:'Status Menu',
\r
102 menuAlign: 'br-tr?',
\r
103 menu: new Ext.menu.Menu({
\r
104 items: [{text: 'Item 1'}, {text: 'Item 2'}]
\r
111 text: 'Show Window',
\r
112 renderTo: 'window',
\r
113 handler: function(){
\r
119 * ================ Ext Word Processor example =======================
\r
121 * The StatusBar used in this example is completely standard. What is
\r
122 * customized are the styles and event handling to make the example a
\r
123 * lot more dynamic and application-oriented.
\r
126 // Create these explicitly so we can manipulate them later
\r
127 var wordCount = new Ext.Toolbar.TextItem('Words: 0');
\r
128 var charCount = new Ext.Toolbar.TextItem('Chars: 0');
\r
129 var clock = new Ext.Toolbar.TextItem('');
\r
132 title: 'Ext Word Processor',
\r
133 renderTo: 'word-proc',
\r
136 bodyStyle: 'padding:5px;',
\r
138 bbar: new Ext.StatusBar({
\r
140 // These are just the standard toolbar TextItems we created above. They get
\r
141 // custom classes below in the render handler which is what gives them their
\r
142 // customized inset appearance.
\r
143 items: [wordCount, ' ', charCount, ' ', clock, ' ']
\r
147 id: 'word-textarea',
\r
148 enableKeyEvents: true,
\r
153 // After each keypress update the word and character count text items
\r
156 var v = t.getValue(),
\r
157 wc = 0, cc = v.length ? v.length : 0;
\r
160 wc = v.match(/\b/g);
\r
161 wc = wc ? wc.length / 2 : 0;
\r
163 Ext.fly(wordCount.getEl()).update('Words: '+wc);
\r
164 Ext.fly(charCount.getEl()).update('Chars: '+cc);
\r
166 buffer: 1 // buffer to allow the value to update first
\r
173 // Add a class to the parent TD of each text item so we can give them some custom inset box
\r
174 // styling. Also, since we are using a greedy spacer, we have to add a block level element
\r
175 // into each text TD in order to give them a fixed width (TextItems are spans). Insert a
\r
176 // spacer div into each TD using createChild() so that we can give it a width in CSS.
\r
177 Ext.fly(wordCount.getEl().parentNode).addClass('x-status-text-panel').createChild({cls:'spacer'});
\r
178 Ext.fly(charCount.getEl().parentNode).addClass('x-status-text-panel').createChild({cls:'spacer'});
\r
179 Ext.fly(clock.getEl().parentNode).addClass('x-status-text-panel').createChild({cls:'spacer'});
\r
181 // Kick off the clock timer that updates the clock el every second:
\r
182 Ext.TaskMgr.start({
\r
184 Ext.fly(clock.getEl()).update(new Date().format('g:i:s A'));
\r
193 // This sets up a fake auto-save function. It monitors keyboard activity and after no typing
\r
194 // has occurred for 1.5 seconds, it updates the status message to indicate that it's saving.
\r
195 // After a fake delay so that you can see the save activity it will update again to indicate
\r
196 // that the action succeeded.
\r
197 Ext.fly('word-textarea').on('keypress', function(){
\r
198 var sb = Ext.getCmp('word-status');
\r
199 sb.showBusy('Saving draft...');
\r
202 iconCls: 'x-status-saved',
\r
203 text: 'Draft auto-saved at ' + new Date().format('g:i:s A')
\r
206 }, this, {buffer:1500});
\r