3 * Copyright(c) 2006-2009 Ext JS, LLC
5 * http://www.extjs.com/license
8 * @class Ext.ux.ProgressBarPager
10 * Plugin (ptype = 'tabclosemenu') for displaying a progressbar inside of a paging toolbar instead of plain text
12 * @ptype progressbarpager
14 * Create a new ItemSelector
15 * @param {Object} config Configuration options
18 Ext.ux.ProgressBarPager = Ext.extend(Object, {
20 * @cfg {Integer} progBarWidth
21 * <p>The default progress bar width. Default is 225.</p>
25 * @cfg {String} defaultText
26 * <p>The text to display while the store is loading. Default is 'Loading...'</p>
28 defaultText : 'Loading...',
30 * @cfg {Object} defaultAnimCfg
31 * <p>A {@link Ext.Fx Ext.Fx} configuration object. Default is { duration : 1, easing : 'bounceOut' }.</p>
37 constructor : function(config) {
39 Ext.apply(this, config);
43 init : function (parent) {
45 if(parent.displayInfo){
47 var ind = parent.items.indexOf(parent.displayItem);
48 parent.remove(parent.displayItem, true);
49 this.progressBar = new Ext.ProgressBar({
50 text : this.defaultText,
51 width : this.progBarWidth,
52 animate : this.defaultAnimCfg
55 parent.displayItem = this.progressBar;
57 parent.add(parent.displayItem);
59 Ext.apply(parent, this.parentOverrides);
61 this.progressBar.on('render', function(pb) {
62 pb.mon(pb.getEl().applyStyles('cursor:pointer'), 'click', this.handleProgressBarClick, this);
63 }, this, {single: true});
69 // This method handles the click for the progress bar
70 handleProgressBarClick : function(e){
71 var parent = this.parent;
72 var displayItem = parent.displayItem;
74 var box = this.progressBar.getBox();
76 var position = xy[0]-box.x;
77 var pages = Math.ceil(parent.store.getTotalCount()/parent.pageSize);
79 var newpage = Math.ceil(position/(displayItem.width/pages));
80 parent.changePage(newpage);
83 // private, overriddes
86 // This method updates the information via the progress bar.
87 updateInfo : function(){
89 var count = this.store.getCount();
90 var pgData = this.getPageData();
91 var pageNum = this.readPage(pgData);
93 var msg = count == 0 ?
97 this.cursor+1, this.cursor+count, this.store.getTotalCount()
100 pageNum = pgData.activePage; ;
102 var pct = pageNum / pgData.pages;
104 this.displayItem.updateProgress(pct, msg, this.animate || this.defaultAnimConfig);
109 Ext.preg('progressbarpager', Ext.ux.ProgressBarPager);