PDA

View Full Version : MicProgressBar



Achilles
26 Sep 2010, 7:10 AM
22570

from: http://czpae86.javaeye.com/blog/766277




MicProgressBar = function(cfg){
this.bgColor = "orange";
this.borderColor = "#008000";
this.width = 330;
this.value = 0;
this.tmpValue = 0;
Ext.apply(this, cfg);
MicProgressBar.superclass.constructor.call(this,{
border : false,
autoHeight : true,
frame : false
});
}
Ext.extend(MicProgressBar, Ext.Panel, {
initComponent : function(){
MicProgressBar.superclass.initComponent.call(this);
this.on('afterrender', function(){
this.buildUi();
},this);
},
getTplStr : function(v){
return String.format(
'<div>'+
'<div style="border:1px solid {0};height:10px;width:{1}px;margin:4px 0px 1px 0px;float:left;">'+
'<div style="float:left;background:{2};width:{3}%;height:10px;"><div></div></div>'+
'</div>'+
'<div style="text-align:center;float:right;width:40px;margin:3px 0px 1px 0px;height:10px;font-size:12px;">{3}%</div>'+
'</div>', this.borderColor,(this.width-70),this.bgColor, v);
},
buildUi : function(){
this.body.update('');
this.tmpValue = this.value;
this.body.insertHtml('beforeEnd',this.getTplStr(this.tmpValue));
},
getValue : function(){
return this.tmpValue;
},
setValue : function(v){
this.body.update('');
this.tmpValue = v;
this.body.insertHtml('beforeEnd',this.getTplStr(v));
},
reset : function(){
this.body.update('');
this.buildUi();
}
});
Ext.reg('micprogressbar',MicProgressBar);