summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/AppController.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/AppController.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/AppController.js23
1 files changed, 10 insertions, 13 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
index 1ab2e69..3d9d6d3 100644
--- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/AppController.js
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/AppController.js
@@ -1,118 +1,116 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2013 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz, the online password manager.
6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 6For further information about its features and functionalities please
8refer to http://www.clipperz.com. 7refer to http://www.clipperz.com.
9 8
10* Clipperz Community Edition is free software: you can redistribute 9* Clipperz is free software: you can redistribute it and/or modify it
11 it and/or modify it under the terms of the GNU Affero General Public 10 under the terms of the GNU Affero General Public License as published
12 License as published by the Free Software Foundation, either version 11 by the Free Software Foundation, either version 3 of the License, or
13 3 of the License, or (at your option) any later version. 12 (at your option) any later version.
14 13
15* Clipperz Community Edition is distributed in the hope that it will 14* Clipperz is distributed in the hope that it will be useful, but
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 15 WITHOUT ANY WARRANTY; without even the implied warranty of
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 17 See the GNU Affero General Public License for more details.
19 18
20* You should have received a copy of the GNU Affero General Public 19* You should have received a copy of the GNU Affero General Public
21 License along with Clipperz Community Edition. If not, see 20 License along with Clipperz. If not, see http://www.gnu.org/licenses/.
22 <http://www.gnu.org/licenses/>.
23 21
24*/ 22*/
25 23
26Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers'); 24Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers');
27 25
28Clipperz.PM.UI.Web.Controllers.AppController = function(args) { 26Clipperz.PM.UI.Web.Controllers.AppController = function(args) {
29 27
30 this._user = null; 28 this._user = null;
31 this._tabSlotNames = { 29 this._tabSlotNames = {
32 //tabName: slotName 30 //tabName: slotName
33 'cards': 'cardGrid', 31 'cards': 'cardGrid',
34 // 'directLogins':'directLoginGrid', 32 // 'directLogins':'directLoginGrid',
35 'account': 'accountPanel', 33 'account': 'accountPanel',
36 'data': 'dataPanel', 34 'data': 'dataPanel',
37 'tools': 'toolsPanel' 35 'tools': 'toolsPanel'
38 }; 36 };
39 37
40 //controllers 38 //controllers
41 this._cardsController= null; 39 this._cardsController= null;
42 //this._directLoginsController = null; 40 //this._directLoginsController = null;
43 this._filterController = null; //new Clipperz.PM.UI.Web.Controllers.FilterController(); 41 this._filterController = null; //new Clipperz.PM.UI.Web.Controllers.FilterController();
44 42
45 //components 43 //components
46 this._appPage = null; 44 this._appPage = null;
47 this._userInfoBox = null; 45 this._userInfoBox = null;
48 this._tabSidePanel = null; 46 this._tabSidePanel = null;
49 47
50 // MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'editCard', this, 'handleEditCard'); 48 // MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'editCard', this, 'handleEditCard');
51 // MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'deleteCard',this, 'handleDeleteCard'); 49 // MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'deleteCard',this, 'handleDeleteCard');
52 50
53 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'userDataSuccessfullySaved',this, 'userDataSuccessfullySavedHandler'); 51 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'userDataSuccessfullySaved',this, 'userDataSuccessfullySavedHandler');
54 52
55 return this; 53 return this;
56} 54}
57 55
58MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.AppController.prototype, { 56MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.AppController.prototype, {
59 57
60 'toString': function() { 58 'toString': function() {
61 return "Clipperz.PM.UI.Web.Controllers.AppController"; 59 return "Clipperz.PM.UI.Web.Controllers.AppController";
62 }, 60 },
63 61
64 //----------------------------------------------------------------------------- 62 //-----------------------------------------------------------------------------
65 63
66 'setUser': function(anUser) { 64 'setUser': function(anUser) {
67 this._user = anUser; 65 this._user = anUser;
68 }, 66 },
69 67
70 'user': function() { 68 'user': function() {
71 return this._user; 69 return this._user;
72 }, 70 },
73 71
74 //----------------------------------------------------------------------------- 72 //-----------------------------------------------------------------------------
75 /* 73 /*
76 'tabSlotNames': function() { 74 'tabSlotNames': function() {
77 return this._tabSlotNames; 75 return this._tabSlotNames;
78 }, 76 },
79*/ 77*/
80 'slotNameForTab': function(aTabName) { 78 'slotNameForTab': function(aTabName) {
81 return this._tabSlotNames[aTabName]; 79 return this._tabSlotNames[aTabName];
82 }, 80 },
83 81
84 'hideAllAppPageTabSlots': function() { 82 'hideAllAppPageTabSlots': function() {
85 var aTabName; 83 var aTabName;
86 84
87 for (aTabName in this._tabSlotNames) { 85 for (aTabName in this._tabSlotNames) {
88 this.appPage().hideSlot(this.slotNameForTab(aTabName)); 86 this.appPage().hideSlot(this.slotNameForTab(aTabName));
89 } 87 }
90 }, 88 },
91 89
92 //----------------------------------------------------------------------------- 90 //-----------------------------------------------------------------------------
93 91
94 'appPage': function() { 92 'appPage': function() {
95 if (this._appPage == null) { 93 if (this._appPage == null) {
96 this._appPage = new Clipperz.PM.UI.Web.Components.AppPage(); 94 this._appPage = new Clipperz.PM.UI.Web.Components.AppPage();
97 } 95 }
98 96
99 return this._appPage; 97 return this._appPage;
100 }, 98 },
101 99
102 //----------------------------------------------------------------------------- 100 //-----------------------------------------------------------------------------
103 101
104 'tabSidePanel': function() { 102 'tabSidePanel': function() {
105 if (this._tabSidePanel == null) { 103 if (this._tabSidePanel == null) {
106 this._tabSidePanel = new Clipperz.PM.UI.Web.Components.TabSidePanel(); 104 this._tabSidePanel = new Clipperz.PM.UI.Web.Components.TabSidePanel();
107 } 105 }
108 106
109 return this._tabSidePanel; 107 return this._tabSidePanel;
110 }, 108 },
111 109
112 //----------------------------------------------------------------------------- 110 //-----------------------------------------------------------------------------
113 111
114 'userInfoBox': function() { 112 'userInfoBox': function() {
115 if (this._userInfoBox == null) { 113 if (this._userInfoBox == null) {
116 this._userInfoBox = new Clipperz.PM.UI.Web.Components.UserInfoBox(); 114 this._userInfoBox = new Clipperz.PM.UI.Web.Components.UserInfoBox();
117 115
118 MochiKit.Signal.connect(this._userInfoBox, 'logout',this, 'handleLogout'); 116 MochiKit.Signal.connect(this._userInfoBox, 'logout',this, 'handleLogout');
@@ -231,121 +229,120 @@ MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.AppController.prototype, {
231 this.hideAllAppPageTabSlots(); 229 this.hideAllAppPageTabSlots();
232 this.appPage().showSlot(this.slotNameForTab('cards')); 230 this.appPage().showSlot(this.slotNameForTab('cards'));
233 231
234 MochiKit.Signal.connect(this.tabSidePanel(), 'tabSelected', this, 'handleTabSelected'); 232 MochiKit.Signal.connect(this.tabSidePanel(), 'tabSelected', this, 'handleTabSelected');
235 MochiKit.Signal.connect(this.tabSidePanel(), 'addCard', this, 'handleAddCard'); 233 MochiKit.Signal.connect(this.tabSidePanel(), 'addCard', this, 'handleAddCard');
236 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'addCard', this, 'handleAddCard'); 234 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'addCard', this, 'handleAddCard');
237 235
238 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'downloadOfflineCopy',this, 'handleDownloadOfflineCopy'); 236 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'downloadOfflineCopy',this, 'handleDownloadOfflineCopy');
239 237
240 deferredResult = new Clipperz.Async.Deferred("AppController.run", {trace:false}); 238 deferredResult = new Clipperz.Async.Deferred("AppController.run", {trace:false});
241 239
242 deferredResult.addMethod(this.cardsController(), 'run', {slot:this.appPage().slotNamed('cardGrid'), user:user}); 240 deferredResult.addMethod(this.cardsController(), 'run', {slot:this.appPage().slotNamed('cardGrid'), user:user});
243 // deferredResult.addMethod(this.directLoginsController(), 'run', {slot:this.appPage().slotNamed('directLoginGrid'), user:user}); 241 // deferredResult.addMethod(this.directLoginsController(), 'run', {slot:this.appPage().slotNamed('directLoginGrid'), user:user});
244 deferredResult.addMethod(this, 'populateUserInfo'); 242 deferredResult.addMethod(this, 'populateUserInfo');
245 243
246 deferredResult.addCallback(MochiKit.Visual.ScrollTo, 'miscLinks', {duration:0}); 244 deferredResult.addCallback(MochiKit.Visual.ScrollTo, 'miscLinks', {duration:0});
247 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'CARDS_CONTROLLER_DID_RUN'); 245 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'CARDS_CONTROLLER_DID_RUN');
248 deferredResult.addMethod(this.tabSidePanel(), 'selectTab', 'cards'); 246 deferredResult.addMethod(this.tabSidePanel(), 'selectTab', 'cards');
249 deferredResult.callback(); 247 deferredResult.callback();
250 }, 248 },
251 249
252 //----------------------------------------------------------------------------- 250 //-----------------------------------------------------------------------------
253 251
254 'handleTabSelected': function (selectedTabName) { 252 'handleTabSelected': function (selectedTabName) {
255 var aTabName; 253 var aTabName;
256 var aSlotName; 254 var aSlotName;
257 255
258//Clipperz.log(">>> AppController.handleTabSelected", selectedTabName); 256//Clipperz.log(">>> AppController.handleTabSelected", selectedTabName);
259 this.hideAllAppPageTabSlots(); 257 this.hideAllAppPageTabSlots();
260 this.appPage().showSlot(this.slotNameForTab(selectedTabName)); 258 this.appPage().showSlot(this.slotNameForTab(selectedTabName));
261 259
262 switch (selectedTabName) { 260 switch (selectedTabName) {
263 case 'cards': 261 case 'cards':
264 this.cardsController().focus(); 262 this.cardsController().focus();
265 break; 263 break;
266 // case 'directLogins': 264 // case 'directLogins':
267 // this.directLoginsController().focus(); 265 // this.directLoginsController().focus();
268 // break; 266 // break;
269 case 'data': 267 case 'data':
270 break; 268 break;
271 case 'account': 269 case 'account':
272 break; 270 break;
273 case 'tools': 271 case 'tools':
274 break; 272 break;
275 } 273 }
276//Clipperz.log("<-- AppController.handleTabSelected", aTabName); 274//Clipperz.log("<-- AppController.handleTabSelected", aTabName);
277 }, 275 },
278 276
279 //============================================================================= 277 //=============================================================================
280 278
281 'handleAddCard': function (aSourceElement) { 279 'handleAddCard': function (aSourceElement) {
282//Clipperz.log("=== AppController.addCard", aSourceElement); 280//Clipperz.log("=== AppController.addCard", aSourceElement);
283 this.cardsController().addCard(aSourceElement); 281 this.cardsController().addCard(aSourceElement);
284 }, 282 },
285 283
286 //============================================================================= 284 //=============================================================================
287 285
288 'userDataSuccessfullySavedHandler': function (anEvent) { 286 'userDataSuccessfullySavedHandler': function (anEvent) {
289 this.populateUserInfo(); 287 this.populateUserInfo();
290 }, 288 },
291 289
292 //============================================================================= 290 //=============================================================================
293 291
294 'handleLogout': function(anEvent) { 292 'handleLogout': function(anEvent) {
295 var deferredResult; 293 var deferredResult;
296 294
297 deferredResult = new Clipperz.Async.Deferred("AppController.handleLogout", {trace:false}); 295 deferredResult = new Clipperz.Async.Deferred("AppController.handleLogout", {trace:false});
298 deferredResult.addMethod(this.user(), 'logout'); 296 deferredResult.addMethod(this.user(), 'logout');
299 deferredResult.addCallback(MochiKit.Signal.signal, this, 'logout'); 297 deferredResult.addCallback(MochiKit.Signal.signal, this, 'logout');
300 deferredResult.callback(); 298 deferredResult.callback();
301 299
302 return deferredResult; 300 return deferredResult;
303 }, 301 },
304 302
305 //----------------------------------------------------------------------------- 303 //-----------------------------------------------------------------------------
306 304
307 'handleLock': function (anEvent) { 305 'handleLock': function (anEvent) {
308 return Clipperz.Async.callbacks("AppController.handleLock", [ 306 return Clipperz.Async.callbacks("AppController.handleLock", [
309 MochiKit.Base.method(this.cardsController(), 'deleteAllCleanTextData'), 307 MochiKit.Base.method(this.cardsController(), 'deleteAllCleanTextData'),
310 MochiKit.Base.method(this.user(), 'lock') 308 MochiKit.Base.method(this.user(), 'lock')
311 ], {trace:false}); 309 ], {trace:false});
312 }, 310 },
313 311
314 //............................................................................. 312 //.............................................................................
315 313
316 'handleUnlock': function (anEvent) { 314 'handleUnlock': function (anEvent) {
317 return Clipperz.Async.callbacks("AppController.handleUnock", [ 315 return Clipperz.Async.callbacks("AppController.handleUnock", [
318 MochiKit.Base.partial(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress'), 316 MochiKit.Base.partial(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress'),
319 MochiKit.Base.method(this.user(), 'login'), 317 MochiKit.Base.method(this.user(), 'login'),
320 MochiKit.Base.method(this.cardsController(), 'focus'), 318 MochiKit.Base.method(this.cardsController(), 'focus'),
321 MochiKit.Base.partial(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'progressDone'), 319 MochiKit.Base.partial(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'progressDone'),
322 MochiKit.Base.method(this.userInfoBox(), 'unlock') 320 MochiKit.Base.method(this.userInfoBox(), 'unlock')
323 ], {trace:false}); 321 ], {trace:false});
324 }, 322 },
325 323
326 'handleDownloadOfflineCopy': function (anEvent) { 324 'handleDownloadOfflineCopy': function (anEvent) {
327console.log("AppController.handleDownloadOfflineCopy");
328 var downloadHref; 325 var downloadHref;
329 326
330 downloadHref = window.location.href.replace(/\/[^\/]*$/,'') + Clipperz_dumpUrl; 327 downloadHref = window.location.href.replace(/\/[^\/]*$/,'') + Clipperz_dumpUrl;
331 328
332 if (Clipperz_IEisBroken == true) { 329 if (Clipperz_IEisBroken == true) {
333 window.open(downloadHref, ""); 330 window.open(downloadHref, "");
334 } else { 331 } else {
335 vardeferredResult; 332 vardeferredResult;
336 var newWindow; 333 var newWindow;
337 334
338 newWindow = window.open("", ""); 335 newWindow = window.open("", "");
339 336
340 deferredResult = new Clipperz.Async.Deferred("AppController.handleDownloadOfflineCopy", {trace:true}); 337 deferredResult = new Clipperz.Async.Deferred("AppController.handleDownloadOfflineCopy", {trace:true});
341 deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'echo', {'echo':"echo"}); 338 deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'echo', {'echo':"echo"});
342 deferredResult.addCallback(function(aWindow) { 339 deferredResult.addCallback(function(aWindow) {
343 aWindow.location.href = downloadHref; 340 aWindow.location.href = downloadHref;
344 }, newWindow); 341 }, newWindow);
345 deferredResult.callback(); 342 deferredResult.callback();
346 } 343 }
347 }, 344 },
348 345
349 //============================================================================= 346 //=============================================================================
350 __syntaxFix__: "syntax fix" 347 __syntaxFix__: "syntax fix"
351}); 348});