|
|
|
1 |
/* |
2 |
* Copyright 2012 Univention GmbH |
3 |
* |
4 |
* http://www.univention.de/ |
5 |
* |
6 |
* All rights reserved. |
7 |
* |
8 |
* The source code of this program is made available |
9 |
* under the terms of the GNU Affero General Public License version 3 |
10 |
* (GNU AGPL V3) as published by the Free Software Foundation. |
11 |
* |
12 |
* Binary versions of this program provided by Univention to you as |
13 |
* well as other copyrighted, protected or trademarked materials like |
14 |
* Logos, graphics, fonts, specific documentations and configurations, |
15 |
* cryptographic keys etc. are subject to a license agreement between |
16 |
* you and Univention and not subject to the GNU AGPL V3. |
17 |
* |
18 |
* In the case you use this program under the terms of the GNU AGPL V3, |
19 |
* the program is provided in the hope that it will be useful, |
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 |
* GNU Affero General Public License for more details. |
23 |
* |
24 |
* You should have received a copy of the GNU Affero General Public |
25 |
* License with the Debian GNU/Linux or Univention distribution in file |
26 |
* /usr/share/common-licenses/AGPL-3; if not, see |
27 |
* <http://www.gnu.org/licenses/>. |
28 |
*/ |
29 |
/*global console MyError dojo dojox dijit umc */ |
30 |
|
31 |
dojo.provide("umc.widgets.ProgressInfo"); |
32 |
|
33 |
dojo.require("umc.widgets.ContainerWidget"); |
34 |
|
35 |
dojo.declare("umc.widgets.ProgressInfo", umc.widgets.ContainerWidget, { |
36 |
// summary: |
37 |
// widget used displaying progress information |
38 |
|
39 |
_titleWidget: null, |
40 |
|
41 |
_infoWidget: null, |
42 |
|
43 |
_progressBar: null, |
44 |
|
45 |
maximum: 100, |
46 |
|
47 |
current: 0, |
48 |
|
49 |
uninitialize: function() { |
50 |
this.inherited(arguments); |
51 |
this.destroyRecursive(); |
52 |
}, |
53 |
|
54 |
buildRendering: function() { |
55 |
this.inherited(arguments); |
56 |
|
57 |
// setup a progress bar with some info text |
58 |
this._titleWidget = new umc.widgets.Text( { |
59 |
content: '' |
60 |
} ); |
61 |
this._infoWidget = new umc.widgets.Text( { |
62 |
content: '' |
63 |
} ); |
64 |
this._progressBar = new dijit.ProgressBar({ |
65 |
'class' : 'umcProgressInfo' |
66 |
}); |
67 |
this.addChild( this._titleWidget ); |
68 |
this.addChild( this._progressBar ); |
69 |
this.addChild( this._infoWidget ); |
70 |
|
71 |
this.startup(); |
72 |
}, |
73 |
|
74 |
updateTitle: function( title ) { |
75 |
if ( title !== undefined ) { |
76 |
this._titleWidget.set( 'content', title ); |
77 |
} |
78 |
}, |
79 |
|
80 |
updateInfo: function( information ) { |
81 |
if ( information !== undefined ) { |
82 |
this._infoWidget.set( 'content', information ); |
83 |
} |
84 |
}, |
85 |
|
86 |
update: function( value, information, title ) { |
87 |
if ( value === 0 ) { |
88 |
// initiate the progressbar and start the standby |
89 |
this._progressBar.set( 'maximum', this.maximum ); |
90 |
this._progressBar.set( 'value', 0 ); |
91 |
} else if ( value >= this.maximum || value < 0 ) { |
92 |
// finish the progress bar |
93 |
this._progressBar.set( 'value', this.maximum ); |
94 |
} else { |
95 |
this._progressBar.set( 'value', value ); |
96 |
} |
97 |
this.updateInfo( information ); |
98 |
this.updateTitle( title ); |
99 |
} |
100 |
}); |
101 |
|
102 |
|
103 |
|