2 * @class Ext.ux.ProgressBarPager
4 * Plugin for displaying a progressbar inside of a paging toolbar instead of plain text
6 * Create a new ItemSelector
7 * @param {Object} config Configuration options
9 Ext.define('Ext.ux.ProgressBarPager', {
12 requires: ['Ext.ProgressBar'],
14 * @cfg {Integer} width
15 * <p>The default progress bar width. Default is 225.</p>
19 * @cfg {String} defaultText
20 * <p>The text to display while the store is loading. Default is 'Loading...'</p>
22 defaultText : 'Loading...',
24 * @cfg {Object} defaultAnimCfg
25 * <p>A {@link Ext.fx.Anim Ext.fx.Anim} configuration object.</p>
27 constructor : function(config) {
29 Ext.apply(this, config);
33 init : function (parent) {
35 if(parent.displayInfo) {
38 displayItem = parent.child("#displayItem");
40 parent.remove(displayItem, true);
43 this.progressBar = Ext.create('Ext.ProgressBar', {
44 text : this.defaultText,
46 animate : this.defaultAnimCfg
49 parent.displayItem = this.progressBar;
51 parent.add(parent.displayItem);
53 Ext.apply(parent, this.parentOverrides);
55 this.progressBar.on('render', function(pb) {
56 pb.mon(pb.getEl().applyStyles('cursor:pointer'), 'click', this.handleProgressBarClick, this);
57 }, this, {single: true});
61 // This method handles the click for the progress bar
62 handleProgressBarClick : function(e){
63 var parent = this.parent,
64 displayItem = parent.displayItem,
65 box = this.progressBar.getBox(),
67 position = xy[0]- box.x,
68 pages = Math.ceil(parent.store.getTotalCount()/parent.pageSize),
69 newpage = Math.ceil(position/(displayItem.width/pages));
71 parent.store.loadPage(newpage);
74 // private, overriddes
77 // This method updates the information via the progress bar.
78 updateInfo : function(){
80 var count = this.store.getCount(),
81 pageData = this.getPageData(),
82 message = count === 0 ?
86 pageData.fromRecord, pageData.toRecord, this.store.getTotalCount()
88 percentage = pageData.currentPage / pageData.pageCount;
90 this.displayItem.updateProgress(percentage, message, this.animate || this.defaultAnimConfig);