1
0
mirror of http://git.whoc.org.uk/git/password-manager.git synced 2025-10-29 10:27:35 +01:00

First version of the newly restructured repository

This commit is contained in:
Giulio Cesare Solaroli
2011-10-03 00:56:18 +01:00
parent 597ecfbc02
commit ef68436ac0
729 changed files with 232898 additions and 0 deletions

View File

@@ -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
<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, {
'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);

View File

@@ -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
<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:[
{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"
});

View File

@@ -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
<http://www.gnu.org/licenses/>.
*/
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"
});

View File

@@ -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
<http://www.gnu.org/licenses/>.
*/
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"
});

View File

@@ -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
<http://www.gnu.org/licenses/>.
*/
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"
});

View File

@@ -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
<http://www.gnu.org/licenses/>.
*/
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:"&nbsp;"}, true));
// this.setEntropyElement(Clipperz.DOM.Helper.insertBefore(this.element(), {tag:'div', cls:'passwordEntropy', html:"&nbsp;"}, 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__'
});

View File

@@ -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
<http://www.gnu.org/licenses/>.
*/
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"
});

View File

@@ -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
<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);
}
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"
});

View File

@@ -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
<http://www.gnu.org/licenses/>.
*/
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"
});

View File

@@ -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
<http://www.gnu.org/licenses/>.
*/
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);

View File

@@ -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
<http://www.gnu.org/licenses/>.
*/
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();
}
//#############################################################################

View File

@@ -0,0 +1,267 @@
/*
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
<http://www.gnu.org/licenses/>.
*/
Clipperz.Base.module('Clipperz.PM.UI.Common.Controllers');
Clipperz.PM.UI.Common.Controllers.DirectLoginRunner = function(args) {
this._directLogin = args['directLogin'] || Clipperz.Base.exception.raise('MandatoryParameter');
this._target = Clipperz.PM.Crypto.randomKey();
return this;
}
MochiKit.Base.update(Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.prototype, {
'toString': function() {
return "Clipperz.PM.UI.Common.Controllers.DirectLoginRunner";
},
//-----------------------------------------------------------------------------
'directLogin': function () {
return this._directLogin;
},
//-----------------------------------------------------------------------------
'target': function () {
return this._target;
},
//=============================================================================
'setWindowTitle': function (aWindow, aTitle) {
aWindow.document.title = aTitle;
},
'setWindowBody': function (aWindow, anHTML) {
aWindow.document.body.innerHTML = anHTML;
},
//=============================================================================
'initialWindowSetup': function (aWindow) {
this.setWindowTitle(aWindow, "Loading Clipperz Direct Login");
this.setWindowBody (aWindow, MochiKit.DOM.toHTML(MochiKit.DOM.H3("Loading Clipperz Direct Login ...")));
},
//-----------------------------------------------------------------------------
'updateWindowWithDirectLoginLabel': function (aWindow, aLabel) {
var titleText;
var bodyText;
titleText = "Loading '__label__' Direct Login".replace(/__label__/, aLabel)
bodyText = "Loading '__label__' Direct Login... ".replace(/__label__/, aLabel)
this.setWindowTitle(aWindow, titleText);
this.setWindowBody (aWindow, MochiKit.DOM.toHTML(MochiKit.DOM.H3(bodyText)));
},
//-----------------------------------------------------------------------------
'updateWindowWithHTMLContent': function (aWindow, anHtml) {
this.setWindowBody(aWindow, anHtml);
},
//=============================================================================
'submitLoginForm': function(aWindow, aSubmitFunction) {
MochiKit.DOM.withWindow(aWindow, MochiKit.Base.bind(function () {
var formElement;
var submitButtons;
formElement = MochiKit.DOM.getElement('directLoginForm');
submitButtons = MochiKit.Base.filter(function(anInputElement) {
return ((anInputElement.tagName.toLowerCase() == 'input') && (anInputElement.getAttribute('type').toLowerCase() == 'submit'));
}, formElement.elements);
if (submitButtons.length == 0) {
if (typeof(formElement.submit) == 'function') {
formElement.submit();
} else {
aSubmitFunction.apply(formElement);
}
/*
var formSubmitFunction;
formSubmitFunction = MochiKit.Base.method(formElement, 'submit');
if (Clipperz_IEisBroken == true) {
formElement.submit();
} else {
formSubmitFunction();
}
*/
} else {
submitButtons[0].click();
}
}, this));
},
//-------------------------------------------------------------------------
'runSubmitFormDirectLogin': function (aWindow, someAttributes) {
var html;
var formElement;
var submitFunction;
formElement = MochiKit.DOM.FORM({
'id':'directLoginForm',
'method':someAttributes['formAttributes']['method'],
'action':someAttributes['formAttributes']['action']
});
submitFunction = formElement.submit;
MochiKit.DOM.appendChildNodes(formElement, MochiKit.Base.map(function (anInputAttributes) {
return MochiKit.DOM.INPUT({'type':'hidden', 'name':anInputAttributes[0], 'value':anInputAttributes[1]});
}, MochiKit.Base.items(someAttributes['inputValues'])));
html = '';
html += '<h3>Loading ' + someAttributes['label'] + ' ...</h3>';
html += MochiKit.DOM.appendChildNodes(MochiKit.DOM.DIV(), MochiKit.DOM.appendChildNodes(MochiKit.DOM.DIV({style:'display:none; visibility:hidden;'}), formElement)).innerHTML;
this.updateWindowWithHTMLContent(aWindow, html);
this.submitLoginForm(aWindow, submitFunction);
},
//-------------------------------------------------------------------------
'runHttpAuthDirectLogin': function(aWindow, someAttributes) {
var completeUrl;
var url;
//console.log("runHttpAuthDirectLogin", someAttributes);
url = someAttributes['inputValues']['url'];
if (/^https?\:\/\//.test(url) == false) {
url = 'http://' + url;
}
if (Clipperz_IEisBroken === true) {
completeUrl = url;
} else {
var username;
var password;
username = someAttributes['inputValues']['username'];
password = someAttributes['inputValues']['password'];
/(^https?\:\/\/)?(.*)/.test(url);
completeUrl = RegExp.$1 + username + ':' + password + '@' + RegExp.$2;
}
window.open(completeUrl, this.target());
},
//=============================================================================
'runDirectLogin': function (aWindow) {
var deferredResult;
//console.log(">>> runDirectLogin");
deferredResult = new Clipperz.Async.Deferred("DirectLoginRunner.openDirectLogin", {trace:false});
deferredResult.addMethod(this, 'initialWindowSetup', aWindow);
deferredResult.addMethod(this.directLogin(), 'label');
deferredResult.addMethod(this, 'updateWindowWithDirectLoginLabel', aWindow);
deferredResult.collectResults({
'type': MochiKit.Base.method(this.directLogin(), 'type'),
'label': MochiKit.Base.method(this.directLogin(), 'label'),
'formAttributes': MochiKit.Base.method(this.directLogin(), 'formAttributes'),
'inputValues': MochiKit.Base.method(this.directLogin(), 'inputValues')
});
//deferredResult.addCallback(function (aValue) { console.log("SOME ATTRIBUTES", aValue); return aValue; });
deferredResult.addCallback(MochiKit.Base.bind(function (someAttributes) {
//console.log("SOME ATTRIBUTES", someAttributes);
switch (someAttributes['type']) {
case 'http_auth':
this.runHttpAuthDirectLogin(aWindow, someAttributes);
break;
case 'simple_url':
this.runSimpleUrlDirectLogin(aWindow, someAttributes);
break;
default:
this.runSubmitFormDirectLogin(aWindow, someAttributes);
break;
}
}, this));
deferredResult.callback();
//console.log("<<< runDirectLogin");
return deferredResult;
},
//=============================================================================
'run': function () {
var newWindow;
newWindow = window.open(Clipperz.PM.Strings.getValue('directLoginJumpPageUrl'), this.target());
return this.runDirectLogin(newWindow);
},
//=============================================================================
'test': function () {
var iFrame;
var newWindow;
iFrame = MochiKit.DOM.createDOM('iframe');
MochiKit.DOM.appendChildNodes(MochiKit.DOM.currentDocument().body, iFrame);
newWindow = iFrame.contentWindow;
return this.runDirectLogin(newWindow);
},
//=============================================================================
__syntaxFix__: "syntax fix"
});
//-----------------------------------------------------------------------------
Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.openDirectLogin = function (aDirectLogin) {
var runner;
runner = new Clipperz.PM.UI.Common.Controllers.DirectLoginRunner({directLogin:aDirectLogin});
return runner.run();
};
//-----------------------------------------------------------------------------
Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.testDirectLogin = function (aDirectLogin) {
var runner;
//console.log(">>>>>> TESTING DIRECT LOGIN");
runner = new Clipperz.PM.UI.Common.Controllers.DirectLoginRunner({directLogin:aDirectLogin});
return runner.test();
};
//-----------------------------------------------------------------------------

View File

@@ -0,0 +1,143 @@
/*
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
<http://www.gnu.org/licenses/>.
*/
Clipperz.Base.module('Clipperz.PM.UI.Common.Controllers');
Clipperz.PM.UI.Common.Controllers.ProgressBarController = function(args) {
args = args || {};
this._numberOfSteps = 0;
this._currentStep = 0;
MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'initProgress', this, 'initProgressHandle');
MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'updateProgress', this, 'updateProgressHandle');
MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'advanceProgress', this, 'advanceProgressHandle');
MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'progressDone', this, 'progressDoneHandle');
return this;
}
MochiKit.Base.update(Clipperz.PM.UI.Common.Controllers.ProgressBarController.prototype, {
'toString': function() {
return "Clipperz.PM.UI.Common.Controllers.ProgressBarController";
},
//-----------------------------------------------------------------------------
'numberOfSteps': function() {
return this._numberOfSteps;
},
'setNumberOfSteps': function (aValue) {
this._numberOfSteps = aValue;
},
'updateNumberOfSteps': function (aValue) {
this._numberOfSteps += aValue;
},
//-----------------------------------------------------------------------------
'currentStep': function() {
return this._currentStep;
},
'advanceCurrentStep': function () {
this._currentStep ++;
},
//-----------------------------------------------------------------------------
'completedPercentage': function () {
var result;
//Clipperz.log(">>> completedPercentage" + this.currentStep() + "/" + this.numberOfSteps(), this.currentStep() / this.numberOfSteps());
if (this.numberOfSteps() == 0) {
result = 0;
} else {
result = (Math.min(100, 100 * (this.currentStep() / this.numberOfSteps())));
}
//Clipperz.log("<<< completedPercentage", result);
return result;
},
//-----------------------------------------------------------------------------
'resetStatus': function () {
this._numberOfSteps = 0;
this._currentStep = 0;
},
//-----------------------------------------------------------------------------
'updateProgress': function () {
//Clipperz.log(">>> updateProgress: " + this.completedPercentage() + "%");
MochiKit.Signal.signal(this, 'updateProgress', this.completedPercentage());
},
//=============================================================================
'initProgressHandle': function (anEvent) {
//Clipperz.log(">>> initProgressHandle - steps: " + (anEvent != null ? anEvent['steps'] : 0));
this.resetStatus();
if (anEvent != null) {
this.setNumberOfSteps(anEvent['steps']);
}
MochiKit.Signal.signal(this, 'initProgress');
this.updateProgress();
},
//.............................................................................
'updateProgressHandle': function (anEvent) {
this.updateNumberOfSteps(anEvent['extraSteps']);
//Clipperz.log("=== updateProgressHandle - steps: " + this.numberOfSteps() + " (extra " + anEvent['extraSteps'] + ")");
this.updateProgress();
},
//.............................................................................
'advanceProgressHandle': function (anEvent) {
this.advanceCurrentStep();
//Clipperz.log("--- advanceProgressHandle: " + this.currentStep() + "/" + this.numberOfSteps());
this.updateProgress();
},
//.............................................................................
'progressDoneHandle': function (anEvent) {
//Clipperz.log("<<< progressDoneHandle: " + this.currentStep() + "/" + this.numberOfSteps());
this.resetStatus();
MochiKit.Signal.signal(this, 'progressDone');
},
//=============================================================================
__syntaxFix__: "syntax fix"
});
Clipperz.PM.UI.Common.Controllers.ProgressBarController.defaultController = new Clipperz.PM.UI.Common.Controllers.ProgressBarController();

View File

@@ -0,0 +1,188 @@
/*
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
<http://www.gnu.org/licenses/>.
*/
Clipperz.Base.module('Clipperz.PM.UI.Common.Controllers');
Clipperz.PM.UI.Common.Controllers.TabPanelController = function(args) {
args = args || {};
this._component = args.component;
this._configuration = args.configuration;
this._isEnabled = args.enabled || true;
this._selectedTab = null;
return this;
}
MochiKit.Base.update(Clipperz.PM.UI.Common.Controllers.TabPanelController.prototype, {
'toString': function() {
return "Clipperz.PM.UI.Common.Controllers.TabPanelController";
},
//-----------------------------------------------------------------------------
'component': function() {
return this._component;
},
'configuration': function() {
return this._configuration;
},
//-----------------------------------------------------------------------------
'getElement': function(anElementID) {
return this.component().getElement(anElementID);
},
'tabForTabElement': function(anElement) {
var result;
for (result in this.configuration()) {
if (this.getElement(this.configuration()[result]['tab']) == anElement) {
break;
}
}
return result;
},
//-----------------------------------------------------------------------------
'setupTab': function(aConfiguration) {
var tabElement;
tabElement = this.getElement(aConfiguration['tab']);
MochiKit.DOM.removeElementClass(tabElement, 'selected');
MochiKit.Signal.connect(tabElement, 'onclick', this, 'handleTabClick')
},
'setupPanel': function(aConfiguration) {
this.hidePanel(aConfiguration['panel']);
},
'setup': function(args) {
args = args || {};
MochiKit.Base.map(MochiKit.Base.method(this, 'setupTab'), MochiKit.Base.values(this.configuration()));
MochiKit.Base.map(MochiKit.Base.method(this, 'setupPanel'), MochiKit.Base.values(this.configuration()));
this.selectTab(args.selected);
},
//-----------------------------------------------------------------------------
'hidePanel': function(aPanel) {
MochiKit.DOM.removeElementClass(this.getElement(aPanel), 'selected');
},
'selectTab': function(aTab) {
if ((aTab != this.selectedTab()) && (this.isEnabled())) {
if (this.selectedTab() != null) {
MochiKit.DOM.removeElementClass(this.getElement(this.configuration()[this.selectedTab()]['tab']), 'selected');
MochiKit.DOM.removeElementClass(this.getElement(this.configuration()[this.selectedTab()]['panel']), 'selected');
}
if (aTab != null) {
MochiKit.DOM.addElementClass(this.getElement(this.configuration()[aTab]['tab']), 'selected');
MochiKit.DOM.addElementClass(this.getElement(this.configuration()[aTab]['panel']), 'selected');
}
this.setSelectedTab(aTab);
MochiKit.Signal.signal(this, 'tabSelected', aTab);
}
},
//-----------------------------------------------------------------------------
'selectedTab': function() {
return this._selectedTab;
},
'setSelectedTab': function(aTab) {
this._selectedTab = aTab;
},
//-----------------------------------------------------------------------------
'selectedTabElement': function() {
var result;
if (this.selectedTab() != null) {
result = this.getElement(this.configuration()[this.selectedTab()]['tab']);
} else {
result = null;
}
return null;
},
'selectedTabPanelElement': function() {
var result;
if (this.selectedTab() != null) {
result = this.getElement(this.configuration()[this.selectedTab()]['panel']);
} else {
result = null;
}
return result;
},
//-----------------------------------------------------------------------------
'handleTabClick': function(anEvent) {
this.selectTab(this.tabForTabElement(anEvent.src()));
anEvent.preventDefault();
},
//=============================================================================
'isEnabled': function () {
return this._isEnabled;
},
'enable': function () {
this._isEnabled = true;
MochiKit.Base.map(MochiKit.Base.bind(function (aTabComponentID) {
MochiKit.DOM.removeElementClass(this.getElement(this.configuration()[aTabComponentID]['tab']), 'disabled');
}, this), MochiKit.Base.keys(this.configuration()));
},
'disable': function () {
this._isEnabled = false;
MochiKit.Base.map(MochiKit.Base.bind(function (aTabComponentID) {
MochiKit.DOM.addElementClass(this.getElement(this.configuration()[aTabComponentID]['tab']), 'disabled');
}, this), MochiKit.Base.keys(this.configuration()));
},
//=============================================================================
__syntaxFix__: "syntax fix"
});

View File

@@ -0,0 +1,31 @@
/*
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
<http://www.gnu.org/licenses/>.
*/
// Still empty, but here it should be reasonable to factor in code duplicated between
// - DirectLoginWizardController
// - NewUserWizardController