summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/BaseComponent.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/BaseComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/BaseComponent.js249
1 files changed, 249 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/BaseComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/BaseComponent.js
new file mode 100644
index 0000000..1e7b69f
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/BaseComponent.js
@@ -0,0 +1,249 @@
1/*
2
3Copyright 2008-2013 Clipperz Srl
4
5This file is part of Clipperz, the online password manager.
6For further information about its features and functionalities please
7refer to http://www.clipperz.com.
8
9* Clipperz is free software: you can redistribute it and/or modify it
10 under the terms of the GNU Affero General Public License as published
11 by the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14* Clipperz is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 See the GNU Affero General Public License for more details.
18
19* You should have received a copy of the GNU Affero General Public
20 License along with Clipperz. If not, see http://www.gnu.org/licenses/.
21
22*/
23
24Clipperz.Base.module('Clipperz.PM.UI.Mobile.Components');
25
26//#############################################################################
27
28var _Clipperz_PM_Components_base_id_ = 0;
29
30//#############################################################################
31
32Clipperz.PM.UI.Mobile.Components.BaseComponent = function(args) {
33 args = args || {};
34 Clipperz.PM.UI.Mobile.Components.BaseComponent.superclass.constructor.call(this, args);
35
36 this._element = args.element || null;
37 this._ids = {};
38
39 this._isFullyRendered = false;
40 //this._renderingWaitingQueue = [];
41
42 return this;
43}
44
45//=============================================================================
46
47//MochiKit.Base.update(Clipperz.PM.UI.Mobile.Components.BaseComponent, Object, {
48Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.BaseComponent, Object, {
49
50 'isClipperzPMComponent': true,
51
52 //-------------------------------------------------------------------------
53
54 'toString': function () {
55 return "Clipperz.PM.UI.Mobile.Components.BaseComponent component";
56 },
57
58 'componentId': function () {
59 return this.getId('_id_');
60 },
61
62 //-------------------------------------------------------------------------
63
64 'element': function() {
65 return MochiKit.DOM.getElement(this._element);
66 },
67
68 'setElement': function(aNode) {
69 this._element = aNode;
70 },
71
72 //-----------------------------------------------------
73
74 'displayElement': function() {
75 return this.element();
76 },
77
78 //-------------------------------------------------------------------------
79
80 'renderInNode': function(aDomNode) {
81 this.setElement(aDomNode);
82 this.render();
83 },
84
85 'render': function() {
86 this.clear();
87 this.renderSelf();
88 // this.renderComponents();
89 // if (this.shouldShowTranslationHints()) {
90 // this.renderTranslationHints();
91 // }
92 if (this.shouldShowElementWhileRendering()) {
93 MochiKit.Style.showElement(this.displayElement());
94 };
95
96 this._isFullyRendered = true;
97
98 // MochiKit.Iter.forEach(this.renderingWaitingQueue(), MochiKit.Base.methodcaller('callback'));
99 // this.resetRenderingWaitingQueue();
100 },
101
102 'renderSelf': function() {
103 throw Clipperz.Base.exception.AbstractMethod;
104 },
105
106 //'renderComponents': function() {
107 // varslotName;
108 //
109 // for (slotName in this.slotComponents()) {
110 // this.slotComponents()[slotName].renderInNode(this.elementForSlotNamed(slotName));
111 // }
112 //},
113
114 //.........................................................................
115
116 'shouldShowElementWhileRendering': function() {
117 return false;
118 },
119
120 //.........................................................................
121
122 'isFullyRendered': function () {
123 return this._isFullyRendered;
124 },
125
126 //.........................................................................
127/*
128 'renderingWaitingQueue': function () {
129 return this._renderingWaitingQueue;
130 },
131
132 'resetRenderingWaitingQueue': function () {
133 this._renderingWaitingQueue = [];
134 },
135
136 //.........................................................................
137
138 'waitUntilFullyRendered': function () {
139 var deferredResult;
140
141 if (this.isFullyRendered() == true) {
142 deferredResult = MochiKit.Async.succeed
143 } else {
144 deferredResult = new Clipperz.Async.Deferred("BaseComponent.waitUntilFullyRendered", {trace:false});
145 this.renderingWaitingQueue().push(deferredResult);
146 }
147
148 return deferredResult;
149 },
150*/
151 //-----------------------------------------------------
152/*
153 'update': function(args) {
154 throw Clipperz.Base.exception.AbstractMethod;
155 },
156
157 'updateSelf': function(args) {
158 throw Clipperz.Base.exception.AbstractMethod;
159 },
160
161 'updateComponents': function(args) {
162 throw Clipperz.Base.exception.AbstractMethod;
163 },
164*/
165 //-----------------------------------------------------
166/*
167 'refresh': function() {
168 throw Clipperz.Base.exception.AbstractMethod;
169 },
170
171 'refreshSelf': function() {
172 throw Clipperz.Base.exception.AbstractMethod;
173 },
174
175 'refreshComponents': function(args) {
176 throw Clipperz.Base.exception.AbstractMethod;
177 },
178*/
179 //-----------------------------------------------------
180
181 'clear': function() {
182 varslotName;
183 var componentId;
184
185 MochiKit.Signal.disconnectAllTo(this);
186
187 if (this.displayElement() != null) {
188 if (this.element() != this.displayElement()) {
189 MochiKit.DOM.removeElement(this.displayElement());
190 } else {
191 this.displayElement().innerHTML = "";
192 }
193 }
194 },
195
196 'remove': function() {
197 this.clear();
198 MochiKit.Signal.disconnectAll(this);
199 },
200
201 'append': function(aNode, aValue) {
202 return Clipperz.DOM.Helper.append(aNode, aValue);
203 },
204
205 'insertBefore': function (aNode, aValue) {
206 return Clipperz.DOM.Helper.insertBefore(aNode, aValue);
207 },
208
209 'insertAfter': function (aNode, aValue) {
210 return Clipperz.DOM.Helper.insertAfter(aNode, aValue);
211 },
212
213 //-------------------------------------------------------------------------
214
215 'getId': function(aValue) {
216 varresult;
217
218 if (typeof(aValue) != 'undefined') {
219 result = this._ids[aValue];
220
221 if (typeof(result) == 'undefined') {
222 _Clipperz_PM_Components_base_id_ ++;
223
224 result = "Clipperz_PM_Components_" + aValue + "_" + _Clipperz_PM_Components_base_id_;
225 this._ids[aValue] = result;
226 }
227 } else {
228 // result = Clipperz.PM.UI.Common.Components.BaseComponent.superclass.getId.call(this);
229 throw "call to BaseComponent.getId with an undefined value";
230 }
231
232 return result;
233 },
234
235 'getAnchor': function (aValue) {
236 return '#' + this.getId(aValue);
237 },
238
239 //-------------------------------------------------------------------------
240
241 'getElement': function(aValue) {
242 return Clipperz.DOM.get(this.getId(aValue));
243 },
244
245 //-------------------------------------------------------------------------
246
247 __syntaxFix__: "syntax fix"
248
249});