summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Web/Controllers') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/AppController.js329
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js652
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardsController.js207
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js611
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginsController.js145
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/FilterController.js158
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/GridController.js374
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js259
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/MainController.js218
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/NewUserWizardController.js469
10 files changed, 3422 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/AppController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/AppController.js
new file mode 100644
index 0000000..05563bf
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/AppController.js
@@ -0,0 +1,329 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers');
30
31Clipperz.PM.UI.Web.Controllers.AppController = function(args) {
32
33 this._user = null;
34 this._tabSlotNames = {
35 //tabName: slotName
36 'cards': 'cardGrid',
37 // 'directLogins':'directLoginGrid',
38 'account': 'accountPanel',
39 'data': 'dataPanel',
40 'tools': 'toolsPanel'
41 };
42
43 //controllers
44 this._cardsController= null;
45 //this._directLoginsController = null;
46 this._filterController = null; //new Clipperz.PM.UI.Web.Controllers.FilterController();
47
48 //components
49 this._appPage = null;
50 this._userInfoBox = null;
51 this._tabSidePanel = null;
52
53 // MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'editCard', this, 'handleEditCard');
54 // MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'deleteCard',this, 'handleDeleteCard');
55
56 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'userDataSuccessfullySaved',this, 'userDataSuccessfullySavedHandler');
57
58 return this;
59}
60
61MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.AppController.prototype, {
62
63 'toString': function() {
64 return "Clipperz.PM.UI.Web.Controllers.AppController";
65 },
66
67 //-----------------------------------------------------------------------------
68
69 'setUser': function(anUser) {
70 this._user = anUser;
71 },
72
73 'user': function() {
74 return this._user;
75 },
76
77 //-----------------------------------------------------------------------------
78 /*
79 'tabSlotNames': function() {
80 return this._tabSlotNames;
81 },
82*/
83 'slotNameForTab': function(aTabName) {
84 return this._tabSlotNames[aTabName];
85 },
86
87 'hideAllAppPageTabSlots': function() {
88 var aTabName;
89
90 for (aTabName in this._tabSlotNames) {
91 this.appPage().hideSlot(this.slotNameForTab(aTabName));
92 }
93 },
94
95 //-----------------------------------------------------------------------------
96
97 'appPage': function() {
98 if (this._appPage == null) {
99 this._appPage = new Clipperz.PM.UI.Web.Components.AppPage();
100 }
101
102 return this._appPage;
103 },
104
105 //-----------------------------------------------------------------------------
106
107 'tabSidePanel': function() {
108 if (this._tabSidePanel == null) {
109 this._tabSidePanel = new Clipperz.PM.UI.Web.Components.TabSidePanel();
110 }
111
112 return this._tabSidePanel;
113 },
114
115 //-----------------------------------------------------------------------------
116
117 'userInfoBox': function() {
118 if (this._userInfoBox == null) {
119 this._userInfoBox = new Clipperz.PM.UI.Web.Components.UserInfoBox();
120
121 MochiKit.Signal.connect(this._userInfoBox, 'logout',this, 'handleLogout');
122 MochiKit.Signal.connect(this._userInfoBox, 'lock', this, 'handleLock');
123 MochiKit.Signal.connect(this._userInfoBox, 'unlock',this, 'handleUnlock');
124 }
125
126 return this._userInfoBox;
127 },
128
129 //-----------------------------------------------------------------------------
130
131 'accountPanel': function () {
132 if (this._accountPanel == null) {
133 this._accountPanel = new Clipperz.PM.UI.Web.Components.AccountPanel(/*{selected:'Preferences'}*/);
134 }
135
136 return this._accountPanel;
137 },
138
139 //.........................................................................
140
141 'dataPanel': function () {
142 if (this._dataPanel == null) {
143 this._dataPanel = new Clipperz.PM.UI.Web.Components.DataPanel();
144 }
145
146 return this._dataPanel;
147 },
148
149 //.........................................................................
150
151 'toolsPanel': function () {
152 if (this._toolsPanel == null) {
153 this._toolsPanel = new Clipperz.PM.UI.Web.Components.ToolsPanel();
154 }
155
156 return this._toolsPanel;
157 },
158
159 //-----------------------------------------------------------------------------
160
161 'filterController': function () {
162 if (this._filterController == null) {
163 this._filterController = new Clipperz.PM.UI.Web.Controllers.FilterController();
164 }
165
166 return this._filterController;
167 },
168
169 'cardsController': function() {
170 if (this._cardsController == null) {
171 this._cardsController = new Clipperz.PM.UI.Web.Controllers.CardsController({'filterController':this._filterController});
172 }
173
174 return this._cardsController;
175 },
176
177 //-----------------------------------------------------------------------------
178/*
179 'directLoginsController': function() {
180//Clipperz.log(">>> AppController.directLoginsController");
181 if (this._directLoginsController == null) {
182 this._directLoginsController = new Clipperz.PM.UI.Web.Controllers.DirectLoginsController({'filterController':this._filterController});
183 }
184//Clipperz.log("<<< AppController.directLoginsController");
185
186 return this._directLoginsController;
187 },
188*/
189 //-----------------------------------------------------------------------------
190
191 'populateUserInfo': function() {
192 var deferredResult;
193
194 deferredResult = new Clipperz.Async.Deferred("AppController.populateUserInfo", {trace:false});
195 deferredResult.collectResults({
196 'username':MochiKit.Base.methodcaller('displayName'),
197 'cardsNumber':[
198 MochiKit.Base.methodcaller('getRecords'),
199 function (someResults) { return someResults.length; }
200 ],
201 'directLoginsNumber': [
202 MochiKit.Base.methodcaller('getDirectLogins'),
203 function (someResults) { return someResults.length; }
204 ]
205 })
206 deferredResult.addMethod(this.userInfoBox(), 'updateUserDetails');
207 deferredResult.callback(this.user());
208
209 return deferredResult;
210 },
211
212 //-----------------------------------------------------------------------------
213
214 'run': function(args) {
215 var deferredResult;
216 varslot;
217 varpage;
218 var user;
219
220 slot = args.slot;
221 user = args.user;
222
223 this.setUser(user);
224
225 slot.setContent(this.appPage());
226
227 this.appPage().slotNamed('userInfoBox').setContent(this.userInfoBox());
228 this.appPage().slotNamed('tabSidePanel').setContent(this.tabSidePanel());
229
230 this.appPage().slotNamed('accountPanel').setContent(this.accountPanel());
231 this.appPage().slotNamed('dataPanel').setContent(this.dataPanel());
232 this.appPage().slotNamed('toolsPanel').setContent(this.toolsPanel());
233
234 this.hideAllAppPageTabSlots();
235 this.appPage().showSlot(this.slotNameForTab('cards'));
236
237 MochiKit.Signal.connect(this.tabSidePanel(), 'tabSelected',this, 'handleTabSelected');
238 MochiKit.Signal.connect(this.tabSidePanel(), 'addCard', this, 'handleAddCard');
239 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'addCard', this, 'handleAddCard');
240
241 deferredResult = new Clipperz.Async.Deferred("AppController.run", {trace:false});
242
243 deferredResult.addMethod(this.cardsController(), 'run', {slot:this.appPage().slotNamed('cardGrid'), user:user});
244 // deferredResult.addMethod(this.directLoginsController(), 'run', {slot:this.appPage().slotNamed('directLoginGrid'), user:user});
245 deferredResult.addMethod(this, 'populateUserInfo');
246
247 deferredResult.addCallback(MochiKit.Visual.ScrollTo, 'miscLinks', {duration:0});
248 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'CARDS_CONTROLLER_DID_RUN');
249 deferredResult.addMethod(this.tabSidePanel(), 'selectTab', 'cards');
250 deferredResult.callback();
251 },
252
253 //-----------------------------------------------------------------------------
254
255 'handleTabSelected': function (selectedTabName) {
256 var aTabName;
257 var aSlotName;
258
259//Clipperz.log(">>> AppController.handleTabSelected", selectedTabName);
260 this.hideAllAppPageTabSlots();
261 this.appPage().showSlot(this.slotNameForTab(selectedTabName));
262
263 switch (selectedTabName) {
264 case 'cards':
265 this.cardsController().focus();
266 break;
267 // case 'directLogins':
268 // this.directLoginsController().focus();
269 // break;
270 case 'data':
271 break;
272 case 'account':
273 break;
274 case 'tools':
275 break;
276 }
277//Clipperz.log("<-- AppController.handleTabSelected", aTabName);
278 },
279
280 //=============================================================================
281
282 'handleAddCard': function (aSourceElement) {
283//Clipperz.log("=== AppController.addCard", aSourceElement);
284 this.cardsController().addCard(aSourceElement);
285 },
286
287 //=============================================================================
288
289 'userDataSuccessfullySavedHandler': function (anEvent) {
290 this.populateUserInfo();
291 },
292
293 //=============================================================================
294
295 'handleLogout': function(anEvent) {
296 var deferredResult;
297
298 deferredResult = new Clipperz.Async.Deferred("AppController.handleLogout", {trace:false});
299 deferredResult.addMethod(this.user(), 'logout');
300 deferredResult.addCallback(MochiKit.Signal.signal, this, 'logout');
301 deferredResult.callback();
302
303 return deferredResult;
304 },
305
306 //-----------------------------------------------------------------------------
307
308 'handleLock': function (anEvent) {
309 return Clipperz.Async.callbacks("AppController.handleLock", [
310 MochiKit.Base.method(this.cardsController(), 'deleteAllCleanTextData'),
311 MochiKit.Base.method(this.user(), 'lock')
312 ], {trace:false});
313 },
314
315 //.............................................................................
316
317 'handleUnlock': function (anEvent) {
318 return Clipperz.Async.callbacks("AppController.handleUnock", [
319 MochiKit.Base.partial(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress'),
320 MochiKit.Base.method(this.user(), 'login'),
321 MochiKit.Base.method(this.cardsController(), 'focus'),
322 MochiKit.Base.partial(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'progressDone'),
323 MochiKit.Base.method(this.userInfoBox(), 'unlock')
324 ], {trace:false});
325 },
326
327 //=============================================================================
328 __syntaxFix__: "syntax fix"
329});
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js
new file mode 100644
index 0000000..2340aeb
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js
@@ -0,0 +1,652 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers');
30
31Clipperz.PM.UI.Web.Controllers.CardDialogController = function(args) {
32 args = args || {};
33
34 Clipperz.PM.UI.Web.Controllers.CardDialogController.superclass.constructor.call(this, args);
35
36 this._record = args.record || Clipperz.Base.exception.raise('MandatoryParameter');
37 this._delegate = args.delegate || Clipperz.Base.exception.raise('MandatoryParameter');
38
39 this._referenceElement = null;
40 this._cardDialogComponent = null;
41
42 this._fieldsReferences = {};
43 this._directLoginReferences = {};
44
45 this._directLoginWizardController = null;
46 this._directLoginEditingComponent = null;
47 this._isDirectLoginEditingComponentVisible = false;
48
49 return this;
50};
51
52Clipperz.Base.extend(Clipperz.PM.UI.Web.Controllers.CardDialogController, Object, {
53
54 'toString': function() {
55 return "Clipperz.PM.UI.Web.Controllers.CardDialogController";
56 },
57
58 //-------------------------------------------------------------------------
59
60 'record': function () {
61 return this._record;
62 },
63
64 'delegate': function () {
65 return this._delegate;
66 },
67
68 //-------------------------------------------------------------------------
69
70 'fieldsReferences': function () {
71 return this._fieldsReferences;
72 },
73
74 'directLoginReferences': function () {
75 return this._directLoginReferences;
76 },
77
78 //-------------------------------------------------------------------------
79
80 'referenceElement': function () {
81 return this._referenceElement;
82 },
83
84 'setReferenceElement': function (anElement) {
85 this._referenceElement = anElement;
86 },
87
88 //-------------------------------------------------------------------------
89
90 'cardDialogComponent': function () {
91 if (this._cardDialogComponent == null) {
92 this._cardDialogComponent = new Clipperz.PM.UI.Web.Components.CardDialogComponent();
93
94 MochiKit.Signal.connect(this._cardDialogComponent, 'cancel', this, 'handleCancel');
95 MochiKit.Signal.connect(this._cardDialogComponent, 'save', this, 'handleSave');
96
97 MochiKit.Signal.connect(this._cardDialogComponent, 'addField', this, 'handleAddField');
98 MochiKit.Signal.connect(this._cardDialogComponent, 'changedValue',this, 'handleChangedValue');
99
100 MochiKit.Signal.connect(this._cardDialogComponent, 'addDirectLogin',this, 'handleAddDirectLogin');
101 MochiKit.Signal.connect(this._cardDialogComponent, 'keyPressed',this, 'handleCardDialogComponentKeyPressed');
102 }
103
104 return this._cardDialogComponent;
105 },
106
107 //=========================================================================
108
109 'directLoginWizardController': function () {
110 if (this._directLoginWizardController == null) {
111 this._directLoginWizardController = new Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController({
112 'cardLabel': this.cardDialogComponent().title(),
113 'directLoginEditingComponent': this.directLoginEditingComponent()
114 })
115
116 MochiKit.Signal.connect(this._directLoginWizardController, 'exit',this, 'handleHideDirectLoginEditingComponent');
117 MochiKit.Signal.connect(this._directLoginWizardController, 'done',this, 'handleCompleteDirectLoginEditingComponent');
118 }
119
120 return this._directLoginWizardController;
121 },
122
123 //-------------------------------------------------------------------------
124
125 'directLoginEditingComponent': function () {
126 if (this._directLoginEditingComponent == null) {
127 this._directLoginEditingComponent = new Clipperz.PM.UI.Web.Components.DirectLoginEditingComponent();
128
129 this.cardDialogComponent().renderDirectLoginEditingComponent(this._directLoginEditingComponent);
130
131 // MochiKit.Signal.connect(this._directLoginEditingComponent, 'back', this, 'handleHideDirectLoginEditingComponent')
132 // MochiKit.Signal.connect(this._directLoginEditingComponent, 'changedValue',this, 'handleChangedValue');
133 // MochiKit.Signal.connect(this.__directLoginEditingComponent, 'keyPressed',this, 'handleDirectLoginEditingComponentKeyPressed');
134 }
135
136 return this._directLoginEditingComponent;
137 },
138
139 //-------------------------------------------------------------------------
140
141 'isDirectLoginEditingComponentVisible': function () {
142 return this._isDirectLoginEditingComponentVisible;
143 },
144
145 'setIsDirectLoginEditingComponentVisible': function (aValue) {
146 this._isDirectLoginEditingComponentVisible = aValue;
147 },
148
149 //=========================================================================
150
151 'run': function (anElement) {
152 var deferredResult;
153
154 this.setReferenceElement(anElement);
155
156 deferredResult = new Clipperz.Async.Deferred("CardDialogController.run", {trace:false});
157 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':11});
158
159 deferredResult.addMethod(this.cardDialogComponent(), 'deferredShowModal', {openFromElement:this.referenceElement()});
160 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress');
161
162 deferredResult.addMethod(this.record(), 'label');
163 deferredResult.addMethod(this.cardDialogComponent(), 'setTitle');
164 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress');
165
166 deferredResult.addMethod(this, 'updateComponentState');
167 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress');
168 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'progressDone');
169
170 deferredResult.addMethod(this.cardDialogComponent(), 'fixRendering');
171 deferredResult.addMethod(this.cardDialogComponent(), 'hideProgressMask');
172
173 if (this.record().isBrandNew()) {
174 deferredResult.addMethod(this.cardDialogComponent(), 'setHintMode', 'ON');
175 deferredResult.addMethod(this.cardDialogComponent(), 'setFocusOnTitleField');
176 }
177
178 deferredResult.addErrback(MochiKit.Base.method(this.cardDialogComponent(), 'showError'));
179 deferredResult.callback();
180
181 return deferredResult;
182 },
183
184 //=========================================================================
185
186 'updateComponentState': function () {
187 return Clipperz.Async.callbacks("CardDialogController.updateComponentState", [
188 MochiKit.Base.method(this.record(), 'hasPendingChanges'),
189 MochiKit.Base.method(this.cardDialogComponent(), 'setShouldEnableSaving'),
190
191 MochiKit.Base.method(this.record(), 'label'),
192 MochiKit.Base.method(this.cardDialogComponent(), 'setTitle'),
193 MochiKit.Base.method(this.record(), 'notes'),
194 MochiKit.Base.method(this.cardDialogComponent(), 'setNotes'),
195
196 MochiKit.Base.method(this.record(), 'fields'),
197 MochiKit.Base.values,
198 MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'addCardDialogComponentWithField')),
199
200 MochiKit.Base.method(this.record(), 'directLogins'),
201 MochiKit.Base.values,
202 MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'addCardDialogComponentWithDirectLogin')),
203
204 MochiKit.Base.method(this.cardDialogComponent(), 'resetNewFieldInputs'),
205 MochiKit.Base.noop
206 ], {trace:false});
207 },
208
209 //-------------------------------------------------------------------------
210
211 'addCardDialogComponentWithField': function (aField) {
212 varfieldComponent;
213
214 fieldComponent = new Clipperz.PM.UI.Web.Components.CardDialogRecordFieldComponent({reference: aField.reference()});
215 MochiKit.Signal.connect(fieldComponent, 'changedValue',this, 'handleChangedValue');
216 MochiKit.Signal.connect(fieldComponent, 'performAction',this, 'handlePerformFieldAction');
217 MochiKit.Signal.connect(fieldComponent, 'deleteField',this, 'handleDeleteField');
218
219 // this.fieldsReferences().push({'field':aField, 'component':fieldComponent});
220 this.fieldsReferences()[aField.reference()] = {'field':aField, 'component':fieldComponent};
221
222 return Clipperz.Async.callbacks("CardDialogController.addCardDialogComponentWithField", [
223 MochiKit.Base.method(this.cardDialogComponent(), 'addFieldRowComponent', fieldComponent),
224
225 MochiKit.Base.method(aField, 'label'),
226 MochiKit.Base.method(fieldComponent, 'setLabel'),
227 MochiKit.Base.method(aField, 'value'),
228 MochiKit.Base.method(fieldComponent, 'setValue'),
229 MochiKit.Base.method(aField, 'actionType'),
230 MochiKit.Base.method(fieldComponent, 'setActionType'),
231 MochiKit.Base.method(aField, 'isHidden'),
232 MochiKit.Base.method(fieldComponent, 'setIsHidden')
233 ], {trace:false});
234 },
235
236 //-------------------------------------------------------------------------
237
238 'addCardDialogComponentWithDirectLogin': function (aDirectLogin) {
239 var directLoginComponent;
240
241 directLoginComponent = new Clipperz.PM.UI.Web.Components.CardDialogRecordDirectLoginComponent({reference: aDirectLogin.reference()});
242 MochiKit.Signal.connect(directLoginComponent, 'changedValue', this, 'handleChangedValue');
243 MochiKit.Signal.connect(directLoginComponent, 'deleteDirectLogin',this, 'handleDeleteDirectLogin');
244 MochiKit.Signal.connect(directLoginComponent, 'editDirectLogin',this, 'handleEditDirectLogin');
245 MochiKit.Signal.connect(directLoginComponent, 'openDirectLogin',this, 'handleOpenDirectLogin');
246
247 this.directLoginReferences()[aDirectLogin.reference()] = {'directLogin':aDirectLogin, 'component':directLoginComponent};
248
249 return Clipperz.Async.callbacks("CardDialogController.addCardDialogComponentWithDirectLogin", [
250 MochiKit.Base.method(this.cardDialogComponent(), 'addDirectLoginComponent', directLoginComponent),
251 MochiKit.Base.method(this, 'refreshDirectLoginComponent', this.directLoginReferences()[aDirectLogin.reference()])
252 ], {trace:false});
253 },
254
255 //-------------------------------------------------------------------------
256
257 'refreshDirectLoginComponent': function (aDirectLoginReference) {
258 return Clipperz.Async.callbacks("CardDialogController.refreshDirectLoginComponent", [
259 MochiKit.Base.method(aDirectLoginReference['directLogin'],'favicon'),
260 // MochiKit.Base.method(aDirectLoginReference['directLogin'],'faviconData'),
261 MochiKit.Base.method(aDirectLoginReference['component'],'setFavicon'),
262 MochiKit.Base.method(aDirectLoginReference['directLogin'],'label'),
263 MochiKit.Base.method(aDirectLoginReference['component'],'setLabel')
264 ], {trace:false});
265 },
266
267 'refreshDirectLoginComponents': function () {
268 return Clipperz.Async.callbacks("CardDialogController.refreshDirectLoginComponents", [
269 MochiKit.Base.method(this, 'directLoginReferences'),
270 MochiKit.Base.values,
271 MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'refreshDirectLoginComponent')),
272 Clipperz.Async.collectAll
273 ])
274 },
275
276 //-------------------------------------------------------------------------
277
278 'updateRecordValues': function () {
279 return Clipperz.Async.callbacks('CardDialogController.updateRecordValues', [
280 MochiKit.Base.method(this.cardDialogComponent(), 'title'),
281 MochiKit.Base.method(this.record(), 'setLabel'),
282 MochiKit.Base.method(this.cardDialogComponent(), 'notes'),
283 MochiKit.Base.method(this.record(), 'setNotes'),
284
285 MochiKit.Base.method(this, 'fieldsReferences'),
286 MochiKit.Base.values,
287 MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'updateRecordFieldValues')),
288
289 MochiKit.Base.method(this, 'directLoginReferences'),
290 MochiKit.Base.values,
291 MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'updateRecordDirectLoginValues')),
292
293 MochiKit.Base.method(this.directLoginEditingComponent(), 'directLoginReference'),
294 MochiKit.Base.method(this.record(), 'directLoginWithReference'),
295 MochiKit.Base.method(this, 'updateRecordDirectLoginDetails'),
296
297 MochiKit.Base.noop
298 ], {trace:false});
299 },
300
301 //-------------------------------------------------------------------------
302
303 'updateRecordFieldValues': function (aFieldReference) {
304 var deferredResult;
305
306 deferredResult = Clipperz.Async.callbacks('CardDialogController.updateRecordFieldValues', [
307 MochiKit.Base.method(aFieldReference['component'],'label'),
308 MochiKit.Base.method(aFieldReference['field'], 'setLabel'),
309
310 MochiKit.Base.method(aFieldReference['component'],'value'),
311 MochiKit.Base.method(aFieldReference['field'], 'setValue'),
312
313 MochiKit.Base.method(aFieldReference['component'],'isHidden'),
314 MochiKit.Base.method(aFieldReference['field'], 'setIsHidden'),
315
316 MochiKit.Base.method(aFieldReference['field'], 'actionType'),
317 MochiKit.Base.method(aFieldReference['component'],'setActionType')
318 ], {trace:false});
319
320 return deferredResult;
321 },
322
323 //-------------------------------------------------------------------------
324
325 'updateRecordDirectLoginValues': function (aDirectLoginReference) {
326 var deferredResult;
327
328 deferredResult = Clipperz.Async.callbacks('CardDialogController.updateRecordDirectLoginValues', [
329 MochiKit.Base.method(aDirectLoginReference['component'], 'label'),
330 MochiKit.Base.method(aDirectLoginReference['directLogin'], 'setLabel')
331 ], {trace:false});
332
333 return deferredResult;
334 },
335
336 //-------------------------------------------------------------------------
337
338 'updateRecordDirectLoginDetails': function (aDirectLogin) {
339 var result;
340
341 if (MochiKit.Base.isUndefinedOrNull(aDirectLogin)) {
342 result = MochiKit.Async.succeed();
343 } else {
344 result = Clipperz.Async.callbacks("CardDialogController.updateRecordDirectLoginDetails", [
345 MochiKit.Base.method(this.directLoginEditingComponent(), 'label'),
346 MochiKit.Base.method(aDirectLogin, 'setLabel'),
347 MochiKit.Base.method(this.directLoginEditingComponent(), 'favicon'),
348 MochiKit.Base.method(aDirectLogin, 'setFavicon')
349 ], {trace:false});
350 }
351
352 return result;
353 },
354
355 //=========================================================================
356
357 'addField': function () {
358 return this.record().addField({
359 'label':this.cardDialogComponent().newFieldLabel(),
360 'value':this.cardDialogComponent().newFieldValue(),
361 'isHidden':this.cardDialogComponent().newFieldIsHidden()
362 });
363 },
364
365 'handleAddField': function () {
366 return Clipperz.Async.callbacks("CardDialogController.handleAddField", [
367 MochiKit.Base.method(this, 'addField'),
368
369 MochiKit.Base.method(this, 'addCardDialogComponentWithField'),
370 MochiKit.Base.method(this.cardDialogComponent(), 'resetNewFieldInputs'),
371
372 MochiKit.Base.method(this.cardDialogComponent(), 'fixRendering'),
373 MochiKit.Base.method(this, 'handleChangedValue')
374 ], {trace:false})
375 },
376
377 //-------------------------------------------------------------------------
378
379 'handlePerformFieldAction': function (aFieldID, aTargetElement) {
380//console.log("### targetElement", aTargetElement);
381 return Clipperz.Async.callbacks("CardDialogController.handleDeleteField", [
382 MochiKit.Base.method(this.record(), 'fields'),
383 MochiKit.Base.itemgetter(aFieldID),
384 Clipperz.Async.collectResults("CardDialogController.handleDeleteField <collect results>", {
385 'value':MochiKit.Base.methodcaller('value'),
386 'type': MochiKit.Base.methodcaller('actionType')
387 }, {trace:false}),
388 MochiKit.Base.bind(function (someValues) {
389 switch (someValues['type']) {
390 case 'NONE':
391 throw "this event handler should not be triggered for fields with type 'NONE'";
392 break;
393 case 'URL':
394 var url;
395
396 url = someValues['value'];
397 if (/^https?\:\/\//.test(url) == false) {
398 url = 'http://' + url;
399 }
400
401 window.open(url);
402 break;
403 case 'EMAIL':
404 var url;
405
406 url = 'mailto:' + someValues['value'];
407
408 MochiKit.DOM.currentWindow().location = url;
409 break;
410 case 'PASSWORD':
411//Clipperz.log("SHOW PASSWORD " + someValues['value']);
412 this.showPasswordTooltip(someValues['value'], aTargetElement);
413 break;
414 }
415 }, this)
416 ], {trace:false});
417 },
418
419 //-------------------------------------------------------------------------
420
421 'handleDeleteField': function (aFieldID) {
422 return Clipperz.Async.callbacks("CardDialogController.handleDeleteField", [
423 MochiKit.Base.method(this.record(), 'fields'),
424 MochiKit.Base.itemgetter(aFieldID),
425 MochiKit.Base.method(this.record(), 'removeField'),
426
427 MochiKit.Base.method(this, 'fieldsReferences'),
428 MochiKit.Base.itemgetter(aFieldID),
429 MochiKit.Base.itemgetter('component'),
430
431 function (aComponent) {
432 return Clipperz.Async.callbacks("CardDialogController.handleDeleteField [fade and remove]", [
433 MochiKit.Base.partial(Clipperz.Visual.deferredAnimation, MochiKit.Visual.fade, aComponent.element(), {from:1.0, to:0.0, duration:0.5}),
434 // Clipperz.Visual.deferredAnimation(MochiKit.Visual.fade, aComponent.element(), {from:1.0, to:0.0, duration:0.5}),
435 MochiKit.Base.method(aComponent, 'remove')
436 ], {trace:false});
437 },
438
439 MochiKit.Base.bind(function () {
440 delete this.fieldsReferences()[aFieldID];
441 }, this),
442
443 MochiKit.Base.method(this.cardDialogComponent(), 'fixRendering'),
444 MochiKit.Base.method(this, 'handleChangedValue')
445 ], {trace:false});
446 },
447
448 //=========================================================================
449
450 'handleDeleteDirectLogin': function(aDirectLoginReference) {
451 var cardDialogComponent;
452
453 cardDialogComponent = this.cardDialogComponent();
454
455 return Clipperz.Async.callbacks("CardDialogController.handleDeleteDirectLogin", [
456 MochiKit.Base.method(this.record(), 'directLogins'),
457 MochiKit.Base.itemgetter(aDirectLoginReference),
458 MochiKit.Base.methodcaller('remove'),
459
460 MochiKit.Base.method(this, 'directLoginReferences'),
461 MochiKit.Base.itemgetter(aDirectLoginReference),
462 MochiKit.Base.itemgetter('component'),
463
464 function (aComponent) {
465 return Clipperz.Async.callbacks("CardDialogController.handleDeleteDirectLogin [fade and remove]", [
466 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}),
467 /// MochiKit.Base.method(aComponent, 'remove')
468 MochiKit.Base.method(cardDialogComponent, 'removeDirectLoginComponent', aComponent)
469 ], {trace:false});
470 },
471
472 MochiKit.Base.bind(function () {
473 delete this.directLoginReferences()[aDirectLoginReference];
474 }, this),
475
476 MochiKit.Base.method(this.cardDialogComponent(), 'fixRendering'),
477 MochiKit.Base.method(this, 'handleChangedValue')
478 ], {trace:false});
479 },
480
481 //-------------------------------------------------------------------------
482
483 'handleOpenDirectLogin': function (aDirectLoginReference) {
484 return Clipperz.Async.callbacks("CardDialogController.handleOpenDirectLogin", [
485 MochiKit.Base.method(this.record(), 'directLoginWithReference', aDirectLoginReference),
486 Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.openDirectLogin
487 ], {trace:false});
488 },
489
490 //-------------------------------------------------------------------------
491
492 'handleEditDirectLogin': function (aDirectLoginReference) {
493 return Clipperz.Async.callbacks("CardDialogController.handleEditDirectLogin", [
494 MochiKit.Base.method(this, 'setIsDirectLoginEditingComponentVisible', true),
495 MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginReference', aDirectLoginReference),
496 MochiKit.Base.method(this.cardDialogComponent(), 'placeDirectLoginEditingComponent'),
497 MochiKit.Base.method(this.record(), 'directLoginWithReference', aDirectLoginReference),
498 MochiKit.Base.method(this.directLoginWizardController(), 'runWithDirectLogin'),
499 MochiKit.Base.method(this.directLoginWizardController(), 'fixRulerRendering', this.cardDialogComponent().displayMode()),
500 MochiKit.Base.method(this.cardDialogComponent(), 'showDirectLoginEditingComponent')
501 ], {trace:false});
502 },
503
504 //-------------------------------------------------------------------------
505
506 'handleHideDirectLoginEditingComponent': function () {
507 return Clipperz.Async.callbacks("CardDialogController.handleHideDirectLoginEditingComponent", [
508 MochiKit.Base.method(this, 'setIsDirectLoginEditingComponentVisible', false),
509 MochiKit.Base.method(this.directLoginWizardController(), 'hideRuler'),
510 MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginReference', null),
511 MochiKit.Base.method(this, 'refreshDirectLoginComponents'),
512 MochiKit.Base.method(this.cardDialogComponent(), 'hideDirectLoginEditingComponent')
513 ], {trace:false})
514 },
515
516 'handleCompleteDirectLoginEditingComponent': function (someParameters) {
517 return Clipperz.Async.callbacks("CardDialogController.handleCompleteDirectLoginEditingComponent", [
518 MochiKit.Base.method(this, 'setIsDirectLoginEditingComponentVisible', false),
519 MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginReference', null),
520 MochiKit.Base.partial(MochiKit.Async.succeed, someParameters['hasJustBeenAdded']),
521 Clipperz.Async.deferredIf("CardDialogController.handleCompleteDirectLoginEditingComponent - should addTheEditedDirectLogin", [
522 MochiKit.Base.method(this, 'addCardDialogComponentWithDirectLogin', someParameters['directLogin'])
523 ], []),
524 MochiKit.Base.method(this, 'refreshDirectLoginComponents'),
525 MochiKit.Base.method(this, 'handleChangedValue'),
526 MochiKit.Base.method(this.cardDialogComponent(), 'hideDirectLoginEditingComponent')
527 ], {trace:false})
528 },
529
530 //=========================================================================
531
532 'handleChangedValue': function () {
533 return Clipperz.Async.callbacks("CardDialogController.handleChangedValue", [
534 MochiKit.Base.method(this, 'updateRecordValues'),
535 MochiKit.Base.method(this.record(), 'hasPendingChanges'),
536 MochiKit.Base.method(this.cardDialogComponent(), 'setShouldEnableSaving')
537 ], {trace:false});
538 },
539
540 //-------------------------------------------------------------------------
541
542 'handleSave': function () {
543 var deferredResult;
544
545 deferredResult = new Clipperz.Async.Deferred("CardDialogController.handleSave", {trace:false});
546 deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':8});
547 deferredResult.addMethod(this.cardDialogComponent(), 'showProgressMask');
548 deferredResult.addMethod(this.cardDialogComponent(), 'newFieldHasPendingChanges');
549 deferredResult.addIf([
550 MochiKit.Base.method(this, 'addField')
551 ], [])
552 deferredResult.addMethod(this, 'saveChanges');
553 deferredResult.addMethod(this.cardDialogComponent(), 'deferredHideModal', {closeToElement:null});
554 deferredResult.addMethod(this.cardDialogComponent(), 'remove');
555 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'cardDialogComponentClosed');
556
557 deferredResult.callback();
558
559 return deferredResult;
560 },
561
562 //.........................................................................
563
564 'saveChanges': function () {
565 var deferredResult;
566
567 deferredResult = new Clipperz.Async.Deferred("CardDialogController.handleSave", {trace:false});
568 deferredResult.addMethod(this.delegate(), 'saveChanges');
569deferredResult.addErrback(function (aValue) { Clipperz.log("SHIT HAPPENS!!"); return aValue; });
570
571 deferredResult.callback();
572
573 return deferredResult;
574 },
575
576 //-------------------------------------------------------------------------
577
578 'handleCancel': function () {
579 var deferredResult;
580
581 if (this.isDirectLoginEditingComponentVisible()) {
582 deferredResult = this.handleHideDirectLoginEditingComponent();
583 } else {
584 deferredResult = new Clipperz.Async.Deferred("CardDialogController.handleCancel", {trace:false});
585 // deferredResult.addMethod(this.record(), 'hasPendingChanges'),
586 deferredResult.addMethod(this.delegate(), 'hasPendingChanges'),
587 deferredResult.addIf([
588 MochiKit.Base.method(this.cardDialogComponent(), 'askConfirmationForLoosingPendingChanges')
589 ], [])
590 deferredResult.addMethod(this.delegate(), 'revertChanges');
591 deferredResult.addMethod(this.cardDialogComponent(), 'deferredHideModal', {closeToElement:this.referenceElement()});
592 deferredResult.addMethod(this.cardDialogComponent(), 'remove');
593 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'cardDialogComponentClosed');
594
595 deferredResult.callback();
596 }
597
598 return deferredResult;
599 },
600
601 //-------------------------------------------------------------------------
602
603 'handleAddDirectLogin': function () {
604 return Clipperz.Async.callbacks("CardDialogController.handleAddDirectLogin", [
605 MochiKit.Base.method(this.record(), 'createNewDirectLogin'),
606 MochiKit.Base.bind(function (aDirectLogin) {
607 return Clipperz.Async.callbacks("CardDialogController.handleAddDirectLogin - directLogin", [
608 MochiKit.Base.method(this.cardDialogComponent(), 'newFieldHasPendingChanges'),
609 Clipperz.Async.deferredIf("cardDialogComponent.newFieldHasPendingChanges", [
610 MochiKit.Base.method(this, 'handleAddField')
611 ], []),
612
613 MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginReference', aDirectLogin.reference()),
614 MochiKit.Base.method(this.cardDialogComponent(), 'placeDirectLoginEditingComponent'),
615 MochiKit.Base.method(this.directLoginWizardController(), 'runWithDirectLogin', aDirectLogin, true),
616 MochiKit.Base.method(this.directLoginWizardController(), 'fixRulerRendering', this.cardDialogComponent().displayMode()),
617 MochiKit.Base.method(this.cardDialogComponent(), 'showDirectLoginEditingComponent')
618 ], {trace:false});
619 }, this)
620 ], {trace:false});
621 },
622
623 //=========================================================================
624
625 'handleCardDialogComponentKeyPressed': function (anEvent) {
626 if ((anEvent.key().string == 'KEY_TAB') && this.cardDialogComponent().newFieldHasPendingChanges()) {
627 anEvent.preventDefault();
628
629 // MochiKit.Signal.signal(this.cardDialogComponent(), 'addField');
630 this.handleAddField()
631 this.cardDialogComponent().focusOnNewFieldLabel();
632 }
633 },
634
635 //=========================================================================
636
637 'showPasswordTooltip': function (aValue, anElement) {
638 varpasswordTooltip;
639
640 passwordTooltip = new Clipperz.PM.UI.Web.Components.PasswordTooltip({
641 'referebceElement': anElement,
642 'text': aValue
643 });
644
645 passwordTooltip.show();
646
647
648 },
649
650 //=========================================================================
651 __syntaxFix__: "syntax fix"
652});
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardsController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardsController.js
new file mode 100644
index 0000000..b1a34b2
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardsController.js
@@ -0,0 +1,207 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers');
30
31Clipperz.PM.UI.Web.Controllers.CardsController = function() {
32 Clipperz.PM.UI.Web.Controllers.CardsController.superclass.constructor.apply(this, arguments);
33
34 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'cardDialogComponentClosed', this, 'handleHideCard');
35
36 return this;
37}
38
39Clipperz.Base.extend(Clipperz.PM.UI.Web.Controllers.CardsController, Clipperz.PM.UI.Web.Controllers.GridController, {
40
41 'toString': function() {
42 return "Clipperz.PM.UI.Web.Controllers.CardsController";
43 },
44
45 'createGrid': function () {
46 var grid;
47
48 grid = new Clipperz.PM.UI.Web.Components.GridComponent({columnsManagers: [
49 new Clipperz.PM.UI.Web.Components.FaviconColumnManager({
50 'name': 'Cards.favicon',
51 'selector': MochiKit.Base.methodcaller('favicon'),
52 'cssClass': 'favicon'
53 }),
54 new Clipperz.PM.UI.Web.Components.LinkColumnManager({
55 'name': 'Cards.title',
56 'selector': MochiKit.Base.methodcaller('label'),
57 'label': 'title',
58 'cssClass': 'title',
59 'comparator': Clipperz.Base.caseInsensitiveCompare,
60 'sortable': true,
61 'sorted': 'ASCENDING',
62 // 'actionMethod': function(anObject, anEvent) { MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'editCard', {objectData:anObject, element:anEvent.src()})}
63 'actionMethod': MochiKit.Base.method(this, 'handleShowCard')
64 }),
65 new Clipperz.PM.UI.Web.Components.DirectLoginsColumnManager({
66 'name': 'Cards.directLogins',
67 'selector': MochiKit.Base.methodcaller('directLoginReferences'),
68 'label': 'direct logins',
69 'cssClass': 'directLogin'
70 }),
71 new Clipperz.PM.UI.Web.Components.DateColumnManager({
72 'name': 'Cards.latestUpdate',
73 'selector': MochiKit.Base.methodcaller('updateDate'),
74 'label': 'latest update',
75 'cssClass': 'latestUpdate',
76 'format': 'd-m-Y',
77 'comparator': MochiKit.Base.compare,
78 'sortable': true,
79 'sorted': 'UNSORTED'
80 }),
81 new Clipperz.PM.UI.Web.Components.DeleteObjectColumnManager({
82 'name': 'Cards.delete',
83 'selector': MochiKit.Base.noop,
84 'cssClass': 'delete',
85 // 'actionMethod': function(anObject, anEvent) { MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'deleteCard', {objectData:anObject, element:anEvent.src()})}
86 'actionMethod': MochiKit.Base.method(this, 'handleDeleteCard')
87 })
88 ]});
89
90 grid.setComponentForSlotNamed(new Clipperz.PM.UI.Web.Components.BookmarkletComponent(), 'headerSlot');
91
92 return grid;
93 },
94
95 //-----------------------------------------------------------------------------
96
97 'getRows': function () {
98 //TODO relying on user() in GridController, bad code smell :|
99 return this.user().getRecords();
100 },
101
102 //=============================================================================
103
104 'displayEmptyContent': function () {
105 varemptyGridComponent;
106
107 emptyGridComponent = new Clipperz.PM.UI.Web.Components.CreateNewCardSplashComponent();
108
109 return Clipperz.Async.callbacks("CardsController.displayEmptyContent", [
110 MochiKit.Base.method(this.grid(), 'setNoRowsGridComponent', emptyGridComponent),
111 MochiKit.Base.bind(Clipperz.PM.UI.Web.Controllers.CardsController.superclass.displayEmptyContent, this)
112 ], {trace:false});
113 },
114
115 'displaySelectedRows': function (aFilter) {
116 this.columnManagerWithName('Cards.directLogins').hideDirectLoginListPopup();
117
118 return Clipperz.PM.UI.Web.Controllers.CardsController.superclass.displaySelectedRows.apply(this, arguments);
119 },
120
121 //=============================================================================
122
123 'handleShowCard': function (anObject, anEvent) {
124 var cardDialogController;
125
126 cardDialogController = new Clipperz.PM.UI.Web.Controllers.CardDialogController({record:anObject, delegate:this});
127 this.grid().selectRow(anObject);
128
129 cardDialogController.run(anEvent.src());
130 },
131
132 //.........................................................................
133
134 'handleHideCard': function () {
135 this.focus();
136 },
137
138 //-----------------------------------------------------------------------------
139
140 'addCard': function (aSourceElement) {
141 return Clipperz.Async.callbacks("CardsController.addCard", [
142 Clipperz.Async.collectResults("CardsController.addCard <inner results>", {
143 'record': MochiKit.Base.method(this.user(), 'createNewRecord'),
144 'delegate':MochiKit.Base.partial(MochiKit.Async.succeed, this)
145 }, {trace:false}),
146 function (someParameters) {
147 return new Clipperz.PM.UI.Web.Controllers.CardDialogController(someParameters);
148 },
149 MochiKit.Base.methodcaller('run', aSourceElement)
150 ], {trace:false});
151 },
152
153 //-----------------------------------------------------------------------------
154
155 'handleDeleteCard': function (anObject, anEvent) {
156 var deferredResult;
157 var confirmationDialog;
158
159 // confirmationDialog = new Clipperz.PM.UI.Common.Components.SimpleMessagePanel({
160 confirmationDialog = new Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar({
161 'title':"Delete Card",
162 'text': "Do you want to delete …",
163 'type': 'ALERT',
164 'buttons': [
165 {text:"Cancel",result:'CANCEL'},
166 {text:"Delete", result:'OK', isDefault:true}
167 ],
168 'canCancelWhileProcessing':false
169 });
170
171 deferredResult = new Clipperz.Async.Deferred("AppController.handleDeleteCard", {trace:false});
172 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':5}),
173 deferredResult.addMethod(this.grid(), 'selectRow', anObject);
174 deferredResult.addMethod(confirmationDialog, 'deferredShowModal', {
175 'openFromElement': anEvent.src(),
176 'onOkCloseToElement': null, //MochiKit.DOM.currentDocument().body,
177 'onCancelCloseToElement':anEvent.src()
178 });
179 // deferredResult.addCallback(function () { Clipperz.log("DELETE: " + anObject.toString(), anObject); });
180 deferredResult.addMethod(this.user(), 'deleteRecord', anObject);
181 deferredResult.addBothPass(MochiKit.Base.method(this.grid(), 'unselectRow', anObject));
182 deferredResult.addMethod(this, 'saveChanges');
183 deferredResult.addMethod(confirmationDialog, 'deferredDone');
184 deferredResult.addErrbackPass(function (anError) {
185 var result;
186
187 if (! (anError instanceof MochiKit.Async.CancelledError)) {
188 result = confirmationDialog.deferredError({
189 'type': 'ALERT',
190 'title':"Error",
191 'text': Clipperz.PM.Strings.errorDescriptionForException(anError),
192 'buttons':[{text:"Close", result:'CANCEL', isDefault:true}]
193 })
194 } else {
195 result = anError;
196 }
197
198 return result;
199 });
200 deferredResult.callback();
201
202 return deferredResult;
203 },
204
205 //=============================================================================
206 __syntaxFix__: "syntax fix"
207});
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js
new file mode 100644
index 0000000..38fdc08
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js
@@ -0,0 +1,611 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers');
30
31Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController = function(args) {
32 this._directLoginEditingComponent = args.directLoginEditingComponent|| Clipperz.Base.exception.raise('MandatoryParameter');
33 this._cardLabel = args.cardLabel || Clipperz.Base.exception.raise('MandatoryParameter');
34
35 MochiKit.Signal.connect(this._directLoginEditingComponent, 'changedValue',this, 'handleChangedValue');
36 MochiKit.Signal.connect(this._directLoginEditingComponent, 'moveForward',this, 'handleMoveForward');
37 MochiKit.Signal.connect(this._directLoginEditingComponent, 'keyPressed',this, 'handleDirectLoginEditingComponentKeyPressed');
38
39 this._directLogin = null;
40 this._directLoginHasJustBeenAdded = false;
41
42 this._rulerComponent = null;
43
44 this._steps = null;
45 this._currentStepIndex = 0;
46 this._isNextEnabled = false;
47
48 this._recordFields = null;
49 this._originalBindings = null;
50
51 this._bindingComponents = [];
52 this._formValueComponents = [];
53
54 return this;
55}
56
57MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController.prototype, {
58
59 'toString': function() {
60 return "Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController";
61 },
62
63 //-------------------------------------------------------------------------
64
65 'directLogin': function () {
66 return this._directLogin;
67 },
68
69 //-------------------------------------------------------------------------
70
71 'directLoginHasJustBeenAdded': function () {
72 return this._directLoginHasJustBeenAdded;
73 },
74
75 'setDirectLoginHasJustBeenAdded': function (aValue) {
76 this._directLoginHasJustBeenAdded = aValue;
77 },
78
79 //-------------------------------------------------------------------------
80
81 'directLoginEditingComponent': function () {
82 return this._directLoginEditingComponent;
83 },
84
85 //=============================================================================
86
87 'cardLabel': function () {
88 return this._cardLabel;
89 },
90
91 //=============================================================================
92
93 'resetCurrentStepIndex': function () {
94 this._currentStepIndex = 0;
95 this.rulerComponent().resetStatus();
96 },
97
98 //-----------------------------------------------------------------------------
99
100 'enableNext': function (aValue) {
101 this.rulerComponent().enableNext(aValue);
102 this._isNextEnabled = aValue;
103 },
104
105 'isNextEnabled': function () {
106 return this._isNextEnabled;
107 },
108
109 //-----------------------------------------------------------------------------
110
111 'enablePrevious': function (aValue) {
112 this.rulerComponent().enablePrevious(aValue);
113 },
114
115 //=============================================================================
116
117 'bindingComponents': function () {
118 return this._bindingComponents;
119 },
120
121 'resetBindingComponents': function () {
122 this.directLoginEditingComponent().clearAllBindingsComponents();
123 this._bindingComponents = [];
124 },
125
126 //=============================================================================
127
128 'formValueComponents': function () {
129 return this._formValueComponents;
130 },
131
132 'resetFormValueComponents': function () {
133 this.directLoginEditingComponent().clearAllFormValueComponents();
134 this._formValueComponents = [];
135 },
136
137 //=============================================================================
138
139 'recordFields': function () {
140 return this._recordFields;
141 },
142
143 'setRecordFields': function (aValue) {
144 this._recordFields = aValue;
145 },
146
147 'recordFieldWithReference': function (aReference) {
148 var matchingValues;
149 var result;
150
151 matchingValues = MochiKit.Base.filter(function (aField) { return aField['reference'] == aReference; }, this.recordFields());
152
153 if (matchingValues.length == 0) {
154 result = null;
155 } else {
156 result = matchingValues[0];
157 }
158
159 return result;
160 },
161
162 //-----------------------------------------------------------------------------
163
164 'originalBindings': function () {
165 return this._originalBindings;
166 },
167
168 'setOriginalBindings': function (aValue) {
169//console.log("BINDINGS", aValue);
170 this._originalBindings = aValue;
171 },
172
173 //=============================================================================
174
175 'rulerComponent': function () {
176 if (this._rulerComponent == null) {
177 this._rulerComponent = new Clipperz.PM.UI.Web.Components.RulerComponent({
178 translationContext:'Wizards.DirectLoginWizard'
179 });
180 this._rulerComponent.render();
181
182 MochiKit.Signal.connect(this._rulerComponent, 'exit', this, 'handleExit');
183 MochiKit.Signal.connect(this._rulerComponent, 'done', this, 'done');
184 MochiKit.Signal.connect(this._rulerComponent, 'moveForward',this, 'handleMoveForward');
185 MochiKit.Signal.connect(this._rulerComponent, 'moveBackward',this, 'handleMoveBackward');
186 MochiKit.Signal.connect(this._rulerComponent, 'cursorMoved',this, 'handleCursorMoved');
187 }
188
189 return this._rulerComponent;
190 },
191
192 //-----------------------------------------------------------------------------
193
194 'showRuler': function (someSteps) {
195 var rulerElement;
196
197 this.setSteps(someSteps);
198
199 rulerElement = this.rulerComponent().element();
200 this.directLoginEditingComponent().disableAllPanels();
201
202 MochiKit.Style.showElement(rulerElement);
203 MochiKit.Style.setElementPosition(rulerElement, {x:-1000, y:this.directLoginEditingComponent().bottomMargin()});
204 new MochiKit.Visual.Move(rulerElement, {
205 x:0, y:this.directLoginEditingComponent().bottomMargin(),
206 mode:'absolute',
207 duration:1,
208 afterFinish:MochiKit.Base.method(this, 'handleCursorMoved')
209 });
210 },
211
212 'fixRulerRendering': function (aValue) {
213 this.rulerComponent().setDisplayMode(aValue);
214 },
215
216 //-----------------------------------------------------------------------------
217
218 'hideRuler': function () {
219 new MochiKit.Visual.Move(this.rulerComponent().element(), {x:-1000, mode:'relative', duration:1});
220 },
221
222 'doneWithRuler': function () {
223 var rulerComponentElement;
224
225 rulerComponentElement = this.rulerComponent().element();
226 new MochiKit.Visual.Move(this.rulerComponent().element(), {
227 x:1000,
228 mode:'relative',
229 duration:1,
230 // afterFinish:MochiKit.Base.partial(MochiKit.Style.hideElement, rulerComponentElement)
231 afterFinish:function () { MochiKit.Style.hideElement(rulerComponentElement); }
232 });
233 },
234
235 //=============================================================================
236
237 'addNewDirectLoginRulerSteps': function () {
238 return MochiKit.Base.concat([ 'LABEL'], this.editDirectLoginRulerSteps());
239
240 },
241
242 'editDirectLoginRulerSteps': function () {
243 return [ /*'TYPE',*/ 'CONFIGURATION', 'BINDINGS','FAVICON', 'DONE'];
244 },
245
246 //-------------------------------------------------------------------------
247
248 'runWithDirectLogin': function (aDirectLogin, hasJustBeenAdded) {
249 this._directLogin = aDirectLogin;
250 this.setDirectLoginHasJustBeenAdded(hasJustBeenAdded);
251
252 return Clipperz.Async.callbacks("DirectLoginWizardController.runWithDirectLogin", [
253 MochiKit.Base.method(aDirectLogin, 'label'),
254 MochiKit.Base.method(this.directLoginEditingComponent(), 'setLabel'),
255
256 MochiKit.Base.method(aDirectLogin, 'favicon'),
257 MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginFavicon'),
258
259 MochiKit.Base.method(aDirectLogin, 'bookmarkletConfiguration'),
260 MochiKit.Base.method(this.directLoginEditingComponent(), 'setBookmarkletConfiguration'),
261
262 MochiKit.Base.method(aDirectLogin, 'bindings'),
263 MochiKit.Base.method(this, 'setOriginalBindings'),
264
265 MochiKit.Base.method(aDirectLogin, 'record'),
266 MochiKit.Base.methodcaller('fields'),
267 MochiKit.Base.values,
268 MochiKit.Base.partial(MochiKit.Base.map, Clipperz.Async.collectResults("Record.directLoginReferences - collectResults", {
269 'reference': MochiKit.Base.methodcaller('reference'),
270 'label': MochiKit.Base.methodcaller('label'),
271 'isHidden': MochiKit.Base.methodcaller('isHidden'),
272 'value': MochiKit.Base.methodcaller('value')
273 }, {trace:false})),
274 Clipperz.Async.collectAll,
275
276 MochiKit.Base.method(this, 'setRecordFields'),
277
278 MochiKit.Base.partial(MochiKit.Async.succeed, hasJustBeenAdded),
279 Clipperz.Async.deferredIf("Direct login has just been added", [
280 MochiKit.Base.method(this, 'addNewDirectLoginRulerSteps')
281 ], [
282 MochiKit.Base.method(this, 'editDirectLoginRulerSteps')
283 ]),
284 MochiKit.Base.method(this, 'showRuler')
285 ], {trace:false});
286 },
287
288 //-----------------------------------------------------------------------------
289
290 'checkState': function () {
291 var enablePrevious;
292 var enableNext;
293
294 enablePrevious = true;
295 enableNext = false;
296
297 this.directLoginEditingComponent().disableAllPanels();
298
299 switch(this.currentStep()) {
300 case 'LABEL':
301 this.directLoginEditingComponent().enableLabelField();
302
303 enableNext = (this.directLoginEditingComponent().label() != '');
304 enablePrevious = false;
305 break;
306 case 'TYPE':
307 this.directLoginEditingComponent().enableTypeField();
308
309 enableNext = true;
310 enablePrevious = true;
311 break
312 case 'CONFIGURATION':
313 this.directLoginEditingComponent().enableConfigurationField();
314
315 enableNext = (this.directLoginEditingComponent().bookmarkletConfiguration() != '');
316
317 if (enableNext == true) {
318 try {
319 Clipperz.PM.DataModel.DirectLogin.checkBookmarkletConfiguration(this.directLoginEditingComponent().bookmarkletConfiguration());
320 this.directLoginEditingComponent().removeHighlightConfigurationSyntaxError();
321 } catch (e) {
322 this.directLoginEditingComponent().highlightConfigurationSyntaxError();
323 enableNext = false;
324 }
325 }
326 break;
327 case 'BINDINGS':
328 enableNext = MochiKit.Iter.every(this.bindingComponents(), function (aBindingComponent) { return aBindingComponent.selectedValue() != null; })
329 this.directLoginEditingComponent().enableBindingFields();
330 break;
331 case 'FAVICON':
332 enableNext = true;
333 this.directLoginEditingComponent().enableFaviconField();
334 break;
335 case 'DONE':
336 enableNext = true;
337 this.directLoginEditingComponent().enableDonePanel();
338 break;
339 }
340
341 if (this.currentStepIndex() > 0) {
342 this.enablePrevious(enablePrevious);
343 } else {
344 this.enablePrevious(false);
345 }
346 this.enableNext(enableNext);
347 },
348
349 //-----------------------------------------------------------------------------
350
351 'setFocus': function () {
352 switch(this.currentStep()) {
353 case 'LABEL':
354 this.directLoginEditingComponent().focusOnLabelElement();
355 break;
356 case 'TYPE':
357 break;
358 case 'CONFIGURATION':
359 this.directLoginEditingComponent().focusOnBookmarkletConfigurationElement();
360 break;
361 case 'BINDINGS':
362 // this.directLoginEditingComponent().getElement('???').focus();
363 break;
364 case 'FAVICON':
365 this.directLoginEditingComponent().focusOnFaviconElement();
366 break;
367 case 'DONE':
368 break;
369 }
370 },
371
372 //=============================================================================
373
374 'steps': function () {
375 return this._steps;
376 },
377
378 'setSteps': function (aValue) {
379 this._steps = aValue;
380
381 this.rulerComponent().setSteps(aValue);
382 this.resetCurrentStepIndex();
383 },
384
385 'currentStepIndex': function () {
386 return this._currentStepIndex;
387 },
388
389 'currentStep': function () {
390 return this.steps()[this.currentStepIndex()];
391 },
392
393 //=============================================================================
394
395 'handleExit': function () {
396 MochiKit.Signal.signal(this, 'exit');
397 },
398
399 'done': function () {
400 this.doneWithRuler();
401
402 Clipperz.Async.callbacks("DirectLoginWizardController.done", [
403 MochiKit.Base.method(this.directLoginEditingComponent(), 'label'),
404 MochiKit.Base.method(this.directLogin(), 'setLabel'),
405
406 MochiKit.Base.method(this.directLoginEditingComponent(), 'bookmarkletConfiguration'),
407 MochiKit.Base.method(this.directLogin(), 'setBookmarkletConfiguration'),
408
409 //Bindings
410 MochiKit.Base.method(this.directLoginEditingComponent(), 'bindingComponents'),
411 // MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.bind(function (aBindingComponent) {
412 Clipperz.Async.forEach(MochiKit.Base.bind(function (aBindingComponent) {
413//console.log("aBindingComponent", aBindingComponent);
414 // this.directLogin().
415 return Clipperz.Async.callbacks("DirectLoginWizardController.done - update directLogin bindings", [
416 MochiKit.Base.method(this.directLogin(), 'bindings'),
417 MochiKit.Base.itemgetter(aBindingComponent.formFieldName()),
418 MochiKit.Base.methodcaller('setFieldKey', aBindingComponent.selectedValue())
419 ], {trace:false});
420 }, this)),
421
422 MochiKit.Base.method(this.directLoginEditingComponent(), 'favicon'),
423 MochiKit.Base.method(this.directLogin(), 'setFavicon'),
424
425 MochiKit.Base.partial(MochiKit.Signal.signal, this, 'done', {
426 'directLogin': this.directLogin(),
427 'hasJustBeenAdded':this.directLoginHasJustBeenAdded()
428 })
429 ], {trace:false});
430 },
431
432 //=============================================================================
433
434 'handleMoveBackward': function () {
435 if (this._currentStepIndex > 0) {
436 varafterMoveAction;
437
438 this._currentStepIndex --;
439 afterMoveAction = MochiKit.Base.noop;
440
441 switch(this.currentStep()) {
442 case 'LABEL':
443 break;
444 case 'TYPE':
445 break;
446 case 'CONFIGURATION':
447 break;
448 case 'BINDINGS':
449 break;
450 case 'FAVICON':
451 break;
452 case 'DONE':
453 break;
454 };
455
456 this.rulerComponent().moveBackward(afterMoveAction);
457 }
458
459 if (this._currentStepIndex == 0) {
460 this.enablePrevious(false);
461 }
462 },
463
464 'handleMoveForward': function () {
465 if (this.isNextEnabled()) {
466 varafterMoveAction;
467
468 this._currentStepIndex ++;
469 afterMoveAction = MochiKit.Base.noop;
470
471 switch(this.currentStep()) {
472 case 'LABEL':
473 break;
474 case 'TYPE':
475 break;
476 case 'CONFIGURATION':
477 break;
478 case 'BINDINGS':
479 this.resetBindingComponents();
480 this.resetFormValueComponents();
481
482 afterMoveAction = MochiKit.Base.partial(Clipperz.Async.callbacks, "DirectLoginWizardController.handleMoveForward - BINDINGS", [
483 MochiKit.Base.method(this.directLogin(), 'setBookmarkletConfiguration', this.directLoginEditingComponent().bookmarkletConfiguration()),
484
485 MochiKit.Base.method(this.directLogin(), 'favicon'),
486 MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginFavicon'),
487
488 MochiKit.Base.method(this.directLogin(), 'bindings'),
489 MochiKit.Base.values,
490 Clipperz.Async.forEach(MochiKit.Base.bind(function (aBinding) {
491 var bindingComponent;
492
493 bindingComponent = new Clipperz.PM.UI.Web.Components.DirectLoginEditingBindingComponent({
494 formFieldName: aBinding.key(),
495 fields: this.recordFields(),
496 selectedFieldKey: aBinding.fieldKey()
497 });
498
499 this.bindingComponents().push(bindingComponent);
500
501 MochiKit.Signal.connect(bindingComponent, 'bindChange', this, 'handleBindChange', bindingComponent);
502 this.directLoginEditingComponent().addBindingComponent(bindingComponent);
503
504 }, this)),
505
506 MochiKit.Base.method(this.directLogin(), 'formValues'),
507 MochiKit.Base.values,
508 Clipperz.Async.forEach(MochiKit.Base.bind(function (aFormValue) {
509 var formValueComponent;
510
511 formValueComponent = new Clipperz.PM.UI.Web.Components.DirectLoginEditingFormValueComponent({
512 'formFieldName': aFormValue.key(),
513 'fieldOptions': aFormValue.fieldOptions(),
514 'initialValue': aFormValue.value()
515 });
516
517 this.formValueComponents().push(formValueComponent);
518
519 MochiKit.Signal.connect(formValueComponent, 'formValueChange', this, 'handleFormValueChange', formValueComponent);
520 this.directLoginEditingComponent().addFormValueComponent(formValueComponent);
521 }, this))
522
523 ], {trace:false});
524
525 break;
526 case 'FAVICON':
527 break;
528 case 'DONE':
529 this.directLoginEditingComponent().setDoneDescriptionWithKeys({
530 '__cardName__': this.cardLabel(),
531 '__directLoginName__': this.directLoginEditingComponent().label()
532 });
533 break;
534 };
535
536 this.rulerComponent().moveForward(afterMoveAction);
537 };
538 },
539
540 'handleCursorMoved': function () {
541 this.checkState();
542 this.setFocus();
543 },
544
545 //-------------------------------------------------------------------------
546
547 'handleChangedValue': function (anEvent) {
548 this.checkState();
549 },
550
551 //.........................................................................
552
553 'handleBindChange': function (aDirectLoginEditingBindingComponent) {
554 varselectedField;
555
556 selectedField = this.recordFieldWithReference(aDirectLoginEditingBindingComponent.selectedValue());
557
558 return Clipperz.Async.callbacks("DirectLoginWizardController.handleBindChange", [
559 MochiKit.Base.method(this.directLogin(), 'bindings'),
560 MochiKit.Base.itemgetter(aDirectLoginEditingBindingComponent.formFieldName()),
561 MochiKit.Base.methodcaller('setFieldKey', selectedField['reference']),
562 function () {
563 if (selectedField != null) {
564 aDirectLoginEditingBindingComponent.setFieldValue(selectedField['value']);
565 aDirectLoginEditingBindingComponent.setIsHidden(selectedField['isHidden']);
566 } else {
567 aDirectLoginEditingBindingComponent.setFieldValue('');
568 aDirectLoginEditingBindingComponent.setIsHidden(false);
569 }
570 },
571 MochiKit.Base.method(this, 'checkState')
572 ], {trace:false});
573 },
574
575 //.........................................................................
576
577 'handleFormValueChange': function (someOptions) {
578 return Clipperz.Async.callbacks("DirectLoginWizardController.handleFormValueChange", [
579 MochiKit.Base.method(this.directLogin(), 'formValues'),
580 MochiKit.Base.itemgetter(someOptions['fieldName']),
581 MochiKit.Base.methodcaller('setValue', someOptions['selectedValue']),
582 MochiKit.Base.method(this, 'checkState')
583 ], {trace:false});
584 },
585
586 //-------------------------------------------------------------------------
587
588 'handleDirectLoginEditingComponentKeyPressed': function (anEvent) {
589 if (anEvent.key().string == 'KEY_ENTER') {
590 if (anEvent.target().nodeName != 'TEXTAREA') {
591 anEvent.preventDefault();
592 this.handleMoveForward();
593 }
594 } else if (anEvent.key().string == 'KEY_TAB') {
595 this.handleMoveForward();
596 if ((anEvent.target().nodeName == 'INPUT') || (anEvent.target().nodeName == 'TEXTAREA')) {
597 anEvent.preventDefault();
598 }
599 } else if ((anEvent.key().string == 'KEY_ARROW_RIGHT') && (anEvent.modifier().meta == true)) {
600 this.handleMoveForward();
601 } else if ((anEvent.key().string == 'KEY_ARROW_LEFT') && (anEvent.modifier().meta == true)) {
602 this.handleMoveBackward();
603 } else if (anEvent.key().string == 'KEY_ESCAPE') {
604 anEvent.stop();
605 this.handleExit();
606 }
607 },
608
609 //=============================================================================
610 __syntaxFix__: "syntax fix"
611});
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginsController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginsController.js
new file mode 100644
index 0000000..28401a2
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginsController.js
@@ -0,0 +1,145 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29/*
30Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers');
31
32Clipperz.PM.UI.Web.Controllers.DirectLoginsController = function() {
33 Clipperz.PM.UI.Web.Controllers.DirectLoginsController.superclass.constructor.apply(this, arguments);
34
35 return this;
36};
37
38Clipperz.Base.extend(Clipperz.PM.UI.Web.Controllers.DirectLoginsController, Clipperz.PM.UI.Web.Controllers.GridController, {
39
40 'createGrid': function () {
41 return new Clipperz.PM.UI.Web.Components.GridComponent({columnsManagers: [
42 new Clipperz.PM.UI.Web.Components.FaviconColumnManager({
43 'name': 'DirectLogins.favicon',
44 'selector': MochiKit.Base.methodcaller('favicon'),
45 'cssClass': 'favicon'
46 }),
47 // new Clipperz.PM.UI.Web.Components.LinkColumnManager({
48 new Clipperz.PM.UI.Web.Components.DirectLoginColumnManager({
49 'name': 'DirectLogins.title',
50 'selector': MochiKit.Base.methodcaller('label'),
51 'label': 'title',
52 'cssClass': 'title',
53 'comparator': Clipperz.Base.caseInsensitiveCompare,
54 'sortable': true,
55 'sorted': 'ASCENDING',
56 'actionMethod': MochiKit.Base.methodcaller('runDirectLogin')
57 }),
58 // new Clipperz.PM.UI.Web.Components.TextColumnManager({ //should be StrengthColumnManager
59 // 'label':'strength',
60 // 'cssClass':'title',
61 // 'selector': MochiKit.Base.methodcaller('label') //should be 'strength' or a strenght evaluation function
62 // }),
63 new Clipperz.PM.UI.Web.Components.LinkColumnManager({
64 'name': 'DirectLogins.cardTitle',
65 'selector': MochiKit.Base.compose(MochiKit.Base.methodcaller('label'), MochiKit.Base.methodcaller('record')),
66 'label': 'card',
67 'cssClass': 'cardTitle',
68 'comparator': Clipperz.Base.caseInsensitiveCompare,
69 'sortable': true,
70 'sorted': 'UNSORTED',
71 'actionMethod': MochiKit.Base.method(this, 'handleShowCard')
72 }),
73 // new Clipperz.PM.UI.Web.Components.TextColumnManager({ //should be StrengthColumnManager
74 // 'label':'last access',
75 // 'cssClass':'title',
76 // 'selector': MochiKit.Base.methodcaller('label')
77 // // 'sortable': true,
78 // // 'sorted': 'UNSORTED'
79 // }),
80 // new Clipperz.PM.UI.Web.Components.TextColumnManager({
81 // 'label':'commands',
82 // 'cssClass':'title',
83 // 'selector': MochiKit.Base.methodcaller('label'), //should be a function for commands display
84 // }),
85 new Clipperz.PM.UI.Web.Components.DeleteObjectColumnManager({
86 'name': 'DirectLogins.delete',
87 'selector': MochiKit.Base.noop,
88 'cssClass': 'delete',
89 // 'actionMethod': function(anObject, anEvent) { MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'deleteDirectLogin', {objectData:anObject, element:anEvent.src()})}
90 'actionMethod': MochiKit.Base.method(this, 'handleDeleteDirectLogin')
91 })
92 ]});
93
94 },
95
96 //-----------------------------------------------------------------------------
97
98 'getRows': function () {
99 //TODO: relying on user() in GridController, bad code smell :|
100 return this.user().getDirectLogins();
101 },
102
103 //-----------------------------------------------------------------------------
104
105 'handleShowCard': function (anObject, anEvent) {
106 var cardDialogController;
107
108 cardDialogController = new Clipperz.PM.UI.Web.Controllers.CardDialogController({record:anObject.record()})
109 cardDialogController.run(anEvent.src());
110 },
111
112 //-----------------------------------------------------------------------------
113
114 'handleDeleteDirectLogin': function (anObject, anEvent) {
115 var deferredResult;
116 var confirmationDialog;
117
118 confirmationDialog = new Clipperz.PM.UI.Common.Components.SimpleMessagePanel({
119 title:"Delete DirectLogin",
120 text:"Do you want to delete …",
121 type:'ALERT',
122 buttons: [
123 {text:"Cancel",result:'CANCEL', isDefault:true},
124 {text:"Delete", result:'OK'}
125 ]
126 });
127
128 deferredResult = new Clipperz.Async.Deferred("AppController.handleDeleteCard", {trace:false});
129 // deferredResult = confirmationDialog.deferredShow({openFromElement:anEvent.src(), onOkCloseToElement:MochiKit.DOM.currentDocument().body, onCancelCloseToElement:anEvent.src()});
130 deferredResult.addMethod(confirmationDialog, 'deferredShow', {
131 'openFromElement': anEvent.src(),
132 'onOkCloseToElement': null, //MochiKit.DOM.currentDocument().body,
133 'onCancelCloseToElement':anEvent.src()
134 });
135 deferredResult.addCallback(function () { Clipperz.log("DELETE: " + anObject.toString(), anObject); });
136 deferredResult.addErrbackPass(function () { Clipperz.log("skip deletion: " + anObject.toString(), anObject); });
137 deferredResult.callback();
138
139 return deferredResult;
140 },
141
142 //-----------------------------------------------------------------------------
143 __syntaxFix__: "syntax fix"
144});
145*/ \ No newline at end of file
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/FilterController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/FilterController.js
new file mode 100644
index 0000000..13e02bc
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/FilterController.js
@@ -0,0 +1,158 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers');
30
31Clipperz.PM.UI.Web.Controllers.FilterController = function(args) {
32 args = args || {};
33
34 Clipperz.PM.UI.Web.Controllers.FilterController.superclass.constructor.call(this, args);
35
36 this._filterElements = [];
37 this._filter = "";
38
39 this._pendingSearchClicks = 0;
40
41 return this;
42};
43
44
45Clipperz.Base.extend(Clipperz.PM.UI.Web.Controllers.FilterController, Object, {
46
47 //-----------------------------------------------------------------------------
48
49 'getFilter': function () {
50 return this._filter;
51 },
52
53 '_setFilter': function (aFilterElement, aFilter) {
54 if (aFilter != this._filter) {
55 this._filter = aFilter;
56 MochiKit.Signal.signal(this, 'filterUpdated', aFilter);
57 this.updateFilterElements(aFilterElement, aFilter);
58 }
59 },
60
61 'setFilter': function (aFilter) {
62 this._setFilter(null, aFilter);
63 },
64
65 //-----------------------------------------------------------------------------
66
67 'filterElements': function () {
68 return this._filterElements;
69 },
70
71 'registerFilterElement': function (aFilterElement) {
72//Clipperz.log("=== FilterController.registerFilterElement", aFilterElement);
73 this._filterElements.push(aFilterElement);
74 MochiKit.Signal.connect(aFilterElement, 'onkeydown', this, 'searchClickHandler');
75 MochiKit.Signal.connect(aFilterElement, 'onfocus', this, 'searchClickHandler');
76 },
77
78 'removeFilterElement': function (aFilterElement) {
79 var i;
80 var filterElements;
81 for (i=0; i < filterElements; i++) {
82 if (filterElements[i] == aFilterElement);
83 filterElements.splice(i, 1);
84 // TODO unregister/disconnect filterElement ??MochiKit.Signal.disconnect(this.grid().filterElement(), 'updateFilter', this.filterController(), 'handleUpdateFilter');
85 }
86 },
87
88 'updateFilterElements': function (aSourceElement, aFilterString) {
89 MochiKit.Iter.forEach(this.filterElements(),
90 function (aFilterElement) {
91 if (aFilterElement != aSourceElement) {
92 aFilterElement.value = aFilterString;
93 }
94 }
95 );
96
97 if (aSourceElement != null) {
98 aSourceElement.focus();
99 }
100 },
101
102 //-----------------------------------------------------------------------------
103
104 'run': function () {
105//Clipperz.log("=== FilterController.run");
106 },
107
108 //-----------------------------------------------------------------------------
109
110 'pendingSearchClicks': function () {
111 return this._pendingSearchClicks;
112 },
113
114 'incrementPendingSearchClicks': function () {
115 this._pendingSearchClicks++;
116 },
117
118 'decrementPendingSearchClicks': function () {
119 this._pendingSearchClicks--;
120 },
121
122 //-----------------------------------------------------------------------------
123
124 'searchClickHandler': function (anEvent) {
125 if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ENTER')) {
126 anEvent.preventDefault();
127 } else {
128 var value;
129
130 if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ESCAPE')) {
131 value = ""
132 } else if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ARROW_UP')) {
133 } else if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ARROW_DOWN')) {
134 } else {
135 value = null;
136 }
137
138 this.incrementPendingSearchClicks();
139 MochiKit.Async.callLater(0.1, MochiKit.Base.method(this, "searchClickDeferredHandler", anEvent.src(), value));
140 }
141 },
142
143 //.........................................................................
144
145 'searchClickDeferredHandler': function (aFilterElement, aValue) {
146 if (aValue != null) {
147 aFilterElement.value = aValue;
148 }
149
150 this.decrementPendingSearchClicks();
151 if (this.pendingSearchClicks()==0) {
152 this._setFilter(aFilterElement, aFilterElement.value);
153 }
154 },
155
156 //-----------------------------------------------------------------------------
157 'syntaxFix': 'syntax fix'
158}); \ No newline at end of file
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/GridController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/GridController.js
new file mode 100644
index 0000000..740a091
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/GridController.js
@@ -0,0 +1,374 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers');
30
31Clipperz.PM.UI.Web.Controllers.GridController = function(args) {
32 args = args || {};
33
34 Clipperz.PM.UI.Web.Controllers.GridController.superclass.constructor.call(this, args);
35
36 this._grid = null;
37 this._user = null;
38 this._sortedColumnManager = null;
39 this._cachedObjects = null;
40 this._filterController = args.filterController || null;
41
42 this._deferredDisplaySelectedRowsInvocation = null;
43
44 return this;
45};
46
47Clipperz.Base.extend(Clipperz.PM.UI.Web.Controllers.GridController, Object, {
48
49 'toString': function() {
50 return "Clipperz.PM.UI.Web.Controllers.GridController";
51 },
52
53 //-----------------------------------------------------------------------------
54
55 'createGrid': function () {
56 throw Clipperz.Base.exception.AbstractMethod;
57 },
58
59 'setupWithGrid': function (aGrid) {
60 this._grid = aGrid;
61
62 if (this._grid != null) {
63 MochiKit.Iter.forEach(this.columnsManagers(), function (aColumnManager) {
64 if (aColumnManager.isSortable()) {
65 if (aColumnManager.isSorted()) {
66 this.setSortedColumnManager(aColumnManager);
67 }
68 MochiKit.Signal.connect(aColumnManager, 'sort', this, 'handleColumnManagerSort');
69 }
70 MochiKit.Signal.connect(aColumnManager, 'selectRow', this, 'handleColumnManagerSelectRow');
71 MochiKit.Signal.connect(aColumnManager, 'unselectRow', this, 'handleColumnManagerUnselectRow');
72 }, this);
73 }
74 },
75
76 'grid': function() {
77 if (this._grid == null) {
78 this.setupWithGrid(this.createGrid());
79 }
80
81 return this._grid;
82 },
83
84 'filterController': function () {
85//Clipperz.log('GridController.filterController >>>', this._filterController);
86 if (this._filterController == null) {
87 this._filterController = new Clipperz.PM.UI.Web.Controllers.FilterController();
88 }
89//Clipperz.log('GridController.filterController <<<', this._filterController);
90 return this._filterController;
91 },
92
93 //-----------------------------------------------------------------------------
94
95 'columnsManagers': function () {
96 return this.grid().columnsManagers();
97 },
98
99 'columnManagerWithName': function (aName) {
100 varmanagers;
101 var result;
102
103 managers = MochiKit.Base.filter(function (aManager) { return aManager.name() == aName; } , this.columnsManagers());
104
105 if (managers.length == 1) {
106 result = managers[0];
107 } else if (managers.length == 0) {
108 result = null;
109 } else {
110 throw "WTF!!!";
111 }
112
113 return result;
114 },
115
116 'sortedColumnManager': function () {
117 return this._sortedColumnManager;
118 },
119
120 'setSortedColumnManager': function(aValue) {
121 if (aValue.sorted() != 'UNSORTED') {
122 this._sortedColumnManager = aValue;
123 } else {
124 this._sortedColumnManager = null;
125 }
126 },
127
128 //-----------------------------------------------------------------------------
129
130 'handleColumnManagerSort': function(aSelectedColumnManager) {
131 MochiKit.Iter.forEach(this.columnsManagers(), function(aColumnManager) {
132 if (aSelectedColumnManager != aColumnManager) {
133 if (aColumnManager.isSortable()) {
134 aColumnManager.setSorted('UNSORTED');
135 }
136 }
137 });
138
139 aSelectedColumnManager.toggleSorting();
140 this.setSortedColumnManager(aSelectedColumnManager);
141
142 this.displaySelectedRows(this.filterController().getFilter());
143 },
144
145 'handleColumnManagerSelectRow': function (aRowObject) {
146 this.grid().selectRow(aRowObject);
147 },
148
149 'handleColumnManagerUnselectRow': function (aRowObject) {
150 this.grid().unselectRow(aRowObject);
151 },
152
153 //-----------------------------------------------------------------------------
154
155 'handleFilterUpdated': function (aFilter) {
156 if (this.grid().isActive()) {
157 this.displaySelectedRows(aFilter);
158 }
159 },
160
161 //-----------------------------------------------------------------------------
162 //TODO: relying on user() in GridController, bad code smell :|
163 //mhh: a controller should have access to business logic object too. Otherwise it will fail its controller role. [Giulio Cesare]
164
165 'setUser': function(anUser) {
166 this._user = anUser;
167 },
168
169 'user': function() {
170 return this._user;
171 },
172
173 //-----------------------------------------------------------------------------
174
175 'run': function(args) {
176//Clipperz.log("=== GridController.run");
177 var deferredResult;
178
179 this.setUser(args.user);
180 args.slot.setContent(this.grid());
181 this.filterController().registerFilterElement(this.grid().filterElement());
182 MochiKit.Signal.connect(this.filterController(), 'filterUpdated', this, 'handleFilterUpdated');
183
184 return this.displaySelectedRows();
185 },
186
187 //-----------------------------------------------------------------------------
188
189 'handleGenericError': function(anError) {
190 var result;
191
192 if (anError instanceof MochiKit.Async.CancelledError) {
193 result = anError;
194 } else {
195Clipperz.log("## GridController - GENERIC ERROR" + "\n" + "==>> " + anError + " <<==\n" + anError.stack);
196 result = new MochiKit.Async.CancelledError(anError);
197 }
198
199 return result;
200 },
201
202 //-----------------------------------------------------------------------------
203
204 'getRows': function () {
205 throw Clipperz.Base.AbstractMethod;
206 },
207
208 //-----------------------------------------------------------------------------
209
210 'setDeferredDisplaySelectedRowsInvocation': function (aDeferred) {
211 if (this._deferredDisplaySelectedRowsInvocation != null) {
212 this._deferredDisplaySelectedRowsInvocation.cancel();
213 }
214
215 this._deferredDisplaySelectedRowsInvocation = aDeferred;
216 },
217
218 //-----------------------------------------------------------------------------
219
220 'resetDeferredDisplaySelectedRowsInvocation': function () {
221 if (this._deferredDisplaySelectedRowsInvocation != null) {
222 this._deferredDisplaySelectedRowsInvocation.cancel();
223 }
224 },
225
226 //-----------------------------------------------------------------------------
227
228 '_displaySelectedRows': function (aFilter, someRows) {
229 var result;
230 var delay;
231
232 if ((aFilter != null) && (aFilter != '')) {
233 var filter;
234 varfilterRegExp;
235
236 filter = aFilter.replace(/[^A-Za-z0-9]/g, "\\$&");
237 filterRegExp = new RegExp(filter, "i");
238 result = MochiKit.Base.filter(function (aCachedResult) { return filterRegExp.test(aCachedResult['_searchableContent'])}, someRows);
239 delay = 0.002*result.length;
240
241 this.setDeferredDisplaySelectedRowsInvocation(MochiKit.Async.callLater(delay, MochiKit.Base.method(this, "deferredDisplaySelectedRows", result)));
242 } else {
243 result = someRows;
244
245 this.resetDeferredDisplaySelectedRowsInvocation();
246 this.deferredDisplaySelectedRows(result);
247 }
248
249 },
250
251 //-----------------------------------------------------------------------------
252
253 'deferredDisplaySelectedRows': function (someRows) {
254 if (this.sortedColumnManager() != null) {
255 var comparator;
256 var fieldName;
257
258 fieldName = this.sortedColumnManager().name();
259 comparator = this.sortedColumnManager().comparator();
260 if (this.sortedColumnManager().sorted() == 'DESCENDING') {
261 comparator = Clipperz.Base.reverseComparator(comparator);
262 }
263
264 someRows.sort(MochiKit.Base.partial(function(aKey, aComparator, aObject, bObject){
265 return comparator(aObject[aKey], bObject[aKey]);
266 }, this.sortedColumnManager().name(), comparator));
267 }
268
269 this.grid().update(someRows);
270 this.grid().endSearch();
271 },
272
273 //-----------------------------------------------------------------------------
274
275 'getCachedValues': function () {
276 var deferredResult;
277
278 if (this._cachedObjects != null) {
279 deferredResult = MochiKit.Async.succeed(this._cachedObjects);
280 } else {
281 var objectCollectResultsConfiguration;
282
283 objectCollectResultsConfiguration = {
284 '_rowObject': MochiKit.Async.succeed,
285 '_reference': MochiKit.Base.methodcaller('reference'),
286 '_searchableContent':MochiKit.Base.methodcaller('searchableContent')
287 };
288
289 MochiKit.Base.map(function (aColumnManager) {
290 objectCollectResultsConfiguration[aColumnManager.name()] = aColumnManager.selector();
291 }, this.columnsManagers());
292
293 deferredResult = new Clipperz.Async.Deferred("GridController.getCachedValues", {trace:false});
294 deferredResult.addMethod(this, 'getRows');
295 deferredResult.addCallback(MochiKit.Base.map, Clipperz.Async.collectResults("GridController.getCachedValues - collectResults", objectCollectResultsConfiguration, {trace:false}));
296 deferredResult.addCallback(Clipperz.Async.collectAll);
297 deferredResult.addCallback(MochiKit.Base.bind(function (someRows) {
298 this._cachedObjects = someRows;
299 return this._cachedObjects;
300 }, this));
301 deferredResult.callback();
302 }
303
304 return deferredResult;
305 },
306
307 //-----------------------------------------------------------------------------
308
309 'hasPendingChanges': function () {
310 return this.user().hasPendingChanges();
311 },
312
313 'saveChanges': function () {
314 this._cachedObjects = null;
315
316 return Clipperz.Async.callbacks("GridController.saveChanges", [
317 MochiKit.Base.method(this.user(), 'saveChanges'),
318 MochiKit.Base.method(this, 'focus')
319 ], {trace:false});
320 },
321
322 'revertChanges': function () {
323 return this.user().revertChanges();
324 },
325
326 //-----------------------------------------------------------------------------
327
328 'displayEmptyContent': function () {
329 },
330
331 'hideEmptyContent': function () {
332 this.grid().removeNoRowsGridComponent();
333 },
334
335 'displaySelectedRows': function (aFilter) {
336 if ((aFilter != null) && (aFilter != '')){
337 this.grid().startSearch();
338 }
339
340 return Clipperz.Async.callbacks("GridController.displaySelectedrows", [
341 MochiKit.Base.method(this, 'getCachedValues'),
342 MochiKit.Base.itemgetter('length'),
343 Clipperz.Async.deferredIf("There are some items to show in the grid", [
344 MochiKit.Base.method(this, 'hideEmptyContent'),
345 MochiKit.Base.method(this, 'getCachedValues'),
346 MochiKit.Base.method(this, '_displaySelectedRows', aFilter)
347 ], [
348 MochiKit.Base.method(this, 'displayEmptyContent'),
349 MochiKit.Base.method(this.grid(), 'endSearch')
350 ])
351 ], {trace:false});
352 },
353
354 //-----------------------------------------------------------------------------
355
356 'focus': function () {
357 return Clipperz.Async.callbacks("GridController.focus", [
358 MochiKit.Base.method(this, 'displaySelectedRows', this.filterController().getFilter()),
359 MochiKit.Base.method(this.grid(), 'focus')
360 ], {trace:false})
361 //*##*/this.displaySelectedRows(this.filterController().getFilter());
362 // this.grid().focus();
363 },
364
365 //=============================================================================
366
367 'deleteAllCleanTextData': function () {
368 this._cachedObjects = null;
369 this.grid().drawEmpty();
370 },
371
372 //=============================================================================
373 __syntaxFix__: "syntax fix"
374});
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js
new file mode 100644
index 0000000..d88af41
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js
@@ -0,0 +1,259 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers');
30
31Clipperz.PM.UI.Web.Controllers.LoginController = function(args) {
32 this._args = args || {};
33
34 this._loginPage = null;
35
36 this._newUserWizardController = null;
37 this._newUserCreationComponent = null;
38
39 return this;
40}
41
42MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.LoginController.prototype, {
43
44 'toString': function() {
45 return "Clipperz.PM.UI.Web.Controllers.LoginController";
46 },
47
48 'args': function () {
49 return this._args;
50 },
51
52 //-----------------------------------------------------------------------------
53
54 'loginPage': function() {
55 if (this._loginPage == null) {
56 this._loginPage = new Clipperz.PM.UI.Web.Components.LoginPage();
57
58 MochiKit.Signal.connect(this._loginPage, 'createNewAccountClick', this, 'handleCreateNewAccountClick')
59 }
60
61 return this._loginPage;
62 },
63
64 //-----------------------------------------------------------------------------
65
66 'run': function(args) {
67 varslot;
68 varloginPage;
69 varloginForm;
70
71 slot = args.slot;
72
73 loginForm =new Clipperz.PM.UI.Web.Components.LoginForm({'autocomplete': this.args()['autocomplete']});
74
75 slot.setContent(this.loginPage());
76 this.loginPage().slotNamed('loginForm').setContent(loginForm);
77
78 MochiKit.Signal.connect(loginForm, 'doLogin', MochiKit.Base.method(this, 'doLogin', loginForm));
79 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'doLogin', MochiKit.Base.method(this, 'doLogin', loginForm));
80 },
81
82 //-----------------------------------------------------------------------------
83
84 'doLogin': function(aLoginForm, anEvent) {
85 var deferredResult;
86 varparameters;
87 // varshouldUseOTP;
88 var loginProgress;
89 varuser;
90 var getPassphraseDelegate;
91
92 parameters = anEvent;
93 // shouldUseOTP = (typeof(parameters.passphrase) == 'undefined');
94
95 getPassphraseDelegate = MochiKit.Base.partial(MochiKit.Async.succeed, parameters.passphrase);
96 user = new Clipperz.PM.DataModel.User({'username':parameters.username, 'getPassphraseFunction':MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'getPassphrase')});
97
98 loginProgress = new Clipperz.PM.UI.Web.Components.LoginProgress();
99
100 deferredResult = new Clipperz.Async.Deferred("LoginController.doLogin", {trace:false});
101 deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':4});
102 deferredResult.addMethod(Clipperz.PM.RunTime.mainController, 'setPassphraseDelegate', getPassphraseDelegate);
103 deferredResult.addMethod(loginProgress, 'deferredShowModal', {deferredObject:deferredResult, openFromElement:aLoginForm.submitButtonElement()});
104 deferredResult.addMethod(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'deferredEntropyCollection');
105 // if (shouldUseOTP == false) {
106 deferredResult.addMethod(user, 'login');
107 // } else {
108 // deferredResult.addMethod(user, 'loginUsingOTP', parameters.username, parameters.otp);
109 // }
110 deferredResult.addCallback(function(aLoginProgress, res) {
111 aLoginProgress.disableCancel();
112 return res;
113 }, loginProgress);
114 deferredResult.addCallback(function () {
115 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'CARDS_CONTROLLER_DID_RUN',MochiKit.Base.method(loginProgress, 'deferredHideModalAndRemove', {closeToElement:MochiKit.DOM.currentDocument().body}));
116 })
117 deferredResult.addMethod(this, 'userLoggedIn', user, loginProgress, aLoginForm);
118 deferredResult.addErrback (MochiKit.Base.method(this, 'handleFailedLogin', loginProgress));
119
120 deferredResult.addErrback (MochiKit.Base.method(loginProgress, 'deferredHideModalAndRemove', {closeToElement:aLoginForm.submitButtonElement()}));
121 deferredResult.addErrbackPass (MochiKit.Base.method(aLoginForm, 'focusOnPassphraseField'));
122 deferredResult.addBoth(MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'removePassphraseDelegate', getPassphraseDelegate));
123 deferredResult.callback();
124
125 MochiKit.Signal.connect(loginProgress, 'cancelEvent', deferredResult, 'cancel');
126
127 return deferredResult;
128 },
129
130 //-----------------------------------------------------------------------------
131
132 'userLoggedIn': function(aUser) {
133//Clipperz.log(">>> LoginController.userLoggedIn");
134 MochiKit.Signal.signal(this, 'userLoggedIn', {user: aUser});
135//Clipperz.log("<<< LoginController.userLoggedIn");
136 },
137
138 //=========================================================================
139
140 'handleCreateNewAccountClick': function (aComponent) {
141 // return Clipperz.PM.DataModel.User.registerNewAccount("new", "user");
142 return Clipperz.Async.callbacks("LoginController.handleCreateNewAccountClick", [
143 //' MochiKit.Base.method(this, 'newUserCreationComponent'),
144 // MochiKit.Base.methodcaller('deferredShowModal', {openFromElement:aComponent}),
145 // MochiKit.Base.method(this.newUserWizardController(), 'run')
146
147
148 MochiKit.Base.method(this, 'newUserCreationComponent'),
149 Clipperz.Async.forkAndJoin("Async.test succeedingForkedAndWaitDeferrer", [
150 MochiKit.Base.method(this.newUserCreationComponent(), 'deferredShowModal', {openFromElement:aComponent, duration:0.5}),
151 MochiKit.Base.method(this.newUserWizardController(), 'run')
152 ], {trace:false}),
153 // MochiKit.Base.method(this.newUserCreationComponent(), 'enableCredentialsField')
154 ], {trace:false});
155 },
156
157 //-----------------------------------------------------------------------------
158
159 'newUserWizardController': function () {
160 if (this._newUserWizardController == null) {
161 this._newUserWizardController = new Clipperz.PM.UI.Web.Controllers.NewUserWizardController({
162 'newUserCreationComponent': this.newUserCreationComponent()
163 })
164
165 // MochiKit.Signal.connect(this._newUserWizardController, 'exit',this, 'handleHideNewUserCreationComponent');
166 MochiKit.Signal.connect(this._newUserWizardController, 'done',this, 'handleCompleteNewUserCreationComponent');
167 }
168
169 return this._newUserWizardController;
170 },
171
172 //-------------------------------------------------------------------------
173
174 'newUserCreationComponent': function () {
175 if (this._newUserCreationComponent == null) {
176 this._newUserCreationComponent = new Clipperz.PM.UI.Web.Components.NewUserCreationComponent();
177 }
178
179 return this._newUserCreationComponent;
180 },
181
182 'clearNewUserCreationComponent': function () {
183 if (this._newUserCreationComponent != null) {
184 this._newUserCreationComponent.clear();
185 }
186 this._newUserCreationComponent = null;
187 },
188
189 //-------------------------------------------------------------------------
190
191 'handleHideNewUserCreationComponent': function () {
192 this.clearNewUserCreationComponent();
193 },
194
195 'handleCompleteNewUserCreationComponent': function (someParameters) {
196 vardeferredResult;
197 varuser;
198 varnewUserCreationComponent;
199
200 user = someParameters.user;
201 newUserCreationComponent = this.newUserCreationComponent();
202 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'CARDS_CONTROLLER_DID_RUN',MochiKit.Base.method(newUserCreationComponent, 'deferredHideModal', {closeToElement:MochiKit.DOM.currentDocument().body})),
203
204 deferredResult = new Clipperz.Async.Deferred("LoginController.handleCompleteNewUserCreationComponent", {trace:false});
205
206 deferredResult.addCallbackList([
207 MochiKit.Base.method(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'deferredEntropyCollection'),
208 MochiKit.Base.method(user, 'login'),
209 MochiKit.Base.method(this, 'userLoggedIn', user),
210 MochiKit.Base.method(this, 'clearNewUserCreationComponent')
211 ]);
212 deferredResult.addErrback(function (aValue) { Clipperz.log("WTF!! Error doing the login after creating a new user" + aValue)});
213 deferredResult.callback();
214
215 return deferredResult;
216 },
217
218
219 //=========================================================================
220
221 'handleFailedLogin': function(aLoginProgress, anError) {
222 var result;
223
224//console.log("anError", anError);
225 if (anError instanceof MochiKit.Async.CancelledError) {
226 result = anError;
227 } else {
228 var deferredResult;
229
230MochiKit.Logging.logError("## MainController - FAILED LOGIN: " + anError);
231 deferredResult = new MochiKit.Async.Deferred();
232
233 aLoginProgress.showErrorMessage("failed login");
234 // Clipperz.NotificationCenter.register(loginProgress, 'cancelEvent', deferredResult, 'callback');
235 MochiKit.Signal.connect(aLoginProgress, 'cancelEvent', deferredResult, 'callback');
236 deferredResult.addCallback(MochiKit.Async.fail, anError)
237 result = deferredResult;
238 }
239
240 return result;
241 },
242
243 'handleGenericError': function(anError) {
244 var result;
245
246 if (anError instanceof MochiKit.Async.CancelledError) {
247 result = anError;
248 } else {
249MochiKit.Logging.logError("## MainController - GENERIC ERROR" + "\n" + "==>> " + anError + " <<==\n" + anError.stack);
250//console.log(anError);
251 result = new MochiKit.Async.CancelledError(anError);
252 }
253
254 return result;
255 },
256
257 //-----------------------------------------------------------------------------
258 __syntaxFix__: "syntax fix"
259});
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/MainController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/MainController.js
new file mode 100644
index 0000000..aa0d6ad
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/MainController.js
@@ -0,0 +1,218 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers');
30
31Clipperz.PM.UI.Web.Controllers.MainController = function(args) {
32 this._args = args;
33
34 //controllers
35 this._loginController =null;
36 this._appController =null;
37
38 //components
39 this._headerComponent = null;
40 this._pageComponent =null;
41 this._footerComponent = null;
42
43 this._passphraseDelegateLock = new MochiKit.Async.DeferredLock();
44 this._passphraseDelegateLock.acquire();
45//Clipperz.log('MainController init _passphraseDelegateLock', this._passphraseDelegateLock);
46 this._passphraseDelegate = null;
47
48 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'remoteRequestSent', this, 'handleRemoteRequestSent');
49 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'remoteRequestReceived',this, 'handleRemoteRequestReceived');
50
51 return this;
52}
53
54MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.MainController.prototype, {
55
56 'toString': function() {
57 return "Clipperz.PM.UI.Web.Controllers.MainController";
58 },
59
60 'args': function () {
61 return this._args;
62 },
63
64 //-----------------------------------------------------------------------------
65
66 'headerComponent': function() {
67 if (this._headerComponent == null) {
68 this._headerComponent = new Clipperz.PM.UI.Web.Components.PageHeader();
69 }
70
71 return this._headerComponent;
72 },
73
74 'footerComponent': function() {
75 if (this._footerComponent == null) {
76 this._footerComponent = new Clipperz.PM.UI.Web.Components.PageFooter();
77 }
78
79 return this._footerComponent;
80 },
81
82 //-----------------------------------------------------------------------------
83
84 'pageComponent': function() {
85 if (this._pageComponent == null) {
86 this._pageComponent = new Clipperz.PM.UI.Web.Components.Page({element:MochiKit.DOM.getElement('mainDiv')});
87 }
88
89 return this._pageComponent;
90 },
91
92 //-----------------------------------------------------------------------------
93
94 'loginController': function() {
95 if (this._loginController == null) {
96 this._loginController = new Clipperz.PM.UI.Web.Controllers.LoginController(this.args());
97
98 MochiKit.Signal.connect(this._loginController, 'userLoggedIn', this, 'loginControllerUserLoggedInCallback');
99 }
100
101 return this._loginController;
102 },
103
104 'appController': function() {
105 if (this._appController == null) {
106 this._appController = new Clipperz.PM.UI.Web.Controllers.AppController();
107
108 MochiKit.Signal.connect(this._appController, 'logout', this, 'handleLogout');
109 }
110
111 return this._appController;
112 },
113
114 //-----------------------------------------------------------------------------
115
116 'run': function(shoudShowRegistrationForm) {
117 this.pageComponent().slotNamed('header').setContent(this.headerComponent());
118 this.pageComponent().slotNamed('footer').setContent(this.footerComponent());
119
120 this.pageComponent().render();
121
122 this.loginController().run({slot:this.pageComponent().slotNamed('body')});
123
124 if (shoudShowRegistrationForm) {
125 MochiKit.Signal.signal(this.loginController().loginPage(), 'createNewAccountClick');
126 // this.loginController().handleCreateNewAccountClick();
127 }
128 },
129
130 //-----------------------------------------------------------------------------
131
132 'getPassphrase': function () {
133 var deferredResult;
134
135 deferredResult = new Clipperz.Async.Deferred("MainController.getPassphrase", {trace:false});
136
137 deferredResult.acquireLock(this._passphraseDelegateLock);
138 deferredResult.addMethod(this, 'invokePassphraseDelegate');
139 deferredResult.releaseLock(this._passphraseDelegateLock);
140 deferredResult.callback();
141
142 return deferredResult;
143 },
144
145 //.........................................................................
146
147 'invokePassphraseDelegate': function () {
148 return this._passphraseDelegate();
149 },
150
151 'passphraseDelegateLock': function () {
152 return this._passphraseDelegateLock;
153 },
154
155 //.........................................................................
156
157 'setPassphraseDelegate': function (aDelegate) {
158 var shouldReleaseLock;
159
160 shouldReleaseLock = (this._passphraseDelegate == null);
161
162 this._passphraseDelegate = aDelegate;
163
164 if (shouldReleaseLock) {
165 this._passphraseDelegateLock.release();
166 }
167 },
168
169 //.........................................................................
170
171 'removePassphraseDelegate': function (aDelegate) {
172 if (this._passphraseDelegate == aDelegate) {
173 this._passphraseDelegate = null;
174 this._passphraseDelegateLock.acquire();
175 }
176 },
177
178 //-------------------------------------------------------------------------
179
180 'loginControllerUserLoggedInCallback': function(anEvent) {
181//Clipperz.log(">>> loginControllerUserLoggedInCallback", anEvent);
182 // this.setUser(anEvent.parameters()['user']);
183//console.log("--- loginControllerUserLoggedInCallback - 1");
184
185//console.log("--- loginControllerUserLoggedInCallback - 2");
186 this.headerComponent().switchToLoggedMode();
187 this.appController().run({slot:this.pageComponent().slotNamed('body'), user:anEvent['user']});
188//Clipperz.log("<<< loginControllerUserLoggedInCallback");
189 },
190
191 //-----------------------------------------------------------------------------
192
193 'handleRemoteRequestSent': function () {
194//Clipperz.log("REMOTE REQUEST sent >>>");
195 },
196
197 'handleRemoteRequestReceived': function () {
198//Clipperz.log("REMOTE REQUEST received <<<");
199 },
200
201 //-----------------------------------------------------------------------------
202
203 'handleLogout': function(anEvent) {
204 this.exit('logout.html');
205 },
206
207 //-----------------------------------------------------------------------------
208
209 'exit': function(aPageName) {
210//Clipperz.log("### exit " + aPageName);
211 MochiKit.Async.wait(0).addCallback(function() {
212 window.location.href = "./" + aPageName + "?ln=" + Clipperz.PM.Strings.selectedLanguage;
213 });
214 },
215
216 //-----------------------------------------------------------------------------
217 __syntaxFix__: "syntax fix"
218});
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/NewUserWizardController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/NewUserWizardController.js
new file mode 100644
index 0000000..28d9d20
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/NewUserWizardController.js
@@ -0,0 +1,469 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers');
30
31Clipperz.PM.UI.Web.Controllers.NewUserWizardController = function(args) {
32 this._newUserCreationComponent = args.newUserCreationComponent|| Clipperz.Base.exception.raise('MandatoryParameter');
33
34 MochiKit.Signal.connect(this._newUserCreationComponent, 'changedValue',this, 'handleChangedValue');
35 MochiKit.Signal.connect(this._newUserCreationComponent, 'moveForward',this, 'handleMoveForward');
36 MochiKit.Signal.connect(this._newUserCreationComponent, 'keyPressed',this, 'handleNewUserCreationComponentKeyPressed');
37
38 this._rulerComponent = null;
39
40 this._steps = null;
41 this._currentStepIndex = 0;
42 this._isNextEnabled = false;
43
44 this._userCreationState = 'IDLE'; //'IN PROGRESS', 'DONE', 'FAILED'
45 this._user = null;
46 return this;
47}
48
49MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.NewUserWizardController.prototype, {
50
51 'toString': function() {
52 return "Clipperz.PM.UI.Web.Controllers.NewUserWizardController";
53 },
54
55 //-------------------------------------------------------------------------
56
57 'newUserCreationComponent': function () {
58 return this._newUserCreationComponent;
59 },
60
61 //=============================================================================
62
63 'user': function () {
64 return this._user;
65 },
66
67 'setUser': function (aValue) {
68 this._user = aValue;
69 },
70
71 //-----------------------------------------------------------------------------
72
73 'userCreationState': function () {
74 return this._userCreationState;
75 },
76
77 'setUserCreationState': function (aValue) {
78//console.log("+++ NewUserWizardController.setUserCreationState", aValue);
79 this._userCreationState = aValue;
80 this.checkState();
81 },
82
83 //=============================================================================
84
85 'resetCurrentStepIndex': function () {
86 this._currentStepIndex = 0;
87 this.rulerComponent().resetStatus({animateTransition:true});
88 },
89
90 //-----------------------------------------------------------------------------
91
92 'enableNext': function (aValue) {
93 this.rulerComponent().enableNext(aValue);
94 this._isNextEnabled = aValue;
95 },
96
97 'isNextEnabled': function () {
98 return this._isNextEnabled;
99 },
100
101 //-----------------------------------------------------------------------------
102
103 'enablePrevious': function (aValue) {
104 this.rulerComponent().enablePrevious(aValue);
105 },
106
107 //=============================================================================
108
109 'rulerComponent': function () {
110 if (this._rulerComponent == null) {
111 this._rulerComponent = new Clipperz.PM.UI.Web.Components.RulerComponent({
112 translationContext:'Wizards.NewUserWizard'
113 });
114 this._rulerComponent.render();
115
116 MochiKit.Signal.connect(this._rulerComponent, 'exit', this, 'handleExit');
117 MochiKit.Signal.connect(this._rulerComponent, 'done', this, 'done');
118 MochiKit.Signal.connect(this._rulerComponent, 'moveForward',this, 'handleMoveForward');
119 MochiKit.Signal.connect(this._rulerComponent, 'moveBackward',this, 'handleMoveBackward');
120 MochiKit.Signal.connect(this._rulerComponent, 'cursorMoved',this, 'handleCursorMoved');
121 }
122
123 return this._rulerComponent;
124 },
125
126 'resetRuler': function () {
127 // if (this._rulerComponent != null) {
128 // this._rulerComponent.clear();
129 // }
130 // this._rulerComponent = null;
131 },
132
133 //-----------------------------------------------------------------------------
134
135 'showRuler': function (someSteps) {
136 var rulerElement;
137
138 this.setSteps(someSteps);
139
140 rulerElement = this.rulerComponent().element();
141 this.newUserCreationComponent().disableAllPanels();
142
143 MochiKit.Style.showElement(rulerElement);
144 MochiKit.Style.setElementPosition(rulerElement, {x:-1000, y:this.newUserCreationComponent().bottomMargin()});
145 new MochiKit.Visual.Move(rulerElement, {
146 x:0, y:this.newUserCreationComponent().bottomMargin(),
147 mode:'absolute',
148 duration:0.5,
149 // afterFinish:MochiKit.Base.method(this, 'handleCursorMoved')
150 afterFinish:MochiKit.Base.method(this, 'handleRulerShowed')
151 });
152 },
153
154 //-----------------------------------------------------------------------------
155
156 'handleRulerShowed':function () {
157 return Clipperz.Async.callbacks("NewUserWizardController.handlerRulerShowed", [
158 MochiKit.Base.method(this.newUserCreationComponent(), 'waitUntilFullyRendered'),
159 MochiKit.Base.method(this, 'handleCursorMoved')
160 ], {trace:false});
161 },
162
163 //-----------------------------------------------------------------------------
164
165 'hideRuler': function () {
166 new MochiKit.Visual.Move(this.rulerComponent().element(), {x:-1000, mode:'relative', duration:0.5});
167 },
168
169 'doneWithRuler': function () {
170 var rulerComponentElement;
171
172 rulerComponentElement = this.rulerComponent().element();
173 new MochiKit.Visual.Move(this.rulerComponent().element(), {
174 x:1000,
175 mode:'relative',
176 duration:1,
177 // afterFinish:MochiKit.Base.partial(MochiKit.Style.hideElement, rulerComponentElement)
178 afterFinish:function () { MochiKit.Style.hideElement(rulerComponentElement); }
179 });
180 },
181
182 //=============================================================================
183
184 'createNewUserRulerSteps': function () {
185 return [ 'CREDENTIALS', 'CHECK_CREDENTIALS', 'TERMS_OF_SERVICE', 'CREATE_USER'/*, 'LOGIN' */];
186 },
187
188 //-------------------------------------------------------------------------
189
190 'run': function () {
191 return Clipperz.Async.callbacks("NewUserWizardController.run", [
192 MochiKit.Base.method(this, 'createNewUserRulerSteps'),
193 MochiKit.Base.method(this, 'showRuler')
194 ], {trace:false});
195 },
196
197 //-----------------------------------------------------------------------------
198
199 'checkState': function () {
200 var enablePrevious;
201 var enableNext;
202
203 enablePrevious = true;
204 enableNext = false;
205
206 this.newUserCreationComponent().disableAllPanels();
207
208 switch(this.currentStep()) {
209 case 'CREDENTIALS':
210 this.newUserCreationComponent().enableCredentialsPanel();
211
212 enableNext = (
213 (this.newUserCreationComponent().username() != '')
214 &&
215 (this.newUserCreationComponent().passphrase() != '')
216 );
217 // enablePrevious = false;
218 break;
219 case 'CHECK_CREDENTIALS':
220 this.newUserCreationComponent().enableCheckCredentialsPanel();
221
222 enableNext = (this.newUserCreationComponent().passphrase() == this.newUserCreationComponent().rePassphrase());
223 // enablePrevious = true;
224 break
225 case 'TERMS_OF_SERVICE':
226 this.newUserCreationComponent().enableTermsOfServicePanel();
227
228//console.log("awareOfUnrecoverablePassphrase", this.newUserCreationComponent().awareOfUnrecoverablePassphrase());
229//console.log("readTermsOfService", this.newUserCreationComponent().readTermsOfService());
230 enableNext = (
231 (this.newUserCreationComponent().awareOfUnrecoverablePassphrase() == 'on')
232 &&
233 (this.newUserCreationComponent().readTermsOfService() == 'on')
234 )
235 break;
236 case 'CREATE_USER':
237//console.log(">>> CREATE_USER", this.userCreationState());
238 this.newUserCreationComponent().enableCreateUserPanel();
239
240 switch (this.userCreationState()) {
241 case 'IDLE':
242 this.setUserCreationState('IN PROGRESS');
243 this.preformActualUserRegistration();
244
245 enablePrevious = false;
246 enableNext = false;
247 break;
248 case 'IN PROGRESS':
249 enablePrevious = false;
250 enableNext = false;
251 break;
252 case 'DONE':
253 enablePrevious = false;
254 enableNext = true;
255 break;
256 case 'FAILED':
257 enablePrevious = true;
258 enableNext = false;
259 break;
260 };
261 break;
262 // case 'LOGIN':
263 // this.newUserCreationComponent().enableLoginPanel();
264 // break;
265 }
266
267 if (this.currentStepIndex() > 0) {
268 this.enablePrevious(enablePrevious);
269 } else {
270 this.enablePrevious(false);
271 }
272 this.enableNext(enableNext);
273 },
274
275 //-----------------------------------------------------------------------------
276
277 'setFocus': function () {
278 switch(this.currentStep()) {
279 case 'CREDENTIALS':
280 this.newUserCreationComponent().focusOnUsernameElement();
281 break;
282 case 'CHECK_CREDENTIALS':
283 this.newUserCreationComponent().focusOnRePassphraseElement();
284 break
285 case 'TERMS_OF_SERVICE':
286 break;
287 case 'CREATE_USER':
288 break;
289 // case 'LOGIN':
290 // break;
291 }
292 },
293
294 //=============================================================================
295
296 'steps': function () {
297 return this._steps;
298 },
299
300 'setSteps': function (aValue) {
301 this._steps = aValue;
302
303 this.rulerComponent().setSteps(aValue);
304 this.resetCurrentStepIndex();
305 },
306
307 'currentStepIndex': function () {
308 return this._currentStepIndex;
309 },
310
311 'currentStep': function () {
312 return this.steps()[this.currentStepIndex()];
313 },
314
315 //=============================================================================
316
317 'handleExit': function () {
318 return Clipperz.Async.callbacks("NewUserWizardController.handleExit", [
319 // MochiKit.Base.method(this.newUserCreationComponent(), 'resetContent'),
320 Clipperz.Async.forkAndJoin("NewUserWizardController.handleExit - fork and join", [
321 MochiKit.Base.method(this, 'hideRuler'),
322 MochiKit.Base.method(this.newUserCreationComponent(), 'deferredHideModal')
323 ], {trace:false}),
324 MochiKit.Base.method(this, 'resetRuler'),
325 // MochiKit.Base.method(this.newUserCreationComponent(), 'reset'),
326 MochiKit.Base.partial(MochiKit.Signal.signal, this, 'exit')
327 ], {trace:false})
328 },
329
330 'done': function () {
331 this.doneWithRuler();
332 MochiKit.Signal.signal(this, 'done', {'user': this.user()});
333 },
334
335 //=============================================================================
336
337 'handleMoveBackward': function () {
338 if (this._currentStepIndex > 0) {
339 varafterMoveAction;
340
341 afterMoveAction = MochiKit.Base.noop;
342
343//console.log("<-- backward", this.currentStep());
344 switch(this.currentStep()) {
345 case 'CREDENTIALS':
346 case 'CHECK_CREDENTIALS':
347 case 'TERMS_OF_SERVICE':
348 this._currentStepIndex --;
349 this.rulerComponent().moveBackward(afterMoveAction);
350 break;
351 case 'CREATE_USER':
352 this.setUser(null);
353 this.newUserCreationComponent().hideAllProgeressStates();
354 this.resetCurrentStepIndex();
355 this.setUserCreationState('IDLE');
356 break;
357 // case 'LOGIN':
358 // break;
359 };
360
361 }
362
363 if (this._currentStepIndex == 0) {
364 this.enablePrevious(false);
365 }
366 },
367
368 'handleMoveForward': function () {
369 if (this.isNextEnabled()) {
370 varafterMoveAction;
371
372 this._currentStepIndex ++;
373 afterMoveAction = MochiKit.Base.noop;
374
375 switch(this.currentStep()) {
376 case 'CREDENTIALS':
377 break;
378 case 'CHECK_CREDENTIALS':
379 break
380 case 'TERMS_OF_SERVICE':
381 break;
382 case 'CREATE_USER':
383 break;
384 // case 'LOGIN':
385 // break;
386 };
387
388 this.rulerComponent().moveForward(afterMoveAction);
389 };
390 },
391
392 'handleCursorMoved': function () {
393 // this.checkState();
394 // this.setFocus();
395
396 return Clipperz.Async.callbacks("NewUserWizardController.handleCursorMoved", [
397 MochiKit.Base.method(this.newUserCreationComponent(), 'waitUntilFullyRendered'),
398 MochiKit.Base.method(this, 'checkState'),
399 MochiKit.Base.method(this, 'setFocus')
400 ], {trace:false});
401 },
402
403 //-------------------------------------------------------------------------
404
405 'handleChangedValue': function (anEvent) {
406 this.checkState();
407 },
408
409 //-------------------------------------------------------------------------
410
411 'handleNewUserCreationComponentKeyPressed': function (anEvent) {
412//console.log(">>> handleNewUserCreationComponentKeyPressed", anEvent.key().string);
413 if (anEvent.key().string == 'KEY_ENTER') {
414 if (anEvent.target().nodeName != 'TEXTAREA') {
415 anEvent.preventDefault();
416 this.handleMoveForward();
417 }
418 } else if (anEvent.key().string == 'KEY_TAB') {
419 if (anEvent.target() == this.newUserCreationComponent().usernameElement()) {
420 } else {
421 this.handleMoveForward();
422 if ((anEvent.target().nodeName == 'INPUT') || (anEvent.target().nodeName == 'TEXTAREA')) {
423 anEvent.preventDefault();
424 }
425 }
426 } else if ((anEvent.key().string == 'KEY_ARROW_RIGHT') && (anEvent.modifier().meta == true)) {
427 this.handleMoveForward();
428 } else if ((anEvent.key().string == 'KEY_ARROW_LEFT') && (anEvent.modifier().meta == true)) {
429 this.handleMoveBackward();
430 } else if (anEvent.key().string == 'KEY_ESCAPE') {
431 anEvent.stop();
432 this.handleExit();
433 } else {
434 MochiKit.Async.callLater(0.1, MochiKit.Base.method(this, 'checkState'));
435 }
436 },
437
438 //=============================================================================
439
440 'preformActualUserRegistration': function () {
441 vardeferredResult;
442
443 deferredResult = new Clipperz.Async.Deferred("NewUSerWizardController.preformActualUserRegistration", {trace:false});
444 deferredResult.addMethod(this.newUserCreationComponent(), 'showProgressOnUserCreation');
445 deferredResult.addMethod(Clipperz.PM.RunTime.mainController, 'setPassphraseDelegate', MochiKit.Base.method(this.newUserCreationComponent(), 'passphrase'));
446 deferredResult.addCallback(Clipperz.PM.DataModel.User.registerNewAccount,
447 this.newUserCreationComponent().username(),
448 MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'getPassphrase')
449 );
450 deferredResult.addMethod(this, 'setUser');
451 deferredResult.addMethod(this.newUserCreationComponent(), 'showUserCreationDone');
452 deferredResult.addMethod(this, 'setUserCreationState', 'DONE');
453
454 // deferredResult.addErrback(MochiKit.Base.method(this.newUserCreationComponent(), 'showUserCreationFailed'));
455 // deferredResult.addErrback(MochiKit.Base.method(this, 'setUser', null));
456 // deferredResult.addErrback(MochiKit.Base.method(this, 'setUserCreationState', 'FAILED'));
457 deferredResult.addErrback(MochiKit.Base.bind(function (aValue) {
458 this.newUserCreationComponent().showUserCreationFailed();
459 this.setUser(null);
460 this.setUserCreationState('FAILED');
461 }, this));
462 deferredResult.callback();
463
464 return deferredResult;
465 },
466
467 //=============================================================================
468 __syntaxFix__: "syntax fix"
469});