mirror of
http://git.whoc.org.uk/git/password-manager.git
synced 2025-10-24 17:27:35 +02:00
Updated version of /gamma
Tons of changes, included a new draft of the mobile version (still VERY rough)
This commit is contained in:
@@ -513,9 +513,9 @@ MochiKit.Base.update(Clipperz.Async, {
|
||||
return MochiKit.Base.map(function (aResult) {
|
||||
if (aResult[0]) {
|
||||
return aResult[1];
|
||||
} else {
|
||||
} else {
|
||||
throw aResult[1];
|
||||
}
|
||||
}
|
||||
}, aResultList);
|
||||
});
|
||||
|
||||
|
||||
@@ -77,6 +77,11 @@ MochiKit.Base.update(Clipperz.Base, {
|
||||
return MochiKit.Base.compose(function(aResult) { return -aResult; }, aComparator);
|
||||
},
|
||||
|
||||
'caseInsensitiveKeyComparator': function (aKey) {
|
||||
return function (a, b) {
|
||||
return MochiKit.Base.compare(a[aKey].toLowerCase(), b[aKey].toLowerCase());
|
||||
}
|
||||
},
|
||||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
'dependsOn': function(module, deps) {
|
||||
|
||||
@@ -41,6 +41,7 @@ Clipperz.PM.Connection = function (args) {
|
||||
this._clipperz_pm_crypto_version = null;
|
||||
this._connectionId = null;
|
||||
this._sharedSecret = null;
|
||||
this._serverLockValue = null;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -146,6 +147,16 @@ MochiKit.Logging.logError("### Connection.defaultErrorHandler: " + anErrorString
|
||||
this._connectionId = aValue;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'serverLockValue': function () {
|
||||
return this._serverLockValue;
|
||||
},
|
||||
|
||||
'setServerLockValue': function (aValue) {
|
||||
this._serverLockValue = aValue;
|
||||
},
|
||||
|
||||
//=========================================================================
|
||||
/*
|
||||
// TODO: ?????
|
||||
@@ -320,13 +331,12 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz.
|
||||
], {trace:false})
|
||||
},
|
||||
|
||||
'login': function(/*anUsername, aPassphrase*/) {
|
||||
'login': function(isReconnecting) {
|
||||
var deferredResult;
|
||||
var cryptoVersion;
|
||||
var srpConnection;
|
||||
|
||||
cryptoVersion = this.clipperz_pm_crypto_version();
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("Connection.login", {trace:false});
|
||||
deferredResult.addCallback(this.getCredentialsFunction());
|
||||
deferredResult.addMethod(this, 'normalizedCredentials');
|
||||
@@ -399,6 +409,13 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz.
|
||||
// if (this.oneTimePassword() != null) {
|
||||
/// ?? result = this.user().oneTimePasswordManager().archiveOneTimePassword(this.oneTimePassword()));
|
||||
// }
|
||||
|
||||
if ((isReconnecting == true) && (this.serverLockValue() != someParameters['lock'])) {
|
||||
throw Clipperz.PM.Connection.exception.StaleData;
|
||||
} else {
|
||||
this.setServerLockValue(someParameters['lock']);
|
||||
}
|
||||
|
||||
return someParameters;
|
||||
}, this));
|
||||
// deferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'updatedProgressState', 'connection_loggedIn');
|
||||
@@ -429,12 +446,19 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz.
|
||||
|
||||
'message': function(aMessageName, someParameters) {
|
||||
var args;
|
||||
var parameters;
|
||||
|
||||
parameters = someParameters || {};
|
||||
if (typeof(parameters['user']) != 'undefined') {
|
||||
parameters['user']['lock'] = this.serverLockValue();
|
||||
}
|
||||
|
||||
//console.log(">>> Connection.message", aMessageName, someParameters);
|
||||
args = {
|
||||
message: aMessageName,
|
||||
srpSharedSecret: this.sharedSecret(),
|
||||
parameters: (someParameters || {})
|
||||
// parameters: (someParameters || {})
|
||||
parameters: parameters
|
||||
}
|
||||
|
||||
return this.sendMessage(args);
|
||||
@@ -449,8 +473,7 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz.
|
||||
deferredResult.addMethod(this.proxy(), 'message', someArguments);
|
||||
deferredResult.addCallback(MochiKit.Base.bind(function(res) {
|
||||
if (typeof(res['lock']) != 'undefined') {
|
||||
// TODO: ?????
|
||||
// ?? this.user().setLock(res['lock']);
|
||||
this.setServerLockValue(res['lock']);
|
||||
}
|
||||
return res;
|
||||
}, this));
|
||||
@@ -587,6 +610,7 @@ Clipperz.PM.Connection.SRP['1.1'].prototype = MochiKit.Base.update(new Clipperz.
|
||||
|
||||
Clipperz.PM.Connection.exception = {
|
||||
WrongChecksum: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.InvalidValue"),
|
||||
StaleData: new MochiKit.Base.NamedError("Stale data"),
|
||||
UnexpectedRequest: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.UnexpectedRequest")
|
||||
};
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ Clipperz.PM.DataModel.User = function (args) {
|
||||
this._connectionVersion = 'current';
|
||||
|
||||
this._serverData = null;
|
||||
this._serverLockValue = null;
|
||||
// this._serverLockValue = null;
|
||||
this._transientState = null;
|
||||
|
||||
this._deferredLocks = {
|
||||
@@ -93,7 +93,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, {
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
'serverLockValue': function () {
|
||||
return this._serverLockValue;
|
||||
},
|
||||
@@ -101,7 +101,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, {
|
||||
'setServerLockValue': function (aValue) {
|
||||
this._serverLockValue = aValue;
|
||||
},
|
||||
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'transientState': function () {
|
||||
@@ -220,8 +220,8 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, {
|
||||
deferredResult.addMethod(this, 'prepareRemoteDataWithKey');
|
||||
deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress');
|
||||
deferredResult.addMethod(this.connection(), 'register');
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('lock'));
|
||||
deferredResult.addMethod(this, 'setServerLockValue');
|
||||
// deferredResult.addCallback(MochiKit.Base.itemgetter('lock'));
|
||||
// deferredResult.addMethod(this, 'setServerLockValue');
|
||||
deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'userSuccessfullyRegistered');
|
||||
|
||||
// deferredResult.addErrback (MochiKit.Base.method(this, 'handleRegistrationFailure'));
|
||||
@@ -247,7 +247,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, {
|
||||
MochiKit.Base.method(this.data(), 'setValue', 'passphrase')
|
||||
], []));
|
||||
deferredResult.addErrback(MochiKit.Base.method(this, 'getPassphrase'));
|
||||
deferredResult.addMethod(this.connection(), 'login');
|
||||
deferredResult.addMethod(this.connection(), 'login', false);
|
||||
deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'userSuccessfullyLoggedIn');
|
||||
deferredResult.addErrback (MochiKit.Base.method(this, 'handleConnectionFallback'));
|
||||
|
||||
@@ -329,7 +329,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, {
|
||||
var oneTimePasswords;
|
||||
|
||||
//console.log(">>> ***************** user.unpackServerData", someServerData);
|
||||
this.setServerLockValue(someServerData['lock']);
|
||||
// this.setServerLockValue(someServerData['lock']);
|
||||
|
||||
headerVersion = this.headerFormatVersion(someServerData['header']);
|
||||
|
||||
@@ -662,8 +662,8 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, {
|
||||
MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'commitTransientState'),
|
||||
|
||||
MochiKit.Base.method(this, 'transientState'),
|
||||
MochiKit.Base.itemgetter('lock'),
|
||||
MochiKit.Base.method(this, 'setServerLockValue'),
|
||||
// MochiKit.Base.itemgetter('lock'),
|
||||
// MochiKit.Base.method(this, 'setServerLockValue'),
|
||||
MochiKit.Base.method(this, 'resetTransientState', true)
|
||||
], {trace:false});
|
||||
},
|
||||
@@ -740,7 +740,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, {
|
||||
return aResult;
|
||||
}, this), result);
|
||||
deferredResult.addCallback(Clipperz.Async.setItem, result, 'version', Clipperz.PM.Crypto.encryptingFunctions.currentVersion);
|
||||
deferredResult.addCallback(Clipperz.Async.setItem, result, 'lock', this.serverLockValue());
|
||||
// deferredResult.addCallback(Clipperz.Async.setItem, result, 'lock', this.serverLockValue());
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
|
||||
134
frontend/gamma/js/Clipperz/PM/PIN.js
Normal file
134
frontend/gamma/js/Clipperz/PM/PIN.js
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
|
||||
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/>.
|
||||
|
||||
*/
|
||||
|
||||
if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
|
||||
if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
|
||||
if (typeof(Clipperz.PM.PIN) == 'undefined') { Clipperz.PM.PIN = {}; }
|
||||
|
||||
MochiKit.Base.update(Clipperz.PM.PIN, {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'__repr__': function () {
|
||||
return "[" + this.NAME + " " + this.VERSION + "]";
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'toString': function () {
|
||||
return this.__repr__();
|
||||
},
|
||||
|
||||
'CREDENTIALS': 'CLIPPERZ.CREDENTIALS',
|
||||
'FAILURE_COUNT': 'CLIPPERZ.FAILED_LOGIN_COUNT',
|
||||
'ALLOWED_RETRY': 3,
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'isSet': function () {
|
||||
return (this.storedCredentials() != null);
|
||||
},
|
||||
|
||||
'storedCredentials': function () {
|
||||
return localStorage[this.CREDENTIALS];
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'recordFailedAttempt': function () {
|
||||
var failureCount;
|
||||
var result;
|
||||
|
||||
failureCount = localStorage[this.FAILURE_COUNT];
|
||||
|
||||
if (failureCount == null) {
|
||||
failureCount = 0
|
||||
}
|
||||
|
||||
failureCount ++;
|
||||
|
||||
if (failureCount < this.ALLOWED_RETRY) {
|
||||
localStorage[this.FAILURE_COUNT] = failureCount;
|
||||
result = failureCount;
|
||||
} else {
|
||||
this.removeLocalCredentials();
|
||||
result = -1;
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
'resetFailedAttemptCount': function () {
|
||||
localStorage.removeItem(this.FAILURE_COUNT);
|
||||
},
|
||||
|
||||
'failureCount': function () {
|
||||
return localStorage[this.FAILURE_COUNT];
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'deriveKeyFromPin': function (aPIN) {
|
||||
return Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray(aPIN));
|
||||
},
|
||||
|
||||
'credentialsWithPIN': function (aPIN) {
|
||||
var byteArrayValue;
|
||||
var decryptedValue;
|
||||
var result;
|
||||
|
||||
byteArrayValue = (new Clipperz.ByteArray()).appendBase64String(localStorage[this.CREDENTIALS]);
|
||||
decryptedValue = Clipperz.Crypto.AES.decrypt(this.deriveKeyFromPin(aPIN), byteArrayValue).asString();
|
||||
try {
|
||||
result = Clipperz.Base.evalJSON(decryptedValue);
|
||||
} catch (error) {
|
||||
result = {'username':'fakeusername', 'passphrase':'fakepassphrase'};
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
'setCredentialsWithPIN': function (aPIN, someCredentials) {
|
||||
var encodedValue;
|
||||
var byteArrayValue;
|
||||
var encryptedValue;
|
||||
|
||||
encodedValue = Clipperz.Base.serializeJSON(someCredentials);
|
||||
byteArrayValue = new Clipperz.ByteArray(encodedValue);
|
||||
encryptedValue = Clipperz.Crypto.AES.encrypt(this.deriveKeyFromPin(aPIN), byteArrayValue).toBase64String();
|
||||
|
||||
localStorage[this.CREDENTIALS] = encryptedValue;
|
||||
},
|
||||
|
||||
'removeLocalCredentials': function () {
|
||||
localStorage.removeItem(this.CREDENTIALS);
|
||||
localStorage.removeItem(this.FAILURE_COUNT);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
__syntaxFix__: "syntax fix"
|
||||
|
||||
});
|
||||
|
||||
65
frontend/gamma/js/Clipperz/PM/Proxy/Proxy.OfflineCache.js
Normal file
65
frontend/gamma/js/Clipperz/PM/Proxy/Proxy.OfflineCache.js
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
|
||||
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/>.
|
||||
|
||||
*/
|
||||
|
||||
if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
|
||||
if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
|
||||
|
||||
//=============================================================================
|
||||
|
||||
Clipperz.PM.Proxy.OfflineCache = function(args) {
|
||||
args = args || {};
|
||||
|
||||
Clipperz.PM.Proxy.Offline.superclass.constructor.call(this, args);
|
||||
|
||||
// this._dataStore = args.dataStore || new Clipperz.PM.Proxy.Offline.DataStore(args);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
Clipperz.Base.extend(Clipperz.PM.Proxy.OfflineCache, Clipperz.PM.Proxy, {
|
||||
|
||||
'toString': function () {
|
||||
return "Clipperz.PM.Proxy.OfflineCache";
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
// 'dataStore': function () {
|
||||
// return this._dataStore;
|
||||
// },
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'sendMessage': function(aFunctionName, someParameters) {
|
||||
throw Clipperz.Base.exception.MethodNotImplementedYet;
|
||||
// return this.dataStore().processMessage(aFunctionName, someParameters);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
__syntaxFix__: "syntax fix"
|
||||
|
||||
});
|
||||
|
||||
@@ -406,6 +406,10 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.BaseComponent, /*Ext.Compo
|
||||
return result;
|
||||
},
|
||||
|
||||
'getAnchor': function (aValue) {
|
||||
return '#' + this.getId(aValue);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'getElement': function(aValue) {
|
||||
|
||||
@@ -62,7 +62,8 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.Button, Clipperz.PM.UI.Com
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'renderSelf': function () {
|
||||
this.append(this.element(), {tag:'div', id:this.getId('wrapper'), cls:'button_wrapper', children:[
|
||||
/*
|
||||
this.append(this.element(), {tag:'div', id:this.getId('button'), cls:'button_wrapper', children:[
|
||||
{tag:'div', id:this.getId('bodyWrapper'), cls:'button_bodyWrapper', children:[
|
||||
{tag:'div', id:this.getId('body'), cls:'button_body', children:[
|
||||
{tag:'span', html:this.text()}
|
||||
@@ -70,36 +71,43 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.Button, Clipperz.PM.UI.Com
|
||||
{tag:'div', id:this.getId('footer'), cls:'button_footer'}
|
||||
]}
|
||||
]});
|
||||
*/
|
||||
/*
|
||||
this.append(this.element(), {tag:'div', id:this.getId('button'), cls:'button', children:[
|
||||
{tag:'span', html:this.text()}
|
||||
]});
|
||||
*/
|
||||
this.append(this.element(), {tag:'a', id:this.getId('button'), cls:'button', html:this.text()});
|
||||
|
||||
if (this.isDefault()) {
|
||||
MochiKit.DOM.addElementClass(this.getId('wrapper'), 'default');
|
||||
MochiKit.DOM.addElementClass(this.getId('button'), 'default');
|
||||
}
|
||||
|
||||
MochiKit.Signal.connect(this.getId('wrapper'), 'onmouseenter', this, 'handleOnMouseEnter');
|
||||
MochiKit.Signal.connect(this.getId('wrapper'), 'onmouseleave', this, 'handleOnMouseLeave');
|
||||
MochiKit.Signal.connect(this.getId('wrapper'), 'onmousedown', this, 'handleOnMouseDown');
|
||||
MochiKit.Signal.connect(this.getId('wrapper'), 'onclick', this, 'handleOnClick');
|
||||
// MochiKit.Signal.connect(this.getId('button'), 'onmouseenter', this, 'handleOnMouseEnter');
|
||||
// MochiKit.Signal.connect(this.getId('button'), 'onmouseleave', this, 'handleOnMouseLeave');
|
||||
// MochiKit.Signal.connect(this.getId('button'), 'onmousedown', this, 'handleOnMouseDown');
|
||||
MochiKit.Signal.connect(this.getId('button'), 'onclick', this, 'handleOnClick');
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
'handleOnMouseEnter': function (anEvent) {
|
||||
MochiKit.DOM.addElementClass(this.getId('wrapper'), 'hover');
|
||||
MochiKit.DOM.addElementClass(this.getId('button'), 'hover');
|
||||
},
|
||||
|
||||
'handleOnMouseLeave': function (anEvent) {
|
||||
MochiKit.DOM.removeElementClass(this.getId('wrapper'), 'hover');
|
||||
MochiKit.DOM.removeElementClass(this.getId('wrapper'), 'clicked');
|
||||
MochiKit.DOM.removeElementClass(this.getId('button'), 'hover');
|
||||
MochiKit.DOM.removeElementClass(this.getId('button'), 'clicked');
|
||||
},
|
||||
|
||||
'handleOnMouseDown': function (anEvent) {
|
||||
MochiKit.DOM.addElementClass(this.getId('wrapper'), 'clicked');
|
||||
MochiKit.DOM.addElementClass(this.getId('button'), 'clicked');
|
||||
},
|
||||
|
||||
*/
|
||||
'handleOnClick': function (anEvent) {
|
||||
MochiKit.Signal.signal(this, 'onclick', anEvent);
|
||||
},
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
__syntaxFix__: "syntax fix"
|
||||
});
|
||||
|
||||
@@ -98,14 +98,29 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.SimpleMessagePanel, Clippe
|
||||
},
|
||||
|
||||
'setType': function (aValue) {
|
||||
if (this.getElement('icon') != null) {
|
||||
MochiKit.DOM.removeElementClass(this.getId('icon'), this._type);
|
||||
MochiKit.DOM.addElementClass(this.getId('icon'), aValue);
|
||||
}
|
||||
// if (this.getElement('icon') != null) {
|
||||
// MochiKit.DOM.removeElementClass(this.getId('icon'), this._type);
|
||||
// MochiKit.DOM.addElementClass(this.getId('icon'), aValue);
|
||||
// }
|
||||
|
||||
this._type = aValue;
|
||||
},
|
||||
|
||||
'icon': function () {
|
||||
var type = this.type();
|
||||
var result;
|
||||
|
||||
if (type == 'ALERT') {
|
||||
result = '!';
|
||||
} else if (type == 'INFO') {
|
||||
result = 'i';
|
||||
} else if (type == 'ERROR') {
|
||||
result = '!';
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'buttons': function () {
|
||||
@@ -132,17 +147,20 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.SimpleMessagePanel, Clippe
|
||||
|
||||
'renderSelf': function() {
|
||||
this.append(this.element(), {tag:'div', cls:'SimpleMessagePanel', id:this.getId('panel'), children: [
|
||||
{tag:'div', cls:'header', children:[]},
|
||||
// {tag:'div', cls:'header', children:[]},
|
||||
{tag:'div', cls:'body', children:[
|
||||
{tag:'div', id:this.getId('icon'), cls:'img ' + this.type(), children:[{tag:'div'}]},
|
||||
// {tag:'div', id:this.getId('icon'), cls:'img ' + this.type(), children:[{tag:'div'}]},
|
||||
{tag:'div', /*id:this.getId('icon'),*/ cls:'img ' + this.type(), children:[{tag:'canvas', id:this.getId('icon')}]},
|
||||
{tag:'h3', id:this.getId('title'), html:this.title()},
|
||||
{tag:'p', id:this.getId('text'), html:this.text()},
|
||||
{tag:'div', id:this.getId('container')},
|
||||
{tag:'div', id:this.getId('buttonArea'), cls:'buttonArea', children:[]}
|
||||
]},
|
||||
{tag:'div', cls:'footer', children:[]}
|
||||
]}
|
||||
// {tag:'div', cls:'footer', children:[]}
|
||||
]});
|
||||
|
||||
Clipperz.PM.UI.Canvas.marks[this.icon()](this.getElement('icon'), "#ffffff");
|
||||
|
||||
MochiKit.Signal.connect(this.getId('panel'), 'onkeydown', this, 'keyDownHandler');
|
||||
|
||||
this.renderButtons();
|
||||
|
||||
@@ -23,30 +23,30 @@ refer to http://www.clipperz.com.
|
||||
|
||||
*/
|
||||
|
||||
Clipperz.Base.module('Clipperz.PM.UI.iPhone.Components');
|
||||
Clipperz.Base.module('Clipperz.PM.UI.Mobile.Components');
|
||||
|
||||
Clipperz.PM.UI.iPhone.Components.CardDetail = function(args) {
|
||||
Clipperz.PM.UI.Mobile.Components.CardDetail = function(args) {
|
||||
args = args || {};
|
||||
|
||||
Clipperz.PM.UI.iPhone.Components.CardDetail.superclass.constructor.apply(this, arguments);
|
||||
Clipperz.PM.UI.Mobile.Components.CardDetail.superclass.constructor.apply(this, arguments);
|
||||
|
||||
this._cardReference = null;
|
||||
// this._cardReference = null;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.CardDetail, Clipperz.PM.UI.Common.Components.BaseComponent, {
|
||||
Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.CardDetail, Clipperz.PM.UI.Common.Components.BaseComponent, {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'toString': function () {
|
||||
return "Clipperz.PM.UI.iPhone.Components.CardDetail component";
|
||||
return "Clipperz.PM.UI.Mobile.Components.CardDetail component";
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
'cardReference': function () {
|
||||
return this._cardReference;
|
||||
},
|
||||
@@ -54,20 +54,156 @@ Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.CardDetail, Clipperz.PM.UI
|
||||
'setCardReference': function (aValue) {
|
||||
this._cardReference = aValue;
|
||||
},
|
||||
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'renderSelf': function(/*aContainer, aPosition*/) {
|
||||
'renderSelf': function () {
|
||||
console.log("CardDetail.renderSelf");
|
||||
this.append(this.element(), {tag:'div', cls:'cardDetail', children:[
|
||||
{tag:'div', cls:'toolbar', children:[
|
||||
{tag:'a', href:'#', cls:'back', html:"List"},
|
||||
{tag:'h1', id:this.getId('cardTitle'), html:"…"}
|
||||
]},
|
||||
{tag:'div', cls:'scroll', id:this.getId('cardDetails'), children:[
|
||||
]}
|
||||
]});
|
||||
},
|
||||
/*
|
||||
'renderSelf': function() {
|
||||
this.append(this.element(), [
|
||||
{tag:'div', cls:'cardDetail', id:this.getId('cardDetail'), children:[
|
||||
{tag:'div', id:this.getId('progressBar')} //,
|
||||
// {tag:'h1', cls:'loading', html:"loading"}
|
||||
]}
|
||||
]);
|
||||
|
||||
this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':this.getElement('progressBar')}));
|
||||
MochiKit.Signal.signal(Clipperz.PM.UI.Common.Controllers.ProgressBarController.defaultController, 'updateProgress', 0);
|
||||
},
|
||||
*/
|
||||
|
||||
'setTitle': function (aValue) {
|
||||
this.getElement('cardTitle').innerHTML = aValue;
|
||||
},
|
||||
|
||||
'fieldListElement': function () {
|
||||
var result;
|
||||
|
||||
result = this.getElement('fieldList');
|
||||
if (result == null) {
|
||||
result = this.append(this.getElement('cardDetails'), {tag:'ul', cls:'rounded', id:this.getId('fieldList')});
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
'renderFieldValues': function (someFieldValues) {
|
||||
var fieldClass;
|
||||
|
||||
if ((someFieldValues['actionType'] != 'NONE') || (someFieldValues['label'] != '') && (someFieldValues['value'] != '')) {
|
||||
if (someFieldValues['isHidden'] == true) {
|
||||
fieldClass = 'password';
|
||||
} else {
|
||||
fieldClass = '';
|
||||
}
|
||||
|
||||
this.append(this.fieldListElement(), {tag:'li', cls:'cardField', children:[
|
||||
{tag:'a', href:'#', cls:fieldClass, html:someFieldValues['value'], children:[
|
||||
{tag:'small', cls:'label', html:someFieldValues['label']}
|
||||
]}
|
||||
]})
|
||||
}
|
||||
},
|
||||
|
||||
'addField': function (aField) {
|
||||
var deferredResult;
|
||||
var fieldValues;
|
||||
|
||||
fieldValues = {};
|
||||
deferredResult = new Clipperz.Async.Deferred("CardDetail.addField", {trace:false});
|
||||
deferredResult.addMethod(aField, 'label');
|
||||
deferredResult.addCallback(function (aValue) { fieldValues['label'] = aValue; });
|
||||
deferredResult.addMethod(aField, 'value');
|
||||
deferredResult.addCallback(function (aValue) { fieldValues['value'] = aValue; });
|
||||
deferredResult.addMethod(aField, 'actionType');
|
||||
deferredResult.addCallback(function (aValue) { fieldValues['actionType'] = aValue; });
|
||||
deferredResult.addMethod(aField, 'isHidden');
|
||||
deferredResult.addCallback(function (aValue) { fieldValues['isHidden'] = aValue; });
|
||||
deferredResult.addMethod(this, 'renderFieldValues', fieldValues);
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'directLoginElement': function () {
|
||||
var result;
|
||||
|
||||
result = this.getElement('directLoginList');
|
||||
if (result == null) {
|
||||
this.append(this.getElement('cardDetails'), {tag:'h2', html:"Direct login"});
|
||||
result = this.append(this.getElement('cardDetails'), {tag:'ul', cls:'rounded', id:this.getId('directLoginList')});
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
'addDirectLogin': function (aDirectLogin) {
|
||||
this.append(this.directLoginElement(), {tag:'li', cls:'directLogin forward', children:[
|
||||
{tag:'a', href:'#', html:"direct login", children:[
|
||||
{tag:'small', cls:'favicon', children:[{tag:'img', cls:'favicon', src:'http://www.clipperz.com/favicon.ico'}]}
|
||||
]}
|
||||
]})
|
||||
|
||||
console.log("ADD DIRECT LOGIN", aDirectLogin);
|
||||
},
|
||||
|
||||
//=========================================================================
|
||||
|
||||
'showCard': function (aCard) {
|
||||
var deferredResult;
|
||||
|
||||
// this.render();
|
||||
|
||||
console.log("CardDetail.showCard", aCard);
|
||||
deferredResult = new Clipperz.Async.Deferred("CardDetail.showCard", {trace:false});
|
||||
deferredResult.addMethod(aCard, 'label');
|
||||
deferredResult.addMethod(this, 'setTitle');
|
||||
|
||||
deferredResult.addMethod(aCard, 'fields');
|
||||
deferredResult.addCallback(MochiKit.Base.values);
|
||||
deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.method(this, 'addField'));
|
||||
|
||||
deferredResult.addMethod(aCard, 'directLogins');
|
||||
deferredResult.addCallback(MochiKit.Base.values);
|
||||
deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.method(this, 'addDirectLogin'));
|
||||
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
// return Clipperz.Async.callbacks("CardDialogController.updateComponentState", [
|
||||
// MochiKit.Base.method(this.record(), 'hasPendingChanges'),
|
||||
// MochiKit.Base.method(this.cardDialogComponent(), 'setShouldEnableSaving'),
|
||||
//
|
||||
// MochiKit.Base.method(this.record(), 'label'),
|
||||
// MochiKit.Base.method(this.cardDialogComponent(), 'setTitle'),
|
||||
// MochiKit.Base.method(this.record(), 'notes'),
|
||||
// MochiKit.Base.method(this.cardDialogComponent(), 'setNotes'),
|
||||
//
|
||||
// MochiKit.Base.method(this.record(), 'fields'),
|
||||
// MochiKit.Base.values,
|
||||
// MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'addCardDialogComponentWithField')),
|
||||
//
|
||||
// MochiKit.Base.method(this.record(), 'directLogins'),
|
||||
// MochiKit.Base.values,
|
||||
// MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'addCardDialogComponentWithDirectLogin')),
|
||||
//
|
||||
// MochiKit.Base.method(this.cardDialogComponent(), 'resetNewFieldInputs'),
|
||||
// MochiKit.Base.noop
|
||||
// ], {trace:false});
|
||||
|
||||
},
|
||||
|
||||
//=========================================================================
|
||||
|
||||
@@ -143,9 +279,9 @@ Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.CardDetail, Clipperz.PM.UI
|
||||
|
||||
MochiKit.DOM.setNodeAttribute(anEvent.src(), 'toggled', nextState);
|
||||
},
|
||||
*/
|
||||
* /
|
||||
//=========================================================================
|
||||
|
||||
/*
|
||||
'directLoginClickHandler': function (anEvent) {
|
||||
anEvent.preventDefault();
|
||||
|
||||
@@ -156,7 +292,7 @@ Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.CardDetail, Clipperz.PM.UI
|
||||
MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'selectedDirectLogin', {cardReference:this.cardReference(), directLoginReference:directLoginReference});
|
||||
}
|
||||
},
|
||||
|
||||
*/
|
||||
//=========================================================================
|
||||
|
||||
__syntaxFix__: "syntax fix"
|
||||
@@ -23,12 +23,12 @@ refer to http://www.clipperz.com.
|
||||
|
||||
*/
|
||||
|
||||
Clipperz.Base.module('Clipperz.PM.UI.iPhone.Components');
|
||||
Clipperz.Base.module('Clipperz.PM.UI.Mobile.Components');
|
||||
|
||||
Clipperz.PM.UI.iPhone.Components.CardList = function(args) {
|
||||
Clipperz.PM.UI.Mobile.Components.CardList = function(args) {
|
||||
args = args || {};
|
||||
|
||||
Clipperz.PM.UI.iPhone.Components.CardList.superclass.constructor.apply(this, arguments);
|
||||
Clipperz.PM.UI.Mobile.Components.CardList.superclass.constructor.apply(this, arguments);
|
||||
|
||||
this._cardDetail = null;
|
||||
|
||||
@@ -37,44 +37,97 @@ Clipperz.PM.UI.iPhone.Components.CardList = function(args) {
|
||||
|
||||
//=============================================================================
|
||||
|
||||
Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.CardList, Clipperz.PM.UI.Common.Components.BaseComponent, {
|
||||
Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.CardList, Clipperz.PM.UI.Common.Components.BaseComponent, {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'toString': function () {
|
||||
return "Clipperz.PM.UI.iPhone.Components.CardList component";
|
||||
return "Clipperz.PM.UI.Mobile.Components.CardList component";
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'renderSelf': function(/*aContainer, aPosition*/) {
|
||||
this.append(this.element(), [
|
||||
{tag:'div', cls:'toolbar', id:'toolbar', children:[
|
||||
{tag:'h1', id:'pageTitle', html:"cards"},
|
||||
{tag:'a', id:'backButton', cls:'button', href:'#', html:"cards"}
|
||||
'renderSelf': function () {
|
||||
this.append(this.element(), {tag:'div', cls:'cardList', children:[
|
||||
{tag:'div', cls:'toolbar', children:[
|
||||
{tag:'h1', html:"clipperz"},
|
||||
// {tag:'input', name:'search', type:'search', autocomplete:'off', placeholder:"search", id:this.getId('search')},
|
||||
{tag:'a', href:'#', id:'settings', cls:'button', html:"*"}
|
||||
]},
|
||||
{tag:'div', cls:'cardList', id:this.getId('cardList'), children:[
|
||||
{tag:'form', title:'search', cls:'panel cardListSearchForm', id:this.getId('cardListSearchForm'), children:[
|
||||
{tag:'input', type:'search', name:'search', value:"", placeholder:"search", id:this.getId('searchField')}
|
||||
]},
|
||||
{tag:'ul', cls:'panel cardListPanel', id:this.getId('cardListPanel'), children:[]}
|
||||
]},
|
||||
{tag:'div', cls:'panel cardDetailPanel', id:this.getId('cardDetail')}
|
||||
]);
|
||||
{tag:'div', cls:'scroll', id:this.getId('listBox'), children:[
|
||||
{tag:'ul', cls:'rounded', id:this.getId('list'), children:[
|
||||
{tag:'li', html:'loading'}
|
||||
]}
|
||||
]}
|
||||
]});
|
||||
|
||||
MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onsubmit', this, 'searchHandler');
|
||||
MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onkeydown', this, 'searchHandler');
|
||||
MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onkeyup', this, 'searchHandler');
|
||||
MochiKit.Signal.connect(this.getElement('list'), 'onclick', this, 'cardSelectionHandler');
|
||||
MochiKit.Signal.connect(this.getElement('list'), 'ontouchstart', this, 'cardSelectionHandler');
|
||||
// MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onsubmit', this, 'searchHandler');
|
||||
// MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onkeydown', this, 'searchHandler');
|
||||
// MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onkeyup', this, 'searchHandler');
|
||||
|
||||
MochiKit.Signal.connect(this.getElement('cardListPanel'), 'onclick', this, 'cardListClickHandler');
|
||||
MochiKit.Signal.connect('backButton', 'onclick', this, 'backButtonClickHandler');
|
||||
// MochiKit.Signal.connect(this.getElement('cardListPanel'), 'onclick', this, 'cardListClickHandler');
|
||||
// MochiKit.Signal.connect('backButton', 'onclick', this, 'backButtonClickHandler');
|
||||
|
||||
MochiKit.Style.hideElement('backButton');
|
||||
MochiKit.Style.hideElement(this.getElement('cardDetail'));
|
||||
// MochiKit.Style.hideElement('backButton');
|
||||
// MochiKit.Style.hideElement(this.getElement('cardDetail'));
|
||||
},
|
||||
|
||||
'showCards': function (someCards) {
|
||||
var cardListElement;
|
||||
if (this.isFullyRendered() == false) {
|
||||
this.render();
|
||||
};
|
||||
|
||||
cardListElement = this.getElement('list')
|
||||
|
||||
cardInfo = {
|
||||
'_rowObject': MochiKit.Async.succeed,
|
||||
'_reference': MochiKit.Base.methodcaller('reference'),
|
||||
'_searchableContent': MochiKit.Base.methodcaller('searchableContent'),
|
||||
'label': MochiKit.Base.methodcaller('label'),
|
||||
'favicon': MochiKit.Base.methodcaller('favicon')
|
||||
};
|
||||
|
||||
//console.log("someCards", someCards);
|
||||
deferredResult = new Clipperz.Async.Deferred("CardList.showCards", {trace:false});
|
||||
deferredResult.addCallback(MochiKit.Base.map, Clipperz.Async.collectResults("CardList.value - collectResults", cardInfo, {trace:false}));
|
||||
deferredResult.addCallback(Clipperz.Async.collectAll);
|
||||
deferredResult.addCallback(MochiKit.Base.methodcaller('sort', Clipperz.Base.caseInsensitiveKeyComparator('label')));
|
||||
deferredResult.addCallbackPass(MochiKit.DOM.replaceChildNodes, cardListElement);
|
||||
// deferredResult.addCallbackPass(MochiKit.DOM.removeElementClass, cardListElement, 'loading');
|
||||
deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.method(this, 'appendCardToList', cardListElement));
|
||||
deferredResult.callback(someCards);
|
||||
},
|
||||
|
||||
'appendCardToList': function (aCardListElement, aCardInfo) {
|
||||
//console.log("appendCardToList", aCardInfo);
|
||||
this.append(aCardListElement, {tag:'li', cls:'cardListItem arrow', cardreference:aCardInfo['_reference'], children:[
|
||||
{tag:'a', href:'#', html:aCardInfo['label'], children:[
|
||||
{tag:'small', cls:'favicon', children:[{tag:'img', cls:'favicon', src:aCardInfo['favicon']}]}
|
||||
]}
|
||||
]});
|
||||
},
|
||||
|
||||
'cardSelectionHandler': function (anEvent) {
|
||||
var listElement;
|
||||
var cardReference;
|
||||
|
||||
anEvent.preventDefault();
|
||||
|
||||
listElement = anEvent.target();
|
||||
if (MochiKit.DOM.getNodeAttribute(listElement, 'cardreference') == null) {
|
||||
listElement = MochiKit.DOM.getFirstParentByTagAndClassName(anEvent.target(), tagName='li', className='cardListItem');
|
||||
}
|
||||
cardReference = MochiKit.DOM.getNodeAttribute(listElement, 'cardreference');
|
||||
console.log("###", listElement, cardReference);
|
||||
// TODO: Notify card with reference MochiKit.DOM.getNodeAttribute(listElement, 'cardreference') has been selected
|
||||
MochiKit.Signal.signal(this, 'selectedCard', cardReference);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
'searchHandler': function (anEvent) {
|
||||
if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ENTER')) { // RETURN
|
||||
anEvent.preventDefault();
|
||||
@@ -127,7 +180,7 @@ Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.CardList, Clipperz.PM.UI.C
|
||||
|
||||
'cardDetail': function (someData) {
|
||||
if (this._cardDetail == null) {
|
||||
this._cardDetail = new Clipperz.PM.UI.iPhone.Components.CardDetail({element:this.getElement('cardDetail')});
|
||||
this._cardDetail = new Clipperz.PM.UI.Mobile.Components.CardDetail({element:this.getElement('cardDetail')});
|
||||
}
|
||||
|
||||
return this._cardDetail;
|
||||
@@ -195,7 +248,7 @@ Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.CardList, Clipperz.PM.UI.C
|
||||
], {duration:1, afterFinish:MochiKit.Base.method(this, 'removeCardDetail')})
|
||||
|
||||
},
|
||||
|
||||
*/
|
||||
//=========================================================================
|
||||
__syntaxFix__: "syntax fix"
|
||||
});
|
||||
356
frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js
Normal file
356
frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js
Normal file
@@ -0,0 +1,356 @@
|
||||
/*
|
||||
|
||||
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.Mobile.Components');
|
||||
|
||||
Clipperz.PM.UI.Mobile.Components.LoginForm = function(args) {
|
||||
args = args || {};
|
||||
|
||||
this._pin = '';
|
||||
|
||||
this._message = null;
|
||||
this._steps = 0;
|
||||
this._actualSteps = 0;
|
||||
|
||||
this._callback = null;
|
||||
this._errorCallback = null;
|
||||
|
||||
this._mode = 'CREDENTIALS';
|
||||
|
||||
Clipperz.PM.UI.Mobile.Components.LoginForm.superclass.constructor.apply(this, arguments);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI.Common.Components.BaseComponent, {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'toString': function () {
|
||||
return "Clipperz.PM.UI.Mobile.Components.LoginForm component";
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'callback': function () {
|
||||
return this._callback;
|
||||
},
|
||||
|
||||
'errorCallback': function () {
|
||||
return this._errorCallback;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'mode': function () {
|
||||
return this._mode;
|
||||
},
|
||||
|
||||
'setMode': function (aValue) {
|
||||
this._mode = aValue;
|
||||
},
|
||||
|
||||
//..........................................................................
|
||||
|
||||
'pin': function () {
|
||||
return this._pin;
|
||||
},
|
||||
|
||||
'setPin': function (aValue) {
|
||||
this._pin = aValue;
|
||||
},
|
||||
|
||||
//..........................................................................
|
||||
|
||||
'username': function () {
|
||||
return this._username;
|
||||
},
|
||||
|
||||
'setUsername': function (aValue) {
|
||||
this._username = aValue;
|
||||
},
|
||||
|
||||
//..........................................................................
|
||||
|
||||
'passphrase': function () {
|
||||
return this._passphrase;
|
||||
},
|
||||
|
||||
'setPassphrase': function (aValue) {
|
||||
this._passphrase = aValue;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'message': function () {
|
||||
return this._message;
|
||||
},
|
||||
|
||||
'_setMessage': function (aValue) {
|
||||
this._message = aValue;
|
||||
|
||||
if (aValue == null) {
|
||||
MochiKit.Style.hideElement(this.getElement('credentialsMessage'));
|
||||
} else {
|
||||
this.getElement('message').innerHTML = aValue;
|
||||
MochiKit.Style.showElement(this.getElement('credentialsMessage'));
|
||||
}
|
||||
},
|
||||
|
||||
'setMessage': function (aValue) {
|
||||
this._setMessage(aValue);
|
||||
MochiKit.DOM.removeElementClass(this.getElement('credentialsMessage'), 'error');
|
||||
},
|
||||
|
||||
'setErrorMessage': function (aValue) {
|
||||
this._setMessage(aValue);
|
||||
MochiKit.DOM.addElementClass(this.getElement('credentialsMessage'), 'error');
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'setCallbacks': function (args) {
|
||||
this._callback = args['callback'];
|
||||
this._errorCallback = args['errorCallback'];
|
||||
},
|
||||
|
||||
'showErrors': function (args) {
|
||||
//console.log("LoginForm.showErrors", args);
|
||||
if (args['previousFailedAttempt'] == 'LOGIN') {
|
||||
this.setErrorMessage("Wrong credentials");
|
||||
} else if (args['previousFailedAttempt'] == 'PIN') {
|
||||
if (args['failedAttempts'] == -1) {
|
||||
this.setErrorMessage("Wrong PIN - Resetted");
|
||||
} else {
|
||||
this.setErrorMessage("Wrong PIN");
|
||||
}
|
||||
} else {
|
||||
this.setMessage(null);
|
||||
}
|
||||
},
|
||||
|
||||
'updateWithArgs': function (args) {
|
||||
this.renderIfNeeded();
|
||||
this.setCallbacks(args);
|
||||
this.showErrors(args);
|
||||
this.updateRendering();
|
||||
},
|
||||
|
||||
'showPinLogin': function (args) {
|
||||
this.setPin('');
|
||||
this.setMode('PIN');
|
||||
this.updateWithArgs(args);
|
||||
|
||||
// $(this.getAnchor('PIN')).focus();
|
||||
this.getElement('PIN').focus();
|
||||
},
|
||||
|
||||
'showCredentialsLogin': function (args) {
|
||||
this.setMode('CREDENTIALS');
|
||||
this.updateWithArgs(args);
|
||||
|
||||
if (this.getElement('usernameField').value.length == 0) {
|
||||
// $(this.getAnchor('usernameField')).focus();
|
||||
this.getElement('usernameField').focus();
|
||||
} else {
|
||||
// $(this.getAnchor('passphraseField')).focus();
|
||||
this.getElement('passphraseField').focus();
|
||||
this.getElement('passphraseField').select();
|
||||
}
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'renderIfNeeded': function () {
|
||||
if (this.isFullyRendered() == false) {
|
||||
this.render();
|
||||
};
|
||||
this.updateRendering();
|
||||
},
|
||||
|
||||
'updateRendering': function () {
|
||||
MochiKit.Style.showElement(this.getElement('credentialsBody'));
|
||||
MochiKit.Style.hideElement(this.getElement('validating'));
|
||||
|
||||
// this.hideAllPanes();
|
||||
MochiKit.Base.map(function (aNode) { MochiKit.Style.hideElement(aNode); }, MochiKit.Selector.findDocElements('div.credentialsBody > div'));
|
||||
if (this.mode() == 'CREDENTIALS') {
|
||||
selectedPanel = this.getElement('credentials')
|
||||
} else if (this.mode() == 'PIN') {
|
||||
selectedPanel = this.getElement('pin')
|
||||
// this.updatePinDisplay();
|
||||
} else {
|
||||
throw 'Unhandled login form mode';
|
||||
}
|
||||
MochiKit.Style.showElement(selectedPanel);
|
||||
|
||||
MochiKit.Style.hideElement(this.getElement('validating'));
|
||||
},
|
||||
|
||||
'renderSelf': function() {
|
||||
var selectedPanel;
|
||||
this.append(this.element(), {tag:'div', id:'login', children:[
|
||||
{tag:'div', cls:'toolbar', children:[
|
||||
{tag:'h1', html:"clipperz"}
|
||||
]},
|
||||
{tag:'div', cls:'scroll', children:[
|
||||
//==================================================================
|
||||
{tag:'div', cls:'credentialsMessage', id:this.getId('credentialsMessage'), children:[
|
||||
{tag:'h1', cls:'message', id:this.getId('message'), html:"Message"}
|
||||
]},
|
||||
//==================================================================
|
||||
{tag:'div', cls:'credentialsBody', id:this.getId('credentialsBody'), children:[
|
||||
//--------------------------------------------------------------
|
||||
{tag:'div', cls:'pin', id:this.getId('pin'), children:[
|
||||
{tag:'form', cls:'scroll', id:this.getId('pinForm'), children:[
|
||||
{tag:'ul', cls:'edit rounded', children:[
|
||||
{tag:'li', children:[{tag:'input', type:'number', name:'PIN', placeholder:"PIN", id:this.getId('PIN') }]},
|
||||
]},
|
||||
{tag:'a', href:'#', cls:'greenButton', id:this.getId('pinSubmitButton'), html:"Login"}
|
||||
]}
|
||||
]},
|
||||
//--------------------------------------------------------------
|
||||
{tag:'div', cls:'credentials', id:this.getId('credentials'), children:[
|
||||
{tag:'form', cls:'scroll', id:this.getId('credentialsForm'), children:[
|
||||
{tag:'ul', cls:'edit rounded', children:[
|
||||
{tag:'li', children:[{tag:'input', type:'email', name:'name', /*value:'joe',*/ placeholder:"username", id:this.getId('usernameField') }]},
|
||||
{tag:'li', children:[{tag:'input', type:'password', name:'passphrase', /*value:'clipperz',*/ placeholder:"passphrase", id:this.getId('passphraseField') }]}
|
||||
]},
|
||||
{tag:'a', href:'#', cls:'greenButton', id:this.getId('credentialsSubmitButton'), html:"Login"}
|
||||
// {tag:'input', type:'submit', cls:'greenButton', id:this.getId('credentialsSubmitButton'), value:"Login"}
|
||||
|
||||
]}
|
||||
]},
|
||||
//--------------------------------------------------------------
|
||||
]},
|
||||
//==================================================================
|
||||
{tag:'div', cls:'validating', id:this.getId('validating'), children:[
|
||||
{tag:'div', cls:'loading', children:[
|
||||
{tag:'div', cls:'spinner', children:[
|
||||
{tag:'div', cls:'bar01'},
|
||||
{tag:'div', cls:'bar02'},
|
||||
{tag:'div', cls:'bar03'},
|
||||
{tag:'div', cls:'bar04'},
|
||||
{tag:'div', cls:'bar05'},
|
||||
{tag:'div', cls:'bar06'},
|
||||
{tag:'div', cls:'bar07'},
|
||||
{tag:'div', cls:'bar08'},
|
||||
{tag:'div', cls:'bar09'},
|
||||
{tag:'div', cls:'bar10'},
|
||||
{tag:'div', cls:'bar11'},
|
||||
{tag:'div', cls:'bar12'}
|
||||
]}
|
||||
]},
|
||||
{tag:'div', id:this.getId('loadingMessage')},
|
||||
{tag:'a', href:'#', cls:'grayButton', id:this.getId('loginCancelButton'), html:"Cancel"}
|
||||
]}
|
||||
//==================================================================
|
||||
]}
|
||||
]});
|
||||
|
||||
MochiKit.Signal.connect(this.getElement('credentialsForm'), 'onsubmit', this, 'submitCredentialsHandler');
|
||||
MochiKit.Signal.connect(this.getElement('credentialsSubmitButton'), 'onclick', this, 'submitCredentialsHandler');
|
||||
|
||||
MochiKit.Signal.connect(this.getElement('pinForm'), 'onsubmit', this, 'submitPinHandler');
|
||||
MochiKit.Signal.connect(this.getElement('pinSubmitButton'), 'onclick', this, 'submitPinHandler');
|
||||
|
||||
MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'initProgress', this, 'initProgressHandle');
|
||||
MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'updateProgress', this, 'updateProgressHandle');
|
||||
MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'advanceProgress', this, 'advanceProgressHandle');
|
||||
MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'progressDone', this, 'progressDoneHandle');
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'submitPinHandler': function (anEvent) {
|
||||
var pin;
|
||||
|
||||
this.setMessage(null);
|
||||
pin = this.getElement('PIN').value;
|
||||
// $(this.getAnchor('PIN')).blur();
|
||||
this.getElement('PIN').blur();
|
||||
|
||||
credentials = Clipperz.PM.PIN.credentialsWithPIN(pin);
|
||||
this.loginWithCredentials(credentials);
|
||||
},
|
||||
|
||||
'submitCredentialsHandler': function (anEvent) {
|
||||
//console.log("submitCredentialsHandler");
|
||||
var credentials;
|
||||
|
||||
this.setMessage(null);
|
||||
|
||||
credentials = {};
|
||||
credentials['username'] = this.getElement('usernameField').value;
|
||||
credentials['passphrase'] = this.getElement('passphraseField').value;
|
||||
// $(this.getAnchor('passphraseField')).blur();
|
||||
this.getElement('passphraseField').blur();
|
||||
|
||||
this.loginWithCredentials(credentials);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'loginWithCredentials': function (someCredentials) {
|
||||
var args;
|
||||
|
||||
args = {};
|
||||
args['credentials'] = someCredentials;
|
||||
args['errorCallback'] = this.errorCallback();
|
||||
|
||||
MochiKit.Style.hideElement(this.getElement('credentialsBody'));
|
||||
MochiKit.Style.showElement(this.getElement('validating'));
|
||||
|
||||
MochiKit.Async.callLater(0.1, this.callback(), args);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'initProgressHandle': function (anEvent) {
|
||||
//console.log("** initProgressHandle", anEvent);
|
||||
this._steps = anEvent['steps'];
|
||||
this._actualSteps = 0;
|
||||
},
|
||||
|
||||
'updateProgressHandle': function (anEvent) {
|
||||
//console.log("** updateProgressHandle", anEvent);
|
||||
this._steps += anEvent['extraSteps'];
|
||||
},
|
||||
|
||||
'advanceProgressHandle': function (anEvent) {
|
||||
//console.log("** advanceProgressHandle", anEvent);
|
||||
this._actualSteps ++;
|
||||
//console.log("STEPS: " + this._actualSteps + "/" + this._steps);
|
||||
},
|
||||
|
||||
'progressDoneHandle': function (anEvent) {
|
||||
//console.log("** progressDoneHandle", anEvent);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
__syntaxFix__: "syntax fix"
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
@@ -41,6 +41,10 @@ Clipperz.PM.UI.Web.Components.AccountPanel = function(args) {
|
||||
tab: 'passphraseTab',
|
||||
panel: 'passphrasePanel'
|
||||
},
|
||||
'OTP': {
|
||||
tab: 'OTPTab',
|
||||
panel: 'OTPPanel'
|
||||
},
|
||||
'PREFERENCES': {
|
||||
tab: 'preferencesTab',
|
||||
panel: 'preferencesPanel'
|
||||
@@ -74,6 +78,7 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.AccountPanel, Clipperz.PM.UI.
|
||||
{tag:'ul', children:[
|
||||
// {tag:'li', id:this.getId('accountTab'), children:[{tag:'a', href:'#', html:'Account'}], cls:'first'},
|
||||
{tag:'li', id:this.getId('passphraseTab'), children:[{tag:'a', href:'#', html:'Passphrase'}], cls:'first'},
|
||||
{tag:'li', id:this.getId('OTPTab'), children:[{tag:'a', href:'#', html:'One Time Passwords'}]},
|
||||
{tag:'li', id:this.getId('preferencesTab'), children:[{tag:'a', href:'#', html:'Preferences'}]},
|
||||
{tag:'li', id:this.getId('loginHistoryTab'), children:[{tag:'a', href:'#', html:'Login history'}]}
|
||||
]}
|
||||
@@ -117,16 +122,16 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.AccountPanel, Clipperz.PM.UI.
|
||||
{tag:'div', cls:'clear'},
|
||||
{tag:'div', cls:'confirmButton', id:this.getId('confirmationButton'), children:[
|
||||
{tag:'span', html:"change passphrase"}
|
||||
]},
|
||||
|
||||
{tag:'h3', cls:'manageOTP', html:"Manage One-Time Passphrases"},
|
||||
{}
|
||||
]}
|
||||
]},
|
||||
{tag:'li', id:this.getId('OTPPanel'), children:[
|
||||
// {tag:'h3', html:"Manage One-Time Passphrases"}
|
||||
]},
|
||||
{tag:'li', id:this.getId('preferencesPanel'), children:[
|
||||
{tag:'h3', html:"-- Preferences --"}
|
||||
// {tag:'h3', html:"-- Preferences --"}
|
||||
]},
|
||||
{tag:'li', id:this.getId('loginHistoryPanel'), children:[
|
||||
{tag:'h3', html:"-- Login History --"}
|
||||
// {tag:'h3', html:"-- Login History --"}
|
||||
]}
|
||||
]}
|
||||
]}
|
||||
|
||||
@@ -82,16 +82,18 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.DataPanel, Clipperz.PM.UI.Com
|
||||
{tag:'div', cls:'subPanelContent', children:[
|
||||
{tag:'ul', children:[
|
||||
{tag:'li', id:this.getId('offlineCopyPanel'), children:[
|
||||
{tag:'h3', html:"Offline copy"}
|
||||
// {tag:'h3', html:"Offline copy"},
|
||||
{tag:'p', html:"With just one click you can dump all your encrypted data from Clipperz servers to your hard disk and create a read-only offline version of Clipperz to be used when you are not connected to the Internet."},
|
||||
{tag:'a', id:this.getId('offlineCopyDownloadLink'), href:'#', html:"Download", cls:'downloadOfflineCopy'}
|
||||
]},
|
||||
{tag:'li', id:this.getId('sharingPanel'), children:[
|
||||
{tag:'h3', html:"Sharing"}
|
||||
// {tag:'h3', html:"Sharing"}
|
||||
]},
|
||||
{tag:'li', id:this.getId('importPanel'), children:[
|
||||
{tag:'h3', html:"Import"}
|
||||
// {tag:'h3', html:"Import"}
|
||||
]},
|
||||
{tag:'li', id:this.getId('exportPanel'), children:[
|
||||
{tag:'h3', html:"Export"}
|
||||
// {tag:'h3', html:"Export"}
|
||||
]}
|
||||
]}
|
||||
]}
|
||||
@@ -101,8 +103,14 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.DataPanel, Clipperz.PM.UI.Com
|
||||
]);
|
||||
|
||||
this.tabPanelController().setup({selected:this.initiallySelectedTab()});
|
||||
MochiKit.Signal.connect(this.getId('offlineCopyDownloadLink'), 'onclick', this, 'downloadOfflineCopy');
|
||||
},
|
||||
|
||||
|
||||
'downloadOfflineCopy': function (anEvent) {
|
||||
anEvent.preventDefault();
|
||||
MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'downloadOfflineCopy', anEvent.src());
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
__syntaxFix__: "syntax fix"
|
||||
});
|
||||
|
||||
@@ -82,9 +82,10 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.LoginProgress, Clipperz.PM.UI
|
||||
]},
|
||||
{tag:'div', cls:'footer', children:[
|
||||
{tag:'div', cls:'buttonArea', id:this.getId('buttonArea'), children:[
|
||||
{tag:'div', cls:'button', id:this.getId('button'), children:[
|
||||
{tag:'a', href:'#', id:this.getId('buttonLink'), html:"cancel"}
|
||||
]}
|
||||
// {tag:'div', cls:'button', id:this.getId('button'), children:[
|
||||
// {tag:'a', href:'#', id:this.getId('buttonLink'), html:"cancel"}
|
||||
// ]}
|
||||
{tag:'a', cls:'button', id:this.getId('button'), html:"cancel"}
|
||||
]}
|
||||
]}
|
||||
]});
|
||||
@@ -95,7 +96,8 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.LoginProgress, Clipperz.PM.UI
|
||||
this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':this.getElement('progressBar')}));
|
||||
MochiKit.Style.hideElement(this.getElement('errorBox'));
|
||||
|
||||
MochiKit.Signal.connect(this.getId('buttonLink'), 'onclick', this, 'cancelEventHandler');
|
||||
// MochiKit.Signal.connect(this.getId('buttonLink'), 'onclick', this, 'cancelEventHandler');
|
||||
MochiKit.Signal.connect(this.getId('button'), 'onclick', this, 'cancelEventHandler');
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@@ -121,7 +123,9 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.LoginProgress, Clipperz.PM.UI
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'showErrorMessage': function() {
|
||||
this.getElement('buttonLink').innerHTML = "close";
|
||||
// this.getElement('buttonLink').innerHTML = "close";
|
||||
this.getElement('button').innerHTML = "close";
|
||||
MochiKit.DOM.addElementClass(this.getElement('button'), 'default');
|
||||
|
||||
MochiKit.Style.hideElement(this.getElement('progressBar'));
|
||||
|
||||
|
||||
@@ -82,16 +82,16 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.ToolsPanel, Clipperz.PM.UI.Co
|
||||
{tag:'div', cls:'subPanelContent', children:[
|
||||
{tag:'ul', children:[
|
||||
{tag:'li', id:this.getId('passwordGeneratorPanel'), children:[
|
||||
{tag:'h3', html:"Password generator"}
|
||||
// {tag:'h3', html:"Password generator"}
|
||||
]},
|
||||
{tag:'li', id:this.getId('bookmarkletPanel'), children:[
|
||||
{tag:'h3', html:"Bookmarklet"}
|
||||
// {tag:'h3', html:"Bookmarklet"}
|
||||
]},
|
||||
{tag:'li', id:this.getId('compactEditionPanel'), children:[
|
||||
{tag:'h3', html:"Compact edition"}
|
||||
// {tag:'h3', html:"Compact edition"}
|
||||
]},
|
||||
{tag:'li', id:this.getId('httpAuthPanel'), children:[
|
||||
{tag:'h3', html:"HTTP Auth"}
|
||||
// {tag:'h3', html:"HTTP Auth"}
|
||||
]}
|
||||
]}
|
||||
]}
|
||||
|
||||
@@ -231,9 +231,11 @@ MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.AppController.prototype, {
|
||||
this.hideAllAppPageTabSlots();
|
||||
this.appPage().showSlot(this.slotNameForTab('cards'));
|
||||
|
||||
MochiKit.Signal.connect(this.tabSidePanel(), 'tabSelected', this, 'handleTabSelected');
|
||||
MochiKit.Signal.connect(this.tabSidePanel(), 'addCard', this, 'handleAddCard');
|
||||
MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'addCard', this, 'handleAddCard');
|
||||
MochiKit.Signal.connect(this.tabSidePanel(), 'tabSelected', this, 'handleTabSelected');
|
||||
MochiKit.Signal.connect(this.tabSidePanel(), 'addCard', this, 'handleAddCard');
|
||||
MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'addCard', this, 'handleAddCard');
|
||||
|
||||
MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'downloadOfflineCopy', this, 'handleDownloadOfflineCopy');
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("AppController.run", {trace:false});
|
||||
|
||||
@@ -321,6 +323,29 @@ MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.AppController.prototype, {
|
||||
], {trace:false});
|
||||
},
|
||||
|
||||
'handleDownloadOfflineCopy': function (anEvent) {
|
||||
console.log("AppController.handleDownloadOfflineCopy");
|
||||
var downloadHref;
|
||||
|
||||
downloadHref = window.location.href.replace(/\/[^\/]*$/,'') + Clipperz_dumpUrl;
|
||||
|
||||
if (Clipperz_IEisBroken == true) {
|
||||
window.open(downloadHref, "");
|
||||
} else {
|
||||
var deferredResult;
|
||||
var newWindow;
|
||||
|
||||
newWindow = window.open("", "");
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("AppController.handleDownloadOfflineCopy", {trace:true});
|
||||
deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'echo', {'echo':"echo"});
|
||||
deferredResult.addCallback(function(aWindow) {
|
||||
aWindow.location.href = downloadHref;
|
||||
}, newWindow);
|
||||
deferredResult.callback();
|
||||
}
|
||||
},
|
||||
|
||||
//=============================================================================
|
||||
__syntaxFix__: "syntax fix"
|
||||
});
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
/*
|
||||
|
||||
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.iPhone.Components');
|
||||
|
||||
Clipperz.PM.UI.iPhone.Components.LoginForm = function(args) {
|
||||
args = args || {};
|
||||
|
||||
Clipperz.PM.UI.iPhone.Components.LoginForm.superclass.constructor.apply(this, arguments);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.LoginForm, Clipperz.PM.UI.Common.Components.BaseComponent, {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'toString': function () {
|
||||
return "Clipperz.PM.UI.iPhone.Components.LoginForm component";
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'focusOnUsername': function () {
|
||||
this.getElement('username').focus();
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'username': function () {
|
||||
return this.getElement('username').value;
|
||||
},
|
||||
|
||||
'passphrase': function () {
|
||||
return this.getElement('passphrase').value;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'renderSelf': function(/*aContainer, aPosition*/) {
|
||||
this.append(this.element(), [
|
||||
{tag:'div', cls:'toolbar iPhoneClipperzToolbar', children:[
|
||||
{tag:'h1', id:'pageTitle', html:'Clipperz'},
|
||||
{tag:'a', id:'backButton', cls:'button', href:'#', html:"back"}
|
||||
]},
|
||||
{tag:'form', title:'Theaters', cls:'panel toolbarlessPanel loginForm', id:this.getId('loginFormPanel'), children:[
|
||||
{tag:'fieldset', id:this.getId('fieldset'), children:[
|
||||
{tag:'div', cls:'row', children:[
|
||||
{tag:'label', html:"username"},
|
||||
{tag:'input', type:'text', name:'username', value:"", autocorrect:'off', autocapitalize:'off', id:this.getId('username')}
|
||||
]},
|
||||
{tag:'div', cls:'row', children:[
|
||||
{tag:'label', html:"passphrase"},
|
||||
{tag:'input', type:'password', name:'passphrase', value:"", id:this.getId('passphrase')}
|
||||
]}
|
||||
]},
|
||||
{tag:'a', cls:'whiteButton', type:'submit', href:'#', html:"Login", id:this.getId('submit')}
|
||||
]},
|
||||
{tag:'div', cls:'panel toolbarlessPanel loginProgressPanel', id:this.getId('loginProgressPanel'), children:[
|
||||
{tag:'div', id:this.getId('progressBar')} //,
|
||||
// {tag:'a', cls:'whiteButton', type:'submit', href:'#', html:"Cancel", id:this.getId('cancel')}
|
||||
]},
|
||||
{tag:'div', cls:'panel loginErrorPanel', id:this.getId('loginErrorPanel'), children:[
|
||||
{tag:'div', cls:'errorMessage', id:this.getId('errorMessageBox'), children:[
|
||||
{tag:'h2', id:this.getId('errorMessage'), html:"Login failed"}
|
||||
]}
|
||||
]}
|
||||
]);
|
||||
|
||||
MochiKit.Signal.connect(this.getElement('submit'), 'onclick', this, 'submitHandler');
|
||||
MochiKit.Signal.connect(this.getElement('loginFormPanel'), 'onsubmit', this, 'submitHandler');
|
||||
|
||||
// MochiKit.Signal.connect(this.getElement('cancel'), 'onclick', this, 'cancelHandler');
|
||||
MochiKit.Signal.connect('backButton', 'onclick', this, 'backHandler');
|
||||
|
||||
this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':this.getElement('progressBar')}));
|
||||
|
||||
// MochiKit.Style.hideElement(this.getElement('errorMessage'));
|
||||
|
||||
this.showLoginForm();
|
||||
// MochiKit.Async.callLater(0.2, MochiKit.Base.method(this, 'focusOnUsername'));
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'showLoginForm': function () {
|
||||
MochiKit.Style.showElement(this.getElement('loginFormPanel'));
|
||||
MochiKit.Style.hideElement(this.getElement('loginProgressPanel'));
|
||||
MochiKit.Style.hideElement(this.getElement('loginErrorPanel'));
|
||||
MochiKit.Style.hideElement('backButton');
|
||||
},
|
||||
|
||||
'slideInLoginForm': function () {
|
||||
var offset;
|
||||
|
||||
offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480);
|
||||
|
||||
MochiKit.Style.showElement(this.getElement('loginFormPanel'));
|
||||
MochiKit.Style.setElementPosition(this.getElement('loginFormPanel'), {x:-offset, y:0});
|
||||
|
||||
new MochiKit.Visual.Sequence([
|
||||
new MochiKit.Visual.Parallel([
|
||||
new MochiKit.Visual.Move(this.getElement('loginErrorPanel'), {x:offset, y:0, mode:'relative', transition:MochiKit.Visual.Transitions.linear, sync:true}),
|
||||
new MochiKit.Visual.Move(this.getElement('loginFormPanel'), {x:0, y:0, mode:'absolute', transition:MochiKit.Visual.Transitions.linear, sync:true}),
|
||||
MochiKit.Visual.fade ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true})
|
||||
], {duration:0.5, sync:true}),
|
||||
MochiKit.Visual.fade(this.getElement('loginErrorPanel'), {duration:0, sync:true})
|
||||
], {})
|
||||
},
|
||||
|
||||
'showLoginProgress': function () {
|
||||
MochiKit.Style.hideElement(this.getElement('loginFormPanel'));
|
||||
MochiKit.Style.showElement(this.getElement('loginProgressPanel'));
|
||||
},
|
||||
|
||||
'showLoginError': function (anError) {
|
||||
this.getElement('errorMessage').innerHTML = "Login error";
|
||||
|
||||
MochiKit.Style.showElement('backButton');
|
||||
MochiKit.Style.hideElement(this.getElement('loginProgressPanel'));
|
||||
MochiKit.Style.showElement(this.getElement('loginErrorPanel'));
|
||||
MochiKit.Style.setElementPosition(this.getElement('loginErrorPanel'), {x:0, y:45});
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
'disableCancelButton': function () {
|
||||
MochiKit.DOM.hideElement(this.getElement('cancel'));
|
||||
},
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'submitHandler': function (anEvent) {
|
||||
anEvent.preventDefault();
|
||||
|
||||
MochiKit.Signal.signal(this, 'doLogin', {'username':this.username(), 'passphrase':this.passphrase()});
|
||||
},
|
||||
|
||||
'cancelHandler': function (anEvent) {
|
||||
anEvent.preventDefault();
|
||||
|
||||
//console.log("CANCEL");
|
||||
},
|
||||
|
||||
'backHandler': function (anEvent) {
|
||||
anEvent.preventDefault();
|
||||
|
||||
this.slideInLoginForm();
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
__syntaxFix__: "syntax fix"
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user