summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components
Unidiff
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 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please
8refer to http://www.clipperz.com.
9
10* Clipperz Community Edition is free software: you can redistribute
11 it and/or modify it under the terms of the GNU Affero General Public
12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version.
14
15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details.
19
20* You should have received a copy of the GNU Affero General Public
21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>.
23
24*/
25
26Clipperz.Base.module('Clipperz.PM.UI.Mobile.Components');
27
28Clipperz.PM.UI.Mobile.Components.CardDetail = function(args) {
29 args = args || {};
30
31 Clipperz.PM.UI.Mobile.Components.CardDetail.superclass.constructor.apply(this, arguments);
32
33 //this._cardReference = null;
34
35 return this;
36}
37
38//=============================================================================
39
40Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.CardDetail, Clipperz.PM.UI.Common.Components.BaseComponent, {
41
42 //-------------------------------------------------------------------------
43
44 'toString': function () {
45 return "Clipperz.PM.UI.Mobile.Components.CardDetail component";
46 },
47
48 //-------------------------------------------------------------------------
49/*
50 'cardReference': function () {
51 return this._cardReference;
52 },
53
54 'setCardReference': function (aValue) {
55 this._cardReference = aValue;
56 },
57*/
58 //-------------------------------------------------------------------------
59
60 'renderSelf': function () {
61console.log("CardDetail.renderSelf");
62 this.append(this.element(), {tag:'div', cls:'cardDetail', children:[
63 {tag:'div', cls:'toolbar', children:[
64 {tag:'a', href:'#', cls:'back', html:"List"},
65 {tag:'h1', id:this.getId('cardTitle'), html:"…"}
66 ]},
67 {tag:'div', cls:'scroll', id:this.getId('cardDetails'), children:[
68 ]}
69 ]});
70 },
71/*
72 'renderSelf': function() {
73 this.append(this.element(), [
74 {tag:'div', cls:'cardDetail', id:this.getId('cardDetail'), children:[
75 {tag:'div', id:this.getId('progressBar')} //,
76 ]}
77 ]);
78
79 this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':this.getElement('progressBar')}));
80 MochiKit.Signal.signal(Clipperz.PM.UI.Common.Controllers.ProgressBarController.defaultController, 'updateProgress', 0);
81 },
82*/
83
84 'setTitle': function (aValue) {
85 this.getElement('cardTitle').innerHTML = aValue;
86 },
87
88 'fieldListElement': function () {
89 varresult;
90
91 result = this.getElement('fieldList');
92 if (result == null) {
93 result = this.append(this.getElement('cardDetails'), {tag:'ul', cls:'rounded', id:this.getId('fieldList')});
94 }
95
96 return result;
97 },
98
99 'renderFieldValues': function (someFieldValues) {
100 varfieldClass;
101
102 if ((someFieldValues['actionType'] != 'NONE') || (someFieldValues['label'] != '') && (someFieldValues['value'] != '')) {
103 if (someFieldValues['isHidden'] == true) {
104 fieldClass = 'password';
105 } else {
106 fieldClass = '';
107 }
108
109 this.append(this.fieldListElement(), {tag:'li', cls:'cardField', children:[
110 {tag:'a', href:'#', cls:fieldClass, html:someFieldValues['value'], children:[
111 {tag:'small', cls:'label', html:someFieldValues['label']}
112 ]}
113 ]})
114 }
115 },
116
117 'addField': function (aField) {
118 var deferredResult;
119 varfieldValues;
120
121 fieldValues = {};
122 deferredResult = new Clipperz.Async.Deferred("CardDetail.addField", {trace:false});
123 deferredResult.addMethod(aField, 'label');
124 deferredResult.addCallback(function (aValue) { fieldValues['label'] = aValue; });
125 deferredResult.addMethod(aField, 'value');
126 deferredResult.addCallback(function (aValue) { fieldValues['value'] = aValue; });
127 deferredResult.addMethod(aField, 'actionType');
128 deferredResult.addCallback(function (aValue) { fieldValues['actionType'] = aValue; });
129 deferredResult.addMethod(aField, 'isHidden');
130 deferredResult.addCallback(function (aValue) { fieldValues['isHidden'] = aValue; });
131 deferredResult.addMethod(this, 'renderFieldValues', fieldValues);
132 deferredResult.callback();
133
134 return deferredResult;
135 },
136
137 //-------------------------------------------------------------------------
138
139 'directLoginElement': function () {
140 varresult;
141
142 result = this.getElement('directLoginList');
143 if (result == null) {
144 this.append(this.getElement('cardDetails'), {tag:'h2', html:"Direct login"});
145 result = this.append(this.getElement('cardDetails'), {tag:'ul', cls:'rounded', id:this.getId('directLoginList')});
146 }
147
148 return result;
149 },
150
151 'addDirectLogin': function (aDirectLogin) {
152 this.append(this.directLoginElement(), {tag:'li', cls:'directLogin forward', children:[
153 {tag:'a', href:'#', html:"direct login", children:[
154 {tag:'small', cls:'favicon', children:[{tag:'img', cls:'favicon', src:'http://www.clipperz.com/favicon.ico'}]}
155 ]}
156 ]})
157
158console.log("ADD DIRECT LOGIN", aDirectLogin);
159 },
160
161 //=========================================================================
162
163 'showCard': function (aCard) {
164 var deferredResult;
165
166 // this.render();
167
168console.log("CardDetail.showCard", aCard);
169 deferredResult = new Clipperz.Async.Deferred("CardDetail.showCard", {trace:false});
170 deferredResult.addMethod(aCard, 'label');
171 deferredResult.addMethod(this, 'setTitle');
172
173 deferredResult.addMethod(aCard, 'fields');
174 deferredResult.addCallback(MochiKit.Base.values);
175 deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.method(this, 'addField'));
176
177 deferredResult.addMethod(aCard, 'directLogins');
178 deferredResult.addCallback(MochiKit.Base.values);
179 deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.method(this, 'addDirectLogin'));
180
181
182 deferredResult.callback();
183
184 return deferredResult;
185 // return Clipperz.Async.callbacks("CardDialogController.updateComponentState", [
186 // MochiKit.Base.method(this.record(), 'hasPendingChanges'),
187 // MochiKit.Base.method(this.cardDialogComponent(), 'setShouldEnableSaving'),
188 //
189 // MochiKit.Base.method(this.record(), 'label'),
190 // MochiKit.Base.method(this.cardDialogComponent(), 'setTitle'),
191 // MochiKit.Base.method(this.record(), 'notes'),
192 // MochiKit.Base.method(this.cardDialogComponent(), 'setNotes'),
193 //
194 // MochiKit.Base.method(this.record(), 'fields'),
195 // MochiKit.Base.values,
196 // MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'addCardDialogComponentWithField')),
197//
198 // MochiKit.Base.method(this.record(), 'directLogins'),
199 // MochiKit.Base.values,
200 // MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'addCardDialogComponentWithDirectLogin')),
201//
202 // MochiKit.Base.method(this.cardDialogComponent(), 'resetNewFieldInputs'),
203 // MochiKit.Base.noop
204 // ], {trace:false});
205
206 },
207
208 //=========================================================================
209
210 'showCardDetails': function (someData) {
211 this.element().innerHTML = '';
212 this.append(this.element(), [
213 {tag:'fieldset', id:this.getId('fields'), children:MochiKit.Base.map(function (aFieldData) {
214 return {tag:'div', cls:'row', children:[
215 {tag:'label', html:aFieldData['label']},
216 // {tag:'span', cls:('fieldValue ' + (aFieldData['isHidden']? 'password' : 'text')), html:aFieldData['value']}
217 {tag:'div', cls:('fieldValue ' + (aFieldData['isHidden']? 'password' : 'text')), children:[
218 {tag:'div', children:[{tag:'p', html:aFieldData['value']}]}
219 ]}
220 // {tag:'input', type:'text', cls:('fieldValue ' + (aFieldData['isHidden']? 'password' : 'text')), value:aFieldData['value'], disabled:true}
221
222 ]}
223 }, someData['fields'])}
224 ]);
225
226 MochiKit.Iter.forEach(MochiKit.Selector.findChildElements(this.element(), ['span.password']), MochiKit.Base.bind(function (aPasswordElement) {
227 MochiKit.Signal.connect(aPasswordElement, 'onclick', function (anEvent) { alert(MochiKit.DOM.scrapeText(anEvent.src())); })
228 }, this));
229
230 if (someData['directLogins'].length > 0) {
231 this.append(this.element(), [
232 {tag:'h2', html:"Direct logins"},
233 {tag:'fieldset', id:this.getId('directLogins'), children:MochiKit.Base.map(function (aDirectLoginData) {
234 return {tag:'div', cls:'row', id:('directLogin_' + aDirectLoginData['_reference']), children:[
235 {tag:'img', cls:'favicon', src:aDirectLoginData['favicon']},
236 // {tag:'input', cls:'directLogin', disabled:'disabled', type:'text', name:aDirectLoginData['label'], value:aDirectLoginData['label']}
237 {tag:'span', cls:'directLogin', html:aDirectLoginData['label']}
238 ]}
239 }, someData['directLogins'])}
240 ]);
241
242 MochiKit.Base.map(MochiKit.Base.bind(function (aRowNode) {
243 MochiKit.Signal.connect(aRowNode, 'onclick', this, 'directLoginClickHandler');
244 }, this),
245 MochiKit.Selector.findChildElements(this.getElement('directLogins'), ['div.row'])
246 )
247 };
248
249 if (someData['notes'] != '') {
250 this.append(this.element(), [
251 {tag:'h2', html:"Notes"},
252 {tag:'fieldset', id:this.getId('fieldset'), children:[
253 {tag:'div', cls:'row notes', children:[
254 {tag:'span', html:someData['notes']}
255 ]}
256 ]}
257 ]);
258 };
259
260 return true;
261 },
262
263 //-------------------------------------------------------------------------
264/*
265 'toggleClickHandler': function (anEvent) {
266 varnextState;
267 varfieldValue;
268
269//console.log("TOGGLE");
270 anEvent.preventDefault;
271 fieldValue = MochiKit.Selector.findChildElements(anEvent.src().parentNode.parentNode, ['span.password'])[0];
272
273 nextState = (MochiKit.DOM.getNodeAttribute(anEvent.src(), 'toggled') != 'true');
274 if (nextState) {
275 MochiKit.DOM.removeElementClass(fieldValue, 'clear');
276 } else {
277 MochiKit.DOM.addElementClass(fieldValue, 'clear');
278 }
279
280 MochiKit.DOM.setNodeAttribute(anEvent.src(), 'toggled', nextState);
281 },
282* /
283 //=========================================================================
284/*
285 'directLoginClickHandler': function (anEvent) {
286 anEvent.preventDefault();
287
288 if (/(directLogin_)/.test(anEvent.src().id)) {
289 var directLoginReference;
290
291 directLoginReference = anEvent.src().id.match(/(directLogin_)(.*)/)[2];
292 MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'selectedDirectLogin', {cardReference:this.cardReference(), directLoginReference:directLoginReference});
293 }
294 },
295*/
296 //=========================================================================
297
298 __syntaxFix__: "syntax fix"
299});
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 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please
8refer to http://www.clipperz.com.
9
10* Clipperz Community Edition is free software: you can redistribute
11 it and/or modify it under the terms of the GNU Affero General Public
12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version.
14
15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details.
19
20* You should have received a copy of the GNU Affero General Public
21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>.
23
24*/
25
26Clipperz.Base.module('Clipperz.PM.UI.Mobile.Components');
27
28Clipperz.PM.UI.Mobile.Components.CardList = function(args) {
29 args = args || {};
30
31 Clipperz.PM.UI.Mobile.Components.CardList.superclass.constructor.apply(this, arguments);
32
33 this._cardDetail = null;
34
35 return this;
36}
37
38//=============================================================================
39
40Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.CardList, Clipperz.PM.UI.Common.Components.BaseComponent, {
41
42 //-------------------------------------------------------------------------
43
44 'toString': function () {
45 return "Clipperz.PM.UI.Mobile.Components.CardList component";
46 },
47
48 //-------------------------------------------------------------------------
49
50 'renderSelf': function () {
51 this.append(this.element(), {tag:'div', cls:'cardList', children:[
52 {tag:'div', cls:'toolbar', children:[
53 {tag:'h1', html:"clipperz"},
54 // {tag:'input', name:'search', type:'search', autocomplete:'off', placeholder:"search", id:this.getId('search')},
55 {tag:'a', href:'#', id:'settings', cls:'button', html:"*"}
56 ]},
57 {tag:'div', cls:'scroll', id:this.getId('listBox'), children:[
58 {tag:'ul', cls:'rounded', id:this.getId('list'), children:[
59 {tag:'li', html:'loading'}
60 ]}
61 ]}
62 ]});
63
64 MochiKit.Signal.connect(this.getElement('list'), 'onclick', this, 'cardSelectionHandler');
65 MochiKit.Signal.connect(this.getElement('list'), 'ontouchstart',this, 'cardSelectionHandler');
66 // MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onsubmit', this,'searchHandler');
67 // MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onkeydown', this,'searchHandler');
68 // MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onkeyup', this,'searchHandler');
69
70 // MochiKit.Signal.connect(this.getElement('cardListPanel'), 'onclick', this,'cardListClickHandler');
71 // MochiKit.Signal.connect('backButton', 'onclick', this,'backButtonClickHandler');
72
73 // MochiKit.Style.hideElement('backButton');
74 // MochiKit.Style.hideElement(this.getElement('cardDetail'));
75 },
76
77 'showCards': function (someCards) {
78 varcardListElement;
79 if (this.isFullyRendered() == false) {
80 this.render();
81 };
82
83 cardListElement = this.getElement('list')
84
85 cardInfo = {
86 '_rowObject': MochiKit.Async.succeed,
87 '_reference': MochiKit.Base.methodcaller('reference'),
88 '_searchableContent':MochiKit.Base.methodcaller('searchableContent'),
89 'label': MochiKit.Base.methodcaller('label'),
90 'favicon': MochiKit.Base.methodcaller('favicon')
91 };
92
93//console.log("someCards", someCards);
94 deferredResult = new Clipperz.Async.Deferred("CardList.showCards", {trace:false});
95 deferredResult.addCallback(MochiKit.Base.map, Clipperz.Async.collectResults("CardList.value - collectResults", cardInfo, {trace:false}));
96 deferredResult.addCallback(Clipperz.Async.collectAll);
97 deferredResult.addCallback(MochiKit.Base.methodcaller('sort', Clipperz.Base.caseInsensitiveKeyComparator('label')));
98 deferredResult.addCallbackPass(MochiKit.DOM.replaceChildNodes, cardListElement);
99 // deferredResult.addCallbackPass(MochiKit.DOM.removeElementClass, cardListElement, 'loading');
100 deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.method(this, 'appendCardToList', cardListElement));
101 deferredResult.callback(someCards);
102 },
103
104 'appendCardToList': function (aCardListElement, aCardInfo) {
105//console.log("appendCardToList", aCardInfo);
106 this.append(aCardListElement, {tag:'li', cls:'cardListItem arrow', cardreference:aCardInfo['_reference'], children:[
107 {tag:'a', href:'#', html:aCardInfo['label'], children:[
108 {tag:'small', cls:'favicon', children:[{tag:'img', cls:'favicon', src:aCardInfo['favicon']}]}
109 ]}
110 ]});
111 },
112
113 'cardSelectionHandler': function (anEvent) {
114 var listElement;
115 varcardReference;
116
117 anEvent.preventDefault();
118
119 listElement = anEvent.target();
120 if (MochiKit.DOM.getNodeAttribute(listElement, 'cardreference') == null) {
121 listElement = MochiKit.DOM.getFirstParentByTagAndClassName(anEvent.target(), tagName='li', className='cardListItem');
122 }
123 cardReference = MochiKit.DOM.getNodeAttribute(listElement, 'cardreference');
124console.log("###", listElement, cardReference);
125 //TODO: Notify card with reference MochiKit.DOM.getNodeAttribute(listElement, 'cardreference') has been selected
126 MochiKit.Signal.signal(this, 'selectedCard', cardReference);
127 },
128
129 //-------------------------------------------------------------------------
130/*
131 'searchHandler': function (anEvent) {
132 if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ENTER')) { //RETURN
133 anEvent.preventDefault();
134 } else {
135 if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ESCAPE')) {
136 anEvent.target().value = "";
137 }
138
139 if (anEvent.type() == 'keyup') {
140 MochiKit.Signal.signal(this, 'searchEvent', anEvent.target().value);
141 }
142 }
143 },
144
145 //-------------------------------------------------------------------------
146
147 'update': function (someObjects) {
148 varcardListPanel;
149 var i,c;
150
151 cardListPanel = this.getElement('cardListPanel');
152 cardListPanel.innerHTML = '';
153
154 c = someObjects.length;
155
156 for (i=0; i<c; i++) {
157 this.append(cardListPanel, {tag:'li', cls:'cardListItem', id:('cardListItem_' + someObjects[i]['_reference']), children:[
158 {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=')},
159 {tag:'a', id:('cardListReference_' + someObjects[i]['_reference']), href:'#', html:someObjects[i]['label']}
160 ]})
161
162 MochiKit.Signal.connect('cardListItem_' + someObjects[i]['_reference'], 'onclick', this, 'cardListClickHandler');
163 }
164
165 },
166
167 'cardListClickHandler': function (anEvent) {
168 anEvent.preventDefault();
169
170 if (/(cardListReference_|cardListItem_)/.test(anEvent.target().id)) {
171 var cardListReference;
172
173 cardListReference = anEvent.target().id.match(/(cardListReference_|cardListItem_)(.*)/)[2];
174//console.log("Showing detail for card named", cardListReference);
175 MochiKit.Signal.signal(this, 'selectedCard', cardListReference);
176 }
177 },
178
179 //=========================================================================
180
181 'cardDetail': function (someData) {
182 if (this._cardDetail == null) {
183 this._cardDetail = new Clipperz.PM.UI.Mobile.Components.CardDetail({element:this.getElement('cardDetail')});
184 }
185
186 return this._cardDetail;
187 },
188
189 //-------------------------------------------------------------------------
190
191 'removeCardDetail': function () {
192 if (this._cardDetail != null) {
193 this._cardDetail.remove();
194 this._cardDetail = null;
195 }
196 },
197
198 //=========================================================================
199
200 'showCard': function (someData) {
201 vardeferredResult;
202 varoffset;
203
204 offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480);
205 this.cardDetail().render();
206 this.cardDetail().setCardReference(someData['_reference']);
207 MochiKit.Style.setElementPosition(this.cardDetail().element(), {x:offset});
208 new MochiKit.Visual.Sequence([
209 // new MochiKit.Visual.Move(this.cardDetail().element(), {x:offset, y:45, mode:'absolute', duration:0, sync:true}),
210 new MochiKit.Visual.Parallel([
211 new MochiKit.Visual.Move(this.getElement('cardList'), {x:-offset, y:0, mode:'relative',transition:MochiKit.Visual.Transitions.linear, sync:true}),
212 new MochiKit.Visual.Move(this.getElement('cardDetail'), {x:0, y:45, mode:'absolute',transition:MochiKit.Visual.Transitions.linear, sync:true}),
213 // new MochiKit.Visual.ScrollTo('toolbar', {sync:true}),
214 MochiKit.Visual.appear ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true})
215 ], {duration:1, sync:true}),
216 MochiKit.Visual.fade(this.getElement('cardList'), {duration:0, sync:true})
217 ], {})
218
219 MochiKit.DOM.getElement('pageTitle').innerHTML = someData['title'];
220
221 return true;
222 },
223
224 //-------------------------------------------------------------------------
225
226 'showCardDetails': function (someData) {
227 return this.cardDetail().showCardDetails(someData);
228 },
229
230 //=========================================================================
231
232 'backButtonClickHandler': function (anEvent) {
233 varoffset;
234
235 anEvent.preventDefault();
236
237 MochiKit.DOM.getElement('pageTitle').innerHTML = "cards";
238
239 offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480);
240 MochiKit.Style.setElementPosition(this.getElement('cardList'), {x:-offset});
241 MochiKit.DOM.showElement(this.getElement('cardList'));
242
243 new MochiKit.Visual.Parallel([
244 new MochiKit.Visual.Move(this.getElement('cardList'), {x:offset, y:0, mode:'relative',transition:MochiKit.Visual.Transitions.linear, sync:true}),
245 new MochiKit.Visual.Move(this.getElement('cardDetail'), {x:offset, y:0, mode:'relative',transition:MochiKit.Visual.Transitions.linear, sync:true}),
246 MochiKit.Visual.fade (this.getElement('cardDetail'), { transition:MochiKit.Visual.Transitions.linear, sync:true}),
247 MochiKit.Visual.fade ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true})
248 ], {duration:1, afterFinish:MochiKit.Base.method(this, 'removeCardDetail')})
249
250 },
251*/
252 //=========================================================================
253 __syntaxFix__: "syntax fix"
254});
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 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please
8refer to http://www.clipperz.com.
9
10* Clipperz Community Edition is free software: you can redistribute
11 it and/or modify it under the terms of the GNU Affero General Public
12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version.
14
15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details.
19
20* You should have received a copy of the GNU Affero General Public
21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>.
23
24*/
25
26Clipperz.Base.module('Clipperz.PM.UI.Mobile.Components');
27
28Clipperz.PM.UI.Mobile.Components.LoginForm = function(args) {
29 args = args || {};
30
31 this._pin = '';
32
33 this._message = null;
34 this._steps = 0;
35 this._actualSteps = 0;
36
37 this._callback = null;
38 this._errorCallback = null;
39
40 this._mode = 'CREDENTIALS';
41
42 Clipperz.PM.UI.Mobile.Components.LoginForm.superclass.constructor.apply(this, arguments);
43
44 return this;
45}
46
47//=============================================================================
48
49Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI.Common.Components.BaseComponent, {
50
51 //-------------------------------------------------------------------------
52
53 'toString': function () {
54 return "Clipperz.PM.UI.Mobile.Components.LoginForm component";
55 },
56
57 //-------------------------------------------------------------------------
58
59 'callback': function () {
60 return this._callback;
61 },
62
63 'errorCallback': function () {
64 return this._errorCallback;
65 },
66
67 //-------------------------------------------------------------------------
68
69 'mode': function () {
70 return this._mode;
71 },
72
73 'setMode': function (aValue) {
74 this._mode = aValue;
75 },
76
77 //..........................................................................
78
79 'pin': function () {
80 return this._pin;
81 },
82
83 'setPin': function (aValue) {
84 this._pin = aValue;
85 },
86
87 //..........................................................................
88
89 'username': function () {
90 return this._username;
91 },
92
93 'setUsername': function (aValue) {
94 this._username = aValue;
95 },
96
97 //..........................................................................
98
99 'passphrase': function () {
100 return this._passphrase;
101 },
102
103 'setPassphrase': function (aValue) {
104 this._passphrase = aValue;
105 },
106
107 //-------------------------------------------------------------------------
108
109 'message': function () {
110 return this._message;
111 },
112
113 '_setMessage': function (aValue) {
114 this._message = aValue;
115
116 if (aValue == null) {
117 MochiKit.Style.hideElement(this.getElement('credentialsMessage'));
118 } else {
119 this.getElement('message').innerHTML = aValue;
120 MochiKit.Style.showElement(this.getElement('credentialsMessage'));
121 }
122 },
123
124 'setMessage': function (aValue) {
125 this._setMessage(aValue);
126 MochiKit.DOM.removeElementClass(this.getElement('credentialsMessage'), 'error');
127 },
128
129 'setErrorMessage': function (aValue) {
130 this._setMessage(aValue);
131 MochiKit.DOM.addElementClass(this.getElement('credentialsMessage'), 'error');
132 },
133
134 //-------------------------------------------------------------------------
135
136 'setCallbacks': function (args) {
137 this._callback = args['callback'];
138 this._errorCallback = args['errorCallback'];
139 },
140
141 'showErrors': function (args) {
142//console.log("LoginForm.showErrors", args);
143 if (args['previousFailedAttempt'] == 'LOGIN') {
144 this.setErrorMessage("Wrong credentials");
145 } else if (args['previousFailedAttempt'] == 'PIN') {
146 if (args['failedAttempts'] == -1) {
147 this.setErrorMessage("Wrong PIN - Resetted");
148 } else {
149 this.setErrorMessage("Wrong PIN");
150 }
151 } else {
152 this.setMessage(null);
153 }
154 },
155
156 'updateWithArgs': function (args) {
157 this.renderIfNeeded();
158 this.setCallbacks(args);
159 this.showErrors(args);
160 this.updateRendering();
161 },
162
163 'showPinLogin': function (args) {
164 this.setPin('');
165 this.setMode('PIN');
166 this.updateWithArgs(args);
167
168 // $(this.getAnchor('PIN')).focus();
169 this.getElement('PIN').focus();
170 },
171
172 'showCredentialsLogin': function (args) {
173 this.setMode('CREDENTIALS');
174 this.updateWithArgs(args);
175
176 if (this.getElement('usernameField').value.length == 0) {
177 // $(this.getAnchor('usernameField')).focus();
178 this.getElement('usernameField').focus();
179 } else {
180 // $(this.getAnchor('passphraseField')).focus();
181 this.getElement('passphraseField').focus();
182 this.getElement('passphraseField').select();
183 }
184 },
185
186 //-------------------------------------------------------------------------
187
188 'renderIfNeeded': function () {
189 if (this.isFullyRendered() == false) {
190 this.render();
191 };
192 this.updateRendering();
193 },
194
195 'updateRendering': function () {
196 MochiKit.Style.showElement(this.getElement('credentialsBody'));
197 MochiKit.Style.hideElement(this.getElement('validating'));
198
199 // this.hideAllPanes();
200 MochiKit.Base.map(function (aNode) { MochiKit.Style.hideElement(aNode); }, MochiKit.Selector.findDocElements('div.credentialsBody > div'));
201 if (this.mode() == 'CREDENTIALS') {
202 selectedPanel = this.getElement('credentials')
203 } else if (this.mode() == 'PIN') {
204 selectedPanel = this.getElement('pin')
205 // this.updatePinDisplay();
206 } else {
207 throw 'Unhandled login form mode';
208 }
209 MochiKit.Style.showElement(selectedPanel);
210
211 MochiKit.Style.hideElement(this.getElement('validating'));
212 },
213
214 'renderSelf': function() {
215 var selectedPanel;
216 this.append(this.element(), {tag:'div', id:'login', children:[
217 {tag:'div', cls:'toolbar', children:[
218 {tag:'h1', html:"clipperz"}
219 ]},
220 {tag:'div', cls:'scroll', children:[
221 //==================================================================
222 {tag:'div', cls:'credentialsMessage', id:this.getId('credentialsMessage'), children:[
223 {tag:'h1', cls:'message', id:this.getId('message'), html:"Message"}
224 ]},
225 //==================================================================
226 {tag:'div', cls:'credentialsBody', id:this.getId('credentialsBody'), children:[
227 //--------------------------------------------------------------
228 {tag:'div', cls:'pin', id:this.getId('pin'), children:[
229 {tag:'form', cls:'scroll', id:this.getId('pinForm'), children:[
230 {tag:'ul', cls:'edit rounded', children:[
231 {tag:'li', children:[{tag:'input', type:'number', name:'PIN', placeholder:"PIN", id:this.getId('PIN') }]},
232 ]},
233 {tag:'a', href:'#', cls:'greenButton', id:this.getId('pinSubmitButton'), html:"Login"}
234 ]}
235 ]},
236 //--------------------------------------------------------------
237 {tag:'div', cls:'credentials', id:this.getId('credentials'), children:[
238 {tag:'form', cls:'scroll', id:this.getId('credentialsForm'), children:[
239 {tag:'ul', cls:'edit rounded', children:[
240 {tag:'li', children:[{tag:'input', type:'email', name:'name', /*value:'joe',*/ placeholder:"username", id:this.getId('usernameField') }]},
241 {tag:'li', children:[{tag:'input', type:'password', name:'passphrase', /*value:'clipperz',*/placeholder:"passphrase", id:this.getId('passphraseField') }]}
242 ]},
243 {tag:'a', href:'#', cls:'greenButton', id:this.getId('credentialsSubmitButton'), html:"Login"}
244 // {tag:'input', type:'submit', cls:'greenButton', id:this.getId('credentialsSubmitButton'), value:"Login"}
245
246 ]}
247 ]},
248 //--------------------------------------------------------------
249 ]},
250 //==================================================================
251 {tag:'div', cls:'validating', id:this.getId('validating'), children:[
252 {tag:'div', cls:'loading', children:[
253 {tag:'div', cls:'spinner', children:[
254 {tag:'div', cls:'bar01'},
255 {tag:'div', cls:'bar02'},
256 {tag:'div', cls:'bar03'},
257 {tag:'div', cls:'bar04'},
258 {tag:'div', cls:'bar05'},
259 {tag:'div', cls:'bar06'},
260 {tag:'div', cls:'bar07'},
261 {tag:'div', cls:'bar08'},
262 {tag:'div', cls:'bar09'},
263 {tag:'div', cls:'bar10'},
264 {tag:'div', cls:'bar11'},
265 {tag:'div', cls:'bar12'}
266 ]}
267 ]},
268 {tag:'div', id:this.getId('loadingMessage')},
269 {tag:'a', href:'#', cls:'grayButton', id:this.getId('loginCancelButton'), html:"Cancel"}
270 ]}
271 //==================================================================
272 ]}
273 ]});
274
275 MochiKit.Signal.connect(this.getElement('credentialsForm'), 'onsubmit', this, 'submitCredentialsHandler');
276 MochiKit.Signal.connect(this.getElement('credentialsSubmitButton'), 'onclick', this, 'submitCredentialsHandler');
277
278 MochiKit.Signal.connect(this.getElement('pinForm'), 'onsubmit', this, 'submitPinHandler');
279 MochiKit.Signal.connect(this.getElement('pinSubmitButton'), 'onclick', this, 'submitPinHandler');
280
281 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'initProgress', this, 'initProgressHandle');
282 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'updateProgress',this, 'updateProgressHandle');
283 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'advanceProgress',this, 'advanceProgressHandle');
284 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'progressDone', this, 'progressDoneHandle');
285 },
286
287 //-------------------------------------------------------------------------
288
289 'submitPinHandler': function (anEvent) {
290 varpin;
291
292 this.setMessage(null);
293 pin = this.getElement('PIN').value;
294 // $(this.getAnchor('PIN')).blur();
295 this.getElement('PIN').blur();
296
297 credentials = Clipperz.PM.PIN.credentialsWithPIN(pin);
298 this.loginWithCredentials(credentials);
299 },
300
301 'submitCredentialsHandler': function (anEvent) {
302//console.log("submitCredentialsHandler");
303 varcredentials;
304
305 this.setMessage(null);
306
307 credentials = {};
308 credentials['username'] = this.getElement('usernameField').value;
309 credentials['passphrase'] = this.getElement('passphraseField').value;
310 // $(this.getAnchor('passphraseField')).blur();
311 this.getElement('passphraseField').blur();
312
313 this.loginWithCredentials(credentials);
314 },
315
316 //-------------------------------------------------------------------------
317
318 'loginWithCredentials': function (someCredentials) {
319 varargs;
320
321 args = {};
322 args['credentials'] = someCredentials;
323 args['errorCallback'] = this.errorCallback();
324
325 MochiKit.Style.hideElement(this.getElement('credentialsBody'));
326 MochiKit.Style.showElement(this.getElement('validating'));
327
328 MochiKit.Async.callLater(0.1, this.callback(), args);
329 },
330
331 //-------------------------------------------------------------------------
332
333 'initProgressHandle': function (anEvent) {
334//console.log("** initProgressHandle", anEvent);
335 this._steps = anEvent['steps'];
336 this._actualSteps = 0;
337 },
338
339 'updateProgressHandle': function (anEvent) {
340//console.log("** updateProgressHandle", anEvent);
341 this._steps += anEvent['extraSteps'];
342 },
343
344 'advanceProgressHandle': function (anEvent) {
345//console.log("** advanceProgressHandle", anEvent);
346 this._actualSteps ++;
347//console.log("STEPS: " + this._actualSteps + "/" + this._steps);
348 },
349
350 'progressDoneHandle': function (anEvent) {
351//console.log("** progressDoneHandle", anEvent);
352 },
353
354 //-------------------------------------------------------------------------
355 __syntaxFix__: "syntax fix"
356});