Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/Panels/AccountPanel.js') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Components/Panels/AccountPanel.js | 784 |
1 files changed, 784 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/Panels/AccountPanel.js b/frontend/beta/js/Clipperz/PM/Components/Panels/AccountPanel.js new file mode 100644 index 0000000..6b467d0 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Panels/AccountPanel.js | |||
@@ -0,0 +1,784 @@ | |||
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 | if (typeof(Clipperz.PM.Components.Panels) == 'undefined') { Clipperz.PM.Components.Panels = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Panels.AccountPanel = function(anElement, args) { | ||
37 | //MochiKit.Logging.logDebug(">>> new AccountPanel"); | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.Panels.AccountPanel.superclass.constructor.call(this, anElement, args); | ||
41 | |||
42 | Clipperz.NotificationCenter.register(null, 'setupDone', this, 'render'); | ||
43 | |||
44 | this._shouldLoadLoginHistory = true; | ||
45 | |||
46 | //this.render(); | ||
47 | //MochiKit.Logging.logDebug("<<< new AccountPanel"); | ||
48 | |||
49 | return this; | ||
50 | } | ||
51 | |||
52 | //============================================================================= | ||
53 | |||
54 | YAHOO.extendX(Clipperz.PM.Components.Panels.AccountPanel, Clipperz.PM.Components.Panels.BasePanel, { | ||
55 | |||
56 | 'toString': function() { | ||
57 | return "Clipperz.PM.Components.AccountPanel component"; | ||
58 | }, | ||
59 | |||
60 | //------------------------------------------------------------------------- | ||
61 | |||
62 | 'render': function() { | ||
63 | var errorMessageActor; | ||
64 | varchangePasswordButton; | ||
65 | var deleteAccountButton; | ||
66 | |||
67 | try { | ||
68 | //MochiKit.Logging.logDebug(">>> AccountPanel.render"); | ||
69 | Clipperz.NotificationCenter.unregister(this); | ||
70 | MochiKit.Signal.disconnectAllTo(this); | ||
71 | |||
72 | this.element().update(""); | ||
73 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'table', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
74 | {tag:'tbody', children:[ | ||
75 | {tag:'tr', children:[ | ||
76 | {tag:'td', valign:'top', width:'200', children:[ | ||
77 | {tag:'ul', id:"accountSubMenu", cls:'subMenu', children:[ | ||
78 | {tag:'li', id:'changePassphraseTab', htmlString:Clipperz.PM.Strings['changePasswordTabLabel']}, | ||
79 | {tag:'li', id:'manageOTPTab', htmlString:Clipperz.PM.Strings['manageOTPTabLabel']}, | ||
80 | {tag:'li', id:'accountPreferencesTab', htmlString:Clipperz.PM.Strings['accountPreferencesLabel']}, | ||
81 | {tag:'li', id:'loginHistoryTab', htmlString:Clipperz.PM.Strings['accountLoginHistoryLabel']}, | ||
82 | {tag:'li', id:'deleteAccountTab', htmlString:Clipperz.PM.Strings['deleteAccountTabLabel']} | ||
83 | // {tag:'li', id:'paidAccountTab'), htmlString:Clipperz.PM.Strings['paidAccountTabLabel']} | ||
84 | ]} | ||
85 | ]}, | ||
86 | {tag:'td', valign:'top', children:[ | ||
87 | {tag:'ul', cls:'clipperzTabPanels', children:[ | ||
88 | {tag:'li', id:this.getId('changePassphrasePanel'), children:[ | ||
89 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
90 | {tag:'h5', htmlString:Clipperz.PM.Strings['changePasswordTabTitle']}, | ||
91 | {tag:'div', cls:'panelBody', id:'changePassphraseBlock', children:[ | ||
92 | {tag:'form', id:this.getId('changePassphraseForm'), children:[ | ||
93 | {tag:'h5', cls:'errorMessage', id:this.getId('changePassphrase_errorMessage')}, | ||
94 | {tag:'table', cls:'panelBody', children:[ | ||
95 | {tag:'tr', children:[ | ||
96 | {tag:'td', children:[ | ||
97 | {tag:'span', cls:'formLabel', htmlString:Clipperz.PM.Strings['changePasswordFormUsernameLabel']} | ||
98 | ]}, | ||
99 | {tag:'td', children:[ | ||
100 | {tag:'input', type:'text', name:'username', id:this.getId('changePassphrase_username')} | ||
101 | ]} | ||
102 | ]}, | ||
103 | {tag:'tr', children:[ | ||
104 | {tag:'td', children:[ | ||
105 | {tag:'span', cls:'formLabel', htmlString:Clipperz.PM.Strings['changePasswordFormOldPassphraseLabel']} | ||
106 | ]}, | ||
107 | {tag:'td', children:[ | ||
108 | {tag:'input', type:'password', name:'oldPassphrase', id:this.getId('changePassphrase_oldPassphrase')} | ||
109 | ]} | ||
110 | ]}, | ||
111 | {tag:'tr', children:[ | ||
112 | {tag:'td', children:[ | ||
113 | {tag:'span', cls:'formLabel', htmlString:Clipperz.PM.Strings['changePasswordFormNewPassphraseLabel']} | ||
114 | ]}, | ||
115 | {tag:'td', children:[ | ||
116 | {tag:'input', type:'password', name:'newPassphrase', id:this.getId('changePassphrase_newPassphrase')} | ||
117 | ]} | ||
118 | ]}, | ||
119 | {tag:'tr', children:[ | ||
120 | {tag:'td', children:[ | ||
121 | {tag:'span', cls:'formLabel', htmlString:Clipperz.PM.Strings['changePasswordFormRetypePassphraseLabel']} | ||
122 | ]}, | ||
123 | {tag:'td', children:[ | ||
124 | {tag:'input', type:'password', name:'renewPassphrase', id:this.getId('changePassphrase_renewPassphrase')} | ||
125 | ]} | ||
126 | ]}, | ||
127 | {tag:'tr', children:[ | ||
128 | {tag:'td', align:'right', children:[ | ||
129 | {tag:'input', type:'checkbox', id:this.getId('changePassphrase_safetyCheck')} | ||
130 | ]}, | ||
131 | {tag:'td', children:[ | ||
132 | {tag:'span', htmlString:Clipperz.PM.Strings['changePasswordFormSafetyCheckboxLabel']} | ||
133 | ]} | ||
134 | ]} | ||
135 | ]}, | ||
136 | {tag:'div', cls:'clipperzSubPanelButtonBox', children:[ | ||
137 | {tag:'div', id:this.getId('changePassphraseButton')} | ||
138 | ]} | ||
139 | ]} | ||
140 | ]} | ||
141 | ]} | ||
142 | ]}, | ||
143 | {tag:'li', id:this.getId('manageOTPPanel'), children:[ | ||
144 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
145 | {tag:'h5', htmlString:Clipperz.PM.Strings['manageOTPTabTitle']}, | ||
146 | {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['manageOTPTabDescription']}, | ||
147 | {tag:'div', id:'OTPComponent'} | ||
148 | ]} | ||
149 | ]}, | ||
150 | {tag:'li', id:this.getId('accountPreferencesPanel'), children:[ | ||
151 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
152 | {tag:'h5', htmlString:Clipperz.PM.Strings['accountPreferencesTabTitle']}, | ||
153 | {tag:'div', cls:'panelBody', id:this.getId('preferencesPanelBody')} | ||
154 | ]} | ||
155 | ]}, | ||
156 | {tag:'li', id:this.getId('loginHistoryAccountPanel'), children:[ | ||
157 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
158 | {tag:'h5', htmlString:Clipperz.PM.Strings['loginHistoryTabTitle']}, | ||
159 | {tag:'div', cls:'panelBody', id:'loginHistoryAccountBlock'} | ||
160 | ]} | ||
161 | ]}, | ||
162 | {tag:'li', id:this.getId('deleteAccountPanel'), children:[ | ||
163 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
164 | {tag:'h5', htmlString:Clipperz.PM.Strings['deleteAccountTabTitle']}, | ||
165 | |||
166 | {tag:'div', cls:'panelBody', id:'deleteAccountBlock', children:[ | ||
167 | {tag:'form', id:this.getId('deleteAccountForm'), children:[ | ||
168 | {tag:'h5', cls:'errorMessage', id:this.getId('deleteAccount_errorMessage')}, | ||
169 | {tag:'table', cls:'panelBody', children:[ | ||
170 | {tag:'tr', children:[ | ||
171 | {tag:'td', children:[ | ||
172 | {tag:'span', cls:'formLabel', htmlString:Clipperz.PM.Strings['deleteAccountFormUsernameLabel']} | ||
173 | ]}, | ||
174 | {tag:'td', children:[ | ||
175 | {tag:'input', type:'text', name:'username', id:this.getId('deleteAccount_username')} | ||
176 | ]} | ||
177 | ]}, | ||
178 | {tag:'tr', children:[ | ||
179 | {tag:'td', children:[ | ||
180 | {tag:'span', cls:'formLabel', htmlString:Clipperz.PM.Strings['deleteAccountFormPassphraseLabel']} | ||
181 | ]}, | ||
182 | {tag:'td', children:[ | ||
183 | {tag:'input', type:'password', name:'passphrase', id:this.getId('deleteAccount_passphrase')} | ||
184 | ]} | ||
185 | ]}, | ||
186 | {tag:'tr', children:[ | ||
187 | {tag:'td', align:'right', children:[ | ||
188 | {tag:'input', type:'checkbox', id:this.getId('deleteAccount_safetyCheck')} | ||
189 | ]}, | ||
190 | {tag:'td', children:[ | ||
191 | {tag:'span', htmlString:Clipperz.PM.Strings['deleteAccountFormSafetyCheckboxLabel']} | ||
192 | ]} | ||
193 | ]} | ||
194 | ]}, | ||
195 | {tag:'div', cls:'clipperzSubPanelButtonBox', children:[ | ||
196 | {tag:'div', id:this.getId('deleteAccountButton')} | ||
197 | ]} | ||
198 | ]} | ||
199 | ]} | ||
200 | ]} | ||
201 | ]} | ||
202 | /* | ||
203 | {tag:'li', id:this.getId('paidAccountPanel'), children:[ | ||
204 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
205 | {tag:'h5', htmlString:Clipperz.PM.Strings['upgradeAccountTabTitle']}, | ||
206 | {tag:'div', htmlString:Clipperz.PM.Strings['comingSoon']} | ||
207 | ]} | ||
208 | ]} | ||
209 | */ | ||
210 | ]} | ||
211 | ]} | ||
212 | ]} | ||
213 | ]} | ||
214 | ]}); | ||
215 | |||
216 | //MochiKit.Logging.logDebug("--- AccountPanel.render - 1"); | ||
217 | MochiKit.Signal.connect(this.getId('changePassphraseForm'), 'onkeydown', this, 'onkeydown'); | ||
218 | errorMessageActor = this.getActor('changePassphrase_errorMessage'); | ||
219 | errorMessageActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
220 | errorMessageActor.update("---"); | ||
221 | errorMessageActor.hide(); | ||
222 | changePasswordButton = new YAHOO.ext.Button(this.getDom('changePassphraseButton'), {text:Clipperz.PM.Strings['changePasswordFormSubmitLabel'], handler:this.doChangePassphrase, scope:this}); | ||
223 | |||
224 | //MochiKit.Logging.logDebug("--- AccountPanel.render - 2"); | ||
225 | |||
226 | MochiKit.Signal.connect(this.getId('deleteAccountForm'), 'onkeydown', this, 'onkeydown'); | ||
227 | errorMessageActor = this.getActor('deleteAccount_errorMessage'); | ||
228 | errorMessageActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
229 | errorMessageActor.update(Clipperz.PM.Strings['deleteAccountFormEmptyErrorMessage']); | ||
230 | errorMessageActor.hide(); | ||
231 | deleteAccountButton = new YAHOO.ext.Button(this.getDom('deleteAccountButton'), {text:Clipperz.PM.Strings['deleteAccountFormSubmitLabel'], handler:this.doDeleteAccount, scope:this}); | ||
232 | //MochiKit.Logging.logDebug("--- AccountPanel.render - 5"); | ||
233 | |||
234 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { | ||
235 | this.getElement('changePassphraseForm').addClass('read-only'); | ||
236 | // this.getElement('accountPreferencesForm').addClass('read-only'); | ||
237 | this.getElement('deleteAccountForm').addClass('read-only'); | ||
238 | changePasswordButton.disable(); | ||
239 | deleteAccountButton.disable(); | ||
240 | } | ||
241 | //MochiKit.Logging.logDebug("--- AccountPanel.render - 6"); | ||
242 | |||
243 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('changePassphrase_oldPassphrase')); | ||
244 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('changePassphrase_newPassphrase')); | ||
245 | |||
246 | new Clipperz.PM.Components.OTP.MainComponent(YAHOO.ext.Element.get('OTPComponent'), {user:this.user()}); | ||
247 | |||
248 | this.tabPanelController().setUp(); | ||
249 | Clipperz.NotificationCenter.register(null, 'tabSelected', this, 'tabSelectedHandler'); | ||
250 | Clipperz.NotificationCenter.register(null, 'updatedPreferences', this, 'renderPreferences'); | ||
251 | Clipperz.NotificationCenter.register(null, 'switchLanguage', this, 'switchLanguageHandler'); | ||
252 | //MochiKit.Logging.logDebug("<<< AccountPanel.render"); | ||
253 | |||
254 | } catch(exception) { | ||
255 | MochiKit.Logging.logError("### " + exception); | ||
256 | throw exception; | ||
257 | } | ||
258 | }, | ||
259 | |||
260 | //------------------------------------------------------------------------- | ||
261 | |||
262 | 'tabPanelController': function() { | ||
263 | if (this._tabPanelController == null) { | ||
264 | var tabPanelControllerConfig; | ||
265 | |||
266 | tabPanelControllerConfig = {} | ||
267 | tabPanelControllerConfig['changePassphraseTab'] = this.getId('changePassphrasePanel'); | ||
268 | tabPanelControllerConfig['manageOTPTab'] = this.getId('manageOTPPanel'); | ||
269 | tabPanelControllerConfig['accountPreferencesTab'] = this.getId('accountPreferencesPanel'); | ||
270 | tabPanelControllerConfig['loginHistoryTab'] = this.getId('loginHistoryAccountPanel'); | ||
271 | tabPanelControllerConfig['deleteAccountTab'] = this.getId('deleteAccountPanel'); | ||
272 | // tabPanelControllerConfig['paidAccountTab'] = this.getId('paidAccountPanel'); | ||
273 | |||
274 | this._tabPanelController = new Clipperz.PM.Components.TabPanel.TabPanelController({ | ||
275 | name:'accountTabPanel', | ||
276 | config:tabPanelControllerConfig, | ||
277 | selectedTab:'changePassphraseTab' | ||
278 | }); | ||
279 | } | ||
280 | |||
281 | return this._tabPanelController; | ||
282 | }, | ||
283 | |||
284 | //------------------------------------------------------------------------- | ||
285 | |||
286 | 'doChangePassphrase': function() { | ||
287 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly() == false) { | ||
288 | varusername; | ||
289 | varoldPassphrase; | ||
290 | var newPassphrase; | ||
291 | var renewPassphrase; | ||
292 | var safetyCheck; | ||
293 | varareThereAnyErrors; | ||
294 | var errorMessageActor; | ||
295 | |||
296 | errorMessageActor = this.getActor('changePassphrase_errorMessage'); | ||
297 | |||
298 | areThereAnyErrors = false; | ||
299 | username = this.getDom('changePassphrase_username').value; | ||
300 | oldPassphrase= this.getDom('changePassphrase_oldPassphrase').value; | ||
301 | newPassphrase= this.getDom('changePassphrase_newPassphrase').value; | ||
302 | renewPassphrase= this.getDom('changePassphrase_renewPassphrase').value; | ||
303 | safetyCheck = this.getDom('changePassphrase_safetyCheck').checked; | ||
304 | |||
305 | if (this.user().username() != username) { | ||
306 | this.showFormErrorMessageAnimation(errorMessageActor, Clipperz.PM.Strings['changePasswordFormWrongUsernameWarning']); | ||
307 | this.getElement('changePassphrase_username').focus().dom.select(); | ||
308 | areThereAnyErrors = true; | ||
309 | } else if (this.user().passphrase() != oldPassphrase) { | ||
310 | this.showFormErrorMessageAnimation(errorMessageActor, Clipperz.PM.Strings['changePasswordFormWrongPassphraseWarning']); | ||
311 | this.getElement('changePassphrase_oldPassphrase').focus().dom.select(); | ||
312 | areThereAnyErrors = true; | ||
313 | } else if (newPassphrase != renewPassphrase) { | ||
314 | this.showFormErrorMessageAnimation(errorMessageActor, Clipperz.PM.Strings['changePasswordFormWrongRetypePassphraseWarning']); | ||
315 | this.getElement('changePassphrase_renewPassphrase').focus().dom.select(); | ||
316 | areThereAnyErrors = true; | ||
317 | } else if (safetyCheck != true) { | ||
318 | this.showFormErrorMessageAnimation(errorMessageActor, Clipperz.PM.Strings['changePasswordFormSafetyCheckWarning']); | ||
319 | this.getElement('changePassphrase_safetyCheck').focus(); | ||
320 | areThereAnyErrors = true; | ||
321 | } | ||
322 | |||
323 | if (areThereAnyErrors == false) { | ||
324 | errorMessageActor.hide(); | ||
325 | this.doChangePassphraseWithUsernameAndPassphrase(username, newPassphrase); | ||
326 | } | ||
327 | } | ||
328 | }, | ||
329 | |||
330 | //------------------------------------------------------------------------- | ||
331 | |||
332 | 'doChangePassphraseWithUsernameAndPassphrase': function(anUsername, aPassphrase) { | ||
333 | var deferredResult; | ||
334 | |||
335 | //MochiKit.Logging.logDebug(">>> AccountPanel.doChangePassphraseWithUsernameAndPassphrase - this.user: " + this.user()); | ||
336 | deferredResult = new MochiKit.Async.Deferred(); | ||
337 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug(" AccountPanel.doChangePassphraseWithUsernameAndPassphrase 1: " + res); return res;}); | ||
338 | deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), | ||
339 | { | ||
340 | title:Clipperz.PM.Strings['changePasswordFormProgressDialogTitle'], | ||
341 | text:Clipperz.PM.Strings['changePasswordFormProgressDialogEmptyText'], | ||
342 | width:240, | ||
343 | showProgressBar:true, | ||
344 | showCloseButton:false, | ||
345 | steps:4 | ||
346 | }, | ||
347 | this.getDom('changePassphraseButton') | ||
348 | ); | ||
349 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug(" AccountPanel.doChangePassphraseWithUsernameAndPassphrase 2: " + res); return res;}); | ||
350 | deferredResult.addCallback(MochiKit.Base.method(this.user(), 'changeCredentials'), anUsername, aPassphrase); | ||
351 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug(" AccountPanel.doChangePassphraseWithUsernameAndPassphrase 3: " + res); return res;}); | ||
352 | deferredResult.addCallback(function() { | ||
353 | Clipperz.PM.Components.MessageBox().update({ | ||
354 | title:Clipperz.PM.Strings['changePasswordFormProgressDialogConnectedMessageTitle'], | ||
355 | text:Clipperz.PM.Strings['changePasswordFormProgressDialogConnectedMessageText'], | ||
356 | /*showProgressBar:false,*/ | ||
357 | step:'next' | ||
358 | }); | ||
359 | }); | ||
360 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug(" AccountPanel.doChangePassphraseWithUsernameAndPassphrase 4: " + res); return res;}); | ||
361 | deferredResult.addCallback(MochiKit.Async.wait, 1); | ||
362 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug(" AccountPanel.doChangePassphraseWithUsernameAndPassphrase 5: " + res); return res;}); | ||
363 | deferredResult.addCallback(function(anAccountPanel, res) { | ||
364 | Clipperz.PM.Components.MessageBox().hide(YAHOO.ext.Element.get('main')); | ||
365 | |||
366 | anAccountPanel.getDom('changePassphrase_username').value = ""; | ||
367 | anAccountPanel.getDom('changePassphrase_oldPassphrase').value = ""; | ||
368 | anAccountPanel.getElement('changePassphrase_oldPassphrase').focus(); | ||
369 | anAccountPanel.getDom('changePassphrase_newPassphrase').value = ""; | ||
370 | anAccountPanel.getElement('changePassphrase_newPassphrase').focus(); | ||
371 | anAccountPanel.getDom('changePassphrase_renewPassphrase').value = ""; | ||
372 | anAccountPanel.getDom('changePassphrase_safetyCheck').checked = false; | ||
373 | |||
374 | anAccountPanel.getElement('changePassphrase_username').focus(); | ||
375 | return res; | ||
376 | }, this); | ||
377 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug(" AccountPanel.doChangePassphraseWithUsernameAndPassphrase 6: " + res); return res;}); | ||
378 | deferredResult.addErrback(function() { | ||
379 | Clipperz.PM.Components.MessageBox().update({ | ||
380 | title:Clipperz.PM.Strings['changePasswordFormProgressDialogErrorMessageTitle'], | ||
381 | text:Clipperz.PM.Strings['changePasswordFormProgressDialogErrorMessageText'], | ||
382 | buttons:{'ok':"close"} | ||
383 | }); | ||
384 | }); | ||
385 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug(" AccountPanel.doChangePassphraseWithUsernameAndPassphrase 7: " + res); return res;}); | ||
386 | deferredResult.callback(); | ||
387 | |||
388 | //MochiKit.Logging.logDebug("<<< AccountPanel.doChangePassphraseWithUsernameAndPassphrase"); | ||
389 | }, | ||
390 | |||
391 | //------------------------------------------------------------------------- | ||
392 | |||
393 | 'doDeleteAccount': function() { | ||
394 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly() == false) { | ||
395 | varusername; | ||
396 | varpassphrase; | ||
397 | var safetyCheck; | ||
398 | varareThereAnyErrors; | ||
399 | var errorMessageActor; | ||
400 | |||
401 | errorMessageActor = this.getActor('deleteAccount_errorMessage'); | ||
402 | |||
403 | areThereAnyErrors = false; | ||
404 | username = this.getDom('deleteAccount_username').value; | ||
405 | passphrase= this.getDom('deleteAccount_passphrase').value; | ||
406 | safetyCheck = this.getDom('deleteAccount_safetyCheck').checked; | ||
407 | |||
408 | if (this.user().username() != username) { | ||
409 | this.showFormErrorMessageAnimation(errorMessageActor, Clipperz.PM.Strings['deleteAccountFormWrongUsernameWarning']); | ||
410 | this.getElement('deleteAccount_username').focus().dom.select(); | ||
411 | areThereAnyErrors = true; | ||
412 | } else if (this.user().passphrase() != passphrase) { | ||
413 | this.showFormErrorMessageAnimation(errorMessageActor, Clipperz.PM.Strings['deleteAccountFormWrongPassphraseWarning']); | ||
414 | this.getElement('deleteAccount_passphrase').focus().dom.select(); | ||
415 | areThereAnyErrors = true; | ||
416 | } else if (safetyCheck != true) { | ||
417 | this.showFormErrorMessageAnimation(errorMessageActor, Clipperz.PM.Strings['deleteAccountFormSafetyCheckWarning']); | ||
418 | this.getElement('deleteAccount_safetyCheck').focus(); | ||
419 | areThereAnyErrors = true; | ||
420 | } | ||
421 | |||
422 | if (areThereAnyErrors == false) { | ||
423 | var deferred; | ||
424 | |||
425 | deferred = new MochiKit.Async.Deferred(); | ||
426 | errorMessageActor.hide(); | ||
427 | |||
428 | deferred.addCallback(function() { | ||
429 | var deferredResult; | ||
430 | |||
431 | //TODO: if the form is submitted with the return key, the confirmation dialog is skipped!? | ||
432 | deferredResult = new MochiKit.Async.Deferred(); | ||
433 | Clipperz.PM.Components.MessageBox().deferredShow({ | ||
434 | title:Clipperz.PM.Strings['accountPanelDeletingAccountPanelConfirmationTitle'], | ||
435 | text:Clipperz.PM.Strings['accountPanelDeleteAccountPanelConfirmationText'], | ||
436 | width:240, | ||
437 | showProgressBar:false, | ||
438 | showCloseButton:false, | ||
439 | buttons:{ | ||
440 | 'yes':Clipperz.PM.Strings['accountPanelDeleteAccountPanelConfirmButtonLabel'], | ||
441 | 'no':Clipperz.PM.Strings['accountPanelDeleteAccountPanelDenyButtonLabel'] | ||
442 | }, | ||
443 | fn:MochiKit.Base.partial(function(aDeferred, aResult) { | ||
444 | if (aResult == 'yes') { | ||
445 | aDeferred.callback(aResult); | ||
446 | } else { | ||
447 | aDeferred.errback(aResult); | ||
448 | } | ||
449 | }, deferredResult) | ||
450 | }); | ||
451 | |||
452 | return deferredResult; | ||
453 | }); | ||
454 | deferred.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), | ||
455 | { | ||
456 | title:Clipperz.PM.Strings['accountPanelDeletingAccountPanelProgressTitle'], | ||
457 | text:Clipperz.PM.Strings['accountPanelDeletingAccountPanelProgressText'], | ||
458 | width:240, | ||
459 | showProgressBar:true, | ||
460 | showCloseButton:false | ||
461 | } | ||
462 | ); | ||
463 | deferred.addCallback(MochiKit.Base.method(this.user(), 'deleteAccountAction')); | ||
464 | deferred.addCallback(Clipperz.PM.exit, 'accountDeleted.html'); | ||
465 | deferred.addErrback(function(res) { | ||
466 | alert(res); | ||
467 | }) | ||
468 | deferred.callback(); | ||
469 | } | ||
470 | } | ||
471 | }, | ||
472 | |||
473 | //------------------------------------------------------------------------- | ||
474 | |||
475 | 'showFormErrorMessageAnimation': function(anActor, anErrorMessage, aCallback) { | ||
476 | anActor.update(anErrorMessage); | ||
477 | anActor.show(true); | ||
478 | anActor.play(aCallback); | ||
479 | }, | ||
480 | |||
481 | //------------------------------------------------------------------------- | ||
482 | |||
483 | 'onkeydown': function(anEvent) { | ||
484 | //MochiKit.Logging.logDebug(">>> onkeydown - " + anEvent.src().id); | ||
485 | if (anEvent.key().code == 13) { | ||
486 | anEvent.stop(); | ||
487 | |||
488 | if (anEvent.src() == this.getDom('changePassphraseForm')) { | ||
489 | this.doChangePassphrase(); | ||
490 | } else if (anEvent.src() == this.getDom('deleteAccountForm')) { | ||
491 | this.doDeleteAccount(); | ||
492 | } else { | ||
493 | } | ||
494 | |||
495 | } | ||
496 | }, | ||
497 | |||
498 | //------------------------------------------------------------------------- | ||
499 | |||
500 | 'selectSelectedLanguageOption': function() { | ||
501 | varuserSelectedLanguage; | ||
502 | |||
503 | userSelectedLanguage = this.user().preferences().preferredLanguage() || "default"; | ||
504 | MochiKit.Base.filter(function(anOption) {return (anOption.value == userSelectedLanguage)}, this.getDom('languageSelector').childNodes)[0].selected = true; | ||
505 | }, | ||
506 | |||
507 | //------------------------------------------------------------------------- | ||
508 | |||
509 | 'doSaveUserPreferences': function() { | ||
510 | var selectedLanguage; | ||
511 | var showDonationReminderDialog; | ||
512 | // var disableUnsecureFaviconLoadingForIE; | ||
513 | |||
514 | //MochiKit.Logging.logDebug(">>> AccountPanel.doSaveUserPreferences"); | ||
515 | selectedLanguage = this.getDom('languageSelector').value; | ||
516 | if (selectedLanguage == "default") { | ||
517 | selectedLanguage = null; | ||
518 | } | ||
519 | this.user().preferences().setPreferredLanguage(selectedLanguage); | ||
520 | |||
521 | showDonationReminderDialog = this.getDom('showDonationReminderCheckbox').checked; | ||
522 | this.user().preferences().setShouldShowDonationPanel(showDonationReminderDialog); | ||
523 | |||
524 | // disableUnsecureFaviconLoadingForIE = this.getDom('disableFaviconForIECheckbox').checked; | ||
525 | // this.user().preferences().setDisableUnsecureFaviconLoadingForIE(disableUnsecureFaviconLoadingForIE); | ||
526 | |||
527 | this.user().preferences().saveChanges(this.getDom('saveUserPreferences')); | ||
528 | }, | ||
529 | |||
530 | 'doCancelUserPreferences': function() { | ||
531 | this.renderPreferences(); | ||
532 | }, | ||
533 | |||
534 | //'switchLanguage': function(anEvent) { | ||
535 | // Clipperz.PM.Strings.Languages.setSelectedLanguage(anEvent.src().value); | ||
536 | //}, | ||
537 | |||
538 | //------------------------------------------------------------------------- | ||
539 | |||
540 | 'renderLoginHistory': function() { | ||
541 | var element; | ||
542 | |||
543 | //MochiKit.Logging.logDebug(">>> AccountPanel.renderLoginHistory"); | ||
544 | element = YAHOO.ext.Element.get('loginHistoryAccountBlock'); | ||
545 | |||
546 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { | ||
547 | element.update(""); | ||
548 | this.domHelper().append(element, {tag:'div', cls:'loginHistoryReadOnlyMessage', htmlString:Clipperz.PM.Strings['loginHistoryReadOnlyMessage']}); | ||
549 | } else { | ||
550 | var deferredResult; | ||
551 | |||
552 | deferredResult = new MochiKit.Async.Deferred(); | ||
553 | deferredResult.addCallback(MochiKit.Base.bind(function(anElement) { | ||
554 | anElement.update(""); | ||
555 | Clipperz.YUI.DomHelper.append(anElement, {tag:'div', cls:'loadingMessage', htmlString:Clipperz.PM.Strings['loginHistoryLoadingMessage']}); | ||
556 | }, this), element); | ||
557 | deferredResult.addCallback(MochiKit.Base.method(this.user(), 'loadLoginHistory')); | ||
558 | deferredResult.addCallback(MochiKit.Base.bind(function(anElement, aResult) { | ||
559 | var loginListItems; | ||
560 | var tBodyElement; | ||
561 | var imageExtension; | ||
562 | var now; | ||
563 | var i, c; | ||
564 | |||
565 | loginListItems = aResult; | ||
566 | //MochiKit.Logging.logDebug("=== loginListItems: " + Clipperz.Base.serializeJSON(loginListItems)); | ||
567 | imageExtension = (Clipperz_IEisBroken == true) ? 'gif': 'png'; | ||
568 | |||
569 | now = new Date(); | ||
570 | anElement.update(""); | ||
571 | Clipperz.YUI.DomHelper.append(anElement, {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['loginHistoryLoadedMessage']}); | ||
572 | Clipperz.YUI.DomHelper.append(anElement, {tag:'table', id:'loginHistoryTable', cellspacing:'0', cellpadding:'2', border:'0', children:[ | ||
573 | {tag:'tbody', id:this.getId('loginHistoryTBody'), children:[]} | ||
574 | ]}); | ||
575 | //# Clipperz.YUI.DomHelper.append(anElement, {tag:'div', id:'loginHistoryFooter', children:[ | ||
576 | Clipperz.YUI.DomHelper.append(anElement, {tag:'div', cls:'clipperzSubPanelButtonBox', children:[ | ||
577 | {tag:'div', id:this.getId('reloadHistoryButton')} | ||
578 | ]}); | ||
579 | |||
580 | new YAHOO.ext.Button(this.getDom('reloadHistoryButton'), {text:Clipperz.PM.Strings['loginHistoryReloadButtonLabel'], handler:this.reloadHistory, scope:this}); | ||
581 | |||
582 | tBodyElement = this.getElement('loginHistoryTBody'); | ||
583 | c = loginListItems.length; | ||
584 | for (i=0; i<c; i++) { | ||
585 | var ip; | ||
586 | var date; | ||
587 | var mainText; | ||
588 | |||
589 | date = Clipperz.PM.Date.parseDateWithUTCFormat(loginListItems[i]['date']); | ||
590 | |||
591 | if (loginListItems[i]['isCurrent'] === true) { | ||
592 | mainText ={tag:'div', cls:'currentSession', htmlString:Clipperz.PM.Strings['loginHistoryCurrentSessionText']} | ||
593 | } else { | ||
594 | mainText = {tag:'div', cls:'elapsedTime', html:Clipperz.PM.Date.getElapsedTimeDescription(date)} | ||
595 | } | ||
596 | |||
597 | if (loginListItems[i]['connectionType'] == "ONE_TIME_PASSPHRASE") { | ||
598 | optionalInfo = [ | ||
599 | {tag:'span', html:"OTP"} | ||
600 | ]; | ||
601 | } else { | ||
602 | optionalInfo = []; | ||
603 | } | ||
604 | |||
605 | ip = (loginListItems[i]['ip'].match(/^\d{1,3}(.\d{1,3}){3}$/)) ? loginListItems[i]['ip'] : Clipperz.PM.Strings['unknown_ip']; | ||
606 | Clipperz.YUI.DomHelper.append(tBodyElement, {tag:'tr', children:[ | ||
607 | {tag:'td', cls:'loginHistoryValues', valign:'top', children:[ | ||
608 | mainText, | ||
609 | {tag:'div', cls:'fullDate', html:Clipperz.PM.Date.formatDateWithTemplate(date, Clipperz.PM.Strings['fullDate_format'])}, | ||
610 | {tag:'div', cls:'loginHistoryIP', children:[ | ||
611 | {tag:'span', cls:'loginHistoryIPLabel', htmlString:Clipperz.PM.Strings['loginHistoryIPLabel']}, | ||
612 | {tag:'span', cls:'loginHistoryIPValue', html:ip} | ||
613 | ]} | ||
614 | ]}, | ||
615 | {tag:'td', cls:'loginHistoryCountry', valign:'top', children:optionalInfo}, | ||
616 | {tag:'td', cls:'loginHistoryCountry', valign:'top', align:'center', children:[ | ||
617 | {tag:'img', title:Clipperz.PM.Strings['countries'][loginListItems[i]['country']], cls:'flag', src:Clipperz.PM.Strings['icons_baseUrl'] + "/flags/" + loginListItems[i]['country'].toLowerCase() + "." + imageExtension, width:'32', height:'32'} | ||
618 | // {tag:'span', cls:'label', htmlString:Clipperz.PM.Strings['countries'][loginListItems[i]['country']]} | ||
619 | ]}, | ||
620 | {tag:'td', cls:'loginHistoryBrowser', valign:'top', align:'center', children:[ | ||
621 | {tag:'img', title:Clipperz.PM.Strings['browsers'][loginListItems[i]['browser']], cls:'browser', src:Clipperz.PM.Strings['icons_baseUrl'] + "/browsers/" + loginListItems[i]['browser'].toLowerCase() + "." + imageExtension, width:'32', height:'32'} | ||
622 | // {tag:'span', cls:'label', htmlString:Clipperz.PM.Strings['browsers'][loginListItems[i]['browser']]} | ||
623 | ]}, | ||
624 | {tag:'td', cls:'loginHistoryOperatingSystem', valign:'top', align:'center', children:[ | ||
625 | {tag:'img', title:Clipperz.PM.Strings['operatingSystems'][loginListItems[i]['operatingSystem']], cls:'operatingSystem', src:Clipperz.PM.Strings['icons_baseUrl'] + "/operatingSystems/" + loginListItems[i]['operatingSystem'].toLowerCase() + "." + imageExtension, width:'32', height:'32'} | ||
626 | // {tag:'span', cls:'label', htmlString:Clipperz.PM.Strings['operatingSystems'][loginListItems[i]['operatingSystem']]} | ||
627 | ]} | ||
628 | ]}); | ||
629 | } | ||
630 | |||
631 | Clipperz.Style.applyZebraStylesToTable('loginHistoryTable'); | ||
632 | }, this), element); | ||
633 | |||
634 | deferredResult.callback(); | ||
635 | } | ||
636 | //MochiKit.Logging.logDebug("<<< AccountPanel.renderLoginHistory"); | ||
637 | }, | ||
638 | |||
639 | //------------------------------------------------------------------------- | ||
640 | |||
641 | 'renderPreferences': function() { | ||
642 | var saveUserPreferencesButton; | ||
643 | var cancelUserPreferencesButton; | ||
644 | var preferencedPanelBodyElement; | ||
645 | |||
646 | preferencedPanelBodyElement = this.getElement('preferencesPanelBody'); | ||
647 | |||
648 | preferencedPanelBodyElement.update(""); | ||
649 | Clipperz.YUI.DomHelper.append(preferencedPanelBodyElement, | ||
650 | {tag:'form', id:this.getId('accountPreferencesForm'), children:[ | ||
651 | {tag:'table', cls:'panelBody', children:[ | ||
652 | {tag:'tr', cls:'openPreferenceBlock', children:[ | ||
653 | {tag:'td', children:[ | ||
654 | {tag:'div', cls:'preferenceBlockTitle', htmlString:Clipperz.PM.Strings['accountPreferencesLanguageTitle']}, | ||
655 | {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['accountPreferencesLanguageDescription']}, | ||
656 | {tag:'div', cls:'panelDescription', children:[ | ||
657 | {tag:'select', | ||
658 | id:this.getId('languageSelector'), | ||
659 | children:MochiKit.Base.concat([{tag:'option', value:"default", html:"---"}], Clipperz.PM.Strings['loginPanelSwitchLanguageSelectOptions']) | ||
660 | } | ||
661 | ]} | ||
662 | ]} | ||
663 | ]}, | ||
664 | {tag:'tr', cls:'openPreferenceBlock', children:[ | ||
665 | {tag:'td', children:[ | ||
666 | {tag:'div', cls:'preferenceBlockTitle', htmlString:Clipperz.PM.Strings['showDonationReminderPanelTitle']}, | ||
667 | {tag:'table', cellpadding:'0', cellspacing:'0', children:[ | ||
668 | {tag:'tbody', children:[ | ||
669 | {tag:'tr', children:[ | ||
670 | {tag:'td', valign:'top', children:[ | ||
671 | {tag:'div', cls:'panelDescription', children:[ | ||
672 | {tag:'input', type:'checkbox', id:this.getId('showDonationReminderCheckbox')} | ||
673 | ]} | ||
674 | ]}, | ||
675 | {tag:'td', valign:'top', children:[ | ||
676 | {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['showDonationReminderPanelDescription']} | ||
677 | ]} | ||
678 | ]} | ||
679 | ]} | ||
680 | ]} | ||
681 | ]} | ||
682 | ]}//, | ||
683 | /* | ||
684 | {tag:'tr', cls:'openPreferenceBlock', children:[ | ||
685 | {tag:'td', children:[ | ||
686 | {tag:'div', cls:'preferenceBlockTitle', htmlString:Clipperz.PM.Strings['disableFaviconForIETitle']}, | ||
687 | {tag:'table', cellpadding:'0', cellspacing:'0', children:[ | ||
688 | {tag:'tbody', children:[ | ||
689 | {tag:'tr', children:[ | ||
690 | {tag:'td', valign:'top', children:[ | ||
691 | {tag:'div', cls:'panelDescription', children:[ | ||
692 | {tag:'input', type:'checkbox', id:this.getId('disableFaviconForIECheckbox')} | ||
693 | ]} | ||
694 | ]}, | ||
695 | {tag:'td', valign:'top', children:[ | ||
696 | {tag:'div', cls:'panelDescription', children:Clipperz.PM.Strings['disableFaviconForIEDescriptionConfig']} | ||
697 | ]} | ||
698 | ]} | ||
699 | ]} | ||
700 | ]} | ||
701 | ]} | ||
702 | ]}, | ||
703 | */ | ||
704 | // {tag:'tr', cls:'openPreferenceBlock', children:[ | ||
705 | // {tag:'td', children:[ | ||
706 | // {tag:'div', cls:'preferenceBlockTitle', htmlString:Clipperz.PM.Strings['accountPreferencesInterfaceTitle']}, | ||
707 | // {tag:'div', cls:'panelDescription', children:Clipperz.PM.Strings['accountPreferencesInterfaceDescriptionConfig']} | ||
708 | // ]} | ||
709 | // ]} | ||
710 | ]}, | ||
711 | {tag:'div', cls:'clipperzSubPanelButtonBox', children:[ | ||
712 | {tag:'table', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
713 | {tag:'tbody', children:[ | ||
714 | {tag:'tr', children:[ | ||
715 | {tag:'td', width:'100', align:'right', cls:'newRecordPanelButtonTD', children:[ | ||
716 | {tag:'div', id:this.getId('saveUserPreferences')} | ||
717 | ]}, | ||
718 | {tag:'td', width:'10', html:" "}, | ||
719 | {tag:'td', cls:'newRecordPanelButtonTD', children:[ | ||
720 | {tag:'div', id:this.getId('cancelUserPreferences')} | ||
721 | ]} | ||
722 | ]} | ||
723 | ]} | ||
724 | ]} | ||
725 | ]} | ||
726 | ]} | ||
727 | ); | ||
728 | |||
729 | this.selectSelectedLanguageOption(); | ||
730 | if (this.user().preferences().shouldShowDonationPanel()) { | ||
731 | this.getDom('showDonationReminderCheckbox').checked = true; | ||
732 | } | ||
733 | // if (this.user().preferences().disableUnsecureFaviconLoadingForIE()) { | ||
734 | // this.getDom('disableFaviconForIECheckbox').checked = true; | ||
735 | // } | ||
736 | |||
737 | //MochiKit.Logging.logDebug("--- AccountPanel.render - 3"); | ||
738 | //# saveUserPreferencesButton = new YAHOO.ext.Button(this.getDom('saveUserPreferences'), {text:Clipperz.PM.Strings['saveUserPreferencesFormSubmitLabel'], handler:this.doSaveUserPreferences, scope:this}); | ||
739 | saveUserPreferencesButton = new YAHOO.ext.Button(this.getDom('saveUserPreferences'), {text:'-----------------', handler:this.doSaveUserPreferences, scope:this}); | ||
740 | saveUserPreferencesButton.setText(Clipperz.PM.Strings['saveUserPreferencesFormSubmitLabel']); | ||
741 | //# cancelUserPreferencesButton = new YAHOO.ext.Button(this.getDom('cancelUserPreferences'), {text:Clipperz.PM.Strings['cancelUserPreferencesFormSubmitLabel'], handler:this.doCancelUserPreferences, scope:this}); | ||
742 | cancelUserPreferencesButton = new YAHOO.ext.Button(this.getDom('cancelUserPreferences'), {text:'-----------------', handler:this.doCancelUserPreferences, scope:this}); | ||
743 | cancelUserPreferencesButton.setText(Clipperz.PM.Strings['cancelUserPreferencesFormSubmitLabel']); | ||
744 | //MochiKit.Logging.logDebug("--- AccountPanel.render - 4"); | ||
745 | |||
746 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { | ||
747 | this.getElement('accountPreferencesForm').addClass('read-only'); | ||
748 | saveUserPreferencesButton.disable(); | ||
749 | cancelUserPreferencesButton.disable(); | ||
750 | } | ||
751 | |||
752 | }, | ||
753 | |||
754 | //------------------------------------------------------------------------- | ||
755 | |||
756 | 'reloadHistory': function() { | ||
757 | this.setShouldLoadLoginHistory(true); | ||
758 | this.renderLoginHistory(); | ||
759 | }, | ||
760 | |||
761 | 'shouldLoadLoginHistory': function() { | ||
762 | return this._shouldLoadLoginHistory; | ||
763 | }, | ||
764 | |||
765 | 'setShouldLoadLoginHistory': function(aValue) { | ||
766 | this._shouldLoadLoginHistory = aValue; | ||
767 | }, | ||
768 | |||
769 | 'tabSelectedHandler': function(anEvent) { | ||
770 | if (anEvent.parameters() == 'accountPreferencesTab') { | ||
771 | this.renderPreferences(); | ||
772 | } | ||
773 | |||
774 | if ((this.shouldLoadLoginHistory()) && (anEvent.parameters() == 'loginHistoryTab')) { | ||
775 | this.renderLoginHistory(); | ||
776 | this.setShouldLoadLoginHistory(false); | ||
777 | } | ||
778 | }, | ||
779 | |||
780 | //------------------------------------------------------------------------- | ||
781 | __syntaxFix__: "syntax fix" | ||
782 | |||
783 | }); | ||
784 | |||