summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js
Side-by-side diff
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 @@
/*
-Copyright 2008-2011 Clipperz Srl
+Copyright 2008-2013 Clipperz Srl
-This file is part of Clipperz Community Edition.
-Clipperz Community Edition is an online password manager.
+This file is part of Clipperz, the online password manager.
For further information about its features and functionalities please
refer to http://www.clipperz.com.
-* Clipperz Community Edition is free software: you can redistribute
- it and/or modify it under the terms of the GNU Affero General Public
- License as published by the Free Software Foundation, either version
- 3 of the License, or (at your option) any later version.
+* Clipperz is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
-* Clipperz Community Edition is distributed in the hope that it will
- be useful, but WITHOUT ANY WARRANTY; without even the implied
- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* Clipperz is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
- License along with Clipperz Community Edition. If not, see
- <http://www.gnu.org/licenses/>.
+ License along with Clipperz. If not, see http://www.gnu.org/licenses/.
*/
Clipperz.Base.module('Clipperz.PM.UI.Common.Components');
//#############################################################################
var _Clipperz_PM_Components_base_id_ = 0;
//#############################################################################
Clipperz.PM.UI.Common.Components.BaseComponent = function(args) {
args = args || {};
Clipperz.PM.UI.Common.Components.BaseComponent.superclass.constructor.call(this, args);
this._element = args.element || null;
this._ids = {};
this._slots = {};
this._slotComponents = {};
this._components = {};
this._cachedSlots = {};
this._isModal = false;
this._isActive = false;
this._elementUsedToEnterModalState;
this._isFullyRendered = false;
this._renderingWaitingQueue = [];
// this._slots = {
// 'header': 'header',
// 'body': 'body',
// 'footer': 'footer'
// };
return this;
}
//=============================================================================
//TODO get back to MochiKit.Base.update as we are not extending anything
//MochiKit.Base.update(Clipperz.PM.UI.Common.Components.BaseComponent.prototype, {
Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.BaseComponent, /*Ext.Component*/ Object, {
@@ -78,97 +76,96 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.BaseComponent, /*Ext.Compo
'componentId': function () {
return this.getId('_id_');
},
//-------------------------------------------------------------------------
/*
'slots': function() {
return this._slots;
},
*/
'slotComponents': function() {
return this._slotComponents;
},
//-------------------------------------------------------------------------
'components': function () {
return this._components;
},
'addComponent': function (aComponent) {
this.components()[aComponent.componentId()] = aComponent;
},
'removeComponent': function (aComponent) {
var componentId;
componentId = aComponent.componentId();
this.components()[componentId].remove();
delete this.components()[componentId];
},
//-------------------------------------------------------------------------
/*
'domHelper': function() {
return Clipperz.YUI.DomHelper;
},
*/
//-------------------------------------------------------------------------
/*
'domHelperAppend': function(aValue) {
Clipperz.YUI.DomHelper.append(this.element().dom, aValue);
},
*/
//-------------------------------------------------------------------------
'element': function() {
-//MochiKit.Logging.logDebug(">>> BaseComponent.element");
return MochiKit.DOM.getElement(this._element);
},
'setElement': function(aNode) {
this._element = aNode;
},
//-----------------------------------------------------
'displayElement': function() {
return this.element();
},
//-------------------------------------------------------------------------
'renderInNode': function(aDomNode) {
this.setElement(aDomNode);
this.render();
},
'render': function() {
this.clear();
this.renderSelf();
this.renderComponents();
if (this.shouldShowTranslationHints()) {
this.renderTranslationHints();
}
if (this.shouldShowElementWhileRendering()) {
MochiKit.Style.showElement(this.displayElement());
};
this._isFullyRendered = true;
MochiKit.Iter.forEach(this.renderingWaitingQueue(), MochiKit.Base.methodcaller('callback'));
this.resetRenderingWaitingQueue();
},
'renderSelf': function() {
throw Clipperz.Base.exception.AbstractMethod;
},
'renderComponents': function() {
var slotName;
for (slotName in this.slotComponents()) {
this.slotComponents()[slotName].renderInNode(this.elementForSlotNamed(slotName));
}
},
@@ -268,101 +265,98 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.BaseComponent, /*Ext.Compo
'slotNamed': function(aSlotName) {
var result;
this.checkSlotNamed(aSlotName);
if (typeof(this.cachedSlots()[aSlotName]) == 'undefined') {
this.cachedSlots()[aSlotName] = new Clipperz.PM.UI.Common.Components.ComponentSlot(this,aSlotName);
}
result = this.cachedSlots()[aSlotName];
return result;
},
//-----------------------------------------------------
'elementForSlotNamed': function(aSlotName) {
return MochiKit.DOM.getElement(this._slots[aSlotName]);
},
//-----------------------------------------------------
'componentForSlotNamed': function(aSlotName) {
return this.slotComponents()[aSlotName];
},
'setComponentForSlotNamed': function(aComponent, aSlotName) {
var domNode;
this.checkSlotNamed(aSlotName);
if (this.slotComponents()[aSlotName] != null) {
this.slotComponents()[aSlotName].remove();
}
this.slotComponents()[aSlotName] = aComponent;
// domNode = MochiKit.DOM.getElement(this.slotNamed(aSlotName));
domNode = this.elementForSlotNamed(aSlotName);
if (domNode != null) {
aComponent.renderInNode(domNode);
}
},
//-----------------------------------------------------
/*
'purgeListeners': function() {
-//MochiKit.Logging.logDebug(">>> Clipperz.PM.UI.Common.Components.BaseComponent.purgeListeners [" + this + "]");
-//MochiKit.Logging.logDebug("--- " + this + ".purgeListeners");
Clipperz.NotificationCenter.unregister(this);
MochiKit.Signal.disconnectAllTo(this);
-//MochiKit.Logging.logDebug("<<< Clipperz.PM.UI.Common.Components.BaseComponent.purgeListeners");
},
*/
//-----------------------------------------------------
'clear': function() {
var slotName;
var componentId;
MochiKit.Signal.disconnectAllTo(this);
for (slotName in this.slotComponents()) {
this.slotComponents()[slotName].clear();
}
for (componentId in this.components()) {
this.components()[componentId].clear();
}
// if (this.element() != null) {
// this.element().innerHTML = "";
// }
if (this.displayElement() != null) {
if (this.element() != this.displayElement()) {
MochiKit.DOM.removeElement(this.displayElement());
} else {
this.displayElement().innerHTML = "";
}
}
if (this.isModal()) {
// TODO: cleanup when the closed element was shown modally.
}
},
'remove': function() {
var slotName;
var componentId;
for (slotName in this.slotComponents()) {
this.slotComponents()[slotName].remove();
delete this.slotComponents()[slotName];
}
for (componentId in this.components()) {
this.components()[componentId].remove();
delete this.components()[componentId];