Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js index a4fa400..41fe17f 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js | |||
@@ -1,120 +1,117 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2011 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz's Javascript Crypto Library. | 5 | This file is part of Clipperz Community Edition. |
6 | Javascript Crypto Library provides web developers with an extensive | 6 | Clipperz Community Edition is an online password manager. |
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
11 | refer to http://www.clipperz.com | 8 | refer to http://www.clipperz.com. |
12 | 9 | ||
13 | * Javascript Crypto Library is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
14 | it and/or modify it under the terms of the GNU Affero General Public | 11 | it and/or modify it under the terms of the GNU Affero General Public |
15 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
16 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
17 | 14 | ||
18 | * Javascript Crypto Library is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
21 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
22 | 19 | ||
23 | * You should have received a copy of the GNU Affero General Public | 20 | * You should have received a copy of the GNU Affero General Public |
24 | License along with Javascript Crypto Library. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
25 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
26 | 23 | ||
27 | */ | 24 | */ |
28 | 25 | ||
29 | Clipperz.Base.module('Clipperz.PM.UI.Common.Controllers'); | 26 | Clipperz.Base.module('Clipperz.PM.UI.Common.Controllers'); |
30 | 27 | ||
31 | Clipperz.PM.UI.Common.Controllers.ProgressBarController = function(args) { | 28 | Clipperz.PM.UI.Common.Controllers.ProgressBarController = function(args) { |
32 | args = args || {}; | 29 | args = args || {}; |
33 | 30 | ||
34 | this._numberOfSteps= 0; | 31 | this._numberOfSteps= 0; |
35 | this._currentStep= 0; | 32 | this._currentStep= 0; |
36 | 33 | ||
37 | MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'initProgress', this, 'initProgressHandle'); | 34 | MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'initProgress', this, 'initProgressHandle'); |
38 | MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'updateProgress',this, 'updateProgressHandle'); | 35 | MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'updateProgress',this, 'updateProgressHandle'); |
39 | MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'advanceProgress',this, 'advanceProgressHandle'); | 36 | MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'advanceProgress',this, 'advanceProgressHandle'); |
40 | MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'progressDone', this, 'progressDoneHandle'); | 37 | MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'progressDone', this, 'progressDoneHandle'); |
41 | 38 | ||
42 | return this; | 39 | return this; |
43 | } | 40 | } |
44 | 41 | ||
45 | MochiKit.Base.update(Clipperz.PM.UI.Common.Controllers.ProgressBarController.prototype, { | 42 | MochiKit.Base.update(Clipperz.PM.UI.Common.Controllers.ProgressBarController.prototype, { |
46 | 43 | ||
47 | 'toString': function() { | 44 | 'toString': function() { |
48 | return "Clipperz.PM.UI.Common.Controllers.ProgressBarController"; | 45 | return "Clipperz.PM.UI.Common.Controllers.ProgressBarController"; |
49 | }, | 46 | }, |
50 | 47 | ||
51 | //----------------------------------------------------------------------------- | 48 | //----------------------------------------------------------------------------- |
52 | 49 | ||
53 | 'numberOfSteps': function() { | 50 | 'numberOfSteps': function() { |
54 | return this._numberOfSteps; | 51 | return this._numberOfSteps; |
55 | }, | 52 | }, |
56 | 53 | ||
57 | 'setNumberOfSteps': function (aValue) { | 54 | 'setNumberOfSteps': function (aValue) { |
58 | this._numberOfSteps = aValue; | 55 | this._numberOfSteps = aValue; |
59 | }, | 56 | }, |
60 | 57 | ||
61 | 'updateNumberOfSteps': function (aValue) { | 58 | 'updateNumberOfSteps': function (aValue) { |
62 | this._numberOfSteps += aValue; | 59 | this._numberOfSteps += aValue; |
63 | }, | 60 | }, |
64 | 61 | ||
65 | //----------------------------------------------------------------------------- | 62 | //----------------------------------------------------------------------------- |
66 | 63 | ||
67 | 'currentStep': function() { | 64 | 'currentStep': function() { |
68 | return this._currentStep; | 65 | return this._currentStep; |
69 | }, | 66 | }, |
70 | 67 | ||
71 | 'advanceCurrentStep': function () { | 68 | 'advanceCurrentStep': function () { |
72 | this._currentStep ++; | 69 | this._currentStep ++; |
73 | }, | 70 | }, |
74 | 71 | ||
75 | //----------------------------------------------------------------------------- | 72 | //----------------------------------------------------------------------------- |
76 | 73 | ||
77 | 'completedPercentage': function () { | 74 | 'completedPercentage': function () { |
78 | var result; | 75 | var result; |
79 | //Clipperz.log(">>> completedPercentage" + this.currentStep() + "/" + this.numberOfSteps(), this.currentStep() / this.numberOfSteps()); | 76 | //Clipperz.log(">>> completedPercentage" + this.currentStep() + "/" + this.numberOfSteps(), this.currentStep() / this.numberOfSteps()); |
80 | if (this.numberOfSteps() == 0) { | 77 | if (this.numberOfSteps() == 0) { |
81 | result = 0; | 78 | result = 0; |
82 | } else { | 79 | } else { |
83 | result = (Math.min(100, 100 * (this.currentStep() / this.numberOfSteps()))); | 80 | result = (Math.min(100, 100 * (this.currentStep() / this.numberOfSteps()))); |
84 | } | 81 | } |
85 | //Clipperz.log("<<< completedPercentage", result); | 82 | //Clipperz.log("<<< completedPercentage", result); |
86 | return result; | 83 | return result; |
87 | }, | 84 | }, |
88 | 85 | ||
89 | //----------------------------------------------------------------------------- | 86 | //----------------------------------------------------------------------------- |
90 | 87 | ||
91 | 'resetStatus': function () { | 88 | 'resetStatus': function () { |
92 | this._numberOfSteps= 0; | 89 | this._numberOfSteps= 0; |
93 | this._currentStep= 0; | 90 | this._currentStep= 0; |
94 | }, | 91 | }, |
95 | 92 | ||
96 | //----------------------------------------------------------------------------- | 93 | //----------------------------------------------------------------------------- |
97 | 94 | ||
98 | 'updateProgress': function () { | 95 | 'updateProgress': function () { |
99 | //Clipperz.log(">>> updateProgress: " + this.completedPercentage() + "%"); | 96 | //Clipperz.log(">>> updateProgress: " + this.completedPercentage() + "%"); |
100 | MochiKit.Signal.signal(this, 'updateProgress', this.completedPercentage()); | 97 | MochiKit.Signal.signal(this, 'updateProgress', this.completedPercentage()); |
101 | }, | 98 | }, |
102 | 99 | ||
103 | //============================================================================= | 100 | //============================================================================= |
104 | 101 | ||
105 | 'initProgressHandle': function (anEvent) { | 102 | 'initProgressHandle': function (anEvent) { |
106 | //Clipperz.log(">>> initProgressHandle - steps: " + (anEvent != null ? anEvent['steps'] : 0)); | 103 | //Clipperz.log(">>> initProgressHandle - steps: " + (anEvent != null ? anEvent['steps'] : 0)); |
107 | this.resetStatus(); | 104 | this.resetStatus(); |
108 | if (anEvent != null) { | 105 | if (anEvent != null) { |
109 | this.setNumberOfSteps(anEvent['steps']); | 106 | this.setNumberOfSteps(anEvent['steps']); |
110 | } | 107 | } |
111 | MochiKit.Signal.signal(this, 'initProgress'); | 108 | MochiKit.Signal.signal(this, 'initProgress'); |
112 | this.updateProgress(); | 109 | this.updateProgress(); |
113 | }, | 110 | }, |
114 | 111 | ||
115 | //............................................................................. | 112 | //............................................................................. |
116 | 113 | ||
117 | 'updateProgressHandle': function (anEvent) { | 114 | 'updateProgressHandle': function (anEvent) { |
118 | this.updateNumberOfSteps(anEvent['extraSteps']); | 115 | this.updateNumberOfSteps(anEvent['extraSteps']); |
119 | //Clipperz.log("=== updateProgressHandle - steps: " + this.numberOfSteps() + " (extra " + anEvent['extraSteps'] + ")"); | 116 | //Clipperz.log("=== updateProgressHandle - steps: " + this.numberOfSteps() + " (extra " + anEvent['extraSteps'] + ")"); |
120 | this.updateProgress(); | 117 | this.updateProgress(); |