Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/Compact') (more/less context) (show whitespace changes)
3 files changed, 587 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/Compact/CompactHeader.js b/frontend/beta/js/Clipperz/PM/Components/Compact/CompactHeader.js new file mode 100644 index 0000000..e51b56f --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Compact/CompactHeader.js | |||
@@ -0,0 +1,86 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | ||
11 | refer 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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Compact) == 'undefined') { Clipperz.PM.Components.Compact = {}; } | ||
33 | |||
34 | Clipperz.PM.Components.Compact.CompactHeader = function(anElement, args) { | ||
35 | |||
36 | Clipperz.PM.Components.Compact.CompactHeader.superclass.constructor.call(this, anElement, args); | ||
37 | |||
38 | this.render(); | ||
39 | |||
40 | return this; | ||
41 | }; | ||
42 | |||
43 | YAHOO.extendX(Clipperz.PM.Components.Compact.CompactHeader, Clipperz.PM.Components.BaseComponent, { | ||
44 | |||
45 | 'toString': function() { | ||
46 | return "Clipperz.PM.Components.Compact.CompactHeader"; | ||
47 | }, | ||
48 | |||
49 | //----------------------------------------------------- | ||
50 | |||
51 | 'render': function() { | ||
52 | this.element().update(""); | ||
53 | |||
54 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', children:[ | ||
55 | {tag:'img', src:'./images/logo.gif'}, | ||
56 | {tag:'div', id:'lockBlock', children:[ | ||
57 | {tag:'input', type:'checkbox', id:'autolock'}, | ||
58 | {tag:'span', html:'auto'}, | ||
59 | {tag:'a', href:'#', htmlString:Clipperz.PM.Strings['lockMenuLabel'], id:'lock'} | ||
60 | ]} | ||
61 | ]}); | ||
62 | |||
63 | Clipperz.YUI.DomHelper.append(this.element().dom, | ||
64 | {tag:'div', id:'compactMiscLinks', children:[ | ||
65 | {tag:'a', id:'donateHeaderIconLink', target:'_blank', href:Clipperz.PM.Strings['donateHeaderLinkUrl'], children:[ | ||
66 | {tag:'img', id:'donateHeaderLinkIcon', src:'./images/smiles_small.gif'} | ||
67 | ]}, | ||
68 | {tag:'ul', children:[ | ||
69 | {tag:'li', children:[{tag:'a', id:'donateHeaderLink', html:'donate', target:'_blank'}]}, | ||
70 | {tag:'li', children:[{tag:'a', id:'creditsHeaderLink', html:'credits', target:'_blank'}]}, | ||
71 | {tag:'li', children:[{tag:'a', id:'feedbackHeaderLink', html:'feedback', target:'_blank'}]}, | ||
72 | {tag:'li', children:[{tag:'a', id:'helpHeaderLink', html:'help', target:'_blank'}]}, | ||
73 | {tag:'li', children:[{tag:'a', id:'forumHeaderLink', html:'forum', target:'_blank'}]} | ||
74 | ]} | ||
75 | ]} | ||
76 | ); | ||
77 | |||
78 | YAHOO.ext.Element.get('lockBlock').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
79 | Clipperz.NotificationCenter.notify(this, 'switchLanguage'); | ||
80 | }, | ||
81 | |||
82 | //----------------------------------------------------- | ||
83 | __syntaxFix__: '__syntaxFix__' | ||
84 | }); | ||
85 | |||
86 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Compact/CompactInterface.js b/frontend/beta/js/Clipperz/PM/Components/Compact/CompactInterface.js new file mode 100644 index 0000000..492f815 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Compact/CompactInterface.js | |||
@@ -0,0 +1,312 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | ||
11 | refer 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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Compact) == 'undefined') { Clipperz.PM.Components.Compact = {}; } | ||
33 | |||
34 | Clipperz.PM.Components.Compact.CompactInterface = function(anElement, args) { | ||
35 | |||
36 | Clipperz.PM.Components.Compact.CompactInterface.superclass.constructor.call(this, anElement, args); | ||
37 | |||
38 | this._directLoginItemTemplate = null; | ||
39 | this._user = args.user; | ||
40 | this._autoLockTimer = null; | ||
41 | |||
42 | Clipperz.NotificationCenter.register(null, 'updatedProgressState', this, 'userNotificationHandler') | ||
43 | Clipperz.NotificationCenter.register(null, 'directLoginAdded', this, 'directLoginAddedHandler'); | ||
44 | |||
45 | this.render(); | ||
46 | |||
47 | return this; | ||
48 | }; | ||
49 | |||
50 | YAHOO.extendX(Clipperz.PM.Components.Compact.CompactInterface, Clipperz.PM.Components.BaseComponent, { | ||
51 | |||
52 | 'toString': function() { | ||
53 | return "Clipperz.PM.Components.Compact.CompactInterface"; | ||
54 | }, | ||
55 | |||
56 | //----------------------------------------------------- | ||
57 | |||
58 | 'render': function() { | ||
59 | var result; | ||
60 | varlayout; | ||
61 | var registerButton; | ||
62 | |||
63 | //MochiKit.Logging.logDebug(">>> CompactInterface.render"); | ||
64 | this.element().update(""); | ||
65 | |||
66 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', children:[ | ||
67 | {tag:'div', id:this.getId('cantentPanel'), children:[ | ||
68 | {tag:'h4', id:this.getId('message')}, | ||
69 | {tag:'ul', id:'directLogins', children:[]} | ||
70 | ]}, | ||
71 | {tag:'div', id:this.getId('lockPanel'), cls:'lockPanel', children:[ | ||
72 | {tag:'div', htmlString:Clipperz.PM.Strings['lockDescription']}, | ||
73 | {tag:'form', id:'lockDialogForm', children:[ | ||
74 | {tag:'input', type:'password', id:this.getId('lockPassphrase')} | ||
75 | ]}, | ||
76 | {tag:'div', id:this.getId('unlock')} | ||
77 | ]} | ||
78 | ]}); | ||
79 | |||
80 | this.getElement('lockPanel').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
81 | |||
82 | YAHOO.ext.Element.get('lockBlock').show(); | ||
83 | MochiKit.Signal.connect(YAHOO.ext.Element.get('lock').dom, 'onclick', this, 'doLockEventHandler'); | ||
84 | new YAHOO.ext.Button(this.getId('unlock'), {text:Clipperz.PM.Strings['unlockButtonLabel'], handler:this.doUnlockEventHandler, scope:this, minWidth:0}); | ||
85 | this.getElement('unlock').swallowEvent('click', true); | ||
86 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('lockPassphrase')); | ||
87 | MochiKit.Signal.connect('lockDialogForm', 'onsubmit', this, 'doUnlockEventHandler'); | ||
88 | |||
89 | this.getElement('cantentPanel').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
90 | //MochiKit.Logging.logDebug("<<< CompactInterface.render"); | ||
91 | |||
92 | return result; | ||
93 | }, | ||
94 | |||
95 | //----------------------------------------------------- | ||
96 | |||
97 | 'directLoginAddedHandler': function(anEvent) { | ||
98 | this.redrawDirectLoginItems(); | ||
99 | }, | ||
100 | |||
101 | //----------------------------------------------------- | ||
102 | |||
103 | 'compareDirectLogins': function(a, b) { | ||
104 | return MochiKit.Base.compare(a.label().toLowerCase(), b.label().toLowerCase()); | ||
105 | }, | ||
106 | |||
107 | //----------------------------------------------------- | ||
108 | |||
109 | 'redrawDirectLoginItems': function() { | ||
110 | var template; | ||
111 | var allDirectLogins; | ||
112 | |||
113 | this.getElement('message').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
114 | //MochiKit.Logging.logDebug(">>> CompactInterface.redrawDirectLoginItems"); | ||
115 | //MochiKit.Logging.logDebug("--- CompactInterface.redrawDirectLoginItems - 0"); | ||
116 | MochiKit.Iter.forEach(YAHOO.ext.Element.get('directLogins').getChildrenByTagName('li'), function(aDirectLoginElement) { | ||
117 | MochiKit.Signal.disconnectAll(aDirectLoginElement.dom); | ||
118 | //MochiKit.Logging.logDebug("disconnecting IMG " + aDirectLoginElement.getChildrenByTagName('img')[0].dom.src); | ||
119 | MochiKit.Signal.disconnectAll(aDirectLoginElement.getChildrenByTagName('img')[0].dom); | ||
120 | }) | ||
121 | //MochiKit.Logging.logDebug("--- CompactInterface.redrawDirectLoginItems - 1"); | ||
122 | YAHOO.ext.Element.get('directLogins').update(""); | ||
123 | //MochiKit.Logging.logDebug("--- CompactInterface.redrawDirectLoginItems - 2"); | ||
124 | allDirectLogins = MochiKit.Base.values(this.user().directLoginReferences()); | ||
125 | //MochiKit.Logging.logDebug("--- CompactInterface.redrawDirectLoginItems - 3"); | ||
126 | allDirectLogins.sort(this.compareDirectLogins); | ||
127 | |||
128 | //MochiKit.Logging.logDebug("--- CompactInterface.redrawDirectLoginItems - 4"); | ||
129 | template = this.directLoginItemTemplate(); | ||
130 | //MochiKit.Logging.logDebug("--- CompactInterface.redrawDirectLoginItems - 5"); | ||
131 | MochiKit.Iter.forEach(allDirectLogins, MochiKit.Base.bind(function(aDirectLogin) { | ||
132 | vardirectLoginElement; | ||
133 | varfaviconImageElementID; | ||
134 | |||
135 | faviconImageElementID = aDirectLogin.reference() + "_faviconIMG"; | ||
136 | directLoginElement = template.append('directLogins', { | ||
137 | elementID:faviconImageElementID, | ||
138 | faviconUrl:aDirectLogin.fixedFavicon(), | ||
139 | directLoginTitle:aDirectLogin.label(), | ||
140 | directLoginReference:aDirectLogin.reference() | ||
141 | }, true); | ||
142 | //MochiKit.Logging.logDebug("--- CompactInterface.redrawDirectLoginItems - 6: " + recordElement.dom); | ||
143 | directLoginElement.addClassOnOver("hover"); | ||
144 | MochiKit.Signal.connect(directLoginElement.dom, 'onclick', this, 'handleDirectLoginClick'); | ||
145 | |||
146 | MochiKit.Signal.connect(faviconImageElementID, 'onload', this, 'handleLoadedFaviconImage'); | ||
147 | MochiKit.Signal.connect(faviconImageElementID, 'onerror', aDirectLogin, 'handleMissingFaviconImage'); | ||
148 | MochiKit.Signal.connect(faviconImageElementID, 'onabort', aDirectLogin, 'handleMissingFaviconImage'); | ||
149 | |||
150 | // YAHOO.ext.Element.get(faviconImageElementID).dom.src = aDirectLogin.fixedFavicon(); | ||
151 | }, this)); | ||
152 | |||
153 | this.resetAutoLockTimer(); | ||
154 | //MochiKit.Logging.logDebug("<<< CompactInterface.redrawDirectLoginItems"); | ||
155 | }, | ||
156 | |||
157 | //----------------------------------------------------- | ||
158 | |||
159 | 'directLoginItemTemplate': function() { | ||
160 | if (this._directLoginItemTemplate == null) { | ||
161 | this._directLoginItemTemplate = Clipperz.YUI.DomHelper.createTemplate({tag:'li', id:'{directLoginReference}', children:[ | ||
162 | {tag:'table', border:'0', cellpadding:'0', cellspacing:'0', children:[ | ||
163 | {tag:'tbody', children:[ | ||
164 | {tag:'tr', children:[ | ||
165 | {tag:'td', width:'20', align:'center', valign:'top', children:[ | ||
166 | {tag:'img', id:'{elementID}', src:'{faviconUrl}'} | ||
167 | ]}, | ||
168 | {tag:'td', valign:'top', children:[ | ||
169 | {tag:'a', cls:'directLoginItemTitle', html:'{directLoginTitle}'} | ||
170 | ]} | ||
171 | ]} | ||
172 | ]} | ||
173 | ]} | ||
174 | ]}); | ||
175 | this._directLoginItemTemplate.compile(); | ||
176 | } | ||
177 | |||
178 | return this._directLoginItemTemplate; | ||
179 | }, | ||
180 | |||
181 | //------------------------------------------------------------------------- | ||
182 | |||
183 | 'handleDirectLoginClick': function(anEvent) { | ||
184 | vardirectLoginReference; | ||
185 | //MochiKit.Logging.logDebug(">>> MainPanel.handleDirectLoginClick !!!"); | ||
186 | |||
187 | directLoginReference = this.user().directLoginReferences()[anEvent.src().id]; | ||
188 | this.openDirectLogin(directLoginReference); | ||
189 | this.resetAutoLockTimer(); | ||
190 | //MochiKit.Logging.logDebug("<<< MainPanel.handleDirectLoginClick"); | ||
191 | }, | ||
192 | |||
193 | //----------------------------------------------------- | ||
194 | |||
195 | 'openDirectLogin': function(aDirectLoginReference) { | ||
196 | vardeferredResult; | ||
197 | varnewWindow; | ||
198 | |||
199 | //MochiKit.Logging.logDebug(">>> MainPanel.openDirectLogin - " + aDirectLoginReference.label()); | ||
200 | deferredResult = new MochiKit.Async.Deferred(); | ||
201 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("MainPanel.openDirectLogin - 1: " + res); return res;}); | ||
202 | deferredResult.addCallback(MochiKit.Base.method(aDirectLoginReference, 'setupJumpPageWindow')); | ||
203 | deferredResult.addCallback(MochiKit.Base.method(aDirectLoginReference, 'deferredDirectLogin')); | ||
204 | deferredResult.addCallback(function(aDirectLogin) { | ||
205 | aDirectLogin.runDirectLogin(newWindow); | ||
206 | }); | ||
207 | |||
208 | newWindow = window.open(Clipperz.PM.Strings['directLoginJumpPageUrl'], ""); | ||
209 | // MochiKit.Signal.connect(newWindow, 'onload', MochiKit.Base.method(deferredResult, 'callback', newWindow)) | ||
210 | // MochiKit.Signal.connect(newWindow, 'onload', MochiKit.Base.partial(alert, "done")); | ||
211 | deferredResult.callback(newWindow); | ||
212 | //MochiKit.Logging.logDebug("<<< MainPanel.openDirectLogin"); | ||
213 | }, | ||
214 | |||
215 | //------------------------------------------------------------------------- | ||
216 | |||
217 | 'handleLoadedFaviconImage': function(anEvent) { | ||
218 | //MochiKit.Logging.logDebug(">>> MainPanel.handleLoadedFaviconImage"); | ||
219 | MochiKit.Signal.disconnectAll(anEvent.src()) | ||
220 | //MochiKit.Logging.logDebug("<<< MainPanel.handleLoadedFaviconImage"); | ||
221 | }, | ||
222 | |||
223 | //------------------------------------------------------------------------- | ||
224 | |||
225 | 'doLockEventHandler': function(anEvent) { | ||
226 | anEvent.stop(); | ||
227 | this.lock(); | ||
228 | }, | ||
229 | |||
230 | 'doUnlockEventHandler': function(anEvent) { | ||
231 | if (typeof(anEvent.stop) != 'undefined') { | ||
232 | anEvent.stop(); | ||
233 | } | ||
234 | this.unlock(); | ||
235 | }, | ||
236 | |||
237 | //------------------------------------------------------------------------- | ||
238 | |||
239 | 'autolock': function() { | ||
240 | varshouldAutoLock; | ||
241 | |||
242 | shouldAutoLock = YAHOO.ext.Element.get('autolock').dom.checked; | ||
243 | |||
244 | if (shouldAutoLock) { | ||
245 | this.lock(); | ||
246 | } else { | ||
247 | this.resetAutoLockTimer(); | ||
248 | } | ||
249 | }, | ||
250 | |||
251 | 'lock': function() { | ||
252 | //MochiKit.Logging.logDebug(">>> lock"); | ||
253 | this.getDom('lockPassphrase').value = ""; | ||
254 | this.getElement('lockPanel').show(); | ||
255 | this.getElement('cantentPanel').hide(); | ||
256 | YAHOO.ext.Element.get('lockBlock').hide(); | ||
257 | //this.getElement('lockPassphrase').focus(); | ||
258 | //MochiKit.Logging.logDebug("<<< lock"); | ||
259 | }, | ||
260 | |||
261 | 'unlock': function(anEvent) { | ||
262 | //MochiKit.Logging.logDebug(">>> unlock"); | ||
263 | if (this.getDom('lockPassphrase').value == this.user().passphrase()) { | ||
264 | this.getElement('lockPanel').hide(); | ||
265 | this.getElement('cantentPanel').show(); | ||
266 | YAHOO.ext.Element.get('lockBlock').show(); | ||
267 | this.resetAutoLockTimer(); | ||
268 | } else { | ||
269 | this.getDom('lockPassphrase').value = ""; | ||
270 | this.getElement('lockPassphrase').focus(); | ||
271 | } | ||
272 | //MochiKit.Logging.logDebug("<<< unlock"); | ||
273 | }, | ||
274 | |||
275 | //------------------------------------------------------------------------- | ||
276 | |||
277 | 'user': function() { | ||
278 | return this._user; | ||
279 | }, | ||
280 | |||
281 | //----------------------------------------------------- | ||
282 | |||
283 | 'autoLockTimer': function() { | ||
284 | if (this._autoLockTimer == null) { | ||
285 | //MochiKit.Logging.logDebug("--- timer started - 1"); | ||
286 | this._autoLockTimer = MochiKit.Async.callLater(60, MochiKit.Base.method(this, 'autolock')); | ||
287 | //MochiKit.Logging.logDebug("--- timer started - 2"); | ||
288 | } | ||
289 | |||
290 | return this._autoLockTimer; | ||
291 | }, | ||
292 | |||
293 | 'resetAutoLockTimer': function() { | ||
294 | //MochiKit.Logging.logDebug(">>> timer resetted"); | ||
295 | this.autoLockTimer().cancel(); | ||
296 | this._autoLockTimer = null; | ||
297 | //MochiKit.Logging.logDebug("--- timer resetted - 1"); | ||
298 | this.autoLockTimer(); | ||
299 | //MochiKit.Logging.logDebug("<<< timer resetted"); | ||
300 | }, | ||
301 | |||
302 | //----------------------------------------------------- | ||
303 | |||
304 | 'userNotificationHandler': function(anEvent) { | ||
305 | this.getElement('message').update(anEvent.parameters().text); | ||
306 | }, | ||
307 | |||
308 | //----------------------------------------------------- | ||
309 | __syntaxFix__: '__syntaxFix__' | ||
310 | }); | ||
311 | |||
312 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Compact/LoginForm.js b/frontend/beta/js/Clipperz/PM/Components/Compact/LoginForm.js new file mode 100644 index 0000000..d708464 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Compact/LoginForm.js | |||
@@ -0,0 +1,189 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | ||
11 | refer 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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Compact) == 'undefined') { Clipperz.PM.Components.Compact = {}; } | ||
33 | |||
34 | Clipperz.PM.Components.Compact.LoginForm = function(anElement, args) { | ||
35 | |||
36 | Clipperz.PM.Components.Compact.LoginForm.superclass.constructor.call(this, anElement, args); | ||
37 | |||
38 | this.render(); | ||
39 | Clipperz.NotificationCenter.register(null, 'updatedProgressState', this, 'userNotificationHandler') | ||
40 | |||
41 | return this; | ||
42 | }; | ||
43 | |||
44 | YAHOO.extendX(Clipperz.PM.Components.Compact.LoginForm, Clipperz.PM.Components.BaseComponent, { | ||
45 | |||
46 | 'toString': function() { | ||
47 | return "Clipperz.PM.Components.Compact.LoginForm"; | ||
48 | }, | ||
49 | |||
50 | //----------------------------------------------------- | ||
51 | |||
52 | 'render': function() { | ||
53 | var result; | ||
54 | varlayout; | ||
55 | |||
56 | MochiKit.Signal.disconnectAllTo(this); | ||
57 | this.element().update(""); | ||
58 | |||
59 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', id:this.getId('baseDiv'), cls:'LoginPanel', children:[ | ||
60 | {tag:'div', id:'compactHeader'}, | ||
61 | {tag:'div', id:'compactBody', children:[ | ||
62 | {tag:'form', id:this.getId('loginForm_form'), children:[ | ||
63 | {tag:'dl', children:[ | ||
64 | {tag:'dt', htmlString:Clipperz.PM.Strings['loginFormUsernameLabel']}, | ||
65 | {tag:'dd', children:[ | ||
66 | {tag:'input', id:this.getId('login_username'), type:'text', size:'30', name:'username'} | ||
67 | ]}, | ||
68 | {tag:'dt', htmlString:Clipperz.PM.Strings['loginFormPassphraseLabel']}, | ||
69 | {tag:'dd', children:[ | ||
70 | {tag:'input', id:this.getId('login_passphrase'), type:'password', size:'30', name:'passphrase'} | ||
71 | ]} | ||
72 | ]}, | ||
73 | {tag:'div', id:this.getId('login_submit')} | ||
74 | ]}, | ||
75 | {tag:'h4', id:this.getId('message')} | ||
76 | ]} | ||
77 | ]}); | ||
78 | |||
79 | new Clipperz.PM.Components.Compact.CompactHeader(YAHOO.ext.Element.get('compactHeader')); | ||
80 | |||
81 | MochiKit.Signal.connect(this.getId('loginForm_form'), 'onsubmit', this, 'stopFormSubmit'); | ||
82 | new YAHOO.ext.Button(this.getId('login_submit'), {text:Clipperz.PM.Strings['loginFormButtonLabel'], handler:this.doLogin, scope:this, minWidth:0}); | ||
83 | this.getElement('login_submit').swallowEvent('click', true); | ||
84 | |||
85 | MochiKit.Signal.connect(this.getId('loginForm_form'), 'onkeydown', this, 'onkeydown'); | ||
86 | |||
87 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('login_passphrase')); | ||
88 | this.getElement('login_username').focus(); | ||
89 | |||
90 | return result; | ||
91 | }, | ||
92 | |||
93 | //----------------------------------------------------- | ||
94 | |||
95 | 'doLogin': function(e) { | ||
96 | //MochiKit.Logging.logDebug(">>> compact.LoginForm.doLogin"); | ||
97 | if (this.checkLoginForm()) { | ||
98 | this.doLoginWithUsernameAndPassphrase(this.getDom('login_username').value, this.getDom('login_passphrase').value); | ||
99 | } | ||
100 | //MochiKit.Logging.logDebug("<<< compact.LoginForm.doLogin"); | ||
101 | }, | ||
102 | |||
103 | //......................................................................... | ||
104 | |||
105 | 'doLoginWithUsernameAndPassphrase': function(anUsername, aPassphrase) { | ||
106 | var deferredResult; | ||
107 | var user; | ||
108 | |||
109 | //MochiKit.Logging.logDebug(">>> compact.LoginForm.doLoginWithUsernameAndPassphrase"); | ||
110 | user = new Clipperz.PM.DataModel.User({username:anUsername, passphrase:aPassphrase}); | ||
111 | |||
112 | deferredResult = new MochiKit.Async.Deferred(); | ||
113 | deferredResult.addCallback(MochiKit.Base.method(user, 'connect')); | ||
114 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadPreferences')); | ||
115 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadRecords')); | ||
116 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadDirectLogins')); | ||
117 | deferredResult.addErrback(MochiKit.Base.bind(function() { | ||
118 | this.getElement('loginForm_form').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show(); | ||
119 | this.getElement('message').update(Clipperz.PM.Strings['loginMessagePanelFailureText']); | ||
120 | this.getDom('login_passphrase').value = ""; | ||
121 | this.getElement('login_passphrase').focus(); | ||
122 | }, this)) | ||
123 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("compact.LoginForm.doLogin - 6: " + res); return res;}); | ||
124 | deferredResult.callback("token"); | ||
125 | //MochiKit.Logging.logDebug("<<< compact.LoginForm.doLoginWithUsernameAndPassphrase"); | ||
126 | |||
127 | return deferredResult; | ||
128 | }, | ||
129 | |||
130 | //......................................................................... | ||
131 | |||
132 | 'checkLoginForm': function() { | ||
133 | var result; | ||
134 | var username | ||
135 | varpassphrase; | ||
136 | |||
137 | //MochiKit.Logging.logDebug(">>> checkLoginForm"); | ||
138 | username = this.getDom('login_username').value; | ||
139 | passphrase = this.getDom('login_passphrase').value; | ||
140 | |||
141 | if ((username != "") && (passphrase != "")) { | ||
142 | result = true; | ||
143 | } else { | ||
144 | if (username == "") { | ||
145 | this.getElement('login_username').focus(); | ||
146 | } else if (passphrase == "") { | ||
147 | this.getElement('login_passphrase').focus(); | ||
148 | } | ||
149 | |||
150 | result = false; | ||
151 | } | ||
152 | //MochiKit.Logging.logDebug("<<< checkLoginForm - " + result); | ||
153 | |||
154 | return result; | ||
155 | }, | ||
156 | |||
157 | //------------------------------------------------------------------------- | ||
158 | |||
159 | 'stopFormSubmit': function(anEvent) { | ||
160 | anEvent.stop(); | ||
161 | }, | ||
162 | |||
163 | //------------------------------------------------------------------------- | ||
164 | |||
165 | 'onkeydown': function(anEvent) { | ||
166 | //MochiKit.Logging.logDebug(">>> onkeydown - " + anEvent.src().id); | ||
167 | if (anEvent.key().code == 13) { | ||
168 | this.doLogin(); | ||
169 | anEvent.stop(); | ||
170 | } | ||
171 | }, | ||
172 | |||
173 | //----------------------------------------------------- | ||
174 | |||
175 | 'userNotificationHandler': function(anEvent) { | ||
176 | //MochiKit.Logging.logDebug(">>> compact.LoginForm.userNotificationHandler"); | ||
177 | //MochiKit.Logging.logDebug("userNotificationHandler - event: " + anEvent.event()); | ||
178 | this.getElement('loginForm_form').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
179 | if (this.getDom('message') != null) { | ||
180 | this.getElement('message').update(Clipperz.PM.Strings.messagePanelConfigurations[anEvent.parameters()]()['text']); | ||
181 | } | ||
182 | //MochiKit.Logging.logDebug("<<< compact.LoginForm.userNotificationHandler"); | ||
183 | }, | ||
184 | |||
185 | //----------------------------------------------------- | ||
186 | __syntaxFix__: '__syntaxFix__' | ||
187 | }); | ||
188 | |||
189 | |||