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