author | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
commit | 541bb378ddece2eab135a8066a16994e94436dea (patch) (unidiff) | |
tree | ff160ea3e26f7fe07fcfd401387c5a0232ca715e /frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginComponent.js | |
parent | 1bf431fd3d45cbdf4afa3e12afefe5d24f4d3bc7 (diff) | |
parent | ecad5e895831337216544e81f1a467e0c68c4a6a (diff) | |
download | clipperz-541bb378ddece2eab135a8066a16994e94436dea.zip clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.gz clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.bz2 |
Merge pull request #1 from gcsolaroli/master
First version of the restructured repository
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginComponent.js | 362 |
1 files changed, 362 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginComponent.js new file mode 100644 index 0000000..7638f00 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginComponent.js | |||
@@ -0,0 +1,362 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | ||
11 | refer 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 | |||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.DirectLoginComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.RecordDetail.DirectLoginComponent.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this._directLogin = args.directLogin || null; | ||
42 | //this._titleElement = null; | ||
43 | this._structureElement = null; | ||
44 | this._removeButton = null; | ||
45 | this._directLoginBindingComponents = null; | ||
46 | this._collapser = null; | ||
47 | |||
48 | this.mainComponent().addEditComponent(this); | ||
49 | this.render(); | ||
50 | |||
51 | return this; | ||
52 | } | ||
53 | |||
54 | //============================================================================= | ||
55 | |||
56 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.DirectLoginComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, { | ||
57 | |||
58 | 'toString': function() { | ||
59 | return "Clipperz.PM.Components.RecordDetail.DirectLoginComponent component"; | ||
60 | }, | ||
61 | |||
62 | //------------------------------------------------------------------------- | ||
63 | |||
64 | 'directLogin': function() { | ||
65 | return this._directLogin; | ||
66 | }, | ||
67 | |||
68 | 'directLoginBindingComponents': function() { | ||
69 | return this._directLoginBindingComponents; | ||
70 | }, | ||
71 | |||
72 | //------------------------------------------------------------------------- | ||
73 | |||
74 | 'removeDirectLogin': function() { | ||
75 | //MochiKit.Logging.logDebug(">>> DirectLoginComponent.removeDirectLogin"); | ||
76 | this.mainComponent().synchronizeComponentValues(); | ||
77 | this.directLogin().remove(); | ||
78 | this.mainComponent().removeEditComponent(this); | ||
79 | this.mainComponent().render(); | ||
80 | //MochiKit.Logging.logDebug("<<< DirectLoginComponent.removeDirectLogin"); | ||
81 | }, | ||
82 | |||
83 | //------------------------------------------------------------------------- | ||
84 | /* | ||
85 | 'formDataValue': function() { | ||
86 | return Clipperz.Base.serializeJSON(this.directLogin().formData()); | ||
87 | }, | ||
88 | |||
89 | 'setFormDataValue': function(aValue) { | ||
90 | |||
91 | }, | ||
92 | */ | ||
93 | //------------------------------------------------------------------------- | ||
94 | |||
95 | 'removeButton': function() { | ||
96 | return this._removeButton; | ||
97 | }, | ||
98 | |||
99 | 'setRemoveButton': function(aValue) { | ||
100 | this._removeButton = aValue; | ||
101 | }, | ||
102 | |||
103 | //------------------------------------------------------------------------- | ||
104 | /* | ||
105 | 'titleElement': function() { | ||
106 | return this._titleElement; | ||
107 | }, | ||
108 | |||
109 | 'setTitleElement': function(aValue) { | ||
110 | this._titleElement = aValue; | ||
111 | }, | ||
112 | */ | ||
113 | //------------------------------------------------------------------------- | ||
114 | |||
115 | 'structureElement': function() { | ||
116 | return this._structureElement; | ||
117 | }, | ||
118 | |||
119 | 'setStructureElement': function(aValue) { | ||
120 | this._structureElement = aValue; | ||
121 | }, | ||
122 | |||
123 | //------------------------------------------------------------------------- | ||
124 | |||
125 | 'render': function() { | ||
126 | //MochiKit.Logging.logDebug(">>> DirectLoginComponent.render"); | ||
127 | try { | ||
128 | this.element().update(""); | ||
129 | Clipperz.YUI.DomHelper.append(this.element().dom, | ||
130 | {tag:'li', children:[ | ||
131 | {tag:'table', width:'100%', border:'0', cellpadding:'0', cellspacing:'0', children:[ | ||
132 | {tag:'tbody', children:[ | ||
133 | {tag:'tr', children:[ | ||
134 | {tag:'td', rowspan:'2', width:'30', valign:'top', html:' ', children:[ | ||
135 | {tag:'div', id:this.getId('removeDirectLogin'), children:[ | ||
136 | {tag:'div', id:this.getId('removeDirectLoginButton')} | ||
137 | ]}, | ||
138 | {tag:'div', id:this.getId('collapseLink'), cls:'directLoginCollapseLink'} | ||
139 | ]}, | ||
140 | {tag:'td', valign:'top', children:[ | ||
141 | {tag:'table', width:'100%', border:'0', cellpadding:'0', cellspacing:'0', children:[ | ||
142 | {tag:'tbody', children:[ | ||
143 | {tag:'tr', children:[ | ||
144 | {tag:'td', width:'20', valign:'top', children:[ | ||
145 | {tag:'a', href:'#', id:this.getId('directLogin'), children:[ | ||
146 | {tag:'img', id:this.getId('faviconImage'), width:'16', height:'16', src:this.directLogin().fixedFavicon()} | ||
147 | ]} | ||
148 | ]}, | ||
149 | {tag:'td', valign:'top', children:[ | ||
150 | {tag:'div', cls:'directLoginDetailTitle', children:[ | ||
151 | {tag:'div', id:this.getId('titleViewBox'), children:[ | ||
152 | {tag:'a', href:'#', id:this.getId('titleLink')} | ||
153 | ]}, | ||
154 | {tag:'div', id:this.getId('titleEditBox'), children:[ | ||
155 | {tag:'input', type:'text', id:this.getId('titleInput')} | ||
156 | ]} | ||
157 | ]} | ||
158 | ]} | ||
159 | ]} | ||
160 | ]} | ||
161 | ]} | ||
162 | ]} | ||
163 | ]}, | ||
164 | {tag:'tr', children:[ | ||
165 | {tag:'td', /*colspan:'2',*/ children:[ | ||
166 | {tag:'div', id:this.getId('details'), children:[ | ||
167 | {tag:'table', cls:'directLoginBindings', border:'0', cellpadding:'0', cellspacing:'0', children:[ | ||
168 | {tag:'tbody', id:this.getId('tbodyBindings'), children:[]} | ||
169 | ]} | ||
170 | ]} | ||
171 | ]} | ||
172 | ]} | ||
173 | ]} | ||
174 | ]} | ||
175 | ]} | ||
176 | ); | ||
177 | |||
178 | MochiKit.Signal.connect(this.getId('faviconImage'), 'onload', this, 'handleLoadedFaviconImage'); | ||
179 | MochiKit.Signal.connect(this.getId('faviconImage'), 'onerror', this.directLogin(), 'handleMissingFaviconImage'); | ||
180 | MochiKit.Signal.connect(this.getId('faviconImage'), 'onabort', this.directLogin(), 'handleMissingFaviconImage'); | ||
181 | |||
182 | this.getElement('removeDirectLogin').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
183 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 1"); | ||
184 | this.getElement('collapseLink').addClassOnOver('hover'); | ||
185 | this._collapser = new Clipperz.YUI.Collapser(this.getElement('collapseLink'), this.getElement('details'), true); | ||
186 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 2"); | ||
187 | MochiKit.Signal.connect(this.getId('directLogin'), 'onclick', this, 'runDirectLogin'); | ||
188 | // this.getElement('directLogin').on('click', this.runDirectLogin, this, false); | ||
189 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 3"); | ||
190 | // this.setTitleElement(new Clipperz.PM.Components.TextFormField(this.getElement('title'), { | ||
191 | // editMode:this.editMode(), | ||
192 | // value:this.directLogin().label() | ||
193 | // })); | ||
194 | this.getElement('titleViewBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
195 | this.getElement('titleEditBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
196 | //- this.getElement('titleLink').on('click', this.runDirectLogin, this, false); | ||
197 | MochiKit.Signal.connect(this.getId('titleLink'), 'onclick', this, 'runDirectLogin'); | ||
198 | |||
199 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 4"); | ||
200 | //- this.setStructureElement(new Clipperz.PM.Components.TextFormField(this.getElement('formStructure'), { | ||
201 | //- editMode:this.editMode(), | ||
202 | //- value:this.formDataValue(), multiline:true | ||
203 | //- })); | ||
204 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 5"); | ||
205 | { | ||
206 | varbindingKey; | ||
207 | var valueName; | ||
208 | var inputsRequiringAdditionalValues; | ||
209 | var bindingsElement; | ||
210 | var i,c; | ||
211 | |||
212 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 6"); | ||
213 | this._directLoginBindingComponents = []; | ||
214 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 7"); | ||
215 | bindingsElement = this.getElement('tbodyBindings'); | ||
216 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 8"); | ||
217 | for (bindingKey in this.directLogin().bindings()) { | ||
218 | try { | ||
219 | var directLoginBindingElement; | ||
220 | var directLoginBindingComponent; | ||
221 | |||
222 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 9"); | ||
223 | directLoginBindingElement = Clipperz.YUI.DomHelper.append(bindingsElement.dom, {tag:'tr'}, true); | ||
224 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 10"); | ||
225 | directLoginBindingComponent =new Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent(directLoginBindingElement, { | ||
226 | mainComponent:this, | ||
227 | directLoginBinding:this.directLogin().bindings()[bindingKey] | ||
228 | }); | ||
229 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 11"); | ||
230 | this._directLoginBindingComponents.push(directLoginBindingComponent); | ||
231 | } catch (e) { | ||
232 | MochiKit.Logging.logError("Error while rendering a DirectLoginBindingComponent - " + e); | ||
233 | } | ||
234 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 12"); | ||
235 | } | ||
236 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 13"); | ||
237 | |||
238 | inputsRequiringAdditionalValues = this.directLogin().inputsRequiringAdditionalValues(); | ||
239 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 13.1"); | ||
240 | for (valueName in inputsRequiringAdditionalValues) { | ||
241 | //- Clipperz.YUI.DomHelper.append(bindingsElement.dom, {tag:'tr', children:[ | ||
242 | //- {tag:'td', html:valueName}, | ||
243 | //- {tag:'td', children:inputsRequiringAdditionalValues[valueName].inputElementConfiguration()} | ||
244 | //- ]}, true) | ||
245 | var directLoginValueElement; | ||
246 | var directLoginValueComponent; | ||
247 | |||
248 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 13.2"); | ||
249 | directLoginValueElement = Clipperz.YUI.DomHelper.append(bindingsElement.dom, {tag:'tr'}, true); | ||
250 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 13.3"); | ||
251 | directLoginValueComponent =new Clipperz.PM.Components.RecordDetail.DirectLoginValueComponent(directLoginValueElement, { | ||
252 | mainComponent:this, | ||
253 | directLoginInputValue:inputsRequiringAdditionalValues[valueName] | ||
254 | }); | ||
255 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 13.4"); | ||
256 | this._directLoginBindingComponents.push(directLoginValueComponent); | ||
257 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 13.5"); | ||
258 | } | ||
259 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 13.6"); | ||
260 | } | ||
261 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 14"); | ||
262 | this.setRemoveButton(new YAHOO.ext.Button(this.getDom('removeDirectLoginButton'), {text:Clipperz.PM.Strings['recordDetailDeleteDirectLoginButtonLabel'], handler:this.removeDirectLogin, scope:this})); | ||
263 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 15"); | ||
264 | this.update(); | ||
265 | } catch (e) { | ||
266 | MochiKit.Logging.logError("Error while rendering a DirectLoginComponent - " + e); | ||
267 | } | ||
268 | //MochiKit.Logging.logDebug("<<< DirectLoginComponent.render"); | ||
269 | }, | ||
270 | |||
271 | //------------------------------------------------------------------------- | ||
272 | |||
273 | 'collapser': function() { | ||
274 | return this._collapser; | ||
275 | }, | ||
276 | |||
277 | //------------------------------------------------------------------------- | ||
278 | |||
279 | 'handleLoadedFaviconImage': function(anEvent) { | ||
280 | MochiKit.Signal.disconnectAll(anEvent.src()) | ||
281 | }, | ||
282 | |||
283 | //------------------------------------------------------------------------- | ||
284 | |||
285 | 'update': function() { | ||
286 | var i,c; | ||
287 | var bindingComponents; | ||
288 | |||
289 | //MochiKit.Logging.logDebug(">>> DirectLoginComponent.update"); | ||
290 | bindingComponents = this.directLoginBindingComponents(); | ||
291 | c = bindingComponents.length; | ||
292 | for (i=0; i<c; i++) { | ||
293 | bindingComponents[i].update(); | ||
294 | } | ||
295 | |||
296 | Clipperz.PM.Components.RecordDetail.DirectLoginComponent.superclass.update.call(this); | ||
297 | //MochiKit.Logging.logDebug("<<< DirectLoginComponent.update"); | ||
298 | }, | ||
299 | |||
300 | //------------------------------------------------------------------------- | ||
301 | |||
302 | 'updateEditMode': function() { | ||
303 | // this.element().update(""); | ||
304 | // Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', style:'border:4px solid red; padding:10px;', children:[ | ||
305 | // {tag:'div', style:'font-weight:bold;', html:this.directLogin().label()}, | ||
306 | // {tag:'div', style:'border:1px solid #aaaaaa;', html:Clipperz.Base.serializeJSON(this.directLogin().formData())}, | ||
307 | // {tag:'div', style:'border:1px solid #aaaaaa;', html:Clipperz.Base.serializeJSON(this.directLogin().bindings())} | ||
308 | // ]}); | ||
309 | |||
310 | this.getElement('titleEditBox').show(); | ||
311 | this.getElement('titleViewBox').hide(); | ||
312 | |||
313 | this.getDom('titleInput').value = this.directLogin().label(); | ||
314 | |||
315 | //MochiKit.Logging.logDebug(">>> DirectLoginComponent.updateEditMode"); | ||
316 | this.collapser().expand(); | ||
317 | this.getElement('collapseLink').hide(); | ||
318 | this.getElement('removeDirectLogin').show(); | ||
319 | // this.removeButton().show(); | ||
320 | //MochiKit.Logging.logDebug("<<< DirectLoginComponent.updateEditMode"); | ||
321 | }, | ||
322 | |||
323 | //------------------------------------------------------------------------- | ||
324 | |||
325 | 'updateViewMode': function() { | ||
326 | //MochiKit.Logging.logDebug(">>> DirectLoginComponent.updateViewMode"); | ||
327 | this.getElement('titleEditBox').hide(); | ||
328 | this.getElement('titleViewBox').show(); | ||
329 | this.getElement('titleLink').update(this.directLogin().label()); | ||
330 | |||
331 | this.getElement('collapseLink').show(); | ||
332 | this.getElement('removeDirectLogin').hide(); | ||
333 | // this.removeButton().hide(); | ||
334 | //MochiKit.Logging.logDebug("<<< DirectLoginComponent.updateViewMode"); | ||
335 | }, | ||
336 | |||
337 | //------------------------------------------------------------------------- | ||
338 | |||
339 | 'synchronizeComponentValues': function() { | ||
340 | //MochiKit.Logging.logDebug(">>> DirectLoginComponent.syncronizeComponentValues"); | ||
341 | this.directLogin().setLabel(this.getDom('titleInput').value); | ||
342 | // this.setFormDataValue(this.structureElement().value()); | ||
343 | |||
344 | MochiKit.Iter.forEach(this.directLoginBindingComponents(), MochiKit.Base.methodcaller('synchronizeComponentValues')); | ||
345 | //MochiKit.Logging.logDebug("<<< DirectLoginComponent.syncronizeComponentValues"); | ||
346 | }, | ||
347 | |||
348 | //------------------------------------------------------------------------- | ||
349 | |||
350 | 'runDirectLogin': function(anEvent) { | ||
351 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.runDirectLogin - 1"); | ||
352 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.runDirectLogin - 1 anEvent: " + anEvent); | ||
353 | anEvent.stop(); | ||
354 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.runDirectLogin - 2"); | ||
355 | this.directLogin().runDirectLogin(); | ||
356 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.runDirectLogin - 3"); | ||
357 | }, | ||
358 | |||
359 | //------------------------------------------------------------------------- | ||
360 | __syntaxFix__: "syntax fix" | ||
361 | }); | ||
362 | |||