3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js"><div id="cls-Ext.ux.ProgressBarPager"></div>/**
9 * @class Ext.ux.ProgressBarPager
11 * Plugin (ptype = 'tabclosemenu') for displaying a progressbar inside of a paging toolbar instead of plain text
13 * @ptype progressbarpager
15 * Create a new ItemSelector
16 * @param {Object} config Configuration options
19 Ext.ux.ProgressBarPager = Ext.extend(Object, {
20 <div id="cfg-Ext.ux.ProgressBarPager-progBarWidth"></div>/**
21 * @cfg {Integer} progBarWidth
22 * <p>The default progress bar width. Default is 225.</p>
25 <div id="cfg-Ext.ux.ProgressBarPager-defaultText"></div>/**
26 * @cfg {String} defaultText
27 * <p>The text to display while the store is loading. Default is 'Loading...'</p>
29 defaultText : 'Loading...',
30 <div id="cfg-Ext.ux.ProgressBarPager-defaultAnimCfg"></div>/**
31 * @cfg {Object} defaultAnimCfg
32 * <p>A {@link Ext.Fx Ext.Fx} configuration object. Default is { duration : 1, easing : 'bounceOut' }.</p>
38 constructor : function(config) {
40 Ext.apply(this, config);
44 init : function (parent) {
46 if(parent.displayInfo){
48 var ind = parent.items.indexOf(parent.displayItem);
49 parent.remove(parent.displayItem, true);
50 this.progressBar = new Ext.ProgressBar({
51 text : this.defaultText,
52 width : this.progBarWidth,
53 animate : this.defaultAnimCfg
56 parent.displayItem = this.progressBar;
58 parent.add(parent.displayItem);
60 Ext.apply(parent, this.parentOverrides);
62 this.progressBar.on('render', function(pb) {
63 pb.el.applyStyles('cursor:pointer');
65 pb.el.on('click', this.handleProgressBarClick, this);
69 // Remove the click handler from the
72 beforeDestroy : function() {
73 this.progressBar.el.un('click', this.handleProgressBarClick, this);
81 // This method handles the click for the progress bar
82 handleProgressBarClick : function(e){
83 var parent = this.parent;
84 var displayItem = parent.displayItem;
86 var box = this.progressBar.getBox();
88 var position = xy[0]-box.x;
89 var pages = Math.ceil(parent.store.getTotalCount()/parent.pageSize);
91 var newpage = Math.ceil(position/(displayItem.width/pages));
92 parent.changePage(newpage);
95 // private, overriddes
98 // This method updates the information via the progress bar.
99 updateInfo : function(){
100 if(this.displayItem){
101 var count = this.store.getCount();
102 var pgData = this.getPageData();
103 var pageNum = this.readPage(pgData);
105 var msg = count == 0 ?
109 this.cursor+1, this.cursor+count, this.store.getTotalCount()
112 pageNum = pgData.activePage; ;
114 var pct = pageNum / pgData.pages;
116 this.displayItem.updateProgress(pct, msg, this.animate || this.defaultAnimConfig);
121 Ext.preg('progressbarpager', Ext.ux.ProgressBarPager);