summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js') (more/less context) (show whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js29
1 files changed, 10 insertions, 19 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js
index eafcdbc..3aeac0c 100644
--- a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js
+++ b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js
@@ -1,46 +1,44 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2013 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz, the online password manager.
6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 6For further information about its features and functionalities please
8refer to http://www.clipperz.com. 7refer to http://www.clipperz.com.
9 8
10* Clipperz Community Edition is free software: you can redistribute 9* Clipperz is free software: you can redistribute it and/or modify it
11 it and/or modify it under the terms of the GNU Affero General Public 10 under the terms of the GNU Affero General Public License as published
12 License as published by the Free Software Foundation, either version 11 by the Free Software Foundation, either version 3 of the License, or
13 3 of the License, or (at your option) any later version. 12 (at your option) any later version.
14 13
15* Clipperz Community Edition is distributed in the hope that it will 14* Clipperz is distributed in the hope that it will be useful, but
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 15 WITHOUT ANY WARRANTY; without even the implied warranty of
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 17 See the GNU Affero General Public License for more details.
19 18
20* You should have received a copy of the GNU Affero General Public 19* You should have received a copy of the GNU Affero General Public
21 License along with Clipperz Community Edition. If not, see 20 License along with Clipperz. If not, see http://www.gnu.org/licenses/.
22 <http://www.gnu.org/licenses/>.
23 21
24*/ 22*/
25 23
26Clipperz.Base.module('Clipperz.PM.UI.Mobile.Components'); 24Clipperz.Base.module('Clipperz.PM.UI.Mobile.Components');
27 25
28Clipperz.PM.UI.Mobile.Components.LoginForm = function(args) { 26Clipperz.PM.UI.Mobile.Components.LoginForm = function(args) {
29 args = args || {}; 27 args = args || {};
30 28
31 this._pin = ''; 29 this._pin = '';
32 30
33 this._message = null; 31 this._message = null;
34 this._steps = 0; 32 this._steps = 0;
35 this._actualSteps = 0; 33 this._actualSteps = 0;
36 34
37 this._callback = null; 35 this._callback = null;
38 this._errorCallback = null; 36 this._errorCallback = null;
39 37
40 this._mode = 'CREDENTIALS'; 38 this._mode = 'CREDENTIALS';
41 39
42 Clipperz.PM.UI.Mobile.Components.LoginForm.superclass.constructor.apply(this, arguments); 40 Clipperz.PM.UI.Mobile.Components.LoginForm.superclass.constructor.apply(this, arguments);
43 41
44 return this; 42 return this;
45} 43}
46 44
@@ -118,49 +116,48 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI.
118 } else { 116 } else {
119 this.getElement('message').innerHTML = aValue; 117 this.getElement('message').innerHTML = aValue;
120 MochiKit.Style.showElement(this.getElement('credentialsMessage')); 118 MochiKit.Style.showElement(this.getElement('credentialsMessage'));
121 } 119 }
122 }, 120 },
123 121
124 'setMessage': function (aValue) { 122 'setMessage': function (aValue) {
125 this._setMessage(aValue); 123 this._setMessage(aValue);
126 MochiKit.DOM.removeElementClass(this.getElement('credentialsMessage'), 'error'); 124 MochiKit.DOM.removeElementClass(this.getElement('credentialsMessage'), 'error');
127 }, 125 },
128 126
129 'setErrorMessage': function (aValue) { 127 'setErrorMessage': function (aValue) {
130 this._setMessage(aValue); 128 this._setMessage(aValue);
131 MochiKit.DOM.addElementClass(this.getElement('credentialsMessage'), 'error'); 129 MochiKit.DOM.addElementClass(this.getElement('credentialsMessage'), 'error');
132 }, 130 },
133 131
134 //------------------------------------------------------------------------- 132 //-------------------------------------------------------------------------
135 133
136 'setCallbacks': function (args) { 134 'setCallbacks': function (args) {
137 this._callback = args['callback']; 135 this._callback = args['callback'];
138 this._errorCallback = args['errorCallback']; 136 this._errorCallback = args['errorCallback'];
139 }, 137 },
140 138
141 'showErrors': function (args) { 139 'showErrors': function (args) {
142//console.log("LoginForm.showErrors", args);
143 if (args['previousFailedAttempt'] == 'LOGIN') { 140 if (args['previousFailedAttempt'] == 'LOGIN') {
144 this.setErrorMessage("Wrong credentials"); 141 this.setErrorMessage("Wrong credentials");
145 } else if (args['previousFailedAttempt'] == 'PIN') { 142 } else if (args['previousFailedAttempt'] == 'PIN') {
146 if (args['failedAttempts'] == -1) { 143 if (args['failedAttempts'] == -1) {
147 this.setErrorMessage("Wrong PIN - Resetted"); 144 this.setErrorMessage("Wrong PIN - Resetted");
148 } else { 145 } else {
149 this.setErrorMessage("Wrong PIN"); 146 this.setErrorMessage("Wrong PIN");
150 } 147 }
151 } else { 148 } else {
152 this.setMessage(null); 149 this.setMessage(null);
153 } 150 }
154 }, 151 },
155 152
156 'updateWithArgs': function (args) { 153 'updateWithArgs': function (args) {
157 this.renderIfNeeded(); 154 this.renderIfNeeded();
158 this.setCallbacks(args); 155 this.setCallbacks(args);
159 this.showErrors(args); 156 this.showErrors(args);
160 this.updateRendering(); 157 this.updateRendering();
161 }, 158 },
162 159
163 'showPinLogin': function (args) { 160 'showPinLogin': function (args) {
164 this.setPin(''); 161 this.setPin('');
165 this.setMode('PIN'); 162 this.setMode('PIN');
166 this.updateWithArgs(args); 163 this.updateWithArgs(args);
@@ -278,79 +275,73 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI.
278 MochiKit.Signal.connect(this.getElement('pinForm'), 'onsubmit', this, 'submitPinHandler'); 275 MochiKit.Signal.connect(this.getElement('pinForm'), 'onsubmit', this, 'submitPinHandler');
279 MochiKit.Signal.connect(this.getElement('pinSubmitButton'), 'onclick', this, 'submitPinHandler'); 276 MochiKit.Signal.connect(this.getElement('pinSubmitButton'), 'onclick', this, 'submitPinHandler');
280 277
281 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'initProgress', this, 'initProgressHandle'); 278 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'initProgress', this, 'initProgressHandle');
282 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'updateProgress',this, 'updateProgressHandle'); 279 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'updateProgress',this, 'updateProgressHandle');
283 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'advanceProgress',this, 'advanceProgressHandle'); 280 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'advanceProgress',this, 'advanceProgressHandle');
284 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'progressDone', this, 'progressDoneHandle'); 281 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'progressDone', this, 'progressDoneHandle');
285 }, 282 },
286 283
287 //------------------------------------------------------------------------- 284 //-------------------------------------------------------------------------
288 285
289 'submitPinHandler': function (anEvent) { 286 'submitPinHandler': function (anEvent) {
290 varpin; 287 varpin;
291 288
292 this.setMessage(null); 289 this.setMessage(null);
293 pin = this.getElement('PIN').value; 290 pin = this.getElement('PIN').value;
294 // $(this.getAnchor('PIN')).blur(); 291 // $(this.getAnchor('PIN')).blur();
295 this.getElement('PIN').blur(); 292 this.getElement('PIN').blur();
296 293
297 credentials = Clipperz.PM.PIN.credentialsWithPIN(pin); 294 credentials = Clipperz.PM.PIN.credentialsWithPIN(pin);
298 this.loginWithCredentials(credentials); 295 this.loginWithCredentials(credentials);
299 }, 296 },
300 297
301 'submitCredentialsHandler': function (anEvent) { 298 'submitCredentialsHandler': function (anEvent) {
302//console.log("submitCredentialsHandler");
303 varcredentials; 299 varcredentials;
304 300
305 this.setMessage(null); 301 this.setMessage(null);
306 302
307 credentials = {}; 303 credentials = {};
308 credentials['username'] = this.getElement('usernameField').value; 304 credentials['username'] = this.getElement('usernameField').value;
309 credentials['passphrase'] = this.getElement('passphraseField').value; 305 credentials['passphrase'] = this.getElement('passphraseField').value;
310 // $(this.getAnchor('passphraseField')).blur(); 306 // $(this.getAnchor('passphraseField')).blur();
311 this.getElement('passphraseField').blur(); 307 this.getElement('passphraseField').blur();
312 308
313 this.loginWithCredentials(credentials); 309 this.loginWithCredentials(credentials);
314 }, 310 },
315 311
316 //------------------------------------------------------------------------- 312 //-------------------------------------------------------------------------
317 313
318 'loginWithCredentials': function (someCredentials) { 314 'loginWithCredentials': function (someCredentials) {
319 varargs; 315 varargs;
320 316
321 args = {}; 317 args = {};
322 args['credentials'] = someCredentials; 318 args['credentials'] = someCredentials;
323 args['errorCallback'] = this.errorCallback(); 319 args['errorCallback'] = this.errorCallback();
324 320
325 MochiKit.Style.hideElement(this.getElement('credentialsBody')); 321 MochiKit.Style.hideElement(this.getElement('credentialsBody'));
326 MochiKit.Style.showElement(this.getElement('validating')); 322 MochiKit.Style.showElement(this.getElement('validating'));
327 323
328 MochiKit.Async.callLater(0.1, this.callback(), args); 324 MochiKit.Async.callLater(0.1, this.callback(), args);
329 }, 325 },
330 326
331 //------------------------------------------------------------------------- 327 //-------------------------------------------------------------------------
332 328
333 'initProgressHandle': function (anEvent) { 329 'initProgressHandle': function (anEvent) {
334//console.log("** initProgressHandle", anEvent);
335 this._steps = anEvent['steps']; 330 this._steps = anEvent['steps'];
336 this._actualSteps = 0; 331 this._actualSteps = 0;
337 }, 332 },
338 333
339 'updateProgressHandle': function (anEvent) { 334 'updateProgressHandle': function (anEvent) {
340//console.log("** updateProgressHandle", anEvent);
341 this._steps += anEvent['extraSteps']; 335 this._steps += anEvent['extraSteps'];
342 }, 336 },
343 337
344 'advanceProgressHandle': function (anEvent) { 338 'advanceProgressHandle': function (anEvent) {
345//console.log("** advanceProgressHandle", anEvent);
346 this._actualSteps ++; 339 this._actualSteps ++;
347//console.log("STEPS: " + this._actualSteps + "/" + this._steps);
348 }, 340 },
349 341
350 'progressDoneHandle': function (anEvent) { 342 'progressDoneHandle': function (anEvent) {
351//console.log("** progressDoneHandle", anEvent);
352 }, 343 },
353 344
354 //------------------------------------------------------------------------- 345 //-------------------------------------------------------------------------
355 __syntaxFix__: "syntax fix" 346 __syntaxFix__: "syntax fix"
356}); 347});