LP#1482400: when activating a PO, provide better progress updates
[working/Evergreen.git] / Open-ILS / web / js / dojo / openils / widget / ProgressDialog.js
1 if(!dojo._hasResource['openils.widget.ProgressDialog']) {
2     dojo.provide('openils.widget.ProgressDialog');
3     dojo.require('dijit.ProgressBar');
4     dojo.require('dijit.Dialog');
5     dojo.require('openils.Util');
6
7     /**
8      * A popup dialog with an embedded progress bar.  imagine that.
9      */
10
11     dojo.declare(
12         'openils.widget.ProgressDialog',
13         [dijit.Dialog],
14         {
15             indeterminate : false,
16             message : '',
17
18             startup : function() {
19                 this.inherited(arguments);
20                 this.progress = new dijit.ProgressBar();
21                 this.progress.startup();
22                 openils.Util.addCSSClass(this.progress.domNode, 'oils-progress-dialog');
23                 this.containerNode.appendChild(this.progress.domNode);
24             },
25
26             update : function() {
27                 this.progress.update.apply(this.progress, arguments);
28             },
29
30             show : function(ind, msg) {
31                 if(ind || this.indeterminate) {
32                     this.progress.indeterminate = true;
33                     this.update();
34                 } else {
35                     this.progress.indeterminate = false;
36                 }
37
38                 if(msg || (msg = this.message) ) {
39                     if(!this.msgDiv) {
40                         this.msgDiv = dojo.create('div', {innerHTML : msg});
41                     }
42                     this.containerNode.insertBefore(this.msgDiv, this.progress.domNode);
43                 } else {
44                     if(this.msgDiv) {
45                         this.containerNode.removeChild(this.msgDiv);
46                         this.msgDiv = null;
47                     }
48                 }
49                     
50                 this.inherited(arguments);
51             },
52
53             update_message : function(msg) {
54                 if(msg || (msg = this.message) ) {
55                     if(!this.msgDiv) {
56                         this.msgDiv = dojo.create('div', {innerHTML : msg});
57                         this.containerNode.insertBefore(this.msgDiv, this.progress.domNode);
58                     } else {
59                         this.msgDiv.innerHTML = msg;
60                     }
61                 } else {
62                     if(this.msgDiv) {
63                         this.containerNode.removeChild(this.msgDiv);
64                         this.msgDiv = null;
65                     }
66                 }
67             }
68         }
69     );
70 }
71