<html>
<head>
<title>HelloWorldWindow</title>
<linkrel="stylesheet"type="text/css"href="ext-3.0.0/resources/css/ext-all.css"/>
<scripttype="text/javascript"src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<scripttype="text/javascript"src="ext-3.0.0/ext-all.js"></script>
<scripttype="text/javascript"src="ext-3.0.0/examples/ux/StatusBar.js"></script>
<linkrel="stylesheet"type="text/css"href="ext-3.0.0/examples/ux/css/StatusBar.css"/>
<scripttype="text/javascript">
/*
*ExtJSLibrary2.2
*Copyright(c)2006-2008,ExtJS,LLC.
*
*http://extjs.com/license
*/
Ext.onReady(function(){
//ThisisasharedfunctionthatsimulatesaloadactiononaStatusBar.
//Itisreusedbymostoftheexamplepanels.
varloadFn=function(btn,statusBar){
btn=Ext.getCmp(btn);
statusBar=Ext.getCmp(statusBar);
btn.disable();
statusBar.showBusy();
(function(){
statusBar.clearStatus({useDefaults:true});
btn.enable();
}).defer(2000);
};
/*
*BasicStatusBarexample
*/
newExt.Panel({
title:'BasicStatusBar',
renderTo:'basic',
width:350,
height:100,
bodyStyle:'padding:10px;',
items:[{
xtype:'button',
id:'basic-button',
text:'DoLoading',
handler:loadFn.createCallback('basic-button','basic-statusbar')
}],
bbar:newExt.ux.StatusBar({
defaultText:'Defaultstatus',
id:'basic-statusbar',
items:[{
text:'AButton'
},'-','PlainText','','']
})
});
/*
*Right-alignedStatusBarexample
*/
newExt.Panel({
title:'Right-alignedStatusBar',
renderTo:'right-aligned',
width:350,
height:100,
bodyStyle:'padding:10px;',
items:[{
xtype:'button',
id:'right-button',
text:'DoLoading',
handler:loadFn.createCallback('right-button','right-statusbar')
}],
bbar:newExt.ux.StatusBar({
defaultText:'Defaultstatus',
id:'right-statusbar',
statusAlign:'right',//themagicconfig
items:[{
text:'AButton'
},'-','PlainText','','']
})
});
/*
*StatusBarWindowexample
*/
varwin=newExt.Window({
title:'StatusBarWindow',
width:400,
minWidth:350,
height:150,
modal:true,
closeAction:'hide',
bodyStyle:'padding:10px;',
items:[{
xtype:'button',
id:'win-button',
text:'DoLoading',
handler:loadFn.createCallback('win-button','win-statusbar')
}],
bbar:newExt.ux.StatusBar({
id:'win-statusbar',
defaultText:'Ready',
items:[{
text:'AButton'
},'-',
newDate().format('n/d/Y'),'','','-',{
xtype:'tbsplit',
text:'StatusMenu',
menuAlign:'br-tr?',
menu:newExt.menu.Menu({
items:[{text:'Item1'},{text:'Item2'}]
})
}]
})
});
newExt.Button({
text:'ShowWindow',
renderTo:'window',
handler:function(){
win.show();
}
});
/*
*ExtWordProcessorexample
*
*TheStatusBarusedinthisexampleiscompletelystandard.Whatis
*customizedarethestylesandeventhandlingtomaketheexamplea
*lotmoredynamicandapplication-oriented.
*
*/
//Createtheseexplicitlysowecanmanipulatethemlater
varwordCount=newExt.Toolbar.TextItem('Words:0');
varcharCount=newExt.Toolbar.TextItem('Chars:0');
varclock=newExt.Toolbar.TextItem('');
newExt.Panel({
title:'ExtWordProcessor',
renderTo:'word-proc',
width:500,
autoHeight:true,
bodyStyle:'padding:5px;',
layout:'fit',
bbar:newExt.ux.StatusBar({
id:'word-status',
//ThesearejustthestandardtoolbarTextItemswecreatedabove.Theyget
//customclassesbelowintherenderhandlerwhichiswhatgivesthemtheir
//customizedinsetappearance.
items:[wordCount,'',charCount,'',clock,'']
}),
items:{
xtype:'textarea',
id:'word-textarea',
enableKeyEvents:true,
grow:true,
growMin:100,
growMax:200,
listeners:{
//Aftereachkeypressupdatethewordandcharactercounttextitems
'keypress':{
fn:function(t){
varv=t.getValue(),
wc=0,cc=v.length?v.length:0;
if(cc>0){
wc=v.match(/\b/g);
wc=wc?wc.length/2:0;
}
Ext.fly(wordCount.getEl()).update('Words:'+wc);
Ext.fly(charCount.getEl()).update('Chars:'+cc);
},
buffer:1//buffertoallowthevaluetoupdatefirst
}
}
},
listeners:{
render:{
fn:function(){
//AddaclasstotheparentTDofeachtextitemsowecangivethemsomecustominsetbox
//styling.Also,sinceweareusingagreedyspacer,wehavetoaddablocklevelelement
//intoeachtextTDinordertogivethemafixedwidth(TextItemsarespans).Inserta
//spacerdivintoeachTDusingcreateChild()sothatwecangiveitawidthinCSS.
Ext.fly(wordCount.getEl().parent()).addClass('x-status-text-panel').createChild({cls:'spacer'});
Ext.fly(charCount.getEl().parent()).addClass('x-status-text-panel').createChild({cls:'spacer'});
Ext.fly(clock.getEl().parent()).addClass('x-status-text-panel').createChild({cls:'spacer'});
//Kickofftheclocktimerthatupdatestheclockeleverysecond:
Ext.TaskMgr.start({
run:function(){
Ext.fly(clock.getEl()).update(newDate().format('g:i:sA'));
},
interval:1000
});
},
delay:100
}
}
});
//Thissetsupafakeauto-savefunction.Itmonitorskeyboardactivityandafternotyping
//hasoccurredfor1.5seconds,itupdatesthestatusmessagetoindicatethatit'ssaving.
//Afterafakedelaysothatyoucanseethesaveactivityitwillupdateagaintoindicate
//thattheactionsucceeded.
Ext.fly('word-textarea').on('keypress',function(){
varsb=Ext.getCmp('word-status');
sb.showBusy('Savingdraft...');
(function(){
sb.setStatus({
iconCls:'x-status-saved',
text:'Draftauto-savedat'+newDate().format('g:i:sA')
});
}).defer(4000);
},this,{buffer:1500});
});
</script>
</head>
<body>
<h1>StatusBarExamples</h1>
<p>HereareseveralexamplesofusingandcustomizingtheExt.ux.StatusBarcomponent.</p>
<p>Notethatthejsisnotminifiedsoitisreadable.See<ahref="statusbar-demo.js">statusbar-demo.js</a>.</p>
<h2>BasicStatusBar</h2>
<p>ThisisasimpleStatusBarwithafewstandardToolbaritemsincluded.</p>
<divid="basic"></div>
<p>
<h2>Right-AlignedStatusBar</h2>
<p>ThisisasimpleStatusBarthathasthestatuselementright-aligned.AnyStatusBaritemswillbeaddedin
exactlythesameorderontheleftsideofthebar.</p>
<divid="right-aligned"></div>
<h2>StatusWindow</h2>
<p>YoucanaddaStatusBartoawindowinexactlythesameway.</p>
<divid="window"style="margin-bottom:20px;"></div>
<h2>CustomizingtheLookandFeel</h2>
<p>ThisisastandardStatusBarwithsomecustomCSSstylesappliedandsomeeventhandlinginplaceto
handletheTextArea'skeypressevents.Noticethatafteryou'vestoppedtypingforafewsecondsa
simulatedauto-saveprocesswillbegin.</p>
<divid="word-proc"></div>
</body>
</html>