]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/widgets/ProgressBar.js
removing old opac images and css
[Evergreen.git] / Open-ILS / src / javascript / widgets / ProgressBar.js
1 function ProgressBar(size,interval) {
2
3         if(interval == null) interval = 100;
4         if(size == null) size = 10;
5         this.is_running = false;
6
7         this.size = size;
8         this.interval = interval;
9
10         this.div = createAppElement("div");
11         this.div.className = "progress_bar";
12         this.current    = 0;
13         this.timeoutId;
14
15         this.percentDiv = createAppElement("div");
16         add_css_class(this.percentDiv, "progress_percent");
17
18         var divWidth = parseInt(100 / parseInt(size));
19         for( i = 0; i!= size; i++ ) {
20                 var div = createAppElement("div");
21                 div.className = "progress_bar_chunk";
22                 div.style.width = "" + divWidth + "%";
23                 this.div.appendChild(div);
24         }
25 }
26
27 ProgressBar.prototype.running = function() {
28         return this.is_running;
29 }
30
31 ProgressBar.prototype.getNode = function() {
32         return this.div;
33 }
34
35 ProgressBar.prototype.next = function() {
36         this.manualNext();
37         var obj = this;
38         this.timeoutId = setTimeout( function(){ obj.next(); }, this.interval );
39 }
40
41 ProgressBar.prototype.start = function() {
42         this.is_running = true;
43         this.next();
44 }
45
46 ProgressBar.prototype.stop = function() {
47         this.is_running = false;
48         this.current = this.size;
49         clearTimeout(this.timeoutId);
50         /*
51         for(var i in this.div.childNodes) {
52                 this.div.childNodes[i].className = "progress_bar_chunk_active";
53         }
54         */
55         add_css_class(this.percentDiv, "hide_me");
56         add_css_class(this.div, "progress_bar_done");
57         this.percentDiv.innerHTML = "";
58 }
59
60
61         
62 ProgressBar.prototype.manualNext = function() {
63         if( this.current == this.size ) {
64                 for( var i in this.div.childNodes ) {
65                         if(!this.div.childNodes[i])
66                         this.div.childNodes[i].className = "progress_bar_chunk";
67                 }
68                 this.current = 0;
69         } else {
70                 var node = this.div.childNodes[this.current];
71                 node.className = "progress_bar_chunk_active";
72                 this.current = parseInt(this.current) + 1;
73         }
74
75         this.percentDiv.innerHTML = parseInt((parseInt(this.current) / parseInt(this.size) * 100)) + "%";
76 }