author | Clipperz <info@clipperz.com> | 2013-01-08 15:21:04 (UTC) |
---|---|---|
committer | Clipperz <info@clipperz.com> | 2013-01-08 15:21:04 (UTC) |
commit | 816fc35420a434b1d54ae5833d617608f7456048 (patch) (unidiff) | |
tree | 95b8caf354083593d7775e4dda6f4c556b44a2d9 /frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js | |
parent | 267603e3aa3cf0029411e67ae14018b52344c296 (diff) | |
download | clipperz-816fc35420a434b1d54ae5833d617608f7456048.zip clipperz-816fc35420a434b1d54ae5833d617608f7456048.tar.gz clipperz-816fc35420a434b1d54ae5833d617608f7456048.tar.bz2 |
Updated version of /gamma
Tons of changes, included a new draft of the mobile version (still VERY rough)
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js | 299 |
1 files changed, 299 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js new file mode 100644 index 0000000..32dfa63 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js | |||
@@ -0,0 +1,299 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz Community Edition. | ||
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | ||
8 | refer to http://www.clipperz.com. | ||
9 | |||
10 | * Clipperz Community Edition is free software: you can redistribute | ||
11 | it and/or modify it under the terms of the GNU Affero General Public | ||
12 | License as published by the Free Software Foundation, either version | ||
13 | 3 of the License, or (at your option) any later version. | ||
14 | |||
15 | * Clipperz Community Edition is distributed in the hope that it will | ||
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
18 | See the GNU Affero General Public License for more details. | ||
19 | |||
20 | * You should have received a copy of the GNU Affero General Public | ||
21 | License along with Clipperz Community Edition. If not, see | ||
22 | <http://www.gnu.org/licenses/>. | ||
23 | |||
24 | */ | ||
25 | |||
26 | Clipperz.Base.module('Clipperz.PM.UI.Mobile.Components'); | ||
27 | |||
28 | Clipperz.PM.UI.Mobile.Components.CardDetail = function(args) { | ||
29 | args = args || {}; | ||
30 | |||
31 | Clipperz.PM.UI.Mobile.Components.CardDetail.superclass.constructor.apply(this, arguments); | ||
32 | |||
33 | //this._cardReference = null; | ||
34 | |||
35 | return this; | ||
36 | } | ||
37 | |||
38 | //============================================================================= | ||
39 | |||
40 | Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.CardDetail, Clipperz.PM.UI.Common.Components.BaseComponent, { | ||
41 | |||
42 | //------------------------------------------------------------------------- | ||
43 | |||
44 | 'toString': function () { | ||
45 | return "Clipperz.PM.UI.Mobile.Components.CardDetail component"; | ||
46 | }, | ||
47 | |||
48 | //------------------------------------------------------------------------- | ||
49 | /* | ||
50 | 'cardReference': function () { | ||
51 | return this._cardReference; | ||
52 | }, | ||
53 | |||
54 | 'setCardReference': function (aValue) { | ||
55 | this._cardReference = aValue; | ||
56 | }, | ||
57 | */ | ||
58 | //------------------------------------------------------------------------- | ||
59 | |||
60 | 'renderSelf': function () { | ||
61 | console.log("CardDetail.renderSelf"); | ||
62 | this.append(this.element(), {tag:'div', cls:'cardDetail', children:[ | ||
63 | {tag:'div', cls:'toolbar', children:[ | ||
64 | {tag:'a', href:'#', cls:'back', html:"List"}, | ||
65 | {tag:'h1', id:this.getId('cardTitle'), html:"…"} | ||
66 | ]}, | ||
67 | {tag:'div', cls:'scroll', id:this.getId('cardDetails'), children:[ | ||
68 | ]} | ||
69 | ]}); | ||
70 | }, | ||
71 | /* | ||
72 | 'renderSelf': function() { | ||
73 | this.append(this.element(), [ | ||
74 | {tag:'div', cls:'cardDetail', id:this.getId('cardDetail'), children:[ | ||
75 | {tag:'div', id:this.getId('progressBar')} //, | ||
76 | ]} | ||
77 | ]); | ||
78 | |||
79 | this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':this.getElement('progressBar')})); | ||
80 | MochiKit.Signal.signal(Clipperz.PM.UI.Common.Controllers.ProgressBarController.defaultController, 'updateProgress', 0); | ||
81 | }, | ||
82 | */ | ||
83 | |||
84 | 'setTitle': function (aValue) { | ||
85 | this.getElement('cardTitle').innerHTML = aValue; | ||
86 | }, | ||
87 | |||
88 | 'fieldListElement': function () { | ||
89 | varresult; | ||
90 | |||
91 | result = this.getElement('fieldList'); | ||
92 | if (result == null) { | ||
93 | result = this.append(this.getElement('cardDetails'), {tag:'ul', cls:'rounded', id:this.getId('fieldList')}); | ||
94 | } | ||
95 | |||
96 | return result; | ||
97 | }, | ||
98 | |||
99 | 'renderFieldValues': function (someFieldValues) { | ||
100 | varfieldClass; | ||
101 | |||
102 | if ((someFieldValues['actionType'] != 'NONE') || (someFieldValues['label'] != '') && (someFieldValues['value'] != '')) { | ||
103 | if (someFieldValues['isHidden'] == true) { | ||
104 | fieldClass = 'password'; | ||
105 | } else { | ||
106 | fieldClass = ''; | ||
107 | } | ||
108 | |||
109 | this.append(this.fieldListElement(), {tag:'li', cls:'cardField', children:[ | ||
110 | {tag:'a', href:'#', cls:fieldClass, html:someFieldValues['value'], children:[ | ||
111 | {tag:'small', cls:'label', html:someFieldValues['label']} | ||
112 | ]} | ||
113 | ]}) | ||
114 | } | ||
115 | }, | ||
116 | |||
117 | 'addField': function (aField) { | ||
118 | var deferredResult; | ||
119 | varfieldValues; | ||
120 | |||
121 | fieldValues = {}; | ||
122 | deferredResult = new Clipperz.Async.Deferred("CardDetail.addField", {trace:false}); | ||
123 | deferredResult.addMethod(aField, 'label'); | ||
124 | deferredResult.addCallback(function (aValue) { fieldValues['label'] = aValue; }); | ||
125 | deferredResult.addMethod(aField, 'value'); | ||
126 | deferredResult.addCallback(function (aValue) { fieldValues['value'] = aValue; }); | ||
127 | deferredResult.addMethod(aField, 'actionType'); | ||
128 | deferredResult.addCallback(function (aValue) { fieldValues['actionType'] = aValue; }); | ||
129 | deferredResult.addMethod(aField, 'isHidden'); | ||
130 | deferredResult.addCallback(function (aValue) { fieldValues['isHidden'] = aValue; }); | ||
131 | deferredResult.addMethod(this, 'renderFieldValues', fieldValues); | ||
132 | deferredResult.callback(); | ||
133 | |||
134 | return deferredResult; | ||
135 | }, | ||
136 | |||
137 | //------------------------------------------------------------------------- | ||
138 | |||
139 | 'directLoginElement': function () { | ||
140 | varresult; | ||
141 | |||
142 | result = this.getElement('directLoginList'); | ||
143 | if (result == null) { | ||
144 | this.append(this.getElement('cardDetails'), {tag:'h2', html:"Direct login"}); | ||
145 | result = this.append(this.getElement('cardDetails'), {tag:'ul', cls:'rounded', id:this.getId('directLoginList')}); | ||
146 | } | ||
147 | |||
148 | return result; | ||
149 | }, | ||
150 | |||
151 | 'addDirectLogin': function (aDirectLogin) { | ||
152 | this.append(this.directLoginElement(), {tag:'li', cls:'directLogin forward', children:[ | ||
153 | {tag:'a', href:'#', html:"direct login", children:[ | ||
154 | {tag:'small', cls:'favicon', children:[{tag:'img', cls:'favicon', src:'http://www.clipperz.com/favicon.ico'}]} | ||
155 | ]} | ||
156 | ]}) | ||
157 | |||
158 | console.log("ADD DIRECT LOGIN", aDirectLogin); | ||
159 | }, | ||
160 | |||
161 | //========================================================================= | ||
162 | |||
163 | 'showCard': function (aCard) { | ||
164 | var deferredResult; | ||
165 | |||
166 | // this.render(); | ||
167 | |||
168 | console.log("CardDetail.showCard", aCard); | ||
169 | deferredResult = new Clipperz.Async.Deferred("CardDetail.showCard", {trace:false}); | ||
170 | deferredResult.addMethod(aCard, 'label'); | ||
171 | deferredResult.addMethod(this, 'setTitle'); | ||
172 | |||
173 | deferredResult.addMethod(aCard, 'fields'); | ||
174 | deferredResult.addCallback(MochiKit.Base.values); | ||
175 | deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.method(this, 'addField')); | ||
176 | |||
177 | deferredResult.addMethod(aCard, 'directLogins'); | ||
178 | deferredResult.addCallback(MochiKit.Base.values); | ||
179 | deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.method(this, 'addDirectLogin')); | ||
180 | |||
181 | |||
182 | deferredResult.callback(); | ||
183 | |||
184 | return deferredResult; | ||
185 | // return Clipperz.Async.callbacks("CardDialogController.updateComponentState", [ | ||
186 | // MochiKit.Base.method(this.record(), 'hasPendingChanges'), | ||
187 | // MochiKit.Base.method(this.cardDialogComponent(), 'setShouldEnableSaving'), | ||
188 | // | ||
189 | // MochiKit.Base.method(this.record(), 'label'), | ||
190 | // MochiKit.Base.method(this.cardDialogComponent(), 'setTitle'), | ||
191 | // MochiKit.Base.method(this.record(), 'notes'), | ||
192 | // MochiKit.Base.method(this.cardDialogComponent(), 'setNotes'), | ||
193 | // | ||
194 | // MochiKit.Base.method(this.record(), 'fields'), | ||
195 | // MochiKit.Base.values, | ||
196 | // MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'addCardDialogComponentWithField')), | ||
197 | // | ||
198 | // MochiKit.Base.method(this.record(), 'directLogins'), | ||
199 | // MochiKit.Base.values, | ||
200 | // MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'addCardDialogComponentWithDirectLogin')), | ||
201 | // | ||
202 | // MochiKit.Base.method(this.cardDialogComponent(), 'resetNewFieldInputs'), | ||
203 | // MochiKit.Base.noop | ||
204 | // ], {trace:false}); | ||
205 | |||
206 | }, | ||
207 | |||
208 | //========================================================================= | ||
209 | |||
210 | 'showCardDetails': function (someData) { | ||
211 | this.element().innerHTML = ''; | ||
212 | this.append(this.element(), [ | ||
213 | {tag:'fieldset', id:this.getId('fields'), children:MochiKit.Base.map(function (aFieldData) { | ||
214 | return {tag:'div', cls:'row', children:[ | ||
215 | {tag:'label', html:aFieldData['label']}, | ||
216 | // {tag:'span', cls:('fieldValue ' + (aFieldData['isHidden']? 'password' : 'text')), html:aFieldData['value']} | ||
217 | {tag:'div', cls:('fieldValue ' + (aFieldData['isHidden']? 'password' : 'text')), children:[ | ||
218 | {tag:'div', children:[{tag:'p', html:aFieldData['value']}]} | ||
219 | ]} | ||
220 | // {tag:'input', type:'text', cls:('fieldValue ' + (aFieldData['isHidden']? 'password' : 'text')), value:aFieldData['value'], disabled:true} | ||
221 | |||
222 | ]} | ||
223 | }, someData['fields'])} | ||
224 | ]); | ||
225 | |||
226 | MochiKit.Iter.forEach(MochiKit.Selector.findChildElements(this.element(), ['span.password']), MochiKit.Base.bind(function (aPasswordElement) { | ||
227 | MochiKit.Signal.connect(aPasswordElement, 'onclick', function (anEvent) { alert(MochiKit.DOM.scrapeText(anEvent.src())); }) | ||
228 | }, this)); | ||
229 | |||
230 | if (someData['directLogins'].length > 0) { | ||
231 | this.append(this.element(), [ | ||
232 | {tag:'h2', html:"Direct logins"}, | ||
233 | {tag:'fieldset', id:this.getId('directLogins'), children:MochiKit.Base.map(function (aDirectLoginData) { | ||
234 | return {tag:'div', cls:'row', id:('directLogin_' + aDirectLoginData['_reference']), children:[ | ||
235 | {tag:'img', cls:'favicon', src:aDirectLoginData['favicon']}, | ||
236 | // {tag:'input', cls:'directLogin', disabled:'disabled', type:'text', name:aDirectLoginData['label'], value:aDirectLoginData['label']} | ||
237 | {tag:'span', cls:'directLogin', html:aDirectLoginData['label']} | ||
238 | ]} | ||
239 | }, someData['directLogins'])} | ||
240 | ]); | ||
241 | |||
242 | MochiKit.Base.map(MochiKit.Base.bind(function (aRowNode) { | ||
243 | MochiKit.Signal.connect(aRowNode, 'onclick', this, 'directLoginClickHandler'); | ||
244 | }, this), | ||
245 | MochiKit.Selector.findChildElements(this.getElement('directLogins'), ['div.row']) | ||
246 | ) | ||
247 | }; | ||
248 | |||
249 | if (someData['notes'] != '') { | ||
250 | this.append(this.element(), [ | ||
251 | {tag:'h2', html:"Notes"}, | ||
252 | {tag:'fieldset', id:this.getId('fieldset'), children:[ | ||
253 | {tag:'div', cls:'row notes', children:[ | ||
254 | {tag:'span', html:someData['notes']} | ||
255 | ]} | ||
256 | ]} | ||
257 | ]); | ||
258 | }; | ||
259 | |||
260 | return true; | ||
261 | }, | ||
262 | |||
263 | //------------------------------------------------------------------------- | ||
264 | /* | ||
265 | 'toggleClickHandler': function (anEvent) { | ||
266 | varnextState; | ||
267 | varfieldValue; | ||
268 | |||
269 | //console.log("TOGGLE"); | ||
270 | anEvent.preventDefault; | ||
271 | fieldValue = MochiKit.Selector.findChildElements(anEvent.src().parentNode.parentNode, ['span.password'])[0]; | ||
272 | |||
273 | nextState = (MochiKit.DOM.getNodeAttribute(anEvent.src(), 'toggled') != 'true'); | ||
274 | if (nextState) { | ||
275 | MochiKit.DOM.removeElementClass(fieldValue, 'clear'); | ||
276 | } else { | ||
277 | MochiKit.DOM.addElementClass(fieldValue, 'clear'); | ||
278 | } | ||
279 | |||
280 | MochiKit.DOM.setNodeAttribute(anEvent.src(), 'toggled', nextState); | ||
281 | }, | ||
282 | * / | ||
283 | //========================================================================= | ||
284 | /* | ||
285 | 'directLoginClickHandler': function (anEvent) { | ||
286 | anEvent.preventDefault(); | ||
287 | |||
288 | if (/(directLogin_)/.test(anEvent.src().id)) { | ||
289 | var directLoginReference; | ||
290 | |||
291 | directLoginReference = anEvent.src().id.match(/(directLogin_)(.*)/)[2]; | ||
292 | MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'selectedDirectLogin', {cardReference:this.cardReference(), directLoginReference:directLoginReference}); | ||
293 | } | ||
294 | }, | ||
295 | */ | ||
296 | //========================================================================= | ||
297 | |||
298 | __syntaxFix__: "syntax fix" | ||
299 | }); | ||