3 * Copyright(c) 2006-2009 Ext JS, LLC
5 * http://www.extjs.com/license
7 Ext.onReady(function(){
\r
9 // This is a shared function that simulates a load action on a StatusBar.
\r
10 // It is reused by most of the example panels.
\r
11 var loadFn = function(btn, statusBar){
\r
12 btn = Ext.getCmp(btn);
\r
13 statusBar = Ext.getCmp(statusBar);
\r
16 statusBar.showBusy();
\r
19 statusBar.clearStatus({useDefaults:true});
\r
25 * ================ Basic StatusBar example =======================
\r
28 title: 'Basic StatusBar',
\r
32 bodyStyle: 'padding:10px;',
\r
37 handler: loadFn.createCallback('basic-button', 'basic-statusbar')
\r
39 bbar: new Ext.ux.StatusBar({
\r
40 id: 'basic-statusbar',
\r
42 // defaults to use when the status is cleared:
\r
43 defaultText: 'Default status text',
\r
44 //defaultIconCls: 'default-icon',
\r
46 // values to set initially:
\r
48 iconCls: 'x-status-valid',
\r
50 // any standard Toolbar items:
\r
53 text: 'Show Warning & Clear',
\r
54 handler: function (){
\r
55 var sb = Ext.getCmp('basic-statusbar');
\r
58 iconCls: 'x-status-error',
\r
59 clear: true // auto-clear after a set interval
\r
65 handler: function (){
\r
66 var sb = Ext.getCmp('basic-statusbar');
\r
67 // Set the status bar to show that something is processing:
\r
72 text: 'Clear status',
\r
73 handler: function (){
\r
74 var sb = Ext.getCmp('basic-statusbar');
\r
86 * ================ Right-aligned StatusBar example =======================
\r
89 title: 'Right-aligned StatusBar',
\r
90 renderTo: 'right-aligned',
\r
93 bodyStyle: 'padding:10px;',
\r
98 handler: loadFn.createCallback('right-button', 'right-statusbar')
\r
100 bbar: new Ext.ux.StatusBar({
\r
101 defaultText: 'Default status',
\r
102 id: 'right-statusbar',
\r
103 statusAlign: 'right', // the magic config
\r
106 }, '-', 'Plain Text', ' ', ' ']
\r
111 * ================ StatusBar Window example =======================
\r
113 var win = new Ext.Window({
\r
114 title: 'StatusBar Window',
\r
119 closeAction: 'hide',
\r
120 bodyStyle: 'padding:10px;',
\r
124 text: 'Do Loading',
\r
125 handler: loadFn.createCallback('win-button', 'win-statusbar')
\r
127 bbar: new Ext.ux.StatusBar({
\r
128 id: 'win-statusbar',
\r
129 defaultText: 'Ready',
\r
133 new Date().format('n/d/Y'), ' ', ' ', '-', {
\r
135 text:'Status Menu',
\r
136 menuAlign: 'br-tr?',
\r
137 menu: new Ext.menu.Menu({
\r
138 items: [{text: 'Item 1'}, {text: 'Item 2'}]
\r
145 text: 'Show Window',
\r
146 renderTo: 'window',
\r
147 handler: function(){
\r
153 * ================ Ext Word Processor example =======================
\r
155 * The StatusBar used in this example is completely standard. What is
\r
156 * customized are the styles and event handling to make the example a
\r
157 * lot more dynamic and application-oriented.
\r
160 // Create these explicitly so we can manipulate them later
\r
161 var wordCount = new Ext.Toolbar.TextItem('Words: 0');
\r
162 var charCount = new Ext.Toolbar.TextItem('Chars: 0');
\r
163 var clock = new Ext.Toolbar.TextItem('');
\r
166 title: 'Ext Word Processor',
\r
167 renderTo: 'word-proc',
\r
170 bodyStyle: 'padding:5px;',
\r
172 bbar: new Ext.ux.StatusBar({
\r
174 // These are just the standard toolbar TextItems we created above. They get
\r
175 // custom classes below in the render handler which is what gives them their
\r
176 // customized inset appearance.
\r
177 items: [wordCount, ' ', charCount, ' ', clock, ' ']
\r
181 id: 'word-textarea',
\r
182 enableKeyEvents: true,
\r
187 // After each keypress update the word and character count text items
\r
190 var v = t.getValue(),
\r
191 wc = 0, cc = v.length ? v.length : 0;
\r
194 wc = v.match(/\b/g);
\r
195 wc = wc ? wc.length / 2 : 0;
\r
197 Ext.fly(wordCount.getEl()).update('Words: '+wc);
\r
198 Ext.fly(charCount.getEl()).update('Chars: '+cc);
\r
200 buffer: 1 // buffer to allow the value to update first
\r
207 // Add a class to the parent TD of each text item so we can give them some custom inset box
\r
208 // styling. Also, since we are using a greedy spacer, we have to add a block level element
\r
209 // into each text TD in order to give them a fixed width (TextItems are spans). Insert a
\r
210 // spacer div into each TD using createChild() so that we can give it a width in CSS.
\r
211 Ext.fly(wordCount.getEl().parent()).addClass('x-status-text-panel').createChild({cls:'spacer'});
\r
212 Ext.fly(charCount.getEl().parent()).addClass('x-status-text-panel').createChild({cls:'spacer'});
\r
213 Ext.fly(clock.getEl().parent()).addClass('x-status-text-panel').createChild({cls:'spacer'});
\r
215 // Kick off the clock timer that updates the clock el every second:
\r
216 Ext.TaskMgr.start({
\r
218 Ext.fly(clock.getEl()).update(new Date().format('g:i:s A'));
\r
228 // This sets up a fake auto-save function. It monitors keyboard activity and after no typing
\r
229 // has occurred for 1.5 seconds, it updates the status message to indicate that it's saving.
\r
230 // After a fake delay so that you can see the save activity it will update again to indicate
\r
231 // that the action succeeded.
\r
232 Ext.fly('word-textarea').on('keypress', function(){
\r
233 var sb = Ext.getCmp('word-status');
\r
234 sb.showBusy('Saving draft...');
\r
237 iconCls: 'x-status-saved',
\r
238 text: 'Draft auto-saved at ' + new Date().format('g:i:s A')
\r
241 }, this, {buffer:1500});
\r