Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js index b9d7adf..58b7593 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js | |||
@@ -1,416 +1,410 @@ | |||
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.Common.Components'); | 24 | Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); |
27 | 25 | ||
28 | //############################################################################# | 26 | //############################################################################# |
29 | 27 | ||
30 | var _Clipperz_PM_Components_base_id_ = 0; | 28 | var _Clipperz_PM_Components_base_id_ = 0; |
31 | 29 | ||
32 | //############################################################################# | 30 | //############################################################################# |
33 | 31 | ||
34 | Clipperz.PM.UI.Common.Components.BaseComponent = function(args) { | 32 | Clipperz.PM.UI.Common.Components.BaseComponent = function(args) { |
35 | args = args || {}; | 33 | args = args || {}; |
36 | Clipperz.PM.UI.Common.Components.BaseComponent.superclass.constructor.call(this, args); | 34 | Clipperz.PM.UI.Common.Components.BaseComponent.superclass.constructor.call(this, args); |
37 | 35 | ||
38 | this._element = args.element || null; | 36 | this._element = args.element || null; |
39 | this._ids = {}; | 37 | this._ids = {}; |
40 | 38 | ||
41 | this._slots = {}; | 39 | this._slots = {}; |
42 | this._slotComponents = {}; | 40 | this._slotComponents = {}; |
43 | 41 | ||
44 | this._components = {}; | 42 | this._components = {}; |
45 | 43 | ||
46 | this._cachedSlots = {}; | 44 | this._cachedSlots = {}; |
47 | 45 | ||
48 | this._isModal = false; | 46 | this._isModal = false; |
49 | 47 | ||
50 | this._isActive = false; | 48 | this._isActive = false; |
51 | this._elementUsedToEnterModalState; | 49 | this._elementUsedToEnterModalState; |
52 | 50 | ||
53 | this._isFullyRendered = false; | 51 | this._isFullyRendered = false; |
54 | this._renderingWaitingQueue = []; | 52 | this._renderingWaitingQueue = []; |
55 | 53 | ||
56 | //this._slots = { | 54 | //this._slots = { |
57 | // 'header':'header', | 55 | // 'header':'header', |
58 | // 'body': 'body', | 56 | // 'body': 'body', |
59 | // 'footer':'footer' | 57 | // 'footer':'footer' |
60 | //}; | 58 | //}; |
61 | 59 | ||
62 | return this; | 60 | return this; |
63 | } | 61 | } |
64 | 62 | ||
65 | //============================================================================= | 63 | //============================================================================= |
66 | 64 | ||
67 | //TODO get back to MochiKit.Base.update as we are not extending anything | 65 | //TODO get back to MochiKit.Base.update as we are not extending anything |
68 | //MochiKit.Base.update(Clipperz.PM.UI.Common.Components.BaseComponent.prototype, { | 66 | //MochiKit.Base.update(Clipperz.PM.UI.Common.Components.BaseComponent.prototype, { |
69 | Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.BaseComponent, /*Ext.Component*/ Object, { | 67 | Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.BaseComponent, /*Ext.Component*/ Object, { |
70 | 68 | ||
71 | 'isClipperzPMComponent': true, | 69 | 'isClipperzPMComponent': true, |
72 | 70 | ||
73 | //------------------------------------------------------------------------- | 71 | //------------------------------------------------------------------------- |
74 | 72 | ||
75 | 'toString': function () { | 73 | 'toString': function () { |
76 | return "Clipperz.PM.UI.Common.Components.BaseComponent component"; | 74 | return "Clipperz.PM.UI.Common.Components.BaseComponent component"; |
77 | }, | 75 | }, |
78 | 76 | ||
79 | 'componentId': function () { | 77 | 'componentId': function () { |
80 | return this.getId('_id_'); | 78 | return this.getId('_id_'); |
81 | }, | 79 | }, |
82 | 80 | ||
83 | //------------------------------------------------------------------------- | 81 | //------------------------------------------------------------------------- |
84 | /* | 82 | /* |
85 | 'slots': function() { | 83 | 'slots': function() { |
86 | return this._slots; | 84 | return this._slots; |
87 | }, | 85 | }, |
88 | */ | 86 | */ |
89 | 'slotComponents': function() { | 87 | 'slotComponents': function() { |
90 | return this._slotComponents; | 88 | return this._slotComponents; |
91 | }, | 89 | }, |
92 | 90 | ||
93 | //------------------------------------------------------------------------- | 91 | //------------------------------------------------------------------------- |
94 | 92 | ||
95 | 'components': function () { | 93 | 'components': function () { |
96 | return this._components; | 94 | return this._components; |
97 | }, | 95 | }, |
98 | 96 | ||
99 | 'addComponent': function (aComponent) { | 97 | 'addComponent': function (aComponent) { |
100 | this.components()[aComponent.componentId()] = aComponent; | 98 | this.components()[aComponent.componentId()] = aComponent; |
101 | }, | 99 | }, |
102 | 100 | ||
103 | 'removeComponent': function (aComponent) { | 101 | 'removeComponent': function (aComponent) { |
104 | var componentId; | 102 | var componentId; |
105 | 103 | ||
106 | componentId = aComponent.componentId(); | 104 | componentId = aComponent.componentId(); |
107 | this.components()[componentId].remove(); | 105 | this.components()[componentId].remove(); |
108 | delete this.components()[componentId]; | 106 | delete this.components()[componentId]; |
109 | }, | 107 | }, |
110 | 108 | ||
111 | //------------------------------------------------------------------------- | 109 | //------------------------------------------------------------------------- |
112 | /* | 110 | /* |
113 | 'domHelper': function() { | 111 | 'domHelper': function() { |
114 | return Clipperz.YUI.DomHelper; | 112 | return Clipperz.YUI.DomHelper; |
115 | }, | 113 | }, |
116 | */ | 114 | */ |
117 | //------------------------------------------------------------------------- | 115 | //------------------------------------------------------------------------- |
118 | /* | 116 | /* |
119 | 'domHelperAppend': function(aValue) { | 117 | 'domHelperAppend': function(aValue) { |
120 | Clipperz.YUI.DomHelper.append(this.element().dom, aValue); | 118 | Clipperz.YUI.DomHelper.append(this.element().dom, aValue); |
121 | }, | 119 | }, |
122 | */ | 120 | */ |
123 | //------------------------------------------------------------------------- | 121 | //------------------------------------------------------------------------- |
124 | 122 | ||
125 | 'element': function() { | 123 | 'element': function() { |
126 | //MochiKit.Logging.logDebug(">>> BaseComponent.element"); | ||
127 | return MochiKit.DOM.getElement(this._element); | 124 | return MochiKit.DOM.getElement(this._element); |
128 | }, | 125 | }, |
129 | 126 | ||
130 | 'setElement': function(aNode) { | 127 | 'setElement': function(aNode) { |
131 | this._element = aNode; | 128 | this._element = aNode; |
132 | }, | 129 | }, |
133 | 130 | ||
134 | //----------------------------------------------------- | 131 | //----------------------------------------------------- |
135 | 132 | ||
136 | 'displayElement': function() { | 133 | 'displayElement': function() { |
137 | return this.element(); | 134 | return this.element(); |
138 | }, | 135 | }, |
139 | 136 | ||
140 | //------------------------------------------------------------------------- | 137 | //------------------------------------------------------------------------- |
141 | 138 | ||
142 | 'renderInNode': function(aDomNode) { | 139 | 'renderInNode': function(aDomNode) { |
143 | this.setElement(aDomNode); | 140 | this.setElement(aDomNode); |
144 | this.render(); | 141 | this.render(); |
145 | }, | 142 | }, |
146 | 143 | ||
147 | 'render': function() { | 144 | 'render': function() { |
148 | this.clear(); | 145 | this.clear(); |
149 | this.renderSelf(); | 146 | this.renderSelf(); |
150 | this.renderComponents(); | 147 | this.renderComponents(); |
151 | if (this.shouldShowTranslationHints()) { | 148 | if (this.shouldShowTranslationHints()) { |
152 | this.renderTranslationHints(); | 149 | this.renderTranslationHints(); |
153 | } | 150 | } |
154 | if (this.shouldShowElementWhileRendering()) { | 151 | if (this.shouldShowElementWhileRendering()) { |
155 | MochiKit.Style.showElement(this.displayElement()); | 152 | MochiKit.Style.showElement(this.displayElement()); |
156 | }; | 153 | }; |
157 | 154 | ||
158 | this._isFullyRendered = true; | 155 | this._isFullyRendered = true; |
159 | 156 | ||
160 | MochiKit.Iter.forEach(this.renderingWaitingQueue(), MochiKit.Base.methodcaller('callback')); | 157 | MochiKit.Iter.forEach(this.renderingWaitingQueue(), MochiKit.Base.methodcaller('callback')); |
161 | this.resetRenderingWaitingQueue(); | 158 | this.resetRenderingWaitingQueue(); |
162 | }, | 159 | }, |
163 | 160 | ||
164 | 'renderSelf': function() { | 161 | 'renderSelf': function() { |
165 | throw Clipperz.Base.exception.AbstractMethod; | 162 | throw Clipperz.Base.exception.AbstractMethod; |
166 | }, | 163 | }, |
167 | 164 | ||
168 | 'renderComponents': function() { | 165 | 'renderComponents': function() { |
169 | varslotName; | 166 | varslotName; |
170 | 167 | ||
171 | for (slotName in this.slotComponents()) { | 168 | for (slotName in this.slotComponents()) { |
172 | this.slotComponents()[slotName].renderInNode(this.elementForSlotNamed(slotName)); | 169 | this.slotComponents()[slotName].renderInNode(this.elementForSlotNamed(slotName)); |
173 | } | 170 | } |
174 | }, | 171 | }, |
175 | 172 | ||
176 | //......................................................................... | 173 | //......................................................................... |
177 | 174 | ||
178 | 'isFullyRendered': function () { | 175 | 'isFullyRendered': function () { |
179 | return this._isFullyRendered; | 176 | return this._isFullyRendered; |
180 | }, | 177 | }, |
181 | 178 | ||
182 | //......................................................................... | 179 | //......................................................................... |
183 | 180 | ||
184 | 'renderingWaitingQueue': function () { | 181 | 'renderingWaitingQueue': function () { |
185 | return this._renderingWaitingQueue; | 182 | return this._renderingWaitingQueue; |
186 | }, | 183 | }, |
187 | 184 | ||
188 | 'resetRenderingWaitingQueue': function () { | 185 | 'resetRenderingWaitingQueue': function () { |
189 | this._renderingWaitingQueue = []; | 186 | this._renderingWaitingQueue = []; |
190 | }, | 187 | }, |
191 | 188 | ||
192 | //......................................................................... | 189 | //......................................................................... |
193 | 190 | ||
194 | 'waitUntilFullyRendered': function () { | 191 | 'waitUntilFullyRendered': function () { |
195 | var deferredResult; | 192 | var deferredResult; |
196 | 193 | ||
197 | if (this.isFullyRendered() == true) { | 194 | if (this.isFullyRendered() == true) { |
198 | deferredResult = MochiKit.Async.succeed | 195 | deferredResult = MochiKit.Async.succeed |
199 | } else { | 196 | } else { |
200 | deferredResult = new Clipperz.Async.Deferred("BaseComponent.waitUntilFullyRendered", {trace:false}); | 197 | deferredResult = new Clipperz.Async.Deferred("BaseComponent.waitUntilFullyRendered", {trace:false}); |
201 | this.renderingWaitingQueue().push(deferredResult); | 198 | this.renderingWaitingQueue().push(deferredResult); |
202 | } | 199 | } |
203 | 200 | ||
204 | return deferredResult; | 201 | return deferredResult; |
205 | }, | 202 | }, |
206 | 203 | ||
207 | //----------------------------------------------------- | 204 | //----------------------------------------------------- |
208 | 205 | ||
209 | 'renderTranslationHints': function () { | 206 | 'renderTranslationHints': function () { |
210 | vartranslatableItems; | 207 | vartranslatableItems; |
211 | 208 | ||
212 | translatableItems = MochiKit.Selector.findChildElements(this.displayElement(), ['[stringID]']); | 209 | translatableItems = MochiKit.Selector.findChildElements(this.displayElement(), ['[stringID]']); |
213 | MochiKit.Iter.forEach(translatableItems, MochiKit.Base.method(this, 'enhanceTranslatableElement')) | 210 | MochiKit.Iter.forEach(translatableItems, MochiKit.Base.method(this, 'enhanceTranslatableElement')) |
214 | }, | 211 | }, |
215 | 212 | ||
216 | 'enhanceTranslatableElement': function (anElement) { | 213 | 'enhanceTranslatableElement': function (anElement) { |
217 | //Clipperz.log(">>> enhanceTranslatableElement", anElement); | 214 | //Clipperz.log(">>> enhanceTranslatableElement", anElement); |
218 | // new Clipperz.PM.UI.Common.Components.TranslatorWidget({ | 215 | // new Clipperz.PM.UI.Common.Components.TranslatorWidget({ |
219 | // 'element':anElement | 216 | // 'element':anElement |
220 | // }); | 217 | // }); |
221 | 218 | ||
222 | MochiKit.Signal.connect(anElement, 'onmouseenter', MochiKit.Base.partial(Clipperz.PM.UI.Common.Components.TranslatorWidget.show, anElement, MochiKit.DOM.getNodeAttribute(anElement, 'stringID'))); | 219 | MochiKit.Signal.connect(anElement, 'onmouseenter', MochiKit.Base.partial(Clipperz.PM.UI.Common.Components.TranslatorWidget.show, anElement, MochiKit.DOM.getNodeAttribute(anElement, 'stringID'))); |
223 | MochiKit.Signal.connect(anElement, 'onmouseleave', Clipperz.PM.UI.Common.Components.TranslatorWidget.hide); | 220 | MochiKit.Signal.connect(anElement, 'onmouseleave', Clipperz.PM.UI.Common.Components.TranslatorWidget.hide); |
224 | //Clipperz.log("<<< enhanceTranslatableElement"); | 221 | //Clipperz.log("<<< enhanceTranslatableElement"); |
225 | }, | 222 | }, |
226 | 223 | ||
227 | //----------------------------------------------------- | 224 | //----------------------------------------------------- |
228 | 225 | ||
229 | 'update': function(args) { | 226 | 'update': function(args) { |
230 | throw Clipperz.Base.exception.AbstractMethod; | 227 | throw Clipperz.Base.exception.AbstractMethod; |
231 | }, | 228 | }, |
232 | 229 | ||
233 | 'updateSelf': function(args) { | 230 | 'updateSelf': function(args) { |
234 | throw Clipperz.Base.exception.AbstractMethod; | 231 | throw Clipperz.Base.exception.AbstractMethod; |
235 | }, | 232 | }, |
236 | 233 | ||
237 | 'updateComponents': function(args) { | 234 | 'updateComponents': function(args) { |
238 | throw Clipperz.Base.exception.AbstractMethod; | 235 | throw Clipperz.Base.exception.AbstractMethod; |
239 | }, | 236 | }, |
240 | 237 | ||
241 | //----------------------------------------------------- | 238 | //----------------------------------------------------- |
242 | 239 | ||
243 | 'refresh': function() { | 240 | 'refresh': function() { |
244 | throw Clipperz.Base.exception.AbstractMethod; | 241 | throw Clipperz.Base.exception.AbstractMethod; |
245 | }, | 242 | }, |
246 | 243 | ||
247 | 'refreshSelf': function() { | 244 | 'refreshSelf': function() { |
248 | throw Clipperz.Base.exception.AbstractMethod; | 245 | throw Clipperz.Base.exception.AbstractMethod; |
249 | }, | 246 | }, |
250 | 247 | ||
251 | 'refreshComponents': function(args) { | 248 | 'refreshComponents': function(args) { |
252 | throw Clipperz.Base.exception.AbstractMethod; | 249 | throw Clipperz.Base.exception.AbstractMethod; |
253 | }, | 250 | }, |
254 | 251 | ||
255 | //----------------------------------------------------- | 252 | //----------------------------------------------------- |
256 | 253 | ||
257 | 'checkSlotNamed': function(aSlotName) { | 254 | 'checkSlotNamed': function(aSlotName) { |
258 | if (typeof(this._slots[aSlotName]) == 'undefined') { | 255 | if (typeof(this._slots[aSlotName]) == 'undefined') { |
259 | throw new Error("undefined slot"); | 256 | throw new Error("undefined slot"); |
260 | }; | 257 | }; |
261 | }, | 258 | }, |
262 | 259 | ||
263 | //----------------------------------------------------- | 260 | //----------------------------------------------------- |
264 | 261 | ||
265 | 'cachedSlots': function() { | 262 | 'cachedSlots': function() { |
266 | return this._cachedSlots; | 263 | return this._cachedSlots; |
267 | }, | 264 | }, |
268 | 265 | ||
269 | 'slotNamed': function(aSlotName) { | 266 | 'slotNamed': function(aSlotName) { |
270 | var result; | 267 | var result; |
271 | 268 | ||
272 | this.checkSlotNamed(aSlotName); | 269 | this.checkSlotNamed(aSlotName); |
273 | if (typeof(this.cachedSlots()[aSlotName]) == 'undefined') { | 270 | if (typeof(this.cachedSlots()[aSlotName]) == 'undefined') { |
274 | this.cachedSlots()[aSlotName] = new Clipperz.PM.UI.Common.Components.ComponentSlot(this,aSlotName); | 271 | this.cachedSlots()[aSlotName] = new Clipperz.PM.UI.Common.Components.ComponentSlot(this,aSlotName); |
275 | } | 272 | } |
276 | 273 | ||
277 | result = this.cachedSlots()[aSlotName]; | 274 | result = this.cachedSlots()[aSlotName]; |
278 | 275 | ||
279 | return result; | 276 | return result; |
280 | }, | 277 | }, |
281 | 278 | ||
282 | //----------------------------------------------------- | 279 | //----------------------------------------------------- |
283 | 280 | ||
284 | 'elementForSlotNamed': function(aSlotName) { | 281 | 'elementForSlotNamed': function(aSlotName) { |
285 | return MochiKit.DOM.getElement(this._slots[aSlotName]); | 282 | return MochiKit.DOM.getElement(this._slots[aSlotName]); |
286 | }, | 283 | }, |
287 | 284 | ||
288 | //----------------------------------------------------- | 285 | //----------------------------------------------------- |
289 | 286 | ||
290 | 'componentForSlotNamed': function(aSlotName) { | 287 | 'componentForSlotNamed': function(aSlotName) { |
291 | return this.slotComponents()[aSlotName]; | 288 | return this.slotComponents()[aSlotName]; |
292 | }, | 289 | }, |
293 | 290 | ||
294 | 'setComponentForSlotNamed': function(aComponent, aSlotName) { | 291 | 'setComponentForSlotNamed': function(aComponent, aSlotName) { |
295 | var domNode; | 292 | var domNode; |
296 | 293 | ||
297 | this.checkSlotNamed(aSlotName); | 294 | this.checkSlotNamed(aSlotName); |
298 | 295 | ||
299 | if (this.slotComponents()[aSlotName] != null) { | 296 | if (this.slotComponents()[aSlotName] != null) { |
300 | this.slotComponents()[aSlotName].remove(); | 297 | this.slotComponents()[aSlotName].remove(); |
301 | } | 298 | } |
302 | 299 | ||
303 | this.slotComponents()[aSlotName] = aComponent; | 300 | this.slotComponents()[aSlotName] = aComponent; |
304 | 301 | ||
305 | // domNode = MochiKit.DOM.getElement(this.slotNamed(aSlotName)); | 302 | // domNode = MochiKit.DOM.getElement(this.slotNamed(aSlotName)); |
306 | domNode = this.elementForSlotNamed(aSlotName); | 303 | domNode = this.elementForSlotNamed(aSlotName); |
307 | 304 | ||
308 | if (domNode != null) { | 305 | if (domNode != null) { |
309 | aComponent.renderInNode(domNode); | 306 | aComponent.renderInNode(domNode); |
310 | } | 307 | } |
311 | }, | 308 | }, |
312 | 309 | ||
313 | //----------------------------------------------------- | 310 | //----------------------------------------------------- |
314 | /* | 311 | /* |
315 | 'purgeListeners': function() { | 312 | 'purgeListeners': function() { |
316 | //MochiKit.Logging.logDebug(">>> Clipperz.PM.UI.Common.Components.BaseComponent.purgeListeners [" + this + "]"); | ||
317 | //MochiKit.Logging.logDebug("--- " + this + ".purgeListeners"); | ||
318 | Clipperz.NotificationCenter.unregister(this); | 313 | Clipperz.NotificationCenter.unregister(this); |
319 | MochiKit.Signal.disconnectAllTo(this); | 314 | MochiKit.Signal.disconnectAllTo(this); |
320 | //MochiKit.Logging.logDebug("<<< Clipperz.PM.UI.Common.Components.BaseComponent.purgeListeners"); | ||
321 | }, | 315 | }, |
322 | */ | 316 | */ |
323 | //----------------------------------------------------- | 317 | //----------------------------------------------------- |
324 | 318 | ||
325 | 'clear': function() { | 319 | 'clear': function() { |
326 | varslotName; | 320 | varslotName; |
327 | var componentId; | 321 | var componentId; |
328 | 322 | ||
329 | MochiKit.Signal.disconnectAllTo(this); | 323 | MochiKit.Signal.disconnectAllTo(this); |
330 | 324 | ||
331 | for (slotName in this.slotComponents()) { | 325 | for (slotName in this.slotComponents()) { |
332 | this.slotComponents()[slotName].clear(); | 326 | this.slotComponents()[slotName].clear(); |
333 | } | 327 | } |
334 | 328 | ||
335 | for (componentId in this.components()) { | 329 | for (componentId in this.components()) { |
336 | this.components()[componentId].clear(); | 330 | this.components()[componentId].clear(); |
337 | } | 331 | } |
338 | 332 | ||
339 | // if (this.element() != null) { | 333 | // if (this.element() != null) { |
340 | // this.element().innerHTML = ""; | 334 | // this.element().innerHTML = ""; |
341 | // } | 335 | // } |
342 | 336 | ||
343 | if (this.displayElement() != null) { | 337 | if (this.displayElement() != null) { |
344 | if (this.element() != this.displayElement()) { | 338 | if (this.element() != this.displayElement()) { |
345 | MochiKit.DOM.removeElement(this.displayElement()); | 339 | MochiKit.DOM.removeElement(this.displayElement()); |
346 | } else { | 340 | } else { |
347 | this.displayElement().innerHTML = ""; | 341 | this.displayElement().innerHTML = ""; |
348 | } | 342 | } |
349 | } | 343 | } |
350 | 344 | ||
351 | if (this.isModal()) { | 345 | if (this.isModal()) { |
352 | //TODO: cleanup when the closed element was shown modally. | 346 | //TODO: cleanup when the closed element was shown modally. |
353 | } | 347 | } |
354 | }, | 348 | }, |
355 | 349 | ||
356 | 350 | ||
357 | 'remove': function() { | 351 | 'remove': function() { |
358 | varslotName; | 352 | varslotName; |
359 | var componentId; | 353 | var componentId; |
360 | 354 | ||
361 | for (slotName in this.slotComponents()) { | 355 | for (slotName in this.slotComponents()) { |
362 | this.slotComponents()[slotName].remove(); | 356 | this.slotComponents()[slotName].remove(); |
363 | delete this.slotComponents()[slotName]; | 357 | delete this.slotComponents()[slotName]; |
364 | } | 358 | } |
365 | 359 | ||
366 | for (componentId in this.components()) { | 360 | for (componentId in this.components()) { |
367 | this.components()[componentId].remove(); | 361 | this.components()[componentId].remove(); |
368 | delete this.components()[componentId]; | 362 | delete this.components()[componentId]; |
369 | } | 363 | } |
370 | 364 | ||
371 | this.clear(); | 365 | this.clear(); |
372 | MochiKit.Signal.disconnectAll(this); | 366 | MochiKit.Signal.disconnectAll(this); |
373 | }, | 367 | }, |
374 | 368 | ||
375 | 'append': function(aNode, aValue) { | 369 | 'append': function(aNode, aValue) { |
376 | return Clipperz.DOM.Helper.append(aNode, aValue); | 370 | return Clipperz.DOM.Helper.append(aNode, aValue); |
377 | }, | 371 | }, |
378 | 372 | ||
379 | 'insertBefore': function (aNode, aValue) { | 373 | 'insertBefore': function (aNode, aValue) { |
380 | return Clipperz.DOM.Helper.insertBefore(aNode, aValue); | 374 | return Clipperz.DOM.Helper.insertBefore(aNode, aValue); |
381 | }, | 375 | }, |
382 | 376 | ||
383 | 'insertAfter': function (aNode, aValue) { | 377 | 'insertAfter': function (aNode, aValue) { |
384 | return Clipperz.DOM.Helper.insertAfter(aNode, aValue); | 378 | return Clipperz.DOM.Helper.insertAfter(aNode, aValue); |
385 | }, | 379 | }, |
386 | 380 | ||
387 | //------------------------------------------------------------------------- | 381 | //------------------------------------------------------------------------- |
388 | 382 | ||
389 | 'getId': function(aValue) { | 383 | 'getId': function(aValue) { |
390 | varresult; | 384 | varresult; |
391 | 385 | ||
392 | if (typeof(aValue) != 'undefined') { | 386 | if (typeof(aValue) != 'undefined') { |
393 | result = this._ids[aValue]; | 387 | result = this._ids[aValue]; |
394 | 388 | ||
395 | if (typeof(result) == 'undefined') { | 389 | if (typeof(result) == 'undefined') { |
396 | _Clipperz_PM_Components_base_id_ ++; | 390 | _Clipperz_PM_Components_base_id_ ++; |
397 | 391 | ||
398 | result = "Clipperz_PM_Components_" + aValue + "_" + _Clipperz_PM_Components_base_id_; | 392 | result = "Clipperz_PM_Components_" + aValue + "_" + _Clipperz_PM_Components_base_id_; |
399 | this._ids[aValue] = result; | 393 | this._ids[aValue] = result; |
400 | } | 394 | } |
401 | } else { | 395 | } else { |
402 | // result = Clipperz.PM.UI.Common.Components.BaseComponent.superclass.getId.call(this); | 396 | // result = Clipperz.PM.UI.Common.Components.BaseComponent.superclass.getId.call(this); |
403 | throw "call to BaseComponent.getId with an undefined value"; | 397 | throw "call to BaseComponent.getId with an undefined value"; |
404 | } | 398 | } |
405 | 399 | ||
406 | return result; | 400 | return result; |
407 | }, | 401 | }, |
408 | 402 | ||
409 | 'getAnchor': function (aValue) { | 403 | 'getAnchor': function (aValue) { |
410 | return '#' + this.getId(aValue); | 404 | return '#' + this.getId(aValue); |
411 | }, | 405 | }, |
412 | 406 | ||
413 | //------------------------------------------------------------------------- | 407 | //------------------------------------------------------------------------- |
414 | 408 | ||
415 | 'getElement': function(aValue) { | 409 | 'getElement': function(aValue) { |
416 | return Clipperz.DOM.get(this.getId(aValue)); | 410 | return Clipperz.DOM.get(this.getId(aValue)); |