Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/MessageBox.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Components/MessageBox.js | 224 |
1 files changed, 224 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/MessageBox.js b/frontend/beta/js/Clipperz/PM/Components/MessageBox.js new file mode 100644 index 0000000..d2bc09a --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/MessageBox.js | |||
@@ -0,0 +1,224 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
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 | ||
11 | refer to http://www.clipperz.com | ||
12 | |||
13 | * Javascript Crypto Library is free software: you can redistribute | ||
14 | 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 | ||
16 | 3 of the License, or (at your option) any later version. | ||
17 | |||
18 | * Javascript Crypto Library is distributed in the hope that it will | ||
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
21 | See the GNU Affero General Public License for more details. | ||
22 | |||
23 | * You should have received a copy of the GNU Affero General Public | ||
24 | License along with Javascript Crypto Library. If not, see | ||
25 | <http://www.gnu.org/licenses/>. | ||
26 | |||
27 | */ | ||
28 | |||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | |||
33 | |||
34 | |||
35 | Clipperz.PM.Components.MessageBoxImplementation = function() { | ||
36 | this._step = 0; | ||
37 | this._steps = 0; | ||
38 | |||
39 | return this; | ||
40 | }; | ||
41 | |||
42 | //YAHOO.extendX(Clipperz.PM.Components.MessageBoxImplementation, Clipperz.PM.Components.BaseComponent, { | ||
43 | Clipperz.PM.Components.MessageBoxImplementation.prototype = MochiKit.Base.update(null, { | ||
44 | |||
45 | 'toString': function() { | ||
46 | return "Clipperz.PM.Components.MessageBox"; | ||
47 | }, | ||
48 | |||
49 | //----------------------------------------------------- | ||
50 | |||
51 | 'step': function() { | ||
52 | return this._step; | ||
53 | }, | ||
54 | |||
55 | 'setStep': function(aValue) { | ||
56 | if (aValue == 'next') { | ||
57 | this._step = this._step + 1; | ||
58 | } else { | ||
59 | this._step = aValue; | ||
60 | } | ||
61 | |||
62 | if (this._step > this.steps()) { | ||
63 | //MochiKit.Logging.logDebug("overstepping: " + this._step + " (" + this.steps() + ")"); | ||
64 | this._step = this.steps(); | ||
65 | } | ||
66 | }, | ||
67 | |||
68 | //----------------------------------------------------- | ||
69 | |||
70 | 'steps': function() { | ||
71 | return this._steps; | ||
72 | }, | ||
73 | |||
74 | 'setSteps': function(aValue) { | ||
75 | if (aValue.constructor == String) { | ||
76 | if (aValue.charAt(0) == '+') { | ||
77 | this._steps += aValue.substring(1)*1; | ||
78 | } else if (aValue.charAt(0) == '-') { | ||
79 | this._steps -= aValue.substring(1)*1; | ||
80 | } else { | ||
81 | this._steps = aValue.substring(1)*1; | ||
82 | } | ||
83 | } else { | ||
84 | this._steps = aValue; | ||
85 | } | ||
86 | }, | ||
87 | |||
88 | //----------------------------------------------------- | ||
89 | |||
90 | 'deferredShow': function(aConfiguration, anAnimationTargetElement, aValue) { | ||
91 | this.show(aConfiguration, anAnimationTargetElement); | ||
92 | |||
93 | return aValue; | ||
94 | }, | ||
95 | |||
96 | 'show': function(aConfiguration, anAnimationTargetElement) { | ||
97 | varmessageBoxConfiguration; | ||
98 | |||
99 | messageBoxConfiguration = MochiKit.Base.clone(aConfiguration); | ||
100 | messageBoxConfiguration.msg = messageBoxConfiguration.text; | ||
101 | messageBoxConfiguration.animEl = anAnimationTargetElement; | ||
102 | messageBoxConfiguration.progress = messageBoxConfiguration.showProgressBar; | ||
103 | messageBoxConfiguration.closable = messageBoxConfiguration.showCloseButton; | ||
104 | this.setSteps(aConfiguration.steps || 0); | ||
105 | this.setStep(aConfiguration.step || 0); | ||
106 | delete messageBoxConfiguration.buttons; | ||
107 | |||
108 | Clipperz.YUI.MessageBox.show(messageBoxConfiguration); | ||
109 | }, | ||
110 | |||
111 | //----------------------------------------------------- | ||
112 | |||
113 | 'update': function(someValues) { | ||
114 | //MochiKit.Logging.logDebug(">>> MessageBox.update"); | ||
115 | if (someValues.title) { | ||
116 | Clipperz.YUI.MessageBox.getDialog().setTitle(someValues.title); | ||
117 | }; | ||
118 | |||
119 | if (someValues.text) { | ||
120 | Clipperz.YUI.MessageBox.updateText(someValues.text); | ||
121 | }; | ||
122 | |||
123 | if (typeof(someValues.showProgressBar) != 'undefined') { | ||
124 | Clipperz.YUI.MessageBox.progressElement().setDisplayed(someValues.showProgressBar); | ||
125 | Clipperz.YUI.MessageBox.updateProgress(0); | ||
126 | }; | ||
127 | |||
128 | if (typeof(someValues.steps) != 'undefined') { | ||
129 | this.setSteps(someValues.steps); | ||
130 | }; | ||
131 | |||
132 | if (typeof(someValues.step) != 'undefined') { | ||
133 | this.setStep(someValues.step); | ||
134 | } else { | ||
135 | this.setStep('next'); | ||
136 | } | ||
137 | Clipperz.YUI.MessageBox.updateProgress(this.step() / this.steps()); | ||
138 | |||
139 | |||
140 | if (typeof(someValues.fn) != 'undefined') { | ||
141 | Clipperz.YUI.MessageBox.opt().fn = someValues.fn; | ||
142 | }; | ||
143 | |||
144 | if (typeof(someValues.scope) != 'undefined') { | ||
145 | Clipperz.YUI.MessageBox.opt().scope = someValues.scope; | ||
146 | }; | ||
147 | |||
148 | if (someValues.buttons) { | ||
149 | Clipperz.YUI.MessageBox.updateButtons(someValues.buttons); | ||
150 | }; | ||
151 | |||
152 | // if (someValues.title) { | ||
153 | // Clipperz.YUI.MessageBox.getDialog().setTitle(someValues.title + " [" + this.step() + " / " + this.steps() + "]"); | ||
154 | // }; | ||
155 | |||
156 | //MochiKit.Logging.logDebug("--- MessageBox.update - step: " + this.step() + " / " + this.steps() + " - " + someValues.text); | ||
157 | //MochiKit.Logging.logDebug("<<< MessageBox.update"); | ||
158 | }, | ||
159 | |||
160 | //----------------------------------------------------- | ||
161 | |||
162 | 'hide': function(anAnimationTargetElement) { | ||
163 | if (anAnimationTargetElement) { | ||
164 | Clipperz.YUI.MessageBox.getDialog().animateTarget = anAnimationTargetElement; | ||
165 | } | ||
166 | |||
167 | Clipperz.YUI.MessageBox.hide(); | ||
168 | }, | ||
169 | |||
170 | //----------------------------------------------------- | ||
171 | __syntaxFix__: '__syntaxFix__' | ||
172 | }); | ||
173 | |||
174 | |||
175 | //########################################################## | ||
176 | |||
177 | _clipperz_pm_components_messageBox = null; | ||
178 | |||
179 | Clipperz.PM.Components.MessageBox = function() { | ||
180 | if (_clipperz_pm_components_messageBox == null) { | ||
181 | _clipperz_pm_components_messageBox = new Clipperz.PM.Components.MessageBoxImplementation(); | ||
182 | } | ||
183 | |||
184 | return _clipperz_pm_components_messageBox; | ||
185 | } | ||
186 | |||
187 | //--------------------------------------------------------- | ||
188 | |||
189 | Clipperz.PM.Components.MessageBox.showProgressPanel = function(aCallback, anErrback, anActivationItem) { | ||
190 | var deferredResult; | ||
191 | |||
192 | deferredResult = new MochiKit.Async.Deferred(); | ||
193 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.PM.Components.MessageBox.showProgressPanel - 0: " + res); return res;}); | ||
194 | deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), | ||
195 | { | ||
196 | title: "", | ||
197 | text: "", | ||
198 | width:240, | ||
199 | showProgressBar:true, | ||
200 | showCloseButton:false, | ||
201 | fn:MochiKit.Base.method(deferredResult, 'cancel'), | ||
202 | scope:this, | ||
203 | buttons:{ | ||
204 | //'ok':Clipperz.PM.Strings['loginMessagePanelInitialButtonLabel'] | ||
205 | } | ||
206 | }, | ||
207 | anActivationItem | ||
208 | ); | ||
209 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.PM.Components.MessageBox.showProgressPanel - 1: " + res); return res;}); | ||
210 | deferredResult.addCallback(aCallback); | ||
211 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.PM.Components.MessageBox.showProgressPanel - 2: " + res); return res;}); | ||
212 | deferredResult.addCallback(MochiKit.Async.wait, 0.5); | ||
213 | deferredResult.addCallback(function(res) { | ||
214 | Clipperz.PM.Components.MessageBox().hide(YAHOO.ext.Element.get(anActivationItem)); | ||
215 | return res; | ||
216 | }); | ||
217 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.PM.Components.MessageBox.showProgressPanel - 3: " + res); return res;}); | ||
218 | deferredResult.addErrback(anErrback); | ||
219 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.PM.Components.MessageBox.showProgressPanel - 4: " + res); return res;}); | ||
220 | deferredResult.callback(); | ||
221 | |||
222 | return deferredResult; | ||
223 | }; | ||
224 | |||