Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js | 174 |
1 files changed, 174 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js new file mode 100644 index 0000000..6171a4e --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js | |||
@@ -0,0 +1,174 @@ | |||
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.DirectLoginBindingComponent = function(anElement, args) { | ||
37 | //MochiKit.Logging.logDebug(">>> new DirectLoginBindingComponent"); | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent.superclass.constructor.call(this, anElement, args); | ||
41 | |||
42 | this._directLoginBinding = args.directLoginBinding || null; | ||
43 | this.render(); | ||
44 | |||
45 | Clipperz.NotificationCenter.register(this.record(), 'addNewRecordField',this, 'syncAndUpdateEditMode'); | ||
46 | Clipperz.NotificationCenter.register(this.record(), 'removedField', this, 'syncAndUpdateEditMode'); | ||
47 | Clipperz.NotificationCenter.register(this.record(), 'updatedFieldLabel',this, 'syncAndUpdateEditMode'); | ||
48 | //MochiKit.Logging.logDebug("<<< new DirectLoginBindingComponent"); | ||
49 | |||
50 | return this; | ||
51 | } | ||
52 | |||
53 | //============================================================================= | ||
54 | |||
55 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, { | ||
56 | |||
57 | 'toString': function() { | ||
58 | return "Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent component"; | ||
59 | }, | ||
60 | |||
61 | //------------------------------------------------------------------------- | ||
62 | |||
63 | 'directLoginBinding': function() { | ||
64 | return this._directLoginBinding; | ||
65 | }, | ||
66 | |||
67 | //------------------------------------------------------------------------- | ||
68 | |||
69 | 'render': function() { | ||
70 | // Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'span', style:'font-weight:bold;', html:this.directLoginBinding().key()}) | ||
71 | // Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'span', html:this.directLoginBinding().value()}) | ||
72 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.render"); | ||
73 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', cls:'directLoginBindingLabelTD', children:[ | ||
74 | {tag:'span', html:this.directLoginBinding().key()} | ||
75 | ]}); | ||
76 | //MochiKit.Logging.logDebug("--- DirectLoginBindingComponent.render - 1"); | ||
77 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', cls:'directLoginBindingValueTD', children:[ | ||
78 | {tag:'div', id:this.getId('editModeBox'), children:[ | ||
79 | {tag:'select', id:this.getId('select'), children:this.recordFieldOptions()} | ||
80 | ]}, | ||
81 | {tag:'div', id:this.getId('viewModeBox'), children:[ | ||
82 | {tag:'span', id:this.getId('viewValue'), html:""} | ||
83 | ]} | ||
84 | ]}); | ||
85 | //MochiKit.Logging.logDebug("--- DirectLoginBindingComponent.render - 2"); | ||
86 | this.getElement('editModeBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
87 | this.getElement('viewModeBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
88 | |||
89 | this.update(); | ||
90 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.render"); | ||
91 | }, | ||
92 | |||
93 | //------------------------------------------------------------------------- | ||
94 | |||
95 | 'recordFieldOptions': function() { | ||
96 | varresult; | ||
97 | var option; | ||
98 | varrecordFieldKey; | ||
99 | varrecordFields; | ||
100 | |||
101 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.recordFieldOptions"); | ||
102 | recordFields = this.directLoginBinding().directLogin().record().currentVersion().fields(); | ||
103 | result = []; | ||
104 | option = {tag:'option', value:null, html:'---'}; | ||
105 | result.push(option); | ||
106 | for (recordFieldKey in recordFields) { | ||
107 | //TODO: remove the value: field and replace it with element.dom.value = <some value> | ||
108 | option = {tag:'option', value:recordFieldKey, html:recordFields[recordFieldKey].label()} | ||
109 | if (recordFieldKey == this.directLoginBinding().fieldKey()) { | ||
110 | option['selected'] = true; | ||
111 | } | ||
112 | result.push(option); | ||
113 | } | ||
114 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.recordFieldOptions"); | ||
115 | |||
116 | return result; | ||
117 | }, | ||
118 | |||
119 | //------------------------------------------------------------------------- | ||
120 | |||
121 | 'syncAndUpdateEditMode': function() { | ||
122 | this.synchronizeComponentValues(); | ||
123 | this.updateEditMode(); | ||
124 | }, | ||
125 | |||
126 | 'updateEditMode': function() { | ||
127 | varselectElementBox; | ||
128 | |||
129 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.updateEditMode"); | ||
130 | this.getElement('viewModeBox').hide(); | ||
131 | |||
132 | selectElementBox = this.getElement('editModeBox'); | ||
133 | selectElementBox.update(""); | ||
134 | |||
135 | Clipperz.YUI.DomHelper.append(selectElementBox.dom, {tag:'select', id:this.getId('select'), children:this.recordFieldOptions()}); | ||
136 | |||
137 | /* | ||
138 | selectElement = this.getElement('select'); | ||
139 | |||
140 | selectElement.update(""); | ||
141 | MochiKit.Iter.forEach(this.recordFieldOptions(), function(anOption) { | ||
142 | Clipperz.YUI.DomHelper.append(selectElement.dom, anOption); | ||
143 | }); | ||
144 | */ | ||
145 | |||
146 | |||
147 | this.getElement('editModeBox').show(); | ||
148 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.updateEditMode"); | ||
149 | }, | ||
150 | |||
151 | //------------------------------------------------------------------------- | ||
152 | |||
153 | 'updateViewMode': function() { | ||
154 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.updateViewMode"); | ||
155 | this.getElement('editModeBox').hide(); | ||
156 | this.getElement('viewModeBox').show(); | ||
157 | |||
158 | this.getElement('viewValue').update(this.directLoginBinding().field().label()); | ||
159 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.updateViewMode"); | ||
160 | }, | ||
161 | |||
162 | //------------------------------------------------------------------------- | ||
163 | |||
164 | 'synchronizeComponentValues': function() { | ||
165 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.synchronizeComponentValues") | ||
166 | //MochiKit.Logging.logDebug("--- DirectLoginBindingComponent.synchronizeComponentValues - 1 - " + this.getId('select')); | ||
167 | this.directLoginBinding().setFieldKey(this.getDom('select').value); | ||
168 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.synchronizeComponentValues"); | ||
169 | }, | ||
170 | |||
171 | //------------------------------------------------------------------------- | ||
172 | __syntaxFix__: "syntax fix" | ||
173 | }); | ||
174 | |||