From ef68436ac04da078ffdcacd7e1f785473a303d45 Mon Sep 17 00:00:00 2001 From: Giulio Cesare Solaroli Date: Sun, 02 Oct 2011 23:56:18 +0000 Subject: First version of the newly restructured repository --- (limited to 'frontend/gamma/js/Clipperz/PM/UI/Common/Components') diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js new file mode 100644 index 0000000..26f2fc4 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js @@ -0,0 +1,611 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library 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. + +* Javascript Crypto Library 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 Javascript Crypto Library. If not, see + . + +*/ + +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, { + + 'isClipperzPMComponent': true, + + //------------------------------------------------------------------------- + + 'toString': function () { + return "Clipperz.PM.UI.Common.Components.BaseComponent component"; + }, + + '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)); + } + }, + + //......................................................................... + + 'isFullyRendered': function () { + return this._isFullyRendered; + }, + + //......................................................................... + + 'renderingWaitingQueue': function () { + return this._renderingWaitingQueue; + }, + + 'resetRenderingWaitingQueue': function () { + this._renderingWaitingQueue = []; + }, + + //......................................................................... + + 'waitUntilFullyRendered': function () { + var deferredResult; + + if (this.isFullyRendered() == true) { + deferredResult = MochiKit.Async.succeed + } else { + deferredResult = new Clipperz.Async.Deferred("BaseComponent.waitUntilFullyRendered", {trace:false}); + this.renderingWaitingQueue().push(deferredResult); + } + + return deferredResult; + }, + + //----------------------------------------------------- + + 'renderTranslationHints': function () { + var translatableItems; + + translatableItems = MochiKit.Selector.findChildElements(this.displayElement(), ['[stringID]']); + MochiKit.Iter.forEach(translatableItems, MochiKit.Base.method(this, 'enhanceTranslatableElement')) + }, + + 'enhanceTranslatableElement': function (anElement) { +//Clipperz.log(">>> enhanceTranslatableElement", anElement); +// new Clipperz.PM.UI.Common.Components.TranslatorWidget({ +// 'element': anElement +// }); + + MochiKit.Signal.connect(anElement, 'onmouseenter', MochiKit.Base.partial(Clipperz.PM.UI.Common.Components.TranslatorWidget.show, anElement, MochiKit.DOM.getNodeAttribute(anElement, 'stringID'))); + MochiKit.Signal.connect(anElement, 'onmouseleave', Clipperz.PM.UI.Common.Components.TranslatorWidget.hide); +//Clipperz.log("<<< enhanceTranslatableElement"); + }, + + //----------------------------------------------------- + + 'update': function(args) { + throw Clipperz.Base.exception.AbstractMethod; + }, + + 'updateSelf': function(args) { + throw Clipperz.Base.exception.AbstractMethod; + }, + + 'updateComponents': function(args) { + throw Clipperz.Base.exception.AbstractMethod; + }, + + //----------------------------------------------------- + + 'refresh': function() { + throw Clipperz.Base.exception.AbstractMethod; + }, + + 'refreshSelf': function() { + throw Clipperz.Base.exception.AbstractMethod; + }, + + 'refreshComponents': function(args) { + throw Clipperz.Base.exception.AbstractMethod; + }, + + //----------------------------------------------------- + + 'checkSlotNamed': function(aSlotName) { + if (typeof(this._slots[aSlotName]) == 'undefined') { + throw new Error("undefined slot"); + }; + }, + + //----------------------------------------------------- + + 'cachedSlots': function() { + return this._cachedSlots; + }, + + '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]; + } + + 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; + }, + + //------------------------------------------------------------------------- + + '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' + }, + + //------------------------------------------------------------------------- + + 'deferredShowModal': function(args) { + var deferredResult; + + deferredResult = new Clipperz.Async.Deferred("BaseComponent.deferredShowModal", {trace:false}); + + deferredResult.addMethod(this, 'setIsModal', true); + deferredResult.addCallback(MochiKit.Style.showElement, this.modalDialogMask()); + deferredResult.addCallback(MochiKit.Base.bind(function(someArgs) { + var result; + var duration; + var from; + var to; + + duration = someArgs.duration || 0.4; + + this.setElementUsedToEnterModalState(someArgs.openFromElement); + from = Clipperz.Style.getSizeAndPosition(someArgs.openFromElement); + this.renderInNode(this.modalDialog()); + MochiKit.DOM.addElementClass(this.modalDialog(), 'fixed'); + to = Clipperz.Style.getSizeAndPosition(this.displayElement()); + Clipperz.PM.UI.Common.Components.BaseComponent.targetModalDimensionsAndPosition = Clipperz.Base.deepClone(to); + + MochiKit.Style.hideElement(this.displayElement()); + MochiKit.Style.showElement(this.modalDialogFrame()); + + result = {from:from, to:to, duration:duration}; + return result; + }, this, args)); + deferredResult.addCallback(Clipperz.Visual.deferredResize, this.modalDialogFrame()); + deferredResult.addCallback(MochiKit.Base.bind(function(someArgs) { + MochiKit.Style.hideElement(this.modalDialogFrame()); + MochiKit.Style.showElement(this.displayElement()); + }, this)); + deferredResult.addCallback(MochiKit.Async.succeed, arguments[arguments.length - 1]); + deferredResult.callback(); + + return deferredResult; + }, + + //------------------------------------------------------------------------- + + 'deferredHideModal': function(args) { + var deferredResult; + + args = args || {}; + + deferredResult = new Clipperz.Async.Deferred("BaseComponent.deferredHideModal", {trace:false}); + deferredResult.addCallback(MochiKit.Base.bind(function(someArgs) { + var result; + var from; + var toElement; + var to; + var duration; + + toElement = args.closeToElement || this.elementUsedToEnterModalState(); + duration = someArgs.duration || 0.4; + from = Clipperz.Style.getSizeAndPosition(this.displayElement()); + to = Clipperz.Style.getSizeAndPosition(toElement); + + MochiKit.Style.hideElement(this.displayElement()); + MochiKit.Style.showElement(this.modalDialogFrame()); + + result = {from:from, to:to, duration:duration}; + return result; + }, this, args)); + deferredResult.addCallback(Clipperz.Visual.deferredResize, this.modalDialogFrame()); + deferredResult.addCallback(MochiKit.Base.bind(function() { + MochiKit.Style.hideElement(this.modalDialogFrame()); + MochiKit.Style.hideElement(this.modalDialogMask()); + }, this)); + deferredResult.addMethod(this, 'setIsModal', false); + deferredResult.addMethod(this, 'clear'); // ############## + deferredResult.addCallback(MochiKit.Async.succeed, arguments[arguments.length - 1]); + deferredResult.callback(); + + return deferredResult; + }, + + //------------------------------------------------------------------------- + + __syntaxFix__: "syntax fix" + +}); + +Clipperz.PM.UI.Common.Components.BaseComponent_modalDialog = function() { + Clipperz.DOM.Helper.append(MochiKit.DOM.currentDocument().body, + {tag:'div', id:'modalDialogWrapper', cls:'modalDialogWrapper', children:[ + {tag:'div', id:'modalDialogMask', cls:'modalDialogMask'}, + {tag:'div', id:'modalDialogFrame', cls:'modalDialogFrame' /*, html:"modal dialog frame"*/}, + {tag:'div', id:'modalDialog', cls:'modalDialog'} +// {tag:'div', id:'modalDialog', cls:'modalDialog', children:[{tag:'div'}]} + ]} + ); + +// MochiKit.Style.hideElement('modalDialogWrapper'); + MochiKit.Style.hideElement('modalDialogMask'); + MochiKit.Style.hideElement('modalDialogFrame'); +// MochiKit.Style.hideElement('modalDialog'); + +}; + +//Clipperz.PM.UI.Common.Components.BaseComponent.targetModalDimensionsAndPosition = {'x':'X', 'y':'Y'}; + +MochiKit.DOM.addLoadEvent(Clipperz.PM.UI.Common.Components.BaseComponent_modalDialog); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Button.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Button.js new file mode 100644 index 0000000..b2761ea --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Button.js @@ -0,0 +1,108 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library 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. + +* Javascript Crypto Library 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 Javascript Crypto Library. If not, see + . + +*/ + +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:[ + {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'} + ]} + ]}); + + if (this.isDefault()) { + MochiKit.DOM.addElementClass(this.getId('wrapper'), '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'); + }, + + //------------------------------------------------------------------------- + + 'handleOnMouseEnter': function (anEvent) { + MochiKit.DOM.addElementClass(this.getId('wrapper'), 'hover'); + }, + + 'handleOnMouseLeave': function (anEvent) { + MochiKit.DOM.removeElementClass(this.getId('wrapper'), 'hover'); + MochiKit.DOM.removeElementClass(this.getId('wrapper'), 'clicked'); + }, + + 'handleOnMouseDown': function (anEvent) { + MochiKit.DOM.addElementClass(this.getId('wrapper'), 'clicked'); + }, + + 'handleOnClick': function (anEvent) { + MochiKit.Signal.signal(this, 'onclick', anEvent); + }, + + //------------------------------------------------------------------------- + __syntaxFix__: "syntax fix" +}); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/ComponentSlot.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/ComponentSlot.js new file mode 100644 index 0000000..0c6e221 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/ComponentSlot.js @@ -0,0 +1,64 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library 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. + +* Javascript Crypto Library 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 Javascript Crypto Library. If not, see + . + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); + +//############################################################################# + + +Clipperz.PM.UI.Common.Components.ComponentSlot = function(aComponent, aSlotName) { + this._component = aComponent; + this._slotName = aSlotName; + + return this; +} + +//============================================================================= + +Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.ComponentSlot, Object, { + + //------------------------------------------------------------------------- + + 'slotName': function() { + return this._slotName; + }, + + 'component': function() { + return this._component; + }, + + //------------------------------------------------------------------------- + + 'setContent': function(aComponent) { + this.component().setComponentForSlotNamed(aComponent, this.slotName()); + }, + + //------------------------------------------------------------------------- + __syntaxFix__: "syntax fix" + +}); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/FaviconComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/FaviconComponent.js new file mode 100644 index 0000000..4735f5c --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/FaviconComponent.js @@ -0,0 +1,91 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library 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. + +* Javascript Crypto Library 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 Javascript Crypto Library. If not, see + . + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); + +Clipperz.PM.UI.Common.Components.FaviconComponent = function(args) { + args = args || {}; + + Clipperz.PM.UI.Common.Components.FaviconComponent.superclass.constructor.apply(this, arguments); + + this.render(); + this.setSrc(args.src); + + return this; +} + +//============================================================================= + +Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.FaviconComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { + + //------------------------------------------------------------------------- + + 'toString': function () { + return "Clipperz.PM.UI.Common.Components.FaviconComponent component"; + }, + + //------------------------------------------------------------------------- + + 'src': function () { + return this.element().src; + }, + + 'setSrc': function (aValue) { + this.element().src = (aValue || Clipperz.PM.Strings.getValue('defaultFaviconUrl')); + }, + + //------------------------------------------------------------------------- + + 'clear': function () {}, + + //------------------------------------------------------------------------- + + 'renderSelf': function () { + MochiKit.Signal.connect(this.element(), 'onerror', this, 'setDefaultFavicon'); + MochiKit.Signal.connect(this.element(), 'onabort', this, 'setDefaultFavicon'); + MochiKit.Signal.connect(this.element(), 'onload', this, 'handleOnLoad'); + }, + + //------------------------------------------------------------------------- + + 'setDefaultFavicon': function (anEvent) { + MochiKit.Signal.disconnectAll(anEvent.src()); + this.setSrc(null); + }, + + 'handleOnLoad': function (anEvent) { + MochiKit.Signal.disconnectAll(anEvent.src()); +//console.log("HANDLE ON LOAD", anEvent, anEvent.src().src); + if (anEvent.src().complete == false) { + this.setSrc(null); + } + }, + + //------------------------------------------------------------------------- + __syntaxFix__: "syntax fix" +}); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/MessagePanelWithProgressBar.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/MessagePanelWithProgressBar.js new file mode 100644 index 0000000..275bbed --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/MessagePanelWithProgressBar.js @@ -0,0 +1,164 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library 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. + +* Javascript Crypto Library 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 Javascript Crypto Library. If not, see + . + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); + +Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar = function(args) { + args = args || {}; + + Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar.superclass.constructor.apply(this, arguments); + +// this._openFromElement = args.openFromElement || null; + this._onOkCloseToElement = args.onOkCloseToElement || null; + this._onCancelCloseToElement = args.onCancelCloseToElement || null; + + this._canCancelWhileProcessing = ((typeof(args.canCancelWhileProcessing) == 'undefined') ? true : args.canCancelWhileProcessing); + + return this; +} + +//============================================================================= + +Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar, Clipperz.PM.UI.Common.Components.SimpleMessagePanel, { + + //------------------------------------------------------------------------- + + 'toString': function () { + return "Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar component"; + }, + + //------------------------------------------------------------------------- +/* + 'openFromElement': function () { + return this._openFromElement; + }, +*/ + //------------------------------------------------------------------------- + + 'onOkCloseToElement': function () { + return this._onOkCloseToElement; + }, + + 'setOnOkCloseToElement': function (anElement) { + this._onOkCloseToElement = anElement; + }, + + //------------------------------------------------------------------------- + + 'onCancelCloseToElement': function () { + return this._onCancelCloseToElement; + }, + + 'setOnCancelCloseToElement': function (anElement) { + this._onCancelCloseToElement = anElement; + }, + + //------------------------------------------------------------------------- + + 'canCancelWhileProcessing': function () { + return this._canCancelWhileProcessing; + }, + + //------------------------------------------------------------------------- + + 'deferredShowModal': function (someArgs, aResult) { + if (someArgs['onOkCloseToElement'] != null) { + this.setOnOkCloseToElement(someArgs['onOkCloseToElement']); + } + + if (someArgs['onCancelCloseToElement'] != null) { + this.setOnCancelCloseToElement(someArgs['onCancelCloseToElement']); + } + + Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar.superclass.deferredShowModal.apply(this, arguments); + return this.deferred(); + }, + + //------------------------------------------------------------------------- + + 'showProgressBar': function () { + var progressBarElement; + + this.getElement('container').innerHTML = ''; + + progressBarElement = this.append(this.getElement('container'), {tag:'div', cls:'progressBarWrapper'}); + this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':progressBarElement})); + + if (this.canCancelWhileProcessing() == true) { + this.setButtons([{text:"Cancel", result:'CANCEL'}]); + } else { + this.setButtons([]); + } + }, + + //------------------------------------------------------------------------- + + 'showFailure': function (someParameters) { +// this.setType('ALERT'); + this.setType(someParameters['type']); +// this.setTitle("Login failed"); + this.setTitle(someParameters['title']); +// this.setText("Wrong passphrase; the unlock has failed."); + this.setText(someParameters['text']); +// this.getElement('container').innerHTML = ''; + this.getElement('container').innerHTML = ''; +// this.setButtons([{text:"Close", result:'CANCEL', isDefault:true}]); + this.setButtons(someParameters['buttons']); + }, + + //------------------------------------------------------------------------- + + 'closeOk': function () { +//console.log("=== closeOk"); + this.showProgressBar(); + MochiKit.Async.callLater(0.5, MochiKit.Base.method(this.deferred(), 'callback')); + this._deferred = null; + }, + + 'closeCancel': function () { +//console.log("=== closeCancel"); + this.deferredHideModal({closeToElement:this.onCancelCloseToElement()}); + this.deferred().cancel(); + this._deferred = null; + }, + + //------------------------------------------------------------------------- + + 'deferredDone': function () { +//console.log("=== deferredDone"); + return this.deferredHideModal({closeToElement:this.onOkCloseToElement()}); + }, + + 'deferredError': function (someParameters) { +//console.log("=== deferredError"); + this.showFailure(someParameters); + }, + + //------------------------------------------------------------------------- + __syntaxFix__: "syntax fix" +}); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js new file mode 100644 index 0000000..c1b4f13 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js @@ -0,0 +1,140 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library 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. + +* Javascript Crypto Library 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 Javascript Crypto Library. If not, see + . + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); + +Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay = function(anElement, args) { + args = args || {}; + +//MochiKit.Logging.logDebug(">>> new TextFormField"); + Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay.superclass.constructor.call(this, anElement, args); + + this._wrapperElement = null; + this._entropyElement = null; + + this.render(); +//MochiKit.Logging.logDebug("<<< new TextFormField"); + + return this; +}; + +Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay, Clipperz.PM.UI.Common.Components.BaseComponent, { + + 'toString': function() { + return "Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay"; + }, + + //----------------------------------------------------- + + 'wrapperElement': function() { + return this._wrapperElement; + }, + + 'setWrapperElement': function(aValue) { + this._wrapperElement = aValue; + }, + + //----------------------------------------------------- + + 'passwordElement': function() { + return this.element(); + }, + + //----------------------------------------------------- + + 'entropyElement': function() { + return this._entropyElement; + }, + + 'setEntropyElement': function(aValue) { + this._entropyElement = aValue; + }, + + //----------------------------------------------------- + + 'render': function() { +/* + MochiKit.Signal.disconnectAllTo(this); + + this.setWrapperElement(this.element().wrap({tag:'div'})); + this.setEntropyElement(Clipperz.DOM.Helper.append(this.wrapperElement().dom, {tag:'div', cls:'passwordEntropy', html:" "}, true)); +// this.setEntropyElement(Clipperz.DOM.Helper.insertBefore(this.element(), {tag:'div', cls:'passwordEntropy', html:" "}, true)); + this.entropyElement().wrap({tag:'div', cls:'passwordEntropyWrapper'}); + + this.updateEntropyElement(); + + this.connect('onkeyup', 'updateEntropyElement'); + this.connect('onchange', 'updateEntropyElement'); + this.connect('onblur', 'updateEntropyElement'); +*/ + MochiKit.Signal.disconnectAllTo(this); + + this.setEntropyElement(this.element()); + this.entropyElement().addClass("entropyLevelIndicator"); + + this.updateEntropyElement(); + + this.connect('onkeyup', 'updateEntropyElement'); + this.connect('onchange', 'updateEntropyElement'); + this.connect('onblur', 'updateEntropyElement'); + }, + + //----------------------------------------------------- + + 'computeEntropyForString': function(aValue) { + return Clipperz.PM.Crypto.passwordEntropy(aValue); + }, + + //----------------------------------------------------- + + 'updateEntropyElement': function(anEvent) { +/* +//MochiKit.Logging.logDebug(">>> PasswordEntropyDisplay.updateEntropyElement"); + var maxExtent; + var entropy; + + entropy = Math.min(128, this.computeEntropyForString(this.passwordElement().dom.value)); +//MochiKit.Logging.logDebug("--- PasswordEntropyDisplay.updateEntropyElement - entropy: " + entropy); + this.entropyElement().setStyle('background-position', "0px " + -entropy + "px"); + this.entropyElement().setWidth(this.passwordElement().getWidth() * (entropy/128)); +//MochiKit.Logging.logDebug("<<< PasswordEntropyDisplay.updateEntropyElement"); +*/ + var entropy; + + entropy = Math.min(128, this.computeEntropyForString(this.passwordElement().dom.value)); + + if (entropy == 0) { + this.entropyElement().setStyle('background-position', "0px 26px"); + } else { + this.entropyElement().setStyle('background-position', "0px -" + (128-entropy)*26 + "px"); + } + }, + + //----------------------------------------------------- + __syntaxFix__: '__syntaxFix__' +}); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/ProgressBar.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/ProgressBar.js new file mode 100644 index 0000000..7e7f8fe --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/ProgressBar.js @@ -0,0 +1,73 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library 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. + +* Javascript Crypto Library 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 Javascript Crypto Library. If not, see + . + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); + +Clipperz.PM.UI.Common.Components.ProgressBar = function(args) { + args = args || {}; + + Clipperz.PM.UI.Common.Components.ProgressBar.superclass.constructor.apply(this, arguments); + + this._element = args.element || Clipperz.Base.exception.raise('MandatoryParameter'); + + this.renderSelf(); + + MochiKit.Signal.connect(Clipperz.PM.UI.Common.Controllers.ProgressBarController.defaultController, 'updateProgress', this, 'updateProgressHandler') + + return this; +} + +//============================================================================= + +Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.ProgressBar, Clipperz.PM.UI.Common.Components.BaseComponent, { + + //------------------------------------------------------------------------- + + 'toString': function () { + return "Clipperz.PM.UI.Common.Components.ProgressBar component"; + }, + + //------------------------------------------------------------------------- + + 'renderSelf': function() { + this.append(this.element(), {tag:'div', cls:'loadingBar', children:[ + {tag:'div', cls:'loadingBarProgressBox', children:[ + {tag:'div', id:this.getId('loadingBarProgress'), cls:'loadingBarProgress'} + ]} + ]}); + }, + + //------------------------------------------------------------------------- + + 'updateProgressHandler': function (anEvent) { + MochiKit.Style.setElementDimensions(this.getId('loadingBarProgress'), {w: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 new file mode 100644 index 0000000..b9bb850 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js @@ -0,0 +1,282 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library 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. + +* Javascript Crypto Library 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 Javascript Crypto Library. If not, see + . + +*/ + +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); + } + + this._type = aValue; + }, + + //------------------------------------------------------------------------- + + '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:'body', children:[ + {tag:'div', id:this.getId('icon'), cls:'img ' + this.type(), children:[{tag:'div'}]}, + {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:[]} + ]}); + + 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'); + }, + + //------------------------------------------------------------------------- + + 'renderModalMask': function () { + Clipperz.DOM.Helper.append(MochiKit.DOM.currentDocument().body, + {tag:'div', id:this.getId('modalDialogWrapper'), cls:'modalDialogWrapper simpleMessagePanelMask', children:[ + {tag:'div', id:this.getId('modalDialogMask'), cls:'modalDialogMask simpleMessagePanelMask'}, + {tag:'div', id:this.getId('modalDialogFrame'), cls:'modalDialogFrame simpleMessagePanelMask'}, + {tag:'div', id:this.getId('modalDialog'), cls:'modalDialog simpleMessagePanelMask'} + ]} + ); + + MochiKit.Style.hideElement(this.getId('modalDialogMask')); + MochiKit.Style.hideElement(this.getId('modalDialogFrame')); + }, + + //------------------------------------------------------------------------- + + 'keyDownHandler': function (anEvent) { + if (anEvent.key().string == 'KEY_ENTER') { + anEvent.preventDefault(); +//console.log("13 - RETURN ?", this); + this.closeOk(); +//console.log('<<< 13') + } + + if (anEvent.key().string == 'KEY_ESCAPE') { + anEvent.preventDefault(); +//console.log("27 - ESC ?", this); + this.closeCancel(); +//console.log("<<< 27"); + } + }, + + //------------------------------------------------------------------------- + __syntaxFix__: "syntax fix" +}); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/TabPanelComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/TabPanelComponent.js new file mode 100644 index 0000000..afb3bf9 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/TabPanelComponent.js @@ -0,0 +1,69 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library 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. + +* Javascript Crypto Library 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 Javascript Crypto Library. If not, see + . + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); + +Clipperz.PM.UI.Common.Components.TabPanelComponent = function(args) { + args = args || {}; + Clipperz.PM.UI.Common.Components.TabPanelComponent.superclass.constructor.call(this, args); + + this._tabPanelController = null; + + return this; +} + +//============================================================================= + +Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.TabPanelComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { + + 'toString': function () { + return "Clipperz.PM.UI.Common.Components.TabPanelComponent component"; + }, + + //------------------------------------------------------------------------- + + 'tabPanelControllerConfiguration': function() { + return this._tabPanelControllerConfiguration; + }, + + 'tabPanelController': function() { + if (this._tabPanelController == null) { + this._tabPanelController = new Clipperz.PM.UI.Common.Controllers.TabPanelController({component:this, configuration:this.tabPanelControllerConfiguration()}); + } + + return this._tabPanelController; + }, + + 'initiallySelectedTab': function() { + return this._initiallySelectedTab; + }, + + //------------------------------------------------------------------------- + __syntaxFix__: "syntax fix" + +}); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js new file mode 100644 index 0000000..7507b86 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js @@ -0,0 +1,216 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library 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. + +* Javascript Crypto Library 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 Javascript Crypto Library. If not, see + . + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); + +Clipperz.PM.UI.Common.Components.Tooltip = function(args) { + args = args || {}; + + Clipperz.PM.UI.Common.Components.Tooltip.superclass.constructor.apply(this, arguments); + + this._element = args.element || Clipperz.Base.exception.raise('MandatoryParameter'); + this._text = args.text || Clipperz.Base.exception.raise('MandatoryParameter'); + this._position = args.position || 'BELOW'; // 'BELOW', 'ABOVE', 'LEFT', 'RIGHT' + + this._boxDimensions = null; + this._enabled = (typeof(args.enabled) == 'undefined' ? true : args.enabled); + this._isVisible = false; + + this.renderSelf(); + + return this; +} + +//============================================================================= + +Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.Tooltip, Clipperz.PM.UI.Common.Components.BaseComponent, { + + //------------------------------------------------------------------------- + + 'toString': function () { + return "Clipperz.PM.UI.Common.Components.Tooltip component"; + }, + + //------------------------------------------------------------------------- + + 'text': function () { + return this._text; + }, + + 'setText': function (aValue) { + this._text = aValue; + }, + + //------------------------------------------------------------------------- + + 'position': function () { + return this._position; + }, + + 'setPosition': function (aValue) { + this._position = aValue; + }, + + //------------------------------------------------------------------------- + + 'enabled': function () { + return this._enabled; + }, + + 'setIsEnabled': function (aValue) { + this._enabled = aValue; + }, + + //------------------------------------------------------------------------- + + 'isVisible': function () { + return this._isVisible; + }, + + 'setIsVisible': function (aValue) { + this._isVisible = aValue; + }, + + //------------------------------------------------------------------------- + + 'renderSelf': function() { +// this.append(this.element(), {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[ +// this.append(MochiKit.DOM.currentDocument().body, {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[ + this.append(MochiKit.DOM.getElement('Clipperz_PM_UI_Common_Components_Tooltip_wrapperNode'), {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[ + {tag:'div', id:this.getId('body'), cls:'tooltip_body', children:[ + {tag:'div', cls:'tooltip_text', children:[ + {tag:'span', html:this.text()} + ]}, + {tag:'div', id:this.getId('footer'), cls:'tooltip_footer'} + ]}, + {tag:'div', id:this.getId('arrow'), cls:'tooltip_arrow'} + ]}); + + this._boxDimensions = MochiKit.Style.getElementDimensions(this.getId('body')); +// this._boxDimensions.h += MochiKit.Style.getElementDimensions(this.getId('footer')).h; + + MochiKit.Style.hideElement(this.displayElement()); + MochiKit.Signal.connect(this.element(), 'onmouseenter', this, 'show'); + MochiKit.Signal.connect(this.element(), 'onmouseleave', this, 'hide'); + }, + + //----------------------------------------------------- + + 'displayElement': function() { + return this.getElement('tooltip'); + }, + + //------------------------------------------------------------------------- + + 'boxDimensions': function () { + return this._boxDimensions; + }, + + //------------------------------------------------------------------------- + + 'show': function () { + var elementSizeAndPosition; + var arrowPosition; + var bodyPosition; + + if (this.isVisible() == false) { + arrowPosition = {}; + bodyPosition = {}; + + this.setIsVisible(true); + elementSizeAndPosition = Clipperz.Style.getSizeAndPosition(this.element()); +//console.log("ELEMENT SIZE AND POSITION", Clipperz.Base.serializeJSON(elementSizeAndPosition)); +//console.log("BOX DIMENSIONS", Clipperz.Base.serializeJSON(this.boxDimensions())); + switch (this.position()) { + case 'ABOVE': +//console.log("ABOVE"); + MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); + bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); + bodyPosition.y = elementSizeAndPosition.position.y - this.boxDimensions().h - 13; + + arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); + arrowPosition.y = elementSizeAndPosition.position.y - 13; + break; + case 'BELOW': +//console.log("BELOW"); + MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); + bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); + bodyPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h + 13; + + arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); + arrowPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h; + break; + case 'LEFT': +//console.log("LEFT"); + MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px'); + bodyPosition.x = elementSizeAndPosition.position.x - this.boxDimensions().w - 13; + bodyPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - this.boxDimensions().h/2); + + arrowPosition.x = elementSizeAndPosition.position.x -13; + arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2); + break; + case 'RIGHT': +//console.log("RIGHT"); + MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px'); + bodyPosition.x = elementSizeAndPosition.position.x + elementSizeAndPosition.dimensions.w + 13; + bodyPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - this.boxDimensions().h/2); + + arrowPosition.x = elementSizeAndPosition.position.x + elementSizeAndPosition.dimensions.w; + arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2); + break; + } +//console.log("X: " + bodyPosition.x + ", Y: " + bodyPosition.y); + + MochiKit.Style.setElementPosition(this.getId('body'), bodyPosition); + MochiKit.Style.setElementPosition(this.getId('arrow'), arrowPosition); + MochiKit.Visual.appear(this.displayElement(), {duration:0.4}); + } + }, + + 'hide': function () { + if (this.isVisible() == true) { + MochiKit.Visual.fade(this.displayElement(), {duration:0.4}); + this.setIsVisible(false); + } + }, + + //------------------------------------------------------------------------- +/* + 'shouldRemoveElementWhenClearningUp': function () { + return false; + }, +*/ + //------------------------------------------------------------------------- + __syntaxFix__: "syntax fix" +}); + +Clipperz.PM.UI.Common.Components.Tooltip.initTooltips = function () { + Clipperz.DOM.Helper.insertBefore(MochiKit.DOM.currentDocument().body.childNodes[0], {tag:'div', id:'Clipperz_PM_UI_Common_Components_Tooltip_wrapperNode'}); +} + +MochiKit.DOM.addLoadEvent(Clipperz.PM.UI.Common.Components.Tooltip.initTooltips); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/TranslatorWidget.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/TranslatorWidget.js new file mode 100644 index 0000000..c31969e --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/TranslatorWidget.js @@ -0,0 +1,170 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library 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. + +* Javascript Crypto Library 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 Javascript Crypto Library. If not, see + . + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); + +Clipperz.PM.UI.Common.Components.TranslatorWidget = function(args) { +Clipperz.log(">>> TranslatorWidget.new"); + args = args || {}; + + Clipperz.PM.UI.Common.Components.TranslatorWidget.superclass.constructor.apply(this, arguments); + +// this._element = args.element || Clipperz.Base.exception.raise('MandatoryParameter'); +// this._stringID = args.stringID || MochiKit.DOM.getNodeAttribute(this.element(), 'stringID') || Clipperz.Base.exception.raise('MandatoryParameter'); + +// MochiKit.Signal.connect(this.element(), 'onmouseenter', this, 'show'); +// MochiKit.Signal.connect(this.element(), 'onmouseleave', this, 'hide'); + +Clipperz.log("<<< TranslatorWidget.new"); + return this; +} + +//============================================================================= + +Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.TranslatorWidget, Clipperz.PM.UI.Common.Components.BaseComponent, { + + //------------------------------------------------------------------------- + + 'toString': function () { + return "Clipperz.PM.UI.Common.Components.TranslatorWidget component"; + }, + + //------------------------------------------------------------------------- +/* + 'renderSelf': function() { + this.append(this.element(), {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[ + {tag:'div', id:this.getId('body'), cls:'tooltip_body', children:[ + {tag:'div', cls:'tooltip_text', children:[ + {tag:'span', html:this.text()} + ]}, + {tag:'div', id:this.getId('footer'), cls:'tooltip_footer'} + ]}, + {tag:'div', id:this.getId('arrow'), cls:'tooltip_arrow'} + ]}); + + this._boxDimensions = MochiKit.Style.getElementDimensions(this.getId('body')); +// this._boxDimensions.h += MochiKit.Style.getElementDimensions(this.getId('footer')).h; + + MochiKit.Style.hideElement(this.displayElement()); + MochiKit.Signal.connect(this.element(), 'onmouseenter', this, 'show'); + MochiKit.Signal.connect(this.element(), 'onmouseleave', this, 'hide'); + }, +*/ + //----------------------------------------------------- +/* + 'displayElement': function() { + return this.getElement('tooltip'); + }, +*/ + //------------------------------------------------------------------------- +/* + 'boxDimensions': function () { + return this._boxDimensions; + }, +*/ + //------------------------------------------------------------------------- + + 'show': function (anElement, aStringID) { + Clipperz.log(">>> Clipperz.PM.UI.Common.Components.TranslatorWidget.show: " + aStringID); +/* + var elementSizeAndPosition; + var arrowPosition; + var bodyPosition; + + arrowPosition = {}; + bodyPosition = {}; + + elementSizeAndPosition = Clipperz.Style.getSizeAndPosition(this.element()); + switch (this.position()) { + case 'ABOVE': + MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); + bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); + bodyPosition.y = elementSizeAndPosition.position.y - this.boxDimensions().h - 13; + + arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); + arrowPosition.y = elementSizeAndPosition.position.y - 13; + break; + case 'BELOW': + MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); + bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); + bodyPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h + 13; + + arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); + arrowPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h; + break; + case 'LEFT': + MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px'); + bodyPosition.x = elementSizeAndPosition.position.x - this.boxDimensions().w - 13; + bodyPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - this.boxDimensions().h/2); + + arrowPosition.x = elementSizeAndPosition.position.x -13; + arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2); + break; + case 'RIGHT': + MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px'); + break; + } + +// MochiKit.Style.setElementPosition(this.getId('body'), bodyPosition); + MochiKit.Style.setElementPosition(this.getId('body'), bodyPosition); + MochiKit.Style.setElementPosition(this.getId('arrow'), arrowPosition); + MochiKit.Visual.appear(this.displayElement(), {duration:0.4}); +*/ + }, + + //------------------------------------------------------------------------- + + 'hide': function () { + Clipperz.log("<<< Clipperz.PM.UI.Common.Components.TranslatorWidget.hide"); +// MochiKit.Visual.fade(this.displayElement(), {duration:0.4}); + }, + + //------------------------------------------------------------------------- + __syntaxFix__: "syntax fix" +}); + +//############################################################################# + +Clipperz.PM.UI.Common.Components.TranslatorWidget._widget = null; + +Clipperz.PM.UI.Common.Components.TranslatorWidget.widget = function () { + if (Clipperz.PM.UI.Common.Components.TranslatorWidget._widget == null) { + Clipperz.PM.UI.Common.Components.TranslatorWidget._widget = new Clipperz.PM.UI.Common.Components.TranslatorWidget(); + } + + return Clipperz.PM.UI.Common.Components.TranslatorWidget._widget; +} +Clipperz.PM.UI.Common.Components.TranslatorWidget.show = function (anElement, aStringID) { + Clipperz.PM.UI.Common.Components.TranslatorWidget.widget().show(anElement, aStringID); +} + +Clipperz.PM.UI.Common.Components.TranslatorWidget.hide = function () { + Clipperz.PM.UI.Common.Components.TranslatorWidget.widget().hide(); +} + +//############################################################################# -- cgit v0.9.0.2