summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM
Side-by-side diff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM') (more/less context) (show whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/Proxy.js2
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js33
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js50
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js6
4 files changed, 32 insertions, 59 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/Proxy.js b/frontend/gamma/js/Clipperz/PM/Proxy.js
index 9817eac..190bffd 100644
--- a/frontend/gamma/js/Clipperz/PM/Proxy.js
+++ b/frontend/gamma/js/Clipperz/PM/Proxy.js
@@ -49,121 +49,121 @@ Clipperz.PM.Proxy = function(args) {
Clipperz.PM.Proxy.prototype = MochiKit.Base.update(null, {
'toString': function() {
return "Clipperz.PM.Proxy";
},
//=========================================================================
'shouldPayTolls': function() {
return this._shouldPayTolls;
},
//-------------------------------------------------------------------------
'tolls': function() {
return this._tolls;
},
//-------------------------------------------------------------------------
'payToll': function(aRequestType, someParameters) {
var deferredResult;
//console.log(">>> Proxy.payToll", aRequestType, someParameters);
if (this.shouldPayTolls()) {
deferredResult = new Clipperz.Async.Deferred("Proxy.payToll", {trace:false});
if (this.tolls()[aRequestType].length == 0) {
deferredResult.addMethod(this, 'sendMessage', 'knock', {requestType:aRequestType});
deferredResult.addMethod(this, 'setTollCallback');
}
deferredResult.addMethod(this.tolls()[aRequestType], 'pop');
deferredResult.addCallback(MochiKit.Base.methodcaller('deferredPay'));
deferredResult.addCallback(function(aToll) {
var result;
result = {
parameters: someParameters,
toll: aToll
}
return result;
});
deferredResult.callback();
} else {
deferredResult = MochiKit.Async.succeed({parameters:someParameters});
}
//console.log("<<< Proxy.payToll");
return deferredResult;
},
//-------------------------------------------------------------------------
'addToll': function(aToll) {
//console.log(">>> Proxy.addToll", aToll);
this.tolls()[aToll.requestType()].push(aToll);
//console.log("<<< Proxy.addToll");
},
//=========================================================================
'setTollCallback': function(someParameters) {
//console.log(">>> Proxy.setTollCallback", someParameters);
if (typeof(someParameters['toll']) != 'undefined') {
//console.log("added a new toll", someParameters['toll']);
this.addToll(new Clipperz.PM.Toll(someParameters['toll']));
}
//console.log("<<< Proxy.setTallCallback", someParameters['result']);
return someParameters['result'];
},
//=========================================================================
'registration': function (someParameters) {
return this.processMessage('registration', someParameters, 'REGISTER');
},
'handshake': function (someParameters) {
return this.processMessage('handshake', someParameters, 'CONNECT');
},
'message': function (someParameters) {
return this.processMessage('message', someParameters, 'MESSAGE');
},
'logout': function (someParameters) {
return this.processMessage('logout', someParameters, 'MESSAGE');
},
//=========================================================================
'processMessage': function (aFunctionName, someParameters, aRequestType) {
var deferredResult;
- deferredResult = new Clipperz.Async.Deferred("Proxy.processMessage", {trace:true});
+ deferredResult = new Clipperz.Async.Deferred("Proxy.processMessage", {trace:false});
deferredResult.addMethod(this, 'payToll', aRequestType);
deferredResult.addMethod(this, 'sendMessage', aFunctionName);
deferredResult.addMethod(this, 'setTollCallback');
deferredResult.callback(someParameters);
return deferredResult;
},
//=========================================================================
'sendMessage': function () {
throw Clipperz.Base.exception.AbstractMethod;
},
//=========================================================================
'isReadOnly': function () {
return false;
},
//=========================================================================
__syntaxFix__: "syntax fix"
});
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js
index 095e8ed..8df7e0e 100644
--- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js
+++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js
@@ -9,205 +9,206 @@ refer to http://www.clipperz.com.
* Clipperz Community Edition is free software: you can redistribute
it and/or modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.
* Clipperz Community Edition is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Clipperz Community Edition. If not, see
<http://www.gnu.org/licenses/>.
*/
Clipperz.Base.module('Clipperz.PM.UI.Common.Components');
Clipperz.PM.UI.Common.Components.Tooltip = function(args) {
args = args || {};
Clipperz.PM.UI.Common.Components.Tooltip.superclass.constructor.apply(this, arguments);
this._element = args.element || Clipperz.Base.exception.raise('MandatoryParameter');
this._text = args.text || Clipperz.Base.exception.raise('MandatoryParameter');
this._position = args.position || 'BELOW'; // 'BELOW', 'ABOVE', 'LEFT', 'RIGHT'
this._boxDimensions = null;
this._enabled = (typeof(args.enabled) == 'undefined' ? true : args.enabled);
this._isVisible = false;
this.renderSelf();
return this;
}
//=============================================================================
Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.Tooltip, Clipperz.PM.UI.Common.Components.BaseComponent, {
//-------------------------------------------------------------------------
'toString': function () {
return "Clipperz.PM.UI.Common.Components.Tooltip component";
},
//-------------------------------------------------------------------------
'text': function () {
return this._text;
},
'setText': function (aValue) {
this._text = aValue;
},
//-------------------------------------------------------------------------
'position': function () {
return this._position;
},
'setPosition': function (aValue) {
this._position = aValue;
},
//-------------------------------------------------------------------------
'enabled': function () {
return this._enabled;
},
'setIsEnabled': function (aValue) {
this._enabled = aValue;
},
//-------------------------------------------------------------------------
'isVisible': function () {
return this._isVisible;
},
'setIsVisible': function (aValue) {
this._isVisible = aValue;
},
//-------------------------------------------------------------------------
'renderSelf': function() {
// this.append(this.element(), {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[
// this.append(MochiKit.DOM.currentDocument().body, {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[
this.append(MochiKit.DOM.getElement('Clipperz_PM_UI_Common_Components_Tooltip_wrapperNode'), {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[
{tag:'div', id:this.getId('body'), cls:'tooltip_body', children:[
{tag:'div', cls:'tooltip_text', children:[
{tag:'span', html:this.text()}
- ]},
- {tag:'div', id:this.getId('footer'), cls:'tooltip_footer'}
+ ]}//,
+// {tag:'div', id:this.getId('footer'), cls:'tooltip_footer'}
]},
{tag:'div', id:this.getId('arrow'), cls:'tooltip_arrow'}
]});
this._boxDimensions = MochiKit.Style.getElementDimensions(this.getId('body'));
// this._boxDimensions.h += MochiKit.Style.getElementDimensions(this.getId('footer')).h;
MochiKit.Style.hideElement(this.displayElement());
MochiKit.Signal.connect(this.element(), 'onmouseenter', this, 'show');
MochiKit.Signal.connect(this.element(), 'onmouseleave', this, 'hide');
},
//-----------------------------------------------------
'displayElement': function() {
return this.getElement('tooltip');
},
//-------------------------------------------------------------------------
'boxDimensions': function () {
return this._boxDimensions;
},
//-------------------------------------------------------------------------
'show': function () {
var elementSizeAndPosition;
var arrowPosition;
var bodyPosition;
if (this.isVisible() == false) {
arrowPosition = {};
bodyPosition = {};
this.setIsVisible(true);
elementSizeAndPosition = Clipperz.Style.getSizeAndPosition(this.element());
//console.log("ELEMENT SIZE AND POSITION", Clipperz.Base.serializeJSON(elementSizeAndPosition));
//console.log("BOX DIMENSIONS", Clipperz.Base.serializeJSON(this.boxDimensions()));
switch (this.position()) {
case 'ABOVE':
//console.log("ABOVE");
- MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px');
+// MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px');
bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2);
bodyPosition.y = elementSizeAndPosition.position.y - this.boxDimensions().h - 13;
- arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2);
- arrowPosition.y = elementSizeAndPosition.position.y - 13;
+// arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2);
+// arrowPosition.y = elementSizeAndPosition.position.y - 13;
break;
case 'BELOW':
//console.log("BELOW");
- MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px');
+// MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px');
bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2);
bodyPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h + 13;
- arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2);
- arrowPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h;
+// arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2);
+// arrowPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h;
break;
case 'LEFT':
//console.log("LEFT");
- MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px');
+// MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px');
bodyPosition.x = elementSizeAndPosition.position.x - this.boxDimensions().w - 13;
bodyPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - this.boxDimensions().h/2);
- arrowPosition.x = elementSizeAndPosition.position.x -13;
- arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2);
+// arrowPosition.x = elementSizeAndPosition.position.x -13;
+// arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2);
break;
case 'RIGHT':
//console.log("RIGHT");
- MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px');
+// MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px');
bodyPosition.x = elementSizeAndPosition.position.x + elementSizeAndPosition.dimensions.w + 13;
bodyPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - this.boxDimensions().h/2);
- arrowPosition.x = elementSizeAndPosition.position.x + elementSizeAndPosition.dimensions.w;
- arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2);
+// arrowPosition.x = elementSizeAndPosition.position.x + elementSizeAndPosition.dimensions.w;
+// arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2);
break;
}
//console.log("X: " + bodyPosition.x + ", Y: " + bodyPosition.y);
- MochiKit.Style.setElementPosition(this.getId('body'), bodyPosition);
- MochiKit.Style.setElementPosition(this.getId('arrow'), arrowPosition);
+ MochiKit.Style.setElementPosition(this.getId('tooltip'), bodyPosition);
+// MochiKit.Style.setElementPosition(this.getId('body'), bodyPosition);
+// MochiKit.Style.setElementPosition(this.getId('arrow'), arrowPosition);
MochiKit.Visual.appear(this.displayElement(), {duration:0.4});
}
},
'hide': function () {
if (this.isVisible() == true) {
MochiKit.Visual.fade(this.displayElement(), {duration:0.4});
this.setIsVisible(false);
}
},
//-------------------------------------------------------------------------
/*
'shouldRemoveElementWhenClearningUp': function () {
return false;
},
*/
//-------------------------------------------------------------------------
__syntaxFix__: "syntax fix"
});
Clipperz.PM.UI.Common.Components.Tooltip.initTooltips = function () {
Clipperz.DOM.Helper.insertBefore(MochiKit.DOM.currentDocument().body.childNodes[0], {tag:'div', id:'Clipperz_PM_UI_Common_Components_Tooltip_wrapperNode'});
}
MochiKit.DOM.addLoadEvent(Clipperz.PM.UI.Common.Components.Tooltip.initTooltips);
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js
index 389d876..a10ba4f 100644
--- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js
@@ -1,200 +1,178 @@
/*
Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz Community Edition.
Clipperz Community Edition is an online password manager.
For further information about its features and functionalities please
refer to http://www.clipperz.com.
* Clipperz Community Edition is free software: you can redistribute
it and/or modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.
* Clipperz Community Edition is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Clipperz Community Edition. If not, see
<http://www.gnu.org/licenses/>.
*/
Clipperz.Base.module('Clipperz.PM.UI.Web.Components');
Clipperz.PM.UI.Web.Components.LoginForm = function(args) {
args = args || {};
this._autocomplete = args.autocomplete || 'off';
Clipperz.PM.UI.Web.Components.LoginForm.superclass.constructor.apply(this, arguments);
this._slots = {
'passphraseEntropy': this.getId('passphraseEntropy')
};
return this;
}
//=============================================================================
Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.LoginForm, Clipperz.PM.UI.Common.Components.BaseComponent, {
//-------------------------------------------------------------------------
'toString': function () {
return "Clipperz.PM.UI.Web.Components.LoginForm component";
},
'autocomplete': function () {
return this._autocomplete;
},
//-------------------------------------------------------------------------
'renderSelf': function() {
this.append(this.element(), {tag:'div', id:'loginBox', children:[
{tag:'div', cls:'header'},
{tag:'div', cls:'body', id:this.getId('body'), children:[
{tag:'div', id:this.getId('loginForm'), children:[
{tag:'div', children:[
{tag:'h4', html:'Login'},
// {tag:'form', cls:'loginForm', autocomplete:this.autocomplete(), children:[
{tag:'form', id:this.getId('form'), cls:'loginForm', children:[
{tag:'label', html:'username', 'for':this.getId('usernameField')},
- {tag:'input', id:this.getId('usernameField'), type:'text', cls:'username'/*, value:'joe'*/},
- {tag:'ul', id:this.getId('passwordOptions'), children:[
- {tag:'li', id:this.getId('passphraseOption'), children:[
+ {tag:'input', id:this.getId('usernameField'), type:'text', cls:'username'},
{tag:'label', html:'passphrase / OTP', 'for':this.getId('passphraseField')},
- {tag:'input', id:this.getId('passphraseField'), type:'password', cls:'password'/*, value:'clipperz'*/}
- ]} // ,
-/*
- {tag:'li', id:this.getId('otpOption'), children:[
- {tag:'label', html:'one-time password', 'for':this.getId('otpField_1')},
- {tag:'input', id:this.getId('otpField_1'), type:'text', cls:'otp', value:'abcd-efgh'},
- {tag:'input', id:this.getId('otpField_2'), type:'text', cls:'otp', value:'abcd-efgh'},
- {tag:'input', id:this.getId('otpField_3'), type:'text', cls:'otp', value:'abcd-efgh'},
- {tag:'input', id:this.getId('otpField_4'), type:'text', cls:'otp', value:'abcd-efgh'}
- ]}
-*/
- ]},
-// {tag:'input', id:this.getId('otpCheckbox'), type:'checkbox', cls:'checkbox'},
-// {tag:'label', html:'use a one-time passphrase', 'for':this.getId('otpCheckbox'), cls:'checkbox'},
+ {tag:'input', id:this.getId('passphraseField'), type:'password', cls:'password'},
{tag:'div', cls:'translations', children:[
{tag:'h4', html:'choose your language'},
{tag:'ul', children:[
{tag:'li', cls:'selected', html:'english'},
{tag:'li', html:'italiano'},
{tag:'li', html:'dutch'},
{tag:'li', html:'french'},
{tag:'li', html:'spanish'},
{tag:'li', html:'chinese'},
{tag:'li', html:'japanese'},
{tag:'li', html:'portugal'},
{tag:'li', html:'arabic'}
]}
]},
{tag:'input', id:this.getId('submitButton'), type:'submit', value:'login', cls:'submit'}
]}
]}
]}
]},
{tag:'div', cls:'footer'}
]});
if (this.autocomplete() == 'off') {
MochiKit.DOM.updateNodeAttributes(this.getElement('form'), {autocomplete:'off'});
}
// Clipperz.Style.setBackgroundGradient(this.getElement('body'), {from:"#ff9955", to:"#ff6622"})
// this.setEntropyDisplay(new Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay(this.getElement('passphraseField')));
// MochiKit.Signal.connect(this.getId('otpCheckbox'), 'onclick', this, 'togglePasswordFields');
// this.showPassphraseField();
this.getElement('usernameField').focus();
MochiKit.Signal.connect(this.getElement('loginForm'), 'onsubmit', this, 'loginEventHandler');
},
//-----------------------------------------------------------------------------
/*
'togglePasswordFields': function(anEvent) {
var shouldUseOTP;
shouldUseOTP = this.getElement('otpCheckbox').checked;
if (shouldUseOTP == false) {
this.showPassphraseField();
} else {
this.showOTPFields();
}
},
*/
//-----------------------------------------------------------------------------
/*
'showPassphraseField': function() {
this.showElement('passphraseOption');
this.hideElement('otpOption');
},
*/
//-----------------------------------------------------------------------------
'focusOnPassphraseField': function () {
this.getElement('passphraseField').focus();
this.getElement('passphraseField').select();
},
//-----------------------------------------------------------------------------
/*
'showOTPFields': function() {
this.hideElement('passphraseOption');
this.showElement('otpOption');
},
*/
//-------------------------------------------------------------------------
'loginEventHandler': function(anEvent) {
- var username;
- var passphrase;
-// var shouldUseOTP;
-// var otp;
+// var username;
+// var passphrase;
var signalArguments;
anEvent.preventDefault();
- username = this.getElement('usernameField').value;
- passphrase = this.getElement('passphraseField').value;
-// otp = this.getElement('otpField_1').value +
-// this.getElement('otpField_2').value +
-// this.getElement('otpField_3').value +
-// this.getElement('otpField_4').value;
-// shouldUseOTP = this.getElement('otpCheckbox').checked;
-
- signalArguments = {username:username};
-
-// if (shouldUseOTP) {
-// signalArguments.otp = otp;
-// } else {
- signalArguments.passphrase = passphrase;
-// }
+// username = this.getElement('usernameField').value;
+// passphrase = this.getElement('passphraseField').value;
+
+// signalArguments = {username:username};
+// signalArguments.passphrase = passphrase;
+
+ signalArguments = {
+ 'username': this.getElement('usernameField').value,
+ 'passphrase': this.getElement('passphraseField').value
+ };
MochiKit.Signal.signal(this, 'doLogin', signalArguments);
},
//-------------------------------------------------------------------------
'submitButtonElement': function() {
return this.getElement('submitButton');
},
//-------------------------------------------------------------------------
__syntaxFix__: "syntax fix"
});
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js
index d0b378c..a57152d 100644
--- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js
@@ -1,202 +1,196 @@
/*
Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz Community Edition.
Clipperz Community Edition is an online password manager.
For further information about its features and functionalities please
refer to http://www.clipperz.com.
* Clipperz Community Edition is free software: you can redistribute
it and/or modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.
* Clipperz Community Edition is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Clipperz Community Edition. If not, see
<http://www.gnu.org/licenses/>.
*/
Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers');
Clipperz.PM.UI.Web.Controllers.LoginController = function(args) {
this._args = args || {};
this._loginPage = null;
this._newUserWizardController = null;
this._newUserCreationComponent = null;
return this;
}
MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.LoginController.prototype, {
'toString': function() {
return "Clipperz.PM.UI.Web.Controllers.LoginController";
},
'args': function () {
return this._args;
},
//-----------------------------------------------------------------------------
'loginPage': function() {
if (this._loginPage == null) {
this._loginPage = new Clipperz.PM.UI.Web.Components.LoginPage();
MochiKit.Signal.connect(this._loginPage, 'createNewAccountClick', this, 'handleCreateNewAccountClick')
}
return this._loginPage;
},
//-----------------------------------------------------------------------------
'run': function(args) {
var slot;
var loginPage;
var loginForm;
slot = args.slot;
loginForm = new Clipperz.PM.UI.Web.Components.LoginForm({'autocomplete': this.args()['autocomplete']});
slot.setContent(this.loginPage());
this.loginPage().slotNamed('loginForm').setContent(loginForm);
MochiKit.Signal.connect(loginForm, 'doLogin', MochiKit.Base.method(this, 'doLogin', loginForm));
MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'doLogin', MochiKit.Base.method(this, 'doLogin', loginForm));
},
//-----------------------------------------------------------------------------
'doLogin': function(aLoginForm, anEvent) {
var deferredResult;
var parameters;
-// var shouldUseOTP;
var loginProgress;
var user;
var getPassphraseDelegate;
parameters = anEvent;
-// shouldUseOTP = (typeof(parameters.passphrase) == 'undefined');
getPassphraseDelegate = MochiKit.Base.partial(MochiKit.Async.succeed, parameters.passphrase);
user = new Clipperz.PM.DataModel.User({'username':parameters.username, 'getPassphraseFunction':MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'getPassphrase')});
loginProgress = new Clipperz.PM.UI.Web.Components.LoginProgress();
deferredResult = new Clipperz.Async.Deferred("LoginController.doLogin", {trace:false});
deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':4});
deferredResult.addMethod(Clipperz.PM.RunTime.mainController, 'setPassphraseDelegate', getPassphraseDelegate);
deferredResult.addMethod(loginProgress, 'deferredShowModal', {deferredObject:deferredResult, openFromElement:aLoginForm.submitButtonElement()});
deferredResult.addMethod(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'deferredEntropyCollection');
-// if (shouldUseOTP == false) {
deferredResult.addMethod(user, 'login');
-// } else {
-// deferredResult.addMethod(user, 'loginUsingOTP', parameters.username, parameters.otp);
-// }
deferredResult.addCallback(function(aLoginProgress, res) {
aLoginProgress.disableCancel();
return res;
}, loginProgress);
deferredResult.addCallback(function () {
MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'CARDS_CONTROLLER_DID_RUN', MochiKit.Base.method(loginProgress, 'deferredHideModalAndRemove', {closeToElement:MochiKit.DOM.currentDocument().body}));
})
deferredResult.addMethod(this, 'userLoggedIn', user, loginProgress, aLoginForm);
deferredResult.addErrback (MochiKit.Base.method(this, 'handleFailedLogin', loginProgress));
deferredResult.addErrback (MochiKit.Base.method(loginProgress, 'deferredHideModalAndRemove', {closeToElement:aLoginForm.submitButtonElement()}));
deferredResult.addErrbackPass (MochiKit.Base.method(aLoginForm, 'focusOnPassphraseField'));
deferredResult.addBoth(MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'removePassphraseDelegate', getPassphraseDelegate));
deferredResult.callback();
MochiKit.Signal.connect(loginProgress, 'cancelEvent', deferredResult, 'cancel');
return deferredResult;
},
//-----------------------------------------------------------------------------
'userLoggedIn': function(aUser) {
//Clipperz.log(">>> LoginController.userLoggedIn");
MochiKit.Signal.signal(this, 'userLoggedIn', {user: aUser});
//Clipperz.log("<<< LoginController.userLoggedIn");
},
//=========================================================================
'handleCreateNewAccountClick': function (aComponent) {
// return Clipperz.PM.DataModel.User.registerNewAccount("new", "user");
return Clipperz.Async.callbacks("LoginController.handleCreateNewAccountClick", [
//' MochiKit.Base.method(this, 'newUserCreationComponent'),
// MochiKit.Base.methodcaller('deferredShowModal', {openFromElement:aComponent}),
// MochiKit.Base.method(this.newUserWizardController(), 'run')
MochiKit.Base.method(this, 'newUserCreationComponent'),
Clipperz.Async.forkAndJoin("Async.test succeedingForkedAndWaitDeferrer", [
MochiKit.Base.method(this.newUserCreationComponent(), 'deferredShowModal', {openFromElement:aComponent, duration:0.5}),
MochiKit.Base.method(this.newUserWizardController(), 'run')
], {trace:false}),
// MochiKit.Base.method(this.newUserCreationComponent(), 'enableCredentialsField')
], {trace:false});
},
//-----------------------------------------------------------------------------
'newUserWizardController': function () {
if (this._newUserWizardController == null) {
this._newUserWizardController = new Clipperz.PM.UI.Web.Controllers.NewUserWizardController({
'newUserCreationComponent': this.newUserCreationComponent()
})
// MochiKit.Signal.connect(this._newUserWizardController, 'exit', this, 'handleHideNewUserCreationComponent');
MochiKit.Signal.connect(this._newUserWizardController, 'done', this, 'handleCompleteNewUserCreationComponent');
}
return this._newUserWizardController;
},
//-------------------------------------------------------------------------
'newUserCreationComponent': function () {
if (this._newUserCreationComponent == null) {
this._newUserCreationComponent = new Clipperz.PM.UI.Web.Components.NewUserCreationComponent();
}
return this._newUserCreationComponent;
},
'clearNewUserCreationComponent': function () {
if (this._newUserCreationComponent != null) {
this._newUserCreationComponent.clear();
}
this._newUserCreationComponent = null;
},
//-------------------------------------------------------------------------
'handleHideNewUserCreationComponent': function () {
this.clearNewUserCreationComponent();
},
'handleCompleteNewUserCreationComponent': function (someParameters) {
var deferredResult;
var user;
var newUserCreationComponent;
user = someParameters.user;
newUserCreationComponent = this.newUserCreationComponent();
MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'CARDS_CONTROLLER_DID_RUN', MochiKit.Base.method(newUserCreationComponent, 'deferredHideModal', {closeToElement:MochiKit.DOM.currentDocument().body})),
deferredResult = new Clipperz.Async.Deferred("LoginController.handleCompleteNewUserCreationComponent", {trace:false});