3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
19 Ext.onReady(function(){
20 //Please do not use the following runner code as a best practice! :)
21 var Runner = function(){
22 var f = function(v, pbar, btn, count, cb){
25 btn.dom.disabled = false;
29 //give this one a different count style for fun
31 pbar.updateProgress(i, Math.round(100*i)+'% completed...');
33 pbar.updateProgress(v/count, 'Loading item ' + v + ' of '+count+'...');
39 run : function(pbar, btn, count, cb) {
40 btn.dom.disabled = true;
42 for(var i = 1; i < (count+2); i++){
43 setTimeout(f(i, pbar, btn, count, cb), i*ms);
49 //==== Progress bar 1 ====
50 var pbar1 = Ext.create('Ext.ProgressBar', {
51 text:'Initializing...'
54 var btn1 = Ext.get('btn1');
55 btn1.on('click', function() {
56 Ext.fly('p1text').update('Working');
57 if (!pbar1.rendered) {
60 pbar1.text = 'Initializing...';
63 Runner.run(pbar1, Ext.get('btn1'), 10, function() {
65 Ext.fly('p1text').update('Done.').show();
69 //==== Progress bar 2 ====
70 var pbar2 = Ext.create('Ext.ProgressBar', {
77 var btn2 = Ext.get('btn2');
79 btn2.on('click', function() {
80 Runner.run(pbar2, btn2, 12, function() {
82 pbar2.updateText('Done.');
86 //==== Progress bar 3 ====
87 var pbar3 = Ext.create('Ext.ProgressBar', {
93 pbar3.on('update', function(val) {
94 //You can handle this event at each progress interval if
95 //needed to perform some other action
96 Ext.fly('p3text').dom.innerHTML += '.';
99 var btn3 = Ext.get('btn3');
101 btn3.on('click', function(){
102 Ext.fly('p3text').update('Working');
103 btn3.dom.disabled = true;
109 btn3.dom.disabled = false;
110 Ext.fly('p3text').update('Done');
115 //==== Progress bar 4 ====
116 var pbar4 = Ext.create('Ext.ProgressBar', {
117 text:'Waiting on you...',
124 var btn4 = Ext.get('btn4');
126 btn4.on('click', function() {
127 Runner.run(pbar4, btn4, 19, function() {
128 pbar4.updateText('All finished!');