summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js
Side-by-side diff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js23
1 files changed, 10 insertions, 13 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js
index effde31..b1ff81f 100644
--- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js
@@ -1,118 +1,116 @@
/*
-Copyright 2008-2011 Clipperz Srl
+Copyright 2008-2013 Clipperz Srl
-This file is part of Clipperz Community Edition.
-Clipperz Community Edition is an online password manager.
+This file is part of Clipperz, the online password manager.
For further information about its features and functionalities please
refer to http://www.clipperz.com.
-* Clipperz Community Edition is free software: you can redistribute
- it and/or modify it under the terms of the GNU Affero General Public
- License as published by the Free Software Foundation, either version
- 3 of the License, or (at your option) any later version.
+* Clipperz is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
-* Clipperz Community Edition is distributed in the hope that it will
- be useful, but WITHOUT ANY WARRANTY; without even the implied
- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* Clipperz is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
- License along with Clipperz Community Edition. If not, see
- <http://www.gnu.org/licenses/>.
+ License along with Clipperz. If not, see http://www.gnu.org/licenses/.
*/
Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers');
Clipperz.PM.UI.Web.Controllers.CardDialogController = function(args) {
args = args || {};
Clipperz.PM.UI.Web.Controllers.CardDialogController.superclass.constructor.call(this, args);
this._record = args.record || Clipperz.Base.exception.raise('MandatoryParameter');
this._delegate = args.delegate || Clipperz.Base.exception.raise('MandatoryParameter');
this._referenceElement = null;
this._cardDialogComponent = null;
this._fieldsReferences = {};
this._directLoginReferences = {};
this._directLoginWizardController = null;
this._directLoginEditingComponent = null;
this._isDirectLoginEditingComponentVisible = false;
return this;
};
Clipperz.Base.extend(Clipperz.PM.UI.Web.Controllers.CardDialogController, Object, {
'toString': function() {
return "Clipperz.PM.UI.Web.Controllers.CardDialogController";
},
//-------------------------------------------------------------------------
'record': function () {
return this._record;
},
'delegate': function () {
return this._delegate;
},
//-------------------------------------------------------------------------
'fieldsReferences': function () {
return this._fieldsReferences;
},
'directLoginReferences': function () {
return this._directLoginReferences;
},
//-------------------------------------------------------------------------
'referenceElement': function () {
return this._referenceElement;
},
'setReferenceElement': function (anElement) {
this._referenceElement = anElement;
},
//-------------------------------------------------------------------------
'cardDialogComponent': function () {
if (this._cardDialogComponent == null) {
this._cardDialogComponent = new Clipperz.PM.UI.Web.Components.CardDialogComponent();
MochiKit.Signal.connect(this._cardDialogComponent, 'cancel', this, 'handleCancel');
MochiKit.Signal.connect(this._cardDialogComponent, 'save', this, 'handleSave');
MochiKit.Signal.connect(this._cardDialogComponent, 'addField', this, 'handleAddField');
MochiKit.Signal.connect(this._cardDialogComponent, 'changedValue', this, 'handleChangedValue');
MochiKit.Signal.connect(this._cardDialogComponent, 'addDirectLogin',this, 'handleAddDirectLogin');
MochiKit.Signal.connect(this._cardDialogComponent, 'keyPressed', this, 'handleCardDialogComponentKeyPressed');
}
return this._cardDialogComponent;
},
//=========================================================================
'directLoginWizardController': function () {
if (this._directLoginWizardController == null) {
this._directLoginWizardController = new Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController({
'cardLabel': this.cardDialogComponent().title(),
'directLoginEditingComponent': this.directLoginEditingComponent()
})
MochiKit.Signal.connect(this._directLoginWizardController, 'exit', this, 'handleHideDirectLoginEditingComponent');
MochiKit.Signal.connect(this._directLoginWizardController, 'done', this, 'handleCompleteDirectLoginEditingComponent');
}
return this._directLoginWizardController;
},
@@ -281,193 +279,192 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Controllers.CardDialogController, Object
MochiKit.Base.method(this, 'fieldsReferences'),
MochiKit.Base.values,
MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'updateRecordFieldValues')),
MochiKit.Base.method(this, 'directLoginReferences'),
MochiKit.Base.values,
MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'updateRecordDirectLoginValues')),
MochiKit.Base.method(this.directLoginEditingComponent(), 'directLoginReference'),
MochiKit.Base.method(this.record(), 'directLoginWithReference'),
MochiKit.Base.method(this, 'updateRecordDirectLoginDetails'),
MochiKit.Base.noop
], {trace:false});
},
//-------------------------------------------------------------------------
'updateRecordFieldValues': function (aFieldReference) {
var deferredResult;
deferredResult = Clipperz.Async.callbacks('CardDialogController.updateRecordFieldValues', [
MochiKit.Base.method(aFieldReference['component'], 'label'),
MochiKit.Base.method(aFieldReference['field'], 'setLabel'),
MochiKit.Base.method(aFieldReference['component'], 'value'),
MochiKit.Base.method(aFieldReference['field'], 'setValue'),
MochiKit.Base.method(aFieldReference['component'], 'isHidden'),
MochiKit.Base.method(aFieldReference['field'], 'setIsHidden'),
MochiKit.Base.method(aFieldReference['field'], 'actionType'),
MochiKit.Base.method(aFieldReference['component'], 'setActionType')
], {trace:false});
return deferredResult;
},
//-------------------------------------------------------------------------
'updateRecordDirectLoginValues': function (aDirectLoginReference) {
var deferredResult;
deferredResult = Clipperz.Async.callbacks('CardDialogController.updateRecordDirectLoginValues', [
MochiKit.Base.method(aDirectLoginReference['component'], 'label'),
MochiKit.Base.method(aDirectLoginReference['directLogin'], 'setLabel')
], {trace:false});
return deferredResult;
},
//-------------------------------------------------------------------------
'updateRecordDirectLoginDetails': function (aDirectLogin) {
var result;
if (MochiKit.Base.isUndefinedOrNull(aDirectLogin)) {
result = MochiKit.Async.succeed();
} else {
result = Clipperz.Async.callbacks("CardDialogController.updateRecordDirectLoginDetails", [
MochiKit.Base.method(this.directLoginEditingComponent(), 'label'),
MochiKit.Base.method(aDirectLogin, 'setLabel'),
MochiKit.Base.method(this.directLoginEditingComponent(), 'favicon'),
MochiKit.Base.method(aDirectLogin, 'setFavicon')
], {trace:false});
}
return result;
},
//=========================================================================
'addField': function () {
return this.record().addField({
'label':this.cardDialogComponent().newFieldLabel(),
'value':this.cardDialogComponent().newFieldValue(),
'isHidden':this.cardDialogComponent().newFieldIsHidden()
});
},
'handleAddField': function () {
return Clipperz.Async.callbacks("CardDialogController.handleAddField", [
MochiKit.Base.method(this, 'addField'),
MochiKit.Base.method(this, 'addCardDialogComponentWithField'),
MochiKit.Base.method(this.cardDialogComponent(), 'resetNewFieldInputs'),
MochiKit.Base.method(this.cardDialogComponent(), 'fixRendering'),
MochiKit.Base.method(this, 'handleChangedValue')
], {trace:false})
},
//-------------------------------------------------------------------------
'handlePerformFieldAction': function (aFieldID, aTargetElement) {
-//console.log("### targetElement", aTargetElement);
return Clipperz.Async.callbacks("CardDialogController.handleDeleteField", [
MochiKit.Base.method(this.record(), 'fields'),
MochiKit.Base.itemgetter(aFieldID),
Clipperz.Async.collectResults("CardDialogController.handleDeleteField <collect results>", {
'value': MochiKit.Base.methodcaller('value'),
'type': MochiKit.Base.methodcaller('actionType')
}, {trace:false}),
MochiKit.Base.bind(function (someValues) {
switch (someValues['type']) {
case 'NONE':
throw "this event handler should not be triggered for fields with type 'NONE'";
break;
case 'URL':
var url;
url = someValues['value'];
if (/^https?\:\/\//.test(url) == false) {
url = 'http://' + url;
}
window.open(url);
break;
case 'EMAIL':
var url;
url = 'mailto:' + someValues['value'];
MochiKit.DOM.currentWindow().location = url;
break;
case 'PASSWORD':
//Clipperz.log("SHOW PASSWORD " + someValues['value']);
this.showPasswordTooltip(someValues['value'], aTargetElement);
break;
}
}, this)
], {trace:false});
},
//-------------------------------------------------------------------------
'handleDeleteField': function (aFieldID) {
return Clipperz.Async.callbacks("CardDialogController.handleDeleteField", [
MochiKit.Base.method(this.record(), 'fields'),
MochiKit.Base.itemgetter(aFieldID),
MochiKit.Base.method(this.record(), 'removeField'),
MochiKit.Base.method(this, 'fieldsReferences'),
MochiKit.Base.itemgetter(aFieldID),
MochiKit.Base.itemgetter('component'),
function (aComponent) {
return Clipperz.Async.callbacks("CardDialogController.handleDeleteField [fade and remove]", [
MochiKit.Base.partial(Clipperz.Visual.deferredAnimation, MochiKit.Visual.fade, aComponent.element(), {from:1.0, to:0.0, duration:0.5}),
// Clipperz.Visual.deferredAnimation(MochiKit.Visual.fade, aComponent.element(), {from:1.0, to:0.0, duration:0.5}),
MochiKit.Base.method(aComponent, 'remove')
], {trace:false});
},
MochiKit.Base.bind(function () {
delete this.fieldsReferences()[aFieldID];
}, this),
MochiKit.Base.method(this.cardDialogComponent(), 'fixRendering'),
MochiKit.Base.method(this, 'handleChangedValue')
], {trace:false});
},
//=========================================================================
'handleDeleteDirectLogin': function(aDirectLoginReference) {
var cardDialogComponent;
cardDialogComponent = this.cardDialogComponent();
return Clipperz.Async.callbacks("CardDialogController.handleDeleteDirectLogin", [
MochiKit.Base.method(this.record(), 'directLogins'),
MochiKit.Base.itemgetter(aDirectLoginReference),
MochiKit.Base.methodcaller('remove'),
MochiKit.Base.method(this, 'directLoginReferences'),
MochiKit.Base.itemgetter(aDirectLoginReference),
MochiKit.Base.itemgetter('component'),
function (aComponent) {
return Clipperz.Async.callbacks("CardDialogController.handleDeleteDirectLogin [fade and remove]", [
MochiKit.Base.partial(Clipperz.Visual.deferredAnimation, MochiKit.Visual.fade, aComponent.element(), {from:1.0, to:0.0, duration:0.5}),// Clipperz.Visual.deferredAnimation(MochiKit.Visual.fade, aComponent.element(), {from:1.0, to:0.0, duration:0.5}),
/// MochiKit.Base.method(aComponent, 'remove')
MochiKit.Base.method(cardDialogComponent, 'removeDirectLoginComponent', aComponent)
], {trace:false});
},
MochiKit.Base.bind(function () {
delete this.directLoginReferences()[aDirectLoginReference];
}, this),
MochiKit.Base.method(this.cardDialogComponent(), 'fixRendering'),