summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js
Unidiff
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.js26
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,70 +1,68 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2013 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz, the online password manager.
6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 6For further information about its features and functionalities please
8refer to http://www.clipperz.com. 7refer 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
26Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); 24Clipperz.Base.module('Clipperz.PM.UI.Common.Components');
27 25
28//############################################################################# 26//#############################################################################
29 27
30var _Clipperz_PM_Components_base_id_ = 0; 28var _Clipperz_PM_Components_base_id_ = 0;
31 29
32//############################################################################# 30//#############################################################################
33 31
34Clipperz.PM.UI.Common.Components.BaseComponent = function(args) { 32Clipperz.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, {
69Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.BaseComponent, /*Ext.Component*/ Object, { 67Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.BaseComponent, /*Ext.Component*/ Object, {
70 68
@@ -78,97 +76,96 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.BaseComponent, /*Ext.Compo
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 },
@@ -268,101 +265,98 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.BaseComponent, /*Ext.Compo
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];