summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/iPhone
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/iPhone') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardDetail.js166
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardList.js204
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js181
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/iPhone/Controllers/MainController.js372
4 files changed, 923 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardDetail.js b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardDetail.js
new file mode 100644
index 0000000..23fd236
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardDetail.js
@@ -0,0 +1,166 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Base.module('Clipperz.PM.UI.iPhone.Components');
30
31Clipperz.PM.UI.iPhone.Components.CardDetail = function(args) {
32 args = args || {};
33
34 Clipperz.PM.UI.iPhone.Components.CardDetail.superclass.constructor.apply(this, arguments);
35
36 this._cardReference = null;
37
38 return this;
39}
40
41//=============================================================================
42
43Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.CardDetail, Clipperz.PM.UI.Common.Components.BaseComponent, {
44
45 //-------------------------------------------------------------------------
46
47 'toString': function () {
48 return "Clipperz.PM.UI.iPhone.Components.CardDetail component";
49 },
50
51 //-------------------------------------------------------------------------
52
53 'cardReference': function () {
54 return this._cardReference;
55 },
56
57 'setCardReference': function (aValue) {
58 this._cardReference = aValue;
59 },
60
61 //-------------------------------------------------------------------------
62
63 'renderSelf': function(/*aContainer, aPosition*/) {
64 this.append(this.element(), [
65 {tag:'div', cls:'cardDetail', id:this.getId('cardDetail'), children:[
66 {tag:'div', id:this.getId('progressBar')} //,
67 // {tag:'h1', cls:'loading', html:"loading"}
68 ]}
69 ]);
70
71 this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':this.getElement('progressBar')}));
72 MochiKit.Signal.signal(Clipperz.PM.UI.Common.Controllers.ProgressBarController.defaultController, 'updateProgress', 0);
73 },
74
75 //=========================================================================
76
77 'showCardDetails': function (someData) {
78 this.element().innerHTML = '';
79 this.append(this.element(), [
80 {tag:'fieldset', id:this.getId('fields'), children:MochiKit.Base.map(function (aFieldData) {
81 return {tag:'div', cls:'row', children:[
82 {tag:'label', html:aFieldData['label']},
83 // {tag:'span', cls:('fieldValue ' + (aFieldData['isHidden']? 'password' : 'text')), html:aFieldData['value']}
84 {tag:'div', cls:('fieldValue ' + (aFieldData['isHidden']? 'password' : 'text')), children:[
85 {tag:'div', children:[{tag:'p', html:aFieldData['value']}]}
86 ]}
87 // {tag:'input', type:'text', cls:('fieldValue ' + (aFieldData['isHidden']? 'password' : 'text')), value:aFieldData['value'], disabled:true}
88
89 ]}
90 }, someData['fields'])}
91 ]);
92
93 MochiKit.Iter.forEach(MochiKit.Selector.findChildElements(this.element(), ['span.password']), MochiKit.Base.bind(function (aPasswordElement) {
94 MochiKit.Signal.connect(aPasswordElement, 'onclick', function (anEvent) { alert(MochiKit.DOM.scrapeText(anEvent.src())); })
95 }, this));
96
97 if (someData['directLogins'].length > 0) {
98 this.append(this.element(), [
99 {tag:'h2', html:"Direct logins"},
100 {tag:'fieldset', id:this.getId('directLogins'), children:MochiKit.Base.map(function (aDirectLoginData) {
101 return {tag:'div', cls:'row', id:('directLogin_' + aDirectLoginData['_reference']), children:[
102 {tag:'img', cls:'favicon', src:aDirectLoginData['favicon']},
103 // {tag:'input', cls:'directLogin', disabled:'disabled', type:'text', name:aDirectLoginData['label'], value:aDirectLoginData['label']}
104 {tag:'span', cls:'directLogin', html:aDirectLoginData['label']}
105 ]}
106 }, someData['directLogins'])}
107 ]);
108
109 MochiKit.Base.map(MochiKit.Base.bind(function (aRowNode) {
110 MochiKit.Signal.connect(aRowNode, 'onclick', this, 'directLoginClickHandler');
111 }, this),
112 MochiKit.Selector.findChildElements(this.getElement('directLogins'), ['div.row'])
113 )
114 };
115
116 if (someData['notes'] != '') {
117 this.append(this.element(), [
118 {tag:'h2', html:"Notes"},
119 {tag:'fieldset', id:this.getId('fieldset'), children:[
120 {tag:'div', cls:'row notes', children:[
121 {tag:'span', html:someData['notes']}
122 ]}
123 ]}
124 ]);
125 };
126
127 return true;
128 },
129
130 //-------------------------------------------------------------------------
131/*
132 'toggleClickHandler': function (anEvent) {
133 varnextState;
134 varfieldValue;
135
136//console.log("TOGGLE");
137 anEvent.preventDefault;
138 fieldValue = MochiKit.Selector.findChildElements(anEvent.src().parentNode.parentNode, ['span.password'])[0];
139
140 nextState = (MochiKit.DOM.getNodeAttribute(anEvent.src(), 'toggled') != 'true');
141 if (nextState) {
142 MochiKit.DOM.removeElementClass(fieldValue, 'clear');
143 } else {
144 MochiKit.DOM.addElementClass(fieldValue, 'clear');
145 }
146
147 MochiKit.DOM.setNodeAttribute(anEvent.src(), 'toggled', nextState);
148 },
149*/
150 //=========================================================================
151
152 'directLoginClickHandler': function (anEvent) {
153 anEvent.preventDefault();
154
155 if (/(directLogin_)/.test(anEvent.src().id)) {
156 var directLoginReference;
157
158 directLoginReference = anEvent.src().id.match(/(directLogin_)(.*)/)[2];
159 MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'selectedDirectLogin', {cardReference:this.cardReference(), directLoginReference:directLoginReference});
160 }
161 },
162
163 //=========================================================================
164
165 __syntaxFix__: "syntax fix"
166});
diff --git a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardList.js b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardList.js
new file mode 100644
index 0000000..770f983
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardList.js
@@ -0,0 +1,204 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Base.module('Clipperz.PM.UI.iPhone.Components');
30
31Clipperz.PM.UI.iPhone.Components.CardList = function(args) {
32 args = args || {};
33
34 Clipperz.PM.UI.iPhone.Components.CardList.superclass.constructor.apply(this, arguments);
35
36 this._cardDetail = null;
37
38 return this;
39}
40
41//=============================================================================
42
43Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.CardList, Clipperz.PM.UI.Common.Components.BaseComponent, {
44
45 //-------------------------------------------------------------------------
46
47 'toString': function () {
48 return "Clipperz.PM.UI.iPhone.Components.CardList component";
49 },
50
51 //-------------------------------------------------------------------------
52
53 'renderSelf': function(/*aContainer, aPosition*/) {
54 this.append(this.element(), [
55 {tag:'div', cls:'toolbar', id:'toolbar', children:[
56 {tag:'h1', id:'pageTitle', html:"cards"},
57 {tag:'a', id:'backButton', cls:'button', href:'#', html:"cards"}
58 ]},
59 {tag:'div', cls:'cardList', id:this.getId('cardList'), children:[
60 {tag:'form', title:'search', cls:'panel cardListSearchForm', id:this.getId('cardListSearchForm'), children:[
61 {tag:'input', type:'search', name:'search', value:"", placeholder:"search", id:this.getId('searchField')}
62 ]},
63 {tag:'ul', cls:'panel cardListPanel', id:this.getId('cardListPanel'), children:[]}
64 ]},
65 {tag:'div', cls:'panel cardDetailPanel', id:this.getId('cardDetail')}
66 ]);
67
68 MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onsubmit', this,'searchHandler');
69 MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onkeydown', this,'searchHandler');
70 MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onkeyup', this,'searchHandler');
71
72 MochiKit.Signal.connect(this.getElement('cardListPanel'), 'onclick', this,'cardListClickHandler');
73 MochiKit.Signal.connect('backButton', 'onclick', this,'backButtonClickHandler');
74
75 MochiKit.Style.hideElement('backButton');
76 MochiKit.Style.hideElement(this.getElement('cardDetail'));
77 },
78
79 //-------------------------------------------------------------------------
80
81 'searchHandler': function (anEvent) {
82 if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ENTER')) { //RETURN
83 anEvent.preventDefault();
84 } else {
85 if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ESCAPE')) {
86 anEvent.target().value = "";
87 }
88
89 if (anEvent.type() == 'keyup') {
90 MochiKit.Signal.signal(this, 'searchEvent', anEvent.target().value);
91 }
92 }
93 },
94
95 //-------------------------------------------------------------------------
96
97 'update': function (someObjects) {
98 varcardListPanel;
99 var i,c;
100
101 cardListPanel = this.getElement('cardListPanel');
102 cardListPanel.innerHTML = '';
103
104 c = someObjects.length;
105
106 for (i=0; i<c; i++) {
107 this.append(cardListPanel, {tag:'li', cls:'cardListItem', id:('cardListItem_' + someObjects[i]['_reference']), children:[
108 {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=')},
109 {tag:'a', id:('cardListReference_' + someObjects[i]['_reference']), href:'#', html:someObjects[i]['label']}
110 ]})
111
112 MochiKit.Signal.connect('cardListItem_' + someObjects[i]['_reference'], 'onclick', this, 'cardListClickHandler');
113 }
114
115 },
116
117 'cardListClickHandler': function (anEvent) {
118 anEvent.preventDefault();
119
120 if (/(cardListReference_|cardListItem_)/.test(anEvent.target().id)) {
121 var cardListReference;
122
123 cardListReference = anEvent.target().id.match(/(cardListReference_|cardListItem_)(.*)/)[2];
124//console.log("Showing detail for card named", cardListReference);
125 MochiKit.Signal.signal(this, 'selectedCard', cardListReference);
126 }
127 },
128
129 //=========================================================================
130
131 'cardDetail': function (someData) {
132 if (this._cardDetail == null) {
133 this._cardDetail = new Clipperz.PM.UI.iPhone.Components.CardDetail({element:this.getElement('cardDetail')});
134 }
135
136 return this._cardDetail;
137 },
138
139 //-------------------------------------------------------------------------
140
141 'removeCardDetail': function () {
142 if (this._cardDetail != null) {
143 this._cardDetail.remove();
144 this._cardDetail = null;
145 }
146 },
147
148 //=========================================================================
149
150 'showCard': function (someData) {
151 vardeferredResult;
152 varoffset;
153
154 offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480);
155 this.cardDetail().render();
156 this.cardDetail().setCardReference(someData['_reference']);
157 MochiKit.Style.setElementPosition(this.cardDetail().element(), {x:offset});
158 new MochiKit.Visual.Sequence([
159 // new MochiKit.Visual.Move(this.cardDetail().element(), {x:offset, y:45, mode:'absolute', duration:0, sync:true}),
160 new MochiKit.Visual.Parallel([
161 new MochiKit.Visual.Move(this.getElement('cardList'), {x:-offset, y:0, mode:'relative',transition:MochiKit.Visual.Transitions.linear, sync:true}),
162 new MochiKit.Visual.Move(this.getElement('cardDetail'), {x:0, y:45, mode:'absolute',transition:MochiKit.Visual.Transitions.linear, sync:true}),
163 // new MochiKit.Visual.ScrollTo('toolbar', {sync:true}),
164 MochiKit.Visual.appear ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true})
165 ], {duration:1, sync:true}),
166 MochiKit.Visual.fade(this.getElement('cardList'), {duration:0, sync:true})
167 ], {})
168
169 MochiKit.DOM.getElement('pageTitle').innerHTML = someData['title'];
170
171 return true;
172 },
173
174 //-------------------------------------------------------------------------
175
176 'showCardDetails': function (someData) {
177 return this.cardDetail().showCardDetails(someData);
178 },
179
180 //=========================================================================
181
182 'backButtonClickHandler': function (anEvent) {
183 varoffset;
184
185 anEvent.preventDefault();
186
187 MochiKit.DOM.getElement('pageTitle').innerHTML = "cards";
188
189 offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480);
190 MochiKit.Style.setElementPosition(this.getElement('cardList'), {x:-offset});
191 MochiKit.DOM.showElement(this.getElement('cardList'));
192
193 new MochiKit.Visual.Parallel([
194 new MochiKit.Visual.Move(this.getElement('cardList'), {x:offset, y:0, mode:'relative',transition:MochiKit.Visual.Transitions.linear, sync:true}),
195 new MochiKit.Visual.Move(this.getElement('cardDetail'), {x:offset, y:0, mode:'relative',transition:MochiKit.Visual.Transitions.linear, sync:true}),
196 MochiKit.Visual.fade (this.getElement('cardDetail'), { transition:MochiKit.Visual.Transitions.linear, sync:true}),
197 MochiKit.Visual.fade ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true})
198 ], {duration:1, afterFinish:MochiKit.Base.method(this, 'removeCardDetail')})
199
200 },
201
202 //=========================================================================
203 __syntaxFix__: "syntax fix"
204});
diff --git a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js
new file mode 100644
index 0000000..eec83b0
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js
@@ -0,0 +1,181 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Base.module('Clipperz.PM.UI.iPhone.Components');
30
31Clipperz.PM.UI.iPhone.Components.LoginForm = function(args) {
32 args = args || {};
33
34 Clipperz.PM.UI.iPhone.Components.LoginForm.superclass.constructor.apply(this, arguments);
35
36 return this;
37}
38
39//=============================================================================
40
41Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.LoginForm, Clipperz.PM.UI.Common.Components.BaseComponent, {
42
43 //-------------------------------------------------------------------------
44
45 'toString': function () {
46 return "Clipperz.PM.UI.iPhone.Components.LoginForm component";
47 },
48
49 //-------------------------------------------------------------------------
50
51 'focusOnUsername': function () {
52 this.getElement('username').focus();
53 },
54
55 //-------------------------------------------------------------------------
56
57 'username': function () {
58 return this.getElement('username').value;
59 },
60
61 'passphrase': function () {
62 return this.getElement('passphrase').value;
63 },
64
65 //-------------------------------------------------------------------------
66
67 'renderSelf': function(/*aContainer, aPosition*/) {
68 this.append(this.element(), [
69 {tag:'div', cls:'toolbar iPhoneClipperzToolbar', children:[
70 {tag:'h1', id:'pageTitle', html:'Clipperz'},
71 {tag:'a', id:'backButton', cls:'button', href:'#', html:"back"}
72 ]},
73 {tag:'form', title:'Theaters', cls:'panel toolbarlessPanel loginForm', id:this.getId('loginFormPanel'), children:[
74 {tag:'fieldset', id:this.getId('fieldset'), children:[
75 {tag:'div', cls:'row', children:[
76 {tag:'label', html:"username"},
77 {tag:'input', type:'text', name:'username', value:"", autocorrect:'off', autocapitalize:'off', id:this.getId('username')}
78 ]},
79 {tag:'div', cls:'row', children:[
80 {tag:'label', html:"passphrase"},
81 {tag:'input', type:'password', name:'passphrase', value:"", id:this.getId('passphrase')}
82 ]}
83 ]},
84 {tag:'a', cls:'whiteButton', type:'submit', href:'#', html:"Login", id:this.getId('submit')}
85 ]},
86 {tag:'div', cls:'panel toolbarlessPanel loginProgressPanel', id:this.getId('loginProgressPanel'), children:[
87 {tag:'div', id:this.getId('progressBar')} //,
88 // {tag:'a', cls:'whiteButton', type:'submit', href:'#', html:"Cancel", id:this.getId('cancel')}
89 ]},
90 {tag:'div', cls:'panel loginErrorPanel', id:this.getId('loginErrorPanel'), children:[
91 {tag:'div', cls:'errorMessage', id:this.getId('errorMessageBox'), children:[
92 {tag:'h2', id:this.getId('errorMessage'), html:"Login failed"}
93 ]}
94 ]}
95 ]);
96
97 MochiKit.Signal.connect(this.getElement('submit'), 'onclick',this, 'submitHandler');
98 MochiKit.Signal.connect(this.getElement('loginFormPanel'), 'onsubmit',this, 'submitHandler');
99
100 // MochiKit.Signal.connect(this.getElement('cancel'), 'onclick',this, 'cancelHandler');
101 MochiKit.Signal.connect('backButton', 'onclick',this, 'backHandler');
102
103 this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':this.getElement('progressBar')}));
104
105 // MochiKit.Style.hideElement(this.getElement('errorMessage'));
106
107 this.showLoginForm();
108 // MochiKit.Async.callLater(0.2, MochiKit.Base.method(this, 'focusOnUsername'));
109 },
110
111 //-------------------------------------------------------------------------
112
113 'showLoginForm': function () {
114 MochiKit.Style.showElement(this.getElement('loginFormPanel'));
115 MochiKit.Style.hideElement(this.getElement('loginProgressPanel'));
116 MochiKit.Style.hideElement(this.getElement('loginErrorPanel'));
117 MochiKit.Style.hideElement('backButton');
118 },
119
120 'slideInLoginForm': function () {
121 varoffset;
122
123 offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480);
124
125 MochiKit.Style.showElement(this.getElement('loginFormPanel'));
126 MochiKit.Style.setElementPosition(this.getElement('loginFormPanel'), {x:-offset, y:0});
127
128 new MochiKit.Visual.Sequence([
129 new MochiKit.Visual.Parallel([
130 new MochiKit.Visual.Move(this.getElement('loginErrorPanel'), {x:offset, y:0, mode:'relative',transition:MochiKit.Visual.Transitions.linear, sync:true}),
131 new MochiKit.Visual.Move(this.getElement('loginFormPanel'), {x:0, y:0, mode:'absolute',transition:MochiKit.Visual.Transitions.linear, sync:true}),
132 MochiKit.Visual.fade ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true})
133 ], {duration:0.5, sync:true}),
134 MochiKit.Visual.fade(this.getElement('loginErrorPanel'), {duration:0, sync:true})
135 ], {})
136 },
137
138 'showLoginProgress': function () {
139 MochiKit.Style.hideElement(this.getElement('loginFormPanel'));
140 MochiKit.Style.showElement(this.getElement('loginProgressPanel'));
141 },
142
143 'showLoginError': function (anError) {
144 this.getElement('errorMessage').innerHTML = "Login error";
145
146 MochiKit.Style.showElement('backButton');
147 MochiKit.Style.hideElement(this.getElement('loginProgressPanel'));
148 MochiKit.Style.showElement(this.getElement('loginErrorPanel'));
149 MochiKit.Style.setElementPosition(this.getElement('loginErrorPanel'), {x:0, y:45});
150 },
151
152 //-------------------------------------------------------------------------
153/*
154 'disableCancelButton': function () {
155 MochiKit.DOM.hideElement(this.getElement('cancel'));
156 },
157*/
158 //-------------------------------------------------------------------------
159
160 'submitHandler': function (anEvent) {
161 anEvent.preventDefault();
162
163 MochiKit.Signal.signal(this, 'doLogin', {'username':this.username(), 'passphrase':this.passphrase()});
164 },
165
166 'cancelHandler': function (anEvent) {
167 anEvent.preventDefault();
168
169//console.log("CANCEL");
170 },
171
172 'backHandler': function (anEvent) {
173 anEvent.preventDefault();
174
175 this.slideInLoginForm();
176 },
177
178 //-------------------------------------------------------------------------
179
180 __syntaxFix__: "syntax fix"
181});
diff --git a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Controllers/MainController.js b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Controllers/MainController.js
new file mode 100644
index 0000000..b43d877
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Controllers/MainController.js
@@ -0,0 +1,372 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Base.module('Clipperz.PM.UI.iPhone.Controllers');
30
31 //Some parts of this controller have been derived from the iUI library.
32
33Clipperz.PM.UI.iPhone.Controllers.MainController = function() {
34 this._loginForm = null;
35 this._cardList = null;
36 this._cachedValues =null;
37 this._user = null;
38
39 if (typeof window.onorientationchange == 'object') {
40 MochiKit.Signal.connect(window, 'onorientationchange', this, 'orientationChangeHandler');
41 MochiKit.Async.callLater(0, MochiKit.Base.method(this, 'orientationChangeHandler'));
42 } else {
43 this.setOrientation('portrait');
44 // this.setOrientation('landscape');
45 }
46
47 this.addMetaTag('viewport', 'width=devicewidth; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;');
48 this.addMetaTag('apple-mobile-web-app-capable', 'yes');
49 this.addMetaTag('apple-mobile-web-app-status-bar-style', 'black');
50
51 this.addLinkTag('apple-touch-icon', 'data:image/png;charset=utf-8;base64,iVBORw0KGgoAAAANSUhEUgAAAF8AAABfCAYAAACOTBv1AAAACXBIWXMAAAsTAAALEwEAmpwYAAAQC0lEQVR4nO2ce3wU1b3AvzOzz2TzBpKQhIS3CnLxgYoPqAgiQS8igiAqiFprtT571YpKUa9tvVgrVvhc7IXS4lUUvGgR5CWIoiAIYoQgJGDI+0k2yW42szNz7h8pGBHIPmazqeb7+UD4DHt+vzPfPTnnzJkzIwGCLqKCHO0K/JTpkh9FuuRHkS75UaRLfhTpkh9FuuRHkS75UaRLfhTpkh9FLNGuwKnIzc3l9WXLQAIhQILWvwQnjn3vUNtjkoQQ4kSZr77KY+TIkR1/EgHQKeWnp6eTkJiI0P2gqyeOnxD7T+ttxf/wp4SwOOnTp0/UzqM9OqV8oFXygSVIm3/xvePSKf59up/cWfO9z3c2O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YSM45wJ3Pu3YjZ8/EVIdWiPiC0vVFZWcvVd8/nUPxqrqzt1PoMdlQ5qfWdOub9Gwq9J7NNHsG1XcN3NyTy/8B18fabS2Az729k8XemGj/KhpkFCtrqoyJrO+CfX8E3Bt2HV4Ux0yL6dEZdewO9vTaO5cC1CCHrFCfom/bAlljbA/moJS/pljH1qhymbmJKTk1j50CCaDm/jwt6CtJMWQA0D8kuhsEJCGODKOpcl+d14/d0Pw87dHhHpdk6mqLicFZ9Ucc3E27A35lPv1anxQrKTE5ftPj98WS6BEscz66wcKTZne3lzs48q0rm0ZwsV1V4yUr7L6W2B7QehvFYCAc5zJ3H3kkNs3bHXlNzt0WG3Ed1uNzfcv4j368fh6H4Obi98+i2UN7QOcnnlEqoKB61XsvXz/abmXrt5B/tixtCiSuwuaM1XVgeb86DeI6M4Ezjaazrjn1zFkaKOe8omKtsFzx00kFd/eR6evOUgQYJdUN8sYc+8hHHPfnH69/CEgaIorHl+Es1fvU2yS3DMIyOEIC7nfBbujmXF2tDemRMOUdur6XA4WPDUbWRVr0D11CNbY5i3pzebPjNn7f9U9M7O5LWpyTSV5CFJYB08hbvmf0RpWUXEcp6JDunzT4Wmabz74ReIjBEMH9iNQwzhleWRbX317gbktCGcn6ZzICGX2597i4aGxojmbA8R7T/ZvTKF3W7rsHwDB/SL+jkDIqpbxH/qdMrX+f5U6JIfRbrkR5Eu+VGkS34U6ZIfRbrkR5Eu+VGkS34U6ZIfRbrkR5H/Bx8z6HmTXnicAAAAAElFTkSuQmCCCg==');
52 //this.addLinkTag('apple-touch-startup-image', 'default.png');
53
54 // if (!window.navigator.standalone)// not running as an installed app
55
56 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'selectedDirectLogin', this, 'selectedDirectLoginHandler');
57
58 MochiKit.DOM.addElementClass(document.body, 'iPhone');
59 return this;
60}
61
62MochiKit.Base.update(Clipperz.PM.UI.iPhone.Controllers.MainController.prototype, {
63
64 'toString': function () {
65 return "Clipperz.PM.UI.iPhone.Controllers.MainController";
66 },
67
68 //=========================================================================
69
70 'user': function () {
71 return this._user;
72 },
73
74 'setUser': function (aValue) {
75 this._user = aValue;
76 },
77
78 //=========================================================================
79
80 'loginForm': function() {
81 if (this._loginForm == null) {
82 MochiKit.DOM.removeElement('mainDiv');
83 this._loginForm = new Clipperz.PM.UI.iPhone.Components.LoginForm({element:MochiKit.DOM.currentDocument().body});
84 MochiKit.Signal.connect(this._loginForm, 'doLogin', this, 'doLoginHandler')
85 }
86
87 return this._loginForm;
88 },
89
90 'removeLoginForm': function () {
91 if (this._loginForm != null) {
92 this._loginForm.remove();
93 this._loginForm = null;
94 }
95 },
96
97 //-----------------------------------------------------------------------------
98
99 'cardList': function () {
100 if (this._cardList == null) {
101 this._cardList = new Clipperz.PM.UI.iPhone.Components.CardList({element:MochiKit.DOM.currentDocument().body});
102 MochiKit.Signal.connect(this._cardList, 'searchEvent',this, 'searchEventHandler')
103 MochiKit.Signal.connect(this._cardList, 'selectedCard',this, 'selecetedCardHandler')
104 }
105
106 return this._cardList;
107 },
108
109 //=========================================================================
110
111 'currentWidth': function () {
112 return this._currentWidth;
113 },
114
115 'setCurrentWidth': function (aValue) {
116 this._currentWidth = aValue;
117 },
118
119 //=========================================================================
120
121 'orientationChangeHandler': function () {
122 switch(window.orientation) {
123 case 0:
124 this.setOrientation('portrait');
125 break;
126 case 90:
127 case -90:
128 this.setOrientation('landscape');
129 break;
130 }
131 },
132
133 //-------------------------------------------------------------------------
134
135 'setOrientation': function (anOrientation) {
136 document.body.setAttribute('orientation', anOrientation);
137 setTimeout(scrollTo, 100, 0, 1);
138 },
139
140 //-------------------------------------------------------------------------
141
142 'slidePages': function (fromPage, toPage, backwards) {
143 var axis;
144 var slideDone;
145
146 slideDone = function () {
147 // console.log("slideDone");
148 if (!hasClass(toPage, "dialog")) {
149 fromPage.removeAttribute("selected");
150 }
151 checkTimer = setInterval(checkOrientAndLocation, 300);
152 setTimeout(updatePage, 0, toPage, fromPage);
153 fromPage.removeEventListener('webkitTransitionEnd', slideDone, false);
154 }
155
156 axis = (backwards ? fromPage : toPage).getAttribute("axis");
157
158 clearInterval(checkTimer);
159
160 if (canDoSlideAnim() && axis != 'y') {
161 slide2(fromPage, toPage, backwards, slideDone);
162 } else {
163 slide1(fromPage, toPage, backwards, axis, slideDone);
164 }
165 },
166
167 //-------------------------------------------------------------------------
168
169 'getCachedValues': function () {
170 var deferredResult;
171
172 if (this._cachedObjects != null) {
173 deferredResult = MochiKit.Async.succeed(this._cachedObjects);
174 } else {
175 deferredResult = new Clipperz.Async.Deferred("MainController.getCachedValues", {trace:false});
176 deferredResult.addMethod(this.user(), 'getRecords');
177 deferredResult.addCallback(MochiKit.Base.map, Clipperz.Async.collectResults("MainController.getCachedValues - collectResults", {
178 '_rowObject': MochiKit.Async.succeed,
179 '_reference': MochiKit.Base.methodcaller('reference'),
180 'label': MochiKit.Base.methodcaller('label'),
181 'favicon': MochiKit.Base.methodcaller('favicon'),
182 '_searchableContent':MochiKit.Base.methodcaller('searchableContent')
183 }, {trace:false}));
184 deferredResult.addCallback(Clipperz.Async.collectAll);
185 deferredResult.addCallback(MochiKit.Base.bind(function (someRows) {
186 this._cachedObjects = someRows;
187 return this._cachedObjects;
188 }, this));
189 deferredResult.callback();
190 }
191
192 return deferredResult;
193 },
194 //=========================================================================
195
196 'run': function(shouldShowRegistrationForm) {
197 this.loginForm().render();
198 MochiKit.Async.callLater(1, MochiKit.Base.method(this.loginForm(), 'focusOnUsername'));
199 },
200
201 //=========================================================================
202
203 'doLoginHandler': function (someArgs) {
204 var deferredResult;
205 varparameters;
206 varshouldUseOTP;
207 // var loginProgress;
208 varuser;
209 var getPassphraseDelegate;
210
211 parameters = someArgs;
212 shouldUseOTP = (typeof(parameters.passphrase) == 'undefined');
213
214 getPassphraseDelegate = MochiKit.Base.partial(MochiKit.Async.succeed, parameters.passphrase);
215 user = new Clipperz.PM.DataModel.User({'username':parameters.username, 'getPassphraseFunction':getPassphraseDelegate});
216
217 deferredResult = new Clipperz.Async.Deferred("MainController.doLogin", {trace:false});
218 deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':4});
219 deferredResult.addMethod(this.loginForm(), 'showLoginProgress');
220 deferredResult.addCallback(MochiKit.Async.wait, 0.1);
221 deferredResult.addMethod(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'deferredEntropyCollection');
222 deferredResult.addMethod(user, 'login');
223 deferredResult.addMethod(this, 'setUser', user);
224 deferredResult.addMethod(user, 'getRecords');
225 deferredResult.addMethod(this, 'removeLoginForm');
226 deferredResult.addMethod(this.cardList(), 'render');
227 deferredResult.addMethod(this, 'displaySelectedRecords', '');
228 deferredResult.addErrback(MochiKit.Base.method(this.loginForm(), 'showLoginError'));
229 deferredResult.callback();
230
231 return deferredResult;
232 },
233
234 //=========================================================================
235
236 'searchEventHandler': function (aValue) {
237//console.log("searching for ... " + aValue);
238 return this.displaySelectedRecords(aValue);
239 },
240
241 //=========================================================================
242
243 '_displaySelectedRows': function (aFilter, someRows) {
244 var result;
245
246 result = someRows;
247
248 if (aFilter != null) {
249 var filter;
250 varfilterRegExp;
251
252 filter = aFilter.replace(/[^A-Za-z0-9]/g, "\\$&");
253 filterRegExp = new RegExp(filter, "i");
254 result = MochiKit.Base.filter(function (aCachedResult) { return filterRegExp.test(aCachedResult['_searchableContent'])}, result);
255 }
256
257
258 result.sort(MochiKit.Base.partial(function (aKey, aComparator, aObject, bObject) {
259 return aComparator(aObject[aKey], bObject[aKey]);
260 }, 'label', Clipperz.Base.caseInsensitiveCompare));
261
262 this.cardList().update(result);
263 },
264
265 //-------------------------------------------------------------------------
266
267 'displaySelectedRecords': function (aFilter) {
268 return Clipperz.Async.callbacks("MainController.displaySelectedrows", [
269 MochiKit.Base.method(this, 'getCachedValues'),
270 MochiKit.Base.method(this, '_displaySelectedRows', aFilter)
271 ], {trace:false});
272 },
273
274 //=========================================================================
275
276 'selecetedCardHandler': function (aRecordReference) {
277 vardeferredResult;
278 varrecordData;
279
280 recordData = {};
281//console.log("Showing detail for card with reference", aRecordReference);
282 deferredResult = new Clipperz.Async.Deferred("MainController.selectedCardHandler", {trace:false});
283 deferredResult.addMethod(this.user(), 'getRecord', aRecordReference);
284 deferredResult.collectResults({
285 '_reference':MochiKit.Base.methodcaller('reference'),
286 'title': MochiKit.Base.methodcaller('label'),
287 'favicon': MochiKit.Base.methodcaller('favicon')
288 });
289 deferredResult.addCallback(function (someData) {
290 MochiKit.Base.update(recordData, someData);
291 })
292 deferredResult.addMethod(this.cardList(), 'showCard', recordData);
293
294 deferredResult.addMethod(this.user(), 'getRecord', aRecordReference);
295 deferredResult.addMethodcaller('notes');
296 deferredResult.addCallback(function (someNotes) {
297 recordData['notes'] = someNotes;
298 })
299
300 deferredResult.addMethod(this.user(), 'getRecord', aRecordReference);
301 deferredResult.addMethodcaller('getCurrentRecordVersion');
302 deferredResult.addMethodcaller('fields');
303 deferredResult.addCallback(MochiKit.Base.values);
304 deferredResult.addCallback(MochiKit.Base.map, Clipperz.Async.collectResults("MainController.selectedCardHandler - fields", {
305 'label':MochiKit.Base.methodcaller('label'),
306 'value':MochiKit.Base.methodcaller('value'),
307 'isHidden':MochiKit.Base.methodcaller('isHidden')
308 }, {trace:false}));
309 deferredResult.addCallback(Clipperz.Async.collectAll);
310 deferredResult.addCallback(function (someData) {
311 recordData['fields'] = someData;
312 });
313
314 deferredResult.addMethod(this.user(), 'getRecord', aRecordReference);
315 deferredResult.addMethodcaller('directLogins');
316 deferredResult.addCallback(MochiKit.Base.values);
317 deferredResult.addCallback(MochiKit.Base.map, Clipperz.Async.collectResults("MainController.selectedCardHandler - directLogins", {
318 'label': MochiKit.Base.methodcaller('label'),
319 'favicon': MochiKit.Base.methodcaller('favicon'),
320 '_reference':MochiKit.Base.methodcaller('reference')
321 }, {trace:false}));
322 deferredResult.addCallback(Clipperz.Async.collectAll);
323 deferredResult.addCallback(function (someData) {
324 recordData['directLogins'] = someData;
325 });
326
327 deferredResult.addMethod(this.cardList(), 'showCardDetails', recordData);
328 deferredResult.callback();
329
330 return deferredResult;
331 },
332
333 //=========================================================================
334
335 'selectedDirectLoginHandler': function (someData) {
336 vardeferredResult;
337
338//console.log("<<< signal - directLogin");
339 deferredResult = new Clipperz.Async.Deferred("MainController.selectedDirectLoginHandler", {trace:false});
340 deferredResult.addMethod(this.user(), 'getRecord', someData['cardReference']);
341 deferredResult.addMethodcaller('directLogins');
342 deferredResult.addCallback(MochiKit.Base.itemgetter(someData['directLoginReference']));
343 // deferredResult.addMethodcaller('runDirectLogin');
344 deferredResult.addCallback(Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.openDirectLogin);
345 deferredResult.callback();
346
347 return deferredResult;
348 },
349
350 //=========================================================================
351
352 'addMetaTag': function (aName, aContent) {
353 varmetaTag;
354
355 metaTag = document.createElement('meta');
356 metaTag.name = aName;
357 metaTag.content = aContent;
358 document.getElementsByTagName('head')[0].appendChild(metaTag);
359 },
360
361 'addLinkTag': function (aRel, anHref) {
362 var linkTag;
363
364 linkTag = document.createElement('link');
365 linkTag.rel = aRel;
366 linkTag.href = anHref;
367 document.getElementsByTagName('head')[0].appendChild(linkTag);
368 },
369
370 //=========================================================================
371 __syntaxFix__: "syntax fix"
372}); \ No newline at end of file