summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components
Side-by-side diff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Mobile/Components') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js299
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardList.js254
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js356
3 files changed, 909 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js
new file mode 100644
index 0000000..32dfa63
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js
@@ -0,0 +1,299 @@
+/*
+
+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.CardDetail = function(args) {
+ args = args || {};
+
+ Clipperz.PM.UI.Mobile.Components.CardDetail.superclass.constructor.apply(this, arguments);
+
+// this._cardReference = null;
+
+ return this;
+}
+
+//=============================================================================
+
+Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.CardDetail, Clipperz.PM.UI.Common.Components.BaseComponent, {
+
+ //-------------------------------------------------------------------------
+
+ 'toString': function () {
+ return "Clipperz.PM.UI.Mobile.Components.CardDetail component";
+ },
+
+ //-------------------------------------------------------------------------
+/*
+ 'cardReference': function () {
+ return this._cardReference;
+ },
+
+ 'setCardReference': function (aValue) {
+ this._cardReference = aValue;
+ },
+*/
+ //-------------------------------------------------------------------------
+
+ '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')} //,
+ ]}
+ ]);
+
+ 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});
+
+ },
+
+ //=========================================================================
+
+ 'showCardDetails': function (someData) {
+ this.element().innerHTML = '';
+ this.append(this.element(), [
+ {tag:'fieldset', id:this.getId('fields'), children:MochiKit.Base.map(function (aFieldData) {
+ return {tag:'div', cls:'row', children:[
+ {tag:'label', html:aFieldData['label']},
+// {tag:'span', cls:('fieldValue ' + (aFieldData['isHidden'] ? 'password' : 'text')), html:aFieldData['value']}
+ {tag:'div', cls:('fieldValue ' + (aFieldData['isHidden'] ? 'password' : 'text')), children:[
+ {tag:'div', children:[{tag:'p', html:aFieldData['value']}]}
+ ]}
+// {tag:'input', type:'text', cls:('fieldValue ' + (aFieldData['isHidden'] ? 'password' : 'text')), value:aFieldData['value'], disabled:true}
+
+ ]}
+ }, someData['fields'])}
+ ]);
+
+ MochiKit.Iter.forEach(MochiKit.Selector.findChildElements(this.element(), ['span.password']), MochiKit.Base.bind(function (aPasswordElement) {
+ MochiKit.Signal.connect(aPasswordElement, 'onclick', function (anEvent) { alert(MochiKit.DOM.scrapeText(anEvent.src())); })
+ }, this));
+
+ if (someData['directLogins'].length > 0) {
+ this.append(this.element(), [
+ {tag:'h2', html:"Direct logins"},
+ {tag:'fieldset', id:this.getId('directLogins'), children:MochiKit.Base.map(function (aDirectLoginData) {
+ return {tag:'div', cls:'row', id:('directLogin_' + aDirectLoginData['_reference']), children:[
+ {tag:'img', cls:'favicon', src:aDirectLoginData['favicon']},
+// {tag:'input', cls:'directLogin', disabled:'disabled', type:'text', name:aDirectLoginData['label'], value:aDirectLoginData['label']}
+ {tag:'span', cls:'directLogin', html:aDirectLoginData['label']}
+ ]}
+ }, someData['directLogins'])}
+ ]);
+
+ MochiKit.Base.map(MochiKit.Base.bind(function (aRowNode) {
+ MochiKit.Signal.connect(aRowNode, 'onclick', this, 'directLoginClickHandler');
+ }, this),
+ MochiKit.Selector.findChildElements(this.getElement('directLogins'), ['div.row'])
+ )
+ };
+
+ if (someData['notes'] != '') {
+ this.append(this.element(), [
+ {tag:'h2', html:"Notes"},
+ {tag:'fieldset', id:this.getId('fieldset'), children:[
+ {tag:'div', cls:'row notes', children:[
+ {tag:'span', html:someData['notes']}
+ ]}
+ ]}
+ ]);
+ };
+
+ return true;
+ },
+
+ //-------------------------------------------------------------------------
+/*
+ 'toggleClickHandler': function (anEvent) {
+ var nextState;
+ var fieldValue;
+
+//console.log("TOGGLE");
+ anEvent.preventDefault;
+ fieldValue = MochiKit.Selector.findChildElements(anEvent.src().parentNode.parentNode, ['span.password'])[0];
+
+ nextState = (MochiKit.DOM.getNodeAttribute(anEvent.src(), 'toggled') != 'true');
+ if (nextState) {
+ MochiKit.DOM.removeElementClass(fieldValue, 'clear');
+ } else {
+ MochiKit.DOM.addElementClass(fieldValue, 'clear');
+ }
+
+ MochiKit.DOM.setNodeAttribute(anEvent.src(), 'toggled', nextState);
+ },
+* /
+ //=========================================================================
+/*
+ 'directLoginClickHandler': function (anEvent) {
+ anEvent.preventDefault();
+
+ if (/(directLogin_)/.test(anEvent.src().id)) {
+ var directLoginReference;
+
+ directLoginReference = anEvent.src().id.match(/(directLogin_)(.*)/)[2];
+ MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'selectedDirectLogin', {cardReference:this.cardReference(), directLoginReference:directLoginReference});
+ }
+ },
+*/
+ //=========================================================================
+
+ __syntaxFix__: "syntax fix"
+});
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardList.js b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardList.js
new file mode 100644
index 0000000..a4aa212
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardList.js
@@ -0,0 +1,254 @@
+/*
+
+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.CardList = function(args) {
+ args = args || {};
+
+ Clipperz.PM.UI.Mobile.Components.CardList.superclass.constructor.apply(this, arguments);
+
+ this._cardDetail = null;
+
+ return this;
+}
+
+//=============================================================================
+
+Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.CardList, Clipperz.PM.UI.Common.Components.BaseComponent, {
+
+ //-------------------------------------------------------------------------
+
+ 'toString': function () {
+ return "Clipperz.PM.UI.Mobile.Components.CardList component";
+ },
+
+ //-------------------------------------------------------------------------
+
+ '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:'scroll', id:this.getId('listBox'), children:[
+ {tag:'ul', cls:'rounded', id:this.getId('list'), children:[
+ {tag:'li', html:'loading'}
+ ]}
+ ]}
+ ]});
+
+ 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.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();
+ } else {
+ if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ESCAPE')) {
+ anEvent.target().value = "";
+ }
+
+ if (anEvent.type() == 'keyup') {
+ MochiKit.Signal.signal(this, 'searchEvent', anEvent.target().value);
+ }
+ }
+ },
+
+ //-------------------------------------------------------------------------
+
+ 'update': function (someObjects) {
+ var cardListPanel;
+ var i,c;
+
+ cardListPanel = this.getElement('cardListPanel');
+ cardListPanel.innerHTML = '';
+
+ c = someObjects.length;
+
+ for (i=0; i<c; i++) {
+ this.append(cardListPanel, {tag:'li', cls:'cardListItem', id:('cardListItem_' + someObjects[i]['_reference']), children:[
+ {tag:'img', src:(someObjects[i]['favicon'] ? someObjects[i]['favicon'] : 'data:application/octet-stream;charset=utf-8;base64,AAABAAEAFxcAAAEAGAD8BgAAFgAAACgAAAAXAAAALgAAAAEAGAAAAAAAAAAAABIXAAASFwAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////9zAC////////////////////////////////////////////////////////////////////////////////////////////9pAG////////////////////////////////////////////////////////////////////////////////////////////9rAC////////////////////////////////////////////////////////////////////////////////////////////9yAHP////////////////////////IyMizs7O6urrq6ur////////////Ozs6zs7Ozs7Pq6ur///////////////////////8AAAD////////////////////V1dWXl5eXl5eXl5elpaX4+Pj////Ozs6Xl5eXl5eXl5eenp7///////////////////////8AAAD////////////////////Ozs6Xl5eXl5eXl5eXl5fBwcHq6uqenp6Xl5eXl5eXl5eXl5f///////////////////////8AAAD////////////////////j4+OXl5eXl5eXl5eXl5eXl5elpaWXl5eXl5eXl5eXl5ezs7P///////////////////////8AAAD////////////////////////IyMiXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eenp7x8fH////////////////////////////////////////////////////4+PilpaWXl5eXl5eXl5eXl5eXl5eXl5eXl5fOzs7////////////////////////////////////////////////////////q6uq6urqXl5eXl5eXl5eXl5eXl5eXl5eenp7V1dX4+Pj///////////////////////8AAAD////////////4+PjOzs6lpaWXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5e6urrj4+P///////////////8AAAD////////////BwcGXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5fx8fH///////////8AAAD///////////+zs7OXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5fj4+P///////////8AAAD////////////IyMiXl5eXl5eXl5eXl5e6urqXl5eXl5eXl5eXl5esrKylpaWXl5eXl5eXl5eenp7x8fH///////////8AAAD////////////////Ozs7Ozs7V1dX4+Pj///+Xl5eXl5eXl5eXl5fOzs7////q6urOzs7Ozs7q6ur///////////////8AAAD///////////////////////////////////+Xl5eXl5eXl5eXl5fOzs7///////////////////////////////////8AAAD///////////////////////////////////+Xl5eXl5eXl5eXl5fOzs7///////////////////////////////////8AAAD///////////////////////////////////+Xl5eXl5eXl5eXl5fOzs7///////////////////////////////////8AAAD////////////////////////////////////IyMiXl5eXl5eenp7x8fH///////////////////////////////////8AAAD////////////////////////////////////////j4+Pj4+Px8fH///////////////////////////////////////8AAAD///////////////////////////////////////////////////////////////////////////////////////////8AAAD///////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAo=')},
+ {tag:'a', id:('cardListReference_' + someObjects[i]['_reference']), href:'#', html:someObjects[i]['label']}
+ ]})
+
+ MochiKit.Signal.connect('cardListItem_' + someObjects[i]['_reference'], 'onclick', this, 'cardListClickHandler');
+ }
+
+ },
+
+ 'cardListClickHandler': function (anEvent) {
+ anEvent.preventDefault();
+
+ if (/(cardListReference_|cardListItem_)/.test(anEvent.target().id)) {
+ var cardListReference;
+
+ cardListReference = anEvent.target().id.match(/(cardListReference_|cardListItem_)(.*)/)[2];
+//console.log("Showing detail for card named", cardListReference);
+ MochiKit.Signal.signal(this, 'selectedCard', cardListReference);
+ }
+ },
+
+ //=========================================================================
+
+ 'cardDetail': function (someData) {
+ if (this._cardDetail == null) {
+ this._cardDetail = new Clipperz.PM.UI.Mobile.Components.CardDetail({element:this.getElement('cardDetail')});
+ }
+
+ return this._cardDetail;
+ },
+
+ //-------------------------------------------------------------------------
+
+ 'removeCardDetail': function () {
+ if (this._cardDetail != null) {
+ this._cardDetail.remove();
+ this._cardDetail = null;
+ }
+ },
+
+ //=========================================================================
+
+ 'showCard': function (someData) {
+ var deferredResult;
+ var offset;
+
+ offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480);
+ this.cardDetail().render();
+ this.cardDetail().setCardReference(someData['_reference']);
+ MochiKit.Style.setElementPosition(this.cardDetail().element(), {x:offset});
+ new MochiKit.Visual.Sequence([
+// new MochiKit.Visual.Move(this.cardDetail().element(), {x:offset, y:45, mode:'absolute', duration:0, sync:true}),
+ new MochiKit.Visual.Parallel([
+ new MochiKit.Visual.Move(this.getElement('cardList'), {x:-offset, y:0, mode:'relative', transition:MochiKit.Visual.Transitions.linear, sync:true}),
+ new MochiKit.Visual.Move(this.getElement('cardDetail'), {x:0, y:45, mode:'absolute', transition:MochiKit.Visual.Transitions.linear, sync:true}),
+// new MochiKit.Visual.ScrollTo('toolbar', {sync:true}),
+ MochiKit.Visual.appear ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true})
+ ], {duration:1, sync:true}),
+ MochiKit.Visual.fade(this.getElement('cardList'), {duration:0, sync:true})
+ ], {})
+
+ MochiKit.DOM.getElement('pageTitle').innerHTML = someData['title'];
+
+ return true;
+ },
+
+ //-------------------------------------------------------------------------
+
+ 'showCardDetails': function (someData) {
+ return this.cardDetail().showCardDetails(someData);
+ },
+
+ //=========================================================================
+
+ 'backButtonClickHandler': function (anEvent) {
+ var offset;
+
+ anEvent.preventDefault();
+
+ MochiKit.DOM.getElement('pageTitle').innerHTML = "cards";
+
+ offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480);
+ MochiKit.Style.setElementPosition(this.getElement('cardList'), {x:-offset});
+ MochiKit.DOM.showElement(this.getElement('cardList'));
+
+ new MochiKit.Visual.Parallel([
+ new MochiKit.Visual.Move(this.getElement('cardList'), {x:offset, y:0, mode:'relative', transition:MochiKit.Visual.Transitions.linear, sync:true}),
+ new MochiKit.Visual.Move(this.getElement('cardDetail'), {x:offset, y:0, mode:'relative', transition:MochiKit.Visual.Transitions.linear, sync:true}),
+ MochiKit.Visual.fade (this.getElement('cardDetail'), { transition:MochiKit.Visual.Transitions.linear, sync:true}),
+ MochiKit.Visual.fade ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true})
+ ], {duration:1, afterFinish:MochiKit.Base.method(this, 'removeCardDetail')})
+
+ },
+*/
+ //=========================================================================
+ __syntaxFix__: "syntax fix"
+});
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js
new file mode 100644
index 0000000..eafcdbc
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js
@@ -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"
+});