Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldComponent.js | 189 |
1 files changed, 189 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldComponent.js new file mode 100644 index 0000000..c2d947e --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldComponent.js | |||
@@ -0,0 +1,189 @@ | |||
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.FieldComponent = function(anElement, args) { | ||
37 | //MochiKit.Logging.logDebug(">>> new FieldComponent"); | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.RecordDetail.FieldComponent.superclass.constructor.call(this, anElement, args); | ||
41 | |||
42 | this._element = anElement; | ||
43 | this._recordField = args.recordField || null; | ||
44 | |||
45 | this._buttonComponent = null; | ||
46 | this._labelComponent = null; | ||
47 | this._dragHandler = null; | ||
48 | this._valueComponent = null; | ||
49 | this._typeComponent = null; | ||
50 | |||
51 | this.mainComponent().addEditComponent(this); | ||
52 | |||
53 | this.render(); | ||
54 | |||
55 | return this; | ||
56 | } | ||
57 | |||
58 | //============================================================================= | ||
59 | |||
60 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.FieldComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, { | ||
61 | |||
62 | 'toString': function() { | ||
63 | return "Clipperz.PM.Components.RecordDetail.FieldComponent component"; | ||
64 | }, | ||
65 | |||
66 | //------------------------------------------------------------------------- | ||
67 | |||
68 | 'recordField': function() { | ||
69 | return this._recordField; | ||
70 | }, | ||
71 | |||
72 | //------------------------------------------------------------------------- | ||
73 | |||
74 | 'buttonComponent': function() { | ||
75 | return this._buttonComponent; | ||
76 | }, | ||
77 | |||
78 | 'setButtonComponent': function(aValue) { | ||
79 | this._buttonComponent = aValue; | ||
80 | }, | ||
81 | |||
82 | //------------------------------------------------------------------------- | ||
83 | |||
84 | 'labelComponent': function() { | ||
85 | return this._labelComponent; | ||
86 | }, | ||
87 | |||
88 | 'setLabelComponent': function(aValue) { | ||
89 | this._labelComponent = aValue; | ||
90 | }, | ||
91 | |||
92 | //------------------------------------------------------------------------- | ||
93 | |||
94 | 'dragHandler': function() { | ||
95 | return this._dragHandler; | ||
96 | }, | ||
97 | |||
98 | 'setDragHandler': function(aValue) { | ||
99 | this._dragHandler = aValue; | ||
100 | }, | ||
101 | |||
102 | //------------------------------------------------------------------------- | ||
103 | |||
104 | 'valueComponent': function() { | ||
105 | return this._valueComponent; | ||
106 | }, | ||
107 | |||
108 | 'setValueComponent': function(aValue) { | ||
109 | this._valueComponent = aValue; | ||
110 | }, | ||
111 | |||
112 | //------------------------------------------------------------------------- | ||
113 | |||
114 | 'typeComponent': function() { | ||
115 | return this._typeComponent; | ||
116 | }, | ||
117 | |||
118 | 'setTypeComponent': function(aValue) { | ||
119 | this._typeComponent = aValue; | ||
120 | }, | ||
121 | |||
122 | //------------------------------------------------------------------------- | ||
123 | |||
124 | 'render': function() { | ||
125 | //MochiKit.Logging.logDebug(">>> RecordDetail.FieldComponent.render"); | ||
126 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td',/* width:'32',*/ height:'24', cls:'removeFieldButton', align:'left', valign:'top', id:this.getId('button')}); | ||
127 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td',/* width:'25%',*/ valign:'top', id:this.getId('label')}); | ||
128 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td',/* width:'3',*/ valign:'top', id:this.getId('dragHandler')}); | ||
129 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td',/* width:'50%',*/ valign:'top', children:[ | ||
130 | {tag:'div', cls:'Clipperz_recordFieldData', id:this.getId('value')} | ||
131 | ]}); | ||
132 | |||
133 | |||
134 | this.setButtonComponent(new Clipperz.PM.Components.RecordDetail.FieldButtonComponent(this.getElement('button'), {fieldComponent:this})); | ||
135 | this.setLabelComponent(new Clipperz.PM.Components.RecordDetail.FieldLabelComponent(this.getElement('label'), {fieldComponent:this})); | ||
136 | this.setDragHandler(new Clipperz.PM.Components.RecordDetail.FieldDragHandler(this.getElement('dragHandler'), {fieldComponent:this})); | ||
137 | this.setValueComponent(new Clipperz.PM.Components.RecordDetail.FieldValueComponent(this.getElement('value'), {fieldComponent:this})); | ||
138 | |||
139 | if (this.editMode() == 'EDIT') { | ||
140 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td',/* width:'60',*/ align:'left', cls:'fieldTypeTD', valign:'top', id:this.getId('type')}); | ||
141 | this.setTypeComponent(new Clipperz.PM.Components.RecordDetail.FieldTypeComponent(this.getElement('type'), {fieldComponent:this})); | ||
142 | } | ||
143 | |||
144 | this.update(); | ||
145 | //MochiKit.Logging.logDebug("<<< RecordDetail.FieldComponent.render"); | ||
146 | }, | ||
147 | |||
148 | //------------------------------------------------------------------------- | ||
149 | |||
150 | 'handleButtonClick': function() { | ||
151 | this.mainComponent().record().removeField(this.recordField()); | ||
152 | |||
153 | // if (this.recordField() == null) { | ||
154 | // this.mainComponent().record().addNewField(); | ||
155 | // } else { | ||
156 | // this.mainComponent().record().removeField(this.recordField()); | ||
157 | // } | ||
158 | }, | ||
159 | |||
160 | //------------------------------------------------------------------------- | ||
161 | |||
162 | 'update': function(anEvent) { | ||
163 | //MochiKit.Logging.logDebug(">>> RecordDetail.FieldComponent.update"); | ||
164 | this.buttonComponent().update(); | ||
165 | this.labelComponent().update(); | ||
166 | this.dragHandler().update(); | ||
167 | this.valueComponent().update(); | ||
168 | if (this.editMode() == 'EDIT') { | ||
169 | this.typeComponent().update(); | ||
170 | } | ||
171 | //MochiKit.Logging.logDebug("<<< RecordDetail.FieldComponent.update"); | ||
172 | }, | ||
173 | |||
174 | //------------------------------------------------------------------------- | ||
175 | |||
176 | 'synchronizeComponentValues': function() { | ||
177 | //MochiKit.Logging.logDebug(">>> FieldComponent.synchronizeComponentValues"); | ||
178 | this.labelComponent().synchronizeComponentValues(); | ||
179 | this.valueComponent().synchronizeComponentValues(); | ||
180 | if (this.editMode() == 'EDIT') { | ||
181 | this.typeComponent().synchronizeComponentValues(); | ||
182 | } | ||
183 | //MochiKit.Logging.logDebug("<<< FieldComponent.synchronizeComponentValues"); | ||
184 | }, | ||
185 | |||
186 | //------------------------------------------------------------------------- | ||
187 | __syntaxFix__: "syntax fix" | ||
188 | }); | ||
189 | |||