summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UserInfoBox.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Web/Components/UserInfoBox.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Components/UserInfoBox.js26
1 files changed, 10 insertions, 16 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UserInfoBox.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UserInfoBox.js
index d699dc6..fbf58e0 100644
--- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UserInfoBox.js
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UserInfoBox.js
@@ -1,245 +1,239 @@
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.Components'); 24Clipperz.Base.module('Clipperz.PM.UI.Web.Components');
27 25
28Clipperz.PM.UI.Web.Components.UserInfoBox = function(args) { 26Clipperz.PM.UI.Web.Components.UserInfoBox = function(args) {
29 args = args || {}; 27 args = args || {};
30 28
31 Clipperz.PM.UI.Web.Components.UserInfoBox.superclass.constructor.apply(this, arguments); 29 Clipperz.PM.UI.Web.Components.UserInfoBox.superclass.constructor.apply(this, arguments);
32 30
33 this._slots = {}; 31 this._slots = {};
34 this._isLocked = false; 32 this._isLocked = false;
35 this._lockTooltip = null; 33 this._lockTooltip = null;
36 34
37 return this; 35 return this;
38} 36}
39 37
40//============================================================================= 38//=============================================================================
41 39
42Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.UserInfoBox, Clipperz.PM.UI.Common.Components.BaseComponent, { 40Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.UserInfoBox, Clipperz.PM.UI.Common.Components.BaseComponent, {
43 41
44 //------------------------------------------------------------------------- 42 //-------------------------------------------------------------------------
45 43
46 'toString': function () { 44 'toString': function () {
47 return "Clipperz.PM.UI.Web.Components.UserInfoBox component"; 45 return "Clipperz.PM.UI.Web.Components.UserInfoBox component";
48 }, 46 },
49 47
50 //------------------------------------------------------------------------- 48 //-------------------------------------------------------------------------
51 49
52 'handleLogout': function(anEvent) { 50 'handleLogout': function(anEvent) {
53//Clipperz.log(">>> UserInfoBox.handleLogout"); 51//Clipperz.log(">>> UserInfoBox.handleLogout");
54 anEvent.preventDefault(); 52 anEvent.preventDefault();
55 MochiKit.Signal.signal(this, 'logout'); 53 MochiKit.Signal.signal(this, 'logout');
56//Clipperz.log("<<< UserInfoBox.handleLogout"); 54//Clipperz.log("<<< UserInfoBox.handleLogout");
57 }, 55 },
58 56
59 //------------------------------------------------------------------------- 57 //-------------------------------------------------------------------------
60 58
61 'lockTooltip': function () { 59 'lockTooltip': function () {
62 return this._lockTooltip; 60 return this._lockTooltip;
63 }, 61 },
64 62
65 //------------------------------------------------------------------------- 63 //-------------------------------------------------------------------------
66 64
67 'isLocked': function () { 65 'isLocked': function () {
68 return this._isLocked; 66 return this._isLocked;
69 }, 67 },
70 68
71 'setIsLocked': function (aValue) { 69 'setIsLocked': function (aValue) {
72 this._isLocked = aValue; 70 this._isLocked = aValue;
73 }, 71 },
74 72
75 'toggleLock': function(anEvent) { 73 'toggleLock': function(anEvent) {
76 var deferredResult; 74 var deferredResult;
77 var shouldLock; 75 var shouldLock;
78 76
79//console.log(">>> UserInfoBox.toggleLock [locked: " + this.isLocked() + "]");
80 anEvent.preventDefault(); 77 anEvent.preventDefault();
81 this.lockTooltip().hide(); 78 this.lockTooltip().hide();
82 79
83 shouldLock = (this.isLocked() == false); 80 shouldLock = (this.isLocked() == false);
84 81
85 if (shouldLock) { 82 if (shouldLock) {
86 var maskElement; 83 var maskElement;
87 84
88 this.setIsLocked(true); 85 this.setIsLocked(true);
89 maskElement = this.getId('modalDialogMask'); 86 maskElement = this.getId('modalDialogMask');
90 deferredResult = Clipperz.Async.callbacks("UserInfoBox.toggleLock [lock]", [ 87 deferredResult = Clipperz.Async.callbacks("UserInfoBox.toggleLock [lock]", [
91 MochiKit.Base.partial(MochiKit.DOM.addElementClass, this.element(), 'locked'), 88 MochiKit.Base.partial(MochiKit.DOM.addElementClass, this.element(), 'locked'),
92 MochiKit.Base.partial(Clipperz.Visual.deferredAnimation, MochiKit.Visual.appear, maskElement, {from:0.0, to:0.75, duration:0.5}), 89 MochiKit.Base.partial(Clipperz.Visual.deferredAnimation, MochiKit.Visual.appear, maskElement, {from:0.0, to:0.75, duration:0.5}),
93 MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'setPassphraseDelegate', MochiKit.Base.method(this, 'askForPassphrase')), 90 MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'setPassphraseDelegate', MochiKit.Base.method(this, 'askForPassphrase')),
94 MochiKit.Base.partial(MochiKit.Signal.signal, this, 'lock') 91 MochiKit.Base.partial(MochiKit.Signal.signal, this, 'lock')
95 ], {trace:false}); 92 ], {trace:false});
96 } else { 93 } else {
97 deferredResult = Clipperz.Async.callbacks("UserInfoBox.toggleLock [unlock]", [ 94 deferredResult = Clipperz.Async.callbacks("UserInfoBox.toggleLock [unlock]", [
98 MochiKit.Base.partial(MochiKit.Signal.signal, this, 'unlock') 95 MochiKit.Base.partial(MochiKit.Signal.signal, this, 'unlock')
99 ], {trace:false}); 96 ], {trace:false});
100 } 97 }
101//console.log("<<< UserInfoBox.toggleLock");
102 98
103 return deferredResult; 99 return deferredResult;
104 }, 100 },
105 101
106 //------------------------------------------------------------------------- 102 //-------------------------------------------------------------------------
107 103
108 'unlock': function () { 104 'unlock': function () {
109 var deferredResult; 105 var deferredResult;
110 var maskElement; 106 var maskElement;
111 107
112 this.setIsLocked(false); 108 this.setIsLocked(false);
113 maskElement = this.getId('modalDialogMask'); 109 maskElement = this.getId('modalDialogMask');
114 110
115 deferredResult = Clipperz.Async.callbacks("UserInfoBox.unlock", [ 111 deferredResult = Clipperz.Async.callbacks("UserInfoBox.unlock", [
116 MochiKit.Base.partial(Clipperz.Visual.deferredAnimation, MochiKit.Visual.fade, maskElement, {from:0.75, to:0.0, duration:0.5}), 112 MochiKit.Base.partial(Clipperz.Visual.deferredAnimation, MochiKit.Visual.fade, maskElement, {from:0.75, to:0.0, duration:0.5}),
117 // Clipperz.Visual.deferredAnimation(MochiKit.Visual.fade, maskElement, {from:0.75, to:0.0, duration:0.5}), 113 // Clipperz.Visual.deferredAnimation(MochiKit.Visual.fade, maskElement, {from:0.75, to:0.0, duration:0.5}),
118 MochiKit.Base.partial(MochiKit.DOM.removeElementClass, this.element(), 'locked') 114 MochiKit.Base.partial(MochiKit.DOM.removeElementClass, this.element(), 'locked')
119 ], {trace:false}); 115 ], {trace:false});
120 }, 116 },
121 117
122 //------------------------------------------------------------------------- 118 //-------------------------------------------------------------------------
123 119
124 'askForPassphrase': function () { 120 'askForPassphrase': function () {
125 varunlockPasswordComponent; 121 varunlockPasswordComponent;
126/* 122/*
127 vardeferredResult; 123 vardeferredResult;
128 124
129 deferredResult = new Clipperz.Async.Deferred("UserInfoBox.askForPassphrase", {trace:false}); 125 deferredResult = new Clipperz.Async.Deferred("UserInfoBox.askForPassphrase", {trace:false});
130 deferredResult.addCallback(MochiKit.Async.succeed, 'test'); 126 deferredResult.addCallback(MochiKit.Async.succeed, 'test');
131 127
132 deferredResult.callback(); 128 deferredResult.callback();
133 129
134 return deferredResult; 130 return deferredResult;
135*/ 131*/
136//console.log(">>> UserInfoBox.askForPassphrase");
137 unlockPasswordComponent = new Clipperz.PM.UI.Web.Components.UnlockPasswordComponent({ 132 unlockPasswordComponent = new Clipperz.PM.UI.Web.Components.UnlockPasswordComponent({
138 'title':"Unlock account", 133 'title':"Unlock account",
139 'text': "Insert the passprase to unlock the account", 134 'text': "Insert the passprase to unlock the account",
140 'type': 'INFO', 135 'type': 'INFO',
141 'buttons': [ 136 'buttons': [
142 {text:"Cancel",result:'CANCEL'}, 137 {text:"Cancel",result:'CANCEL'},
143 {text:"Unlock", result:'OK',isDefault:true} 138 {text:"Unlock", result:'OK',isDefault:true}
144 ], 139 ],
145 'openFromElement': this.getElement('lock'), 140 'openFromElement': this.getElement('lock'),
146 'onOkCloseToElement': null, 141 'onOkCloseToElement': null,
147 'onCancelCloseToElement':this.getId('lock') 142 'onCancelCloseToElement':this.getId('lock')
148 }); 143 });
149//console.log("<<< UserInfoBox.askForPassphrase");
150 144
151 return unlockPasswordComponent.getPassphrase(); 145 return unlockPasswordComponent.getPassphrase();
152 }, 146 },
153 147
154 //========================================================================= 148 //=========================================================================
155 149
156 'renderSelf': function(/*aContainer, aPosition*/) { 150 'renderSelf': function(/*aContainer, aPosition*/) {
157 this.append(this.element(), [ 151 this.append(this.element(), [
158 // {tag:'canvas', id:this.getId('canvas'), cls:'canvas', width:'188', height:'154'}, 152 // {tag:'canvas', id:this.getId('canvas'), cls:'canvas', width:'188', height:'154'},
159 {tag:'div', cls:'header', children:[ 153 {tag:'div', cls:'header', children:[
160 {tag:'h1', html:"Welcome"}, 154 {tag:'h1', html:"Welcome"},
161 {tag:'a', cls:'lockButton', href:'#', id:this.getId('lock'), html:'&nbsp;'} 155 {tag:'a', cls:'lockButton', href:'#', id:this.getId('lock'), html:'&nbsp;'}
162 ]}, 156 ]},
163 {tag:'div', cls:'body', children:[ 157 {tag:'div', cls:'body', children:[
164 {tag:'h3', id:this.getId('username'), html:""}, 158 {tag:'h3', id:this.getId('username'), html:""},
165 {tag:'ul', children:[ 159 {tag:'ul', children:[
166 {tag:'li', id:this.getId('cards'), children:[ 160 {tag:'li', id:this.getId('cards'), children:[
167 {tag:'span', id:this.getId('cardsNumber'), cls:'number', html:"-"}, 161 {tag:'span', id:this.getId('cardsNumber'), cls:'number', html:"-"},
168 {tag:'span', id:this.getId('cardsLabel'), html:"cards"} 162 {tag:'span', id:this.getId('cardsLabel'), html:"cards"}
169 ]}, 163 ]},
170 {tag:'li', id:this.getId('directLogins'), children:[ 164 {tag:'li', id:this.getId('directLogins'), children:[
171 {tag:'span', id:this.getId('directLoginsNumber'), cls:'number', html:"-"}, 165 {tag:'span', id:this.getId('directLoginsNumber'), cls:'number', html:"-"},
172 {tag:'span', id:this.getId('directLoginsLabel'), html:"direct logins"} 166 {tag:'span', id:this.getId('directLoginsLabel'), html:"direct logins"}
173 ]} 167 ]}
174 ]}, 168 ]},
175 {tag:'a', href:'#', id:this.getId('logout'), html:"logout >"} 169 {tag:'a', href:'#', id:this.getId('logout'), html:"logout >"}
176 ]}, 170 ]},
177 {tag:'div', cls:'footer'} 171 {tag:'div', cls:'footer'}
178 ]); 172 ]);
179 173
180 MochiKit.Signal.connect(this.getElement('logout'), 'onclick', this, 'handleLogout'); 174 MochiKit.Signal.connect(this.getElement('logout'), 'onclick', this, 'handleLogout');
181 MochiKit.Signal.connect(this.getElement('lock'), 'onclick', this, 'toggleLock'); 175 MochiKit.Signal.connect(this.getElement('lock'), 'onclick', this, 'toggleLock');
182 176
183 this._lockTooltip = new Clipperz.PM.UI.Common.Components.Tooltip({ 177 this._lockTooltip = new Clipperz.PM.UI.Common.Components.Tooltip({
184 element:this.getElement('lock'), 178 element:this.getElement('lock'),
185 text: "Click here to lock/unlock your account.", 179 text: "Click here to lock/unlock your account.",
186 position:'RIGHT' 180 position:'RIGHT'
187 }); 181 });
188 182
189 Clipperz.DOM.Helper.append(MochiKit.DOM.currentDocument().body, 183 Clipperz.DOM.Helper.append(MochiKit.DOM.currentDocument().body,
190 {tag:'div', id:this.getId('modalDialogWrapper'), cls:'modalDialogWrapper', children:[ 184 {tag:'div', id:this.getId('modalDialogWrapper'), cls:'modalDialogWrapper', children:[
191 {tag:'div', id:this.getId('modalDialogMask'), cls:'modalDialogMask userInfoBoxMask'} 185 {tag:'div', id:this.getId('modalDialogMask'), cls:'modalDialogMask userInfoBoxMask'}
192 ]} 186 ]}
193 ); 187 );
194 MochiKit.Style.hideElement(this.getId('modalDialogMask')); 188 MochiKit.Style.hideElement(this.getId('modalDialogMask'));
195 189
196 // this.drawUserInfoBackground(this.getElement('canvas')); 190 // this.drawUserInfoBackground(this.getElement('canvas'));
197 }, 191 },
198 192
199 //------------------------------------------------------------------------- 193 //-------------------------------------------------------------------------
200/* 194/*
201 'drawUserInfoBackground': function (canvas) { 195 'drawUserInfoBackground': function (canvas) {
202 var kMyDrawingFunctionWidth = 188.0; 196 var kMyDrawingFunctionWidth = 188.0;
203 var kMyDrawingFunctionHeight = 154.0; 197 var kMyDrawingFunctionHeight = 154.0;
204 198
205 var context = canvas.getContext("2d"); 199 var context = canvas.getContext("2d");
206 var color; 200 var color;
207 var resolution; 201 var resolution;
208 var alignStroke; 202 var alignStroke;
209 var path; 203 var path;
210 var pointX; 204 var pointX;
211 var pointY; 205 var pointY;
212 var controlPoint1X; 206 var controlPoint1X;
213 var controlPoint1Y; 207 var controlPoint1Y;
214 var controlPoint2X; 208 var controlPoint2X;
215 var controlPoint2Y; 209 var controlPoint2Y;
216 var gradient; 210 var gradient;
217 if (window.devicePixelRatio) 211 if (window.devicePixelRatio)
218 resolution = window.devicePixelRatio; 212 resolution = window.devicePixelRatio;
219 else 213 else
220 resolution = 1.0; 214 resolution = 1.0;
221 resolution *= 0.5 * (canvas.width / kMyDrawingFunctionWidth + canvas.height / kMyDrawingFunctionHeight); 215 resolution *= 0.5 * (canvas.width / kMyDrawingFunctionWidth + canvas.height / kMyDrawingFunctionHeight);
222 216
223 context.save(); 217 context.save();
224 context.scale(canvas.width / kMyDrawingFunctionWidth, canvas.height / kMyDrawingFunctionHeight); 218 context.scale(canvas.width / kMyDrawingFunctionWidth, canvas.height / kMyDrawingFunctionHeight);
225 context.clearRect(0.0, 0.0, kMyDrawingFunctionWidth, kMyDrawingFunctionHeight); 219 context.clearRect(0.0, 0.0, kMyDrawingFunctionWidth, kMyDrawingFunctionHeight);
226 220
227 // Setup for Shadow Effect 221 // Setup for Shadow Effect
228 color = "rgba(0.0%, 0.0%, 0.0%, 0.667)"; 222 color = "rgba(0.0%, 0.0%, 0.0%, 0.667)";
229 context.save(); 223 context.save();
230 context.shadowColor = color; 224 context.shadowColor = color;
231 context.shadowBlur = 3.0; 225 context.shadowBlur = 3.0;
232 context.shadowOffsetX = 5.729 * Math.cos(7.592) * resolution; 226 context.shadowOffsetX = 5.729 * Math.cos(7.592) * resolution;
233 context.shadowOffsetY = 5.729 * Math.sin(7.592) * resolution; 227 context.shadowOffsetY = 5.729 * Math.sin(7.592) * resolution;
234 228
235 // Layer 1 229 // Layer 1
236 230
237 alignStroke = 0.0; 231 alignStroke = 0.0;
238 context.beginPath(); 232 context.beginPath();
239 pointX = 169.5; 233 pointX = 169.5;
240 pointY = 141.5; 234 pointY = 141.5;
241 pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; 235 pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution;
242 pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; 236 pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution;
243 context.moveTo(pointX, pointY); 237 context.moveTo(pointX, pointY);
244 pointX = 177.5; 238 pointX = 177.5;
245 pointY = 133.5; 239 pointY = 133.5;