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 | 15 |
1 files changed, 6 insertions, 9 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 26f2fc4..2a03fdf 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js | |||
@@ -1,216 +1,213 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2011 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz's Javascript Crypto Library. | 5 | This file is part of Clipperz Community Edition. |
6 | Javascript Crypto Library provides web developers with an extensive | 6 | Clipperz Community Edition is an online password manager. |
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 | 7 | For further information about its features and functionalities please |
11 | refer to http://www.clipperz.com | 8 | refer to http://www.clipperz.com. |
12 | 9 | ||
13 | * Javascript Crypto Library is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
14 | it and/or modify it under the terms of the GNU Affero General Public | 11 | 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 | 12 | License as published by the Free Software Foundation, either version |
16 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
17 | 14 | ||
18 | * Javascript Crypto Library is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
21 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
22 | 19 | ||
23 | * You should have received a copy of the GNU Affero General Public | 20 | * You should have received a copy of the GNU Affero General Public |
24 | License along with Javascript Crypto Library. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
25 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
26 | 23 | ||
27 | */ | 24 | */ |
28 | 25 | ||
29 | Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); | 26 | Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); |
30 | 27 | ||
31 | //############################################################################# | 28 | //############################################################################# |
32 | 29 | ||
33 | var _Clipperz_PM_Components_base_id_ = 0; | 30 | var _Clipperz_PM_Components_base_id_ = 0; |
34 | 31 | ||
35 | //############################################################################# | 32 | //############################################################################# |
36 | 33 | ||
37 | Clipperz.PM.UI.Common.Components.BaseComponent = function(args) { | 34 | Clipperz.PM.UI.Common.Components.BaseComponent = function(args) { |
38 | args = args || {}; | 35 | args = args || {}; |
39 | Clipperz.PM.UI.Common.Components.BaseComponent.superclass.constructor.call(this, args); | 36 | Clipperz.PM.UI.Common.Components.BaseComponent.superclass.constructor.call(this, args); |
40 | 37 | ||
41 | this._element = args.element || null; | 38 | this._element = args.element || null; |
42 | this._ids = {}; | 39 | this._ids = {}; |
43 | 40 | ||
44 | this._slots = {}; | 41 | this._slots = {}; |
45 | this._slotComponents = {}; | 42 | this._slotComponents = {}; |
46 | 43 | ||
47 | this._components = {}; | 44 | this._components = {}; |
48 | 45 | ||
49 | this._cachedSlots = {}; | 46 | this._cachedSlots = {}; |
50 | 47 | ||
51 | this._isModal = false; | 48 | this._isModal = false; |
52 | 49 | ||
53 | this._isActive = false; | 50 | this._isActive = false; |
54 | this._elementUsedToEnterModalState; | 51 | this._elementUsedToEnterModalState; |
55 | 52 | ||
56 | this._isFullyRendered = false; | 53 | this._isFullyRendered = false; |
57 | this._renderingWaitingQueue = []; | 54 | this._renderingWaitingQueue = []; |
58 | 55 | ||
59 | //this._slots = { | 56 | //this._slots = { |
60 | // 'header':'header', | 57 | // 'header':'header', |
61 | // 'body': 'body', | 58 | // 'body': 'body', |
62 | // 'footer':'footer' | 59 | // 'footer':'footer' |
63 | //}; | 60 | //}; |
64 | 61 | ||
65 | return this; | 62 | return this; |
66 | } | 63 | } |
67 | 64 | ||
68 | //============================================================================= | 65 | //============================================================================= |
69 | 66 | ||
70 | //TODO get back to MochiKit.Base.update as we are not extending anything | 67 | //TODO get back to MochiKit.Base.update as we are not extending anything |
71 | //MochiKit.Base.update(Clipperz.PM.UI.Common.Components.BaseComponent.prototype, { | 68 | //MochiKit.Base.update(Clipperz.PM.UI.Common.Components.BaseComponent.prototype, { |
72 | Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.BaseComponent, /*Ext.Component*/ Object, { | 69 | Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.BaseComponent, /*Ext.Component*/ Object, { |
73 | 70 | ||
74 | 'isClipperzPMComponent': true, | 71 | 'isClipperzPMComponent': true, |
75 | 72 | ||
76 | //------------------------------------------------------------------------- | 73 | //------------------------------------------------------------------------- |
77 | 74 | ||
78 | 'toString': function () { | 75 | 'toString': function () { |
79 | return "Clipperz.PM.UI.Common.Components.BaseComponent component"; | 76 | return "Clipperz.PM.UI.Common.Components.BaseComponent component"; |
80 | }, | 77 | }, |
81 | 78 | ||
82 | 'componentId': function () { | 79 | 'componentId': function () { |
83 | return this.getId('_id_'); | 80 | return this.getId('_id_'); |
84 | }, | 81 | }, |
85 | 82 | ||
86 | //------------------------------------------------------------------------- | 83 | //------------------------------------------------------------------------- |
87 | /* | 84 | /* |
88 | 'slots': function() { | 85 | 'slots': function() { |
89 | return this._slots; | 86 | return this._slots; |
90 | }, | 87 | }, |
91 | */ | 88 | */ |
92 | 'slotComponents': function() { | 89 | 'slotComponents': function() { |
93 | return this._slotComponents; | 90 | return this._slotComponents; |
94 | }, | 91 | }, |
95 | 92 | ||
96 | //------------------------------------------------------------------------- | 93 | //------------------------------------------------------------------------- |
97 | 94 | ||
98 | 'components': function () { | 95 | 'components': function () { |
99 | return this._components; | 96 | return this._components; |
100 | }, | 97 | }, |
101 | 98 | ||
102 | 'addComponent': function (aComponent) { | 99 | 'addComponent': function (aComponent) { |
103 | this.components()[aComponent.componentId()] = aComponent; | 100 | this.components()[aComponent.componentId()] = aComponent; |
104 | }, | 101 | }, |
105 | 102 | ||
106 | 'removeComponent': function (aComponent) { | 103 | 'removeComponent': function (aComponent) { |
107 | var componentId; | 104 | var componentId; |
108 | 105 | ||
109 | componentId = aComponent.componentId(); | 106 | componentId = aComponent.componentId(); |
110 | this.components()[componentId].remove(); | 107 | this.components()[componentId].remove(); |
111 | delete this.components()[componentId]; | 108 | delete this.components()[componentId]; |
112 | }, | 109 | }, |
113 | 110 | ||
114 | //------------------------------------------------------------------------- | 111 | //------------------------------------------------------------------------- |
115 | /* | 112 | /* |
116 | 'domHelper': function() { | 113 | 'domHelper': function() { |
117 | return Clipperz.YUI.DomHelper; | 114 | return Clipperz.YUI.DomHelper; |
118 | }, | 115 | }, |
119 | */ | 116 | */ |
120 | //------------------------------------------------------------------------- | 117 | //------------------------------------------------------------------------- |
121 | /* | 118 | /* |
122 | 'domHelperAppend': function(aValue) { | 119 | 'domHelperAppend': function(aValue) { |
123 | Clipperz.YUI.DomHelper.append(this.element().dom, aValue); | 120 | Clipperz.YUI.DomHelper.append(this.element().dom, aValue); |
124 | }, | 121 | }, |
125 | */ | 122 | */ |
126 | //------------------------------------------------------------------------- | 123 | //------------------------------------------------------------------------- |
127 | 124 | ||
128 | 'element': function() { | 125 | 'element': function() { |
129 | //MochiKit.Logging.logDebug(">>> BaseComponent.element"); | 126 | //MochiKit.Logging.logDebug(">>> BaseComponent.element"); |
130 | return MochiKit.DOM.getElement(this._element); | 127 | return MochiKit.DOM.getElement(this._element); |
131 | }, | 128 | }, |
132 | 129 | ||
133 | 'setElement': function(aNode) { | 130 | 'setElement': function(aNode) { |
134 | this._element = aNode; | 131 | this._element = aNode; |
135 | }, | 132 | }, |
136 | 133 | ||
137 | //----------------------------------------------------- | 134 | //----------------------------------------------------- |
138 | 135 | ||
139 | 'displayElement': function() { | 136 | 'displayElement': function() { |
140 | return this.element(); | 137 | return this.element(); |
141 | }, | 138 | }, |
142 | 139 | ||
143 | //------------------------------------------------------------------------- | 140 | //------------------------------------------------------------------------- |
144 | 141 | ||
145 | 'renderInNode': function(aDomNode) { | 142 | 'renderInNode': function(aDomNode) { |
146 | this.setElement(aDomNode); | 143 | this.setElement(aDomNode); |
147 | this.render(); | 144 | this.render(); |
148 | }, | 145 | }, |
149 | 146 | ||
150 | 'render': function() { | 147 | 'render': function() { |
151 | this.clear(); | 148 | this.clear(); |
152 | this.renderSelf(); | 149 | this.renderSelf(); |
153 | this.renderComponents(); | 150 | this.renderComponents(); |
154 | if (this.shouldShowTranslationHints()) { | 151 | if (this.shouldShowTranslationHints()) { |
155 | this.renderTranslationHints(); | 152 | this.renderTranslationHints(); |
156 | } | 153 | } |
157 | if (this.shouldShowElementWhileRendering()) { | 154 | if (this.shouldShowElementWhileRendering()) { |
158 | MochiKit.Style.showElement(this.displayElement()); | 155 | MochiKit.Style.showElement(this.displayElement()); |
159 | }; | 156 | }; |
160 | 157 | ||
161 | this._isFullyRendered = true; | 158 | this._isFullyRendered = true; |
162 | 159 | ||
163 | MochiKit.Iter.forEach(this.renderingWaitingQueue(), MochiKit.Base.methodcaller('callback')); | 160 | MochiKit.Iter.forEach(this.renderingWaitingQueue(), MochiKit.Base.methodcaller('callback')); |
164 | this.resetRenderingWaitingQueue(); | 161 | this.resetRenderingWaitingQueue(); |
165 | }, | 162 | }, |
166 | 163 | ||
167 | 'renderSelf': function() { | 164 | 'renderSelf': function() { |
168 | throw Clipperz.Base.exception.AbstractMethod; | 165 | throw Clipperz.Base.exception.AbstractMethod; |
169 | }, | 166 | }, |
170 | 167 | ||
171 | 'renderComponents': function() { | 168 | 'renderComponents': function() { |
172 | varslotName; | 169 | varslotName; |
173 | 170 | ||
174 | for (slotName in this.slotComponents()) { | 171 | for (slotName in this.slotComponents()) { |
175 | this.slotComponents()[slotName].renderInNode(this.elementForSlotNamed(slotName)); | 172 | this.slotComponents()[slotName].renderInNode(this.elementForSlotNamed(slotName)); |
176 | } | 173 | } |
177 | }, | 174 | }, |
178 | 175 | ||
179 | //......................................................................... | 176 | //......................................................................... |
180 | 177 | ||
181 | 'isFullyRendered': function () { | 178 | 'isFullyRendered': function () { |
182 | return this._isFullyRendered; | 179 | return this._isFullyRendered; |
183 | }, | 180 | }, |
184 | 181 | ||
185 | //......................................................................... | 182 | //......................................................................... |
186 | 183 | ||
187 | 'renderingWaitingQueue': function () { | 184 | 'renderingWaitingQueue': function () { |
188 | return this._renderingWaitingQueue; | 185 | return this._renderingWaitingQueue; |
189 | }, | 186 | }, |
190 | 187 | ||
191 | 'resetRenderingWaitingQueue': function () { | 188 | 'resetRenderingWaitingQueue': function () { |
192 | this._renderingWaitingQueue = []; | 189 | this._renderingWaitingQueue = []; |
193 | }, | 190 | }, |
194 | 191 | ||
195 | //......................................................................... | 192 | //......................................................................... |
196 | 193 | ||
197 | 'waitUntilFullyRendered': function () { | 194 | 'waitUntilFullyRendered': function () { |
198 | var deferredResult; | 195 | var deferredResult; |
199 | 196 | ||
200 | if (this.isFullyRendered() == true) { | 197 | if (this.isFullyRendered() == true) { |
201 | deferredResult = MochiKit.Async.succeed | 198 | deferredResult = MochiKit.Async.succeed |
202 | } else { | 199 | } else { |
203 | deferredResult = new Clipperz.Async.Deferred("BaseComponent.waitUntilFullyRendered", {trace:false}); | 200 | deferredResult = new Clipperz.Async.Deferred("BaseComponent.waitUntilFullyRendered", {trace:false}); |
204 | this.renderingWaitingQueue().push(deferredResult); | 201 | this.renderingWaitingQueue().push(deferredResult); |
205 | } | 202 | } |
206 | 203 | ||
207 | return deferredResult; | 204 | return deferredResult; |
208 | }, | 205 | }, |
209 | 206 | ||
210 | //----------------------------------------------------- | 207 | //----------------------------------------------------- |
211 | 208 | ||
212 | 'renderTranslationHints': function () { | 209 | 'renderTranslationHints': function () { |
213 | vartranslatableItems; | 210 | vartranslatableItems; |
214 | 211 | ||
215 | translatableItems = MochiKit.Selector.findChildElements(this.displayElement(), ['[stringID]']); | 212 | translatableItems = MochiKit.Selector.findChildElements(this.displayElement(), ['[stringID]']); |
216 | MochiKit.Iter.forEach(translatableItems, MochiKit.Base.method(this, 'enhanceTranslatableElement')) | 213 | MochiKit.Iter.forEach(translatableItems, MochiKit.Base.method(this, 'enhanceTranslatableElement')) |