summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Common/Components
Side-by-side diff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Common/Components') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js4
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Common/Components/Button.js34
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js34
3 files changed, 51 insertions, 21 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 2a03fdf..b9d7adf 100644
--- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js
+++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js
@@ -313,192 +313,196 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.BaseComponent, /*Ext.Compo
//-----------------------------------------------------
/*
'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];
}
this.clear();
MochiKit.Signal.disconnectAll(this);
},
'append': function(aNode, aValue) {
return Clipperz.DOM.Helper.append(aNode, aValue);
},
'insertBefore': function (aNode, aValue) {
return Clipperz.DOM.Helper.insertBefore(aNode, aValue);
},
'insertAfter': function (aNode, aValue) {
return Clipperz.DOM.Helper.insertAfter(aNode, aValue);
},
//-------------------------------------------------------------------------
'getId': function(aValue) {
var result;
if (typeof(aValue) != 'undefined') {
result = this._ids[aValue];
if (typeof(result) == 'undefined') {
_Clipperz_PM_Components_base_id_ ++;
result = "Clipperz_PM_Components_" + aValue + "_" + _Clipperz_PM_Components_base_id_;
this._ids[aValue] = result;
}
} else {
// result = Clipperz.PM.UI.Common.Components.BaseComponent.superclass.getId.call(this);
throw "call to BaseComponent.getId with an undefined value";
}
return result;
},
+ 'getAnchor': function (aValue) {
+ return '#' + this.getId(aValue);
+ },
+
//-------------------------------------------------------------------------
'getElement': function(aValue) {
return Clipperz.DOM.get(this.getId(aValue));
},
//-------------------------------------------------------------------------
'hideElement': function(anElementName) {
MochiKit.Style.hideElement(this.getElement(anElementName));
},
'showElement': function(anElementName) {
MochiKit.Style.showElement(this.getElement(anElementName));
},
//-------------------------------------------------------------------------
'activate': function () {
this._isActive = true;
},
'deactivate': function () {
this._isActive = false;
},
'isActive': function () {
return this._isActive;
},
//-------------------------------------------------------------------------
'hideSlot': function(aSlotName) {
if (this.componentForSlotNamed(aSlotName)) {
this.componentForSlotNamed(aSlotName).deactivate();
}
MochiKit.Style.hideElement(this.elementForSlotNamed(aSlotName));
},
'showSlot': function(aSlotName) {
if (this.componentForSlotNamed(aSlotName)) {
this.componentForSlotNamed(aSlotName).activate();
}
MochiKit.Style.showElement(this.elementForSlotNamed(aSlotName));
},
//-------------------------------------------------------------------------
'shouldShowTranslationHints': function () {
return false;
},
'shouldShowElementWhileRendering': function() {
return true;
},
// 'shouldRemoveElementWhenClearningUp': function () {
// return true;
// },
//-------------------------------------------------------------------------
'isModal': function() {
return this._isModal;
},
'setIsModal': function(aValue) {
this._isModal = aValue;
},
//-------------------------------------------------------------------------
'elementUsedToEnterModalState': function () {
return this._elementUsedToEnterModalState;
},
'setElementUsedToEnterModalState': function (aValue) {
this._elementUsedToEnterModalState = aValue;
},
//-------------------------------------------------------------------------
'modalDialogMask': function () {
return 'modalDialogMask';
},
'modalDialog': function () {
return 'modalDialog';
},
'modalDialogFrame': function() {
return 'modalDialogFrame'
},
//-------------------------------------------------------------------------
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Button.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Button.js
index 716d851..1010c9d 100644
--- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Button.js
+++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Button.js
@@ -1,105 +1,113 @@
/*
Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz Community Edition.
Clipperz Community Edition is an 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 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.
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/>.
*/
Clipperz.Base.module('Clipperz.PM.UI.Common.Components');
Clipperz.PM.UI.Common.Components.Button = function(args) {
args = args || {};
Clipperz.PM.UI.Common.Components.Button.superclass.constructor.apply(this, arguments);
this._element = args.element || Clipperz.Base.exception.raise('MandatoryParameter');
this._text = args.text || Clipperz.Base.exception.raise('MandatoryParameter');
this._isDefault = args.isDefault || false;
this.render();
return this;
}
//=============================================================================
Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.Button, Clipperz.PM.UI.Common.Components.BaseComponent, {
//-------------------------------------------------------------------------
'toString': function () {
return "Clipperz.PM.UI.Common.Components.Button component";
},
//-------------------------------------------------------------------------
'text': function () {
return this._text;
},
'isDefault': function () {
return this._isDefault;
},
//-------------------------------------------------------------------------
'renderSelf': function () {
- this.append(this.element(), {tag:'div', id:this.getId('wrapper'), cls:'button_wrapper', children:[
+/*
+ this.append(this.element(), {tag:'div', id:this.getId('button'), cls:'button_wrapper', children:[
{tag:'div', id:this.getId('bodyWrapper'), cls:'button_bodyWrapper', children:[
{tag:'div', id:this.getId('body'), cls:'button_body', children:[
{tag:'span', html:this.text()}
]},
{tag:'div', id:this.getId('footer'), cls:'button_footer'}
]}
]});
+*/
+/*
+ this.append(this.element(), {tag:'div', id:this.getId('button'), cls:'button', children:[
+ {tag:'span', html:this.text()}
+ ]});
+*/
+ this.append(this.element(), {tag:'a', id:this.getId('button'), cls:'button', html:this.text()});
if (this.isDefault()) {
- MochiKit.DOM.addElementClass(this.getId('wrapper'), 'default');
+ MochiKit.DOM.addElementClass(this.getId('button'), 'default');
}
- MochiKit.Signal.connect(this.getId('wrapper'), 'onmouseenter', this, 'handleOnMouseEnter');
- MochiKit.Signal.connect(this.getId('wrapper'), 'onmouseleave', this, 'handleOnMouseLeave');
- MochiKit.Signal.connect(this.getId('wrapper'), 'onmousedown', this, 'handleOnMouseDown');
- MochiKit.Signal.connect(this.getId('wrapper'), 'onclick', this, 'handleOnClick');
+// MochiKit.Signal.connect(this.getId('button'), 'onmouseenter', this, 'handleOnMouseEnter');
+// MochiKit.Signal.connect(this.getId('button'), 'onmouseleave', this, 'handleOnMouseLeave');
+// MochiKit.Signal.connect(this.getId('button'), 'onmousedown', this, 'handleOnMouseDown');
+ MochiKit.Signal.connect(this.getId('button'), 'onclick', this, 'handleOnClick');
},
//-------------------------------------------------------------------------
-
+/*
'handleOnMouseEnter': function (anEvent) {
- MochiKit.DOM.addElementClass(this.getId('wrapper'), 'hover');
+ MochiKit.DOM.addElementClass(this.getId('button'), 'hover');
},
'handleOnMouseLeave': function (anEvent) {
- MochiKit.DOM.removeElementClass(this.getId('wrapper'), 'hover');
- MochiKit.DOM.removeElementClass(this.getId('wrapper'), 'clicked');
+ MochiKit.DOM.removeElementClass(this.getId('button'), 'hover');
+ MochiKit.DOM.removeElementClass(this.getId('button'), 'clicked');
},
'handleOnMouseDown': function (anEvent) {
- MochiKit.DOM.addElementClass(this.getId('wrapper'), 'clicked');
+ MochiKit.DOM.addElementClass(this.getId('button'), 'clicked');
},
-
+*/
'handleOnClick': function (anEvent) {
MochiKit.Signal.signal(this, 'onclick', anEvent);
},
-
+
//-------------------------------------------------------------------------
__syntaxFix__: "syntax fix"
});
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js
index 1992154..1d816a9 100644
--- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js
+++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js
@@ -5,237 +5,255 @@ Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz Community Edition.
Clipperz Community Edition is an 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 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.
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/>.
*/
Clipperz.Base.module('Clipperz.PM.UI.Web.Components');
Clipperz.PM.UI.Common.Components.SimpleMessagePanel = function(args) {
args = args || {};
Clipperz.PM.UI.Common.Components.SimpleMessagePanel.superclass.constructor.apply(this, arguments);
this._title = args.title || Clipperz.Base.exception.raise('MandatoryParameter');
this._text = args.text || Clipperz.Base.exception.raise('MandatoryParameter');
this._type = args.type || Clipperz.Base.exception.raise('MandatoryParameter'); // ALERT, INFO, ERROR
this._buttons = args.buttons || Clipperz.Base.exception.raise('MandatoryParameter');
this._buttonComponents = [];
this._deferred = null;
this.renderModalMask();
return this;
}
//=============================================================================
Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.SimpleMessagePanel, Clipperz.PM.UI.Common.Components.BaseComponent, {
//-------------------------------------------------------------------------
'toString': function () {
return "Clipperz.PM.UI.Common.Components.SimpleMessagePanel component";
},
//-------------------------------------------------------------------------
'deferred': function() {
if (this._deferred == null) {
this._deferred = new Clipperz.Async.Deferred("SimpleMessagePanel.deferred", {trace:false});
}
return this._deferred;
},
//-------------------------------------------------------------------------
'title': function () {
return this._title;
},
'setTitle': function (aValue) {
this._title = aValue;
if (this.getElement('title') != null) {
this.getElement('title').innerHTML = aValue;
}
},
//-------------------------------------------------------------------------
'text': function () {
return this._text;
},
'setText': function (aValue) {
this._text = aValue;
if (this.getElement('text') != null) {
this.getElement('text').innerHTML = aValue;
}
},
//-------------------------------------------------------------------------
'type': function () {
return this._type;
},
'setType': function (aValue) {
- if (this.getElement('icon') != null) {
- MochiKit.DOM.removeElementClass(this.getId('icon'), this._type);
- MochiKit.DOM.addElementClass(this.getId('icon'), aValue);
- }
+// if (this.getElement('icon') != null) {
+// MochiKit.DOM.removeElementClass(this.getId('icon'), this._type);
+// MochiKit.DOM.addElementClass(this.getId('icon'), aValue);
+// }
this._type = aValue;
},
+ 'icon': function () {
+ var type = this.type();
+ var result;
+
+ if (type == 'ALERT') {
+ result = '!';
+ } else if (type == 'INFO') {
+ result = 'i';
+ } else if (type == 'ERROR') {
+ result = '!';
+ }
+
+ return result;
+ },
+
//-------------------------------------------------------------------------
'buttons': function () {
return this._buttons;
},
'setButtons': function (someValues) {
MochiKit.Iter.forEach(this.buttonComponents(), MochiKit.Base.methodcaller('clear'));
this._buttons = someValues;
if (this.getElement('buttonArea') != null) {
this.renderButtons();
}
},
//.........................................................................
'buttonComponents': function () {
return this._buttonComponents;
},
//-------------------------------------------------------------------------
'renderSelf': function() {
this.append(this.element(), {tag:'div', cls:'SimpleMessagePanel', id:this.getId('panel'), children: [
- {tag:'div', cls:'header', children:[]},
+// {tag:'div', cls:'header', children:[]},
{tag:'div', cls:'body', children:[
- {tag:'div', id:this.getId('icon'), cls:'img ' + this.type(), children:[{tag:'div'}]},
+// {tag:'div', id:this.getId('icon'), cls:'img ' + this.type(), children:[{tag:'div'}]},
+ {tag:'div', /*id:this.getId('icon'),*/ cls:'img ' + this.type(), children:[{tag:'canvas', id:this.getId('icon')}]},
{tag:'h3', id:this.getId('title'), html:this.title()},
{tag:'p', id:this.getId('text'), html:this.text()},
{tag:'div', id:this.getId('container')},
{tag:'div', id:this.getId('buttonArea'), cls:'buttonArea', children:[]}
- ]},
- {tag:'div', cls:'footer', children:[]}
+ ]}
+// {tag:'div', cls:'footer', children:[]}
]});
+ Clipperz.PM.UI.Canvas.marks[this.icon()](this.getElement('icon'), "#ffffff");
+
MochiKit.Signal.connect(this.getId('panel'), 'onkeydown', this, 'keyDownHandler');
this.renderButtons();
},
//-------------------------------------------------------------------------
'renderButtons': function () {
this.getElement('buttonArea').innerHTML = '';
MochiKit.Base.map(MochiKit.Base.bind(function (aButton) {
var buttonElement;
var buttonComponent;
// element = this.append(this.getElement('buttonArea'), {tag:'div', cls:'button' + (aButton['isDefault'] === true ? ' default' : ''), children:[
// {tag:'a', href:'#'/*, id:this.getId('buttonLink')*/, html:aButton['text']}
// ]});
buttonElement = this.append(this.getElement('buttonArea'), {tag:'div'});
buttonComponent = new Clipperz.PM.UI.Common.Components.Button({'element':buttonElement, 'text':aButton['text'], 'isDefault':aButton['isDefault']});
this.buttonComponents().push(buttonComponent);
MochiKit.Signal.connect(buttonComponent, 'onclick', MochiKit.Base.method(this, 'buttonEventHandler', aButton));
}, this), MochiKit.Iter.reversed(this.buttons()));
},
//-------------------------------------------------------------------------
'displayElement': function() {
return this.getElement('panel');
},
//-------------------------------------------------------------------------
'closeOk': function () {
this.deferred().callback();
this._deferred = null;
},
'closeCancel': function () {
this.deferred().cancel();
this._deferred = null;
},
'closeError': function () {
this.deferred().errback();
this._deferred = null;
},
//-------------------------------------------------------------------------
'buttonEventHandler': function(aButton, anEvent) {
anEvent.preventDefault();
// MochiKit.Signal.signal(this, 'cancelEvent');
switch (aButton['result']) {
case 'OK':
//console.log("==> OK");
this.closeOk();
break;
case 'CANCEL':
//console.log("==> CANCEL");
this.closeCancel();
break;
default:
//console.log("==> ????");
this.closeError();
break;
}
//console.log("<==");
},
//-------------------------------------------------------------------------
'deferredShow': function (someArgs, aResult) {
this.deferredShowModal(someArgs);
this.deferred().addMethod(this, 'deferredHideModal', {closeToElement:someArgs.onOkCloseToElement });
this.deferred().addErrback (MochiKit.Base.method(this, 'deferredHideModal', {closeToElement:someArgs.onCancelCloseToElement }));
this.deferred().addCallback(MochiKit.Async.succeed, aResult);
return this.deferred();
},
//-------------------------------------------------------------------------
'modalDialogMask': function () {
return this.getId('modalDialogMask');
},
'modalDialog': function () {
return this.getId('modalDialog');
},
'modalDialogFrame': function() {
return this.getId('modalDialogFrame');