Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js | 203 |
1 files changed, 203 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js new file mode 100644 index 0000000..de20853 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js | |||
@@ -0,0 +1,203 @@ | |||
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 | Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); | ||
30 | |||
31 | Clipperz.PM.UI.Web.Components.LoginForm = function(args) { | ||
32 | args = args || {}; | ||
33 | |||
34 | this._autocomplete = args.autocomplete || 'off'; | ||
35 | |||
36 | Clipperz.PM.UI.Web.Components.LoginForm.superclass.constructor.apply(this, arguments); | ||
37 | |||
38 | this._slots = { | ||
39 | 'passphraseEntropy':this.getId('passphraseEntropy') | ||
40 | }; | ||
41 | |||
42 | return this; | ||
43 | } | ||
44 | |||
45 | //============================================================================= | ||
46 | |||
47 | Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.LoginForm, Clipperz.PM.UI.Common.Components.BaseComponent, { | ||
48 | |||
49 | //------------------------------------------------------------------------- | ||
50 | |||
51 | 'toString': function () { | ||
52 | return "Clipperz.PM.UI.Web.Components.LoginForm component"; | ||
53 | }, | ||
54 | |||
55 | 'autocomplete': function () { | ||
56 | return this._autocomplete; | ||
57 | }, | ||
58 | |||
59 | //------------------------------------------------------------------------- | ||
60 | |||
61 | 'renderSelf': function() { | ||
62 | this.append(this.element(), {tag:'div', id:'loginBox', children:[ | ||
63 | {tag:'div', cls:'header'}, | ||
64 | {tag:'div', cls:'body', id:this.getId('body'), children:[ | ||
65 | {tag:'div', id:this.getId('loginForm'), children:[ | ||
66 | {tag:'div', children:[ | ||
67 | {tag:'h4', html:'Login'}, | ||
68 | // {tag:'form', cls:'loginForm', autocomplete:this.autocomplete(), children:[ | ||
69 | {tag:'form', id:this.getId('form'), cls:'loginForm', children:[ | ||
70 | {tag:'label', html:'username', 'for':this.getId('usernameField')}, | ||
71 | {tag:'input', id:this.getId('usernameField'), type:'text', cls:'username'/*, value:'joe'*/}, | ||
72 | {tag:'ul', id:this.getId('passwordOptions'), children:[ | ||
73 | {tag:'li', id:this.getId('passphraseOption'), children:[ | ||
74 | {tag:'label', html:'passphrase / OTP', 'for':this.getId('passphraseField')}, | ||
75 | {tag:'input', id:this.getId('passphraseField'), type:'password', cls:'password'/*, value:'clipperz'*/} | ||
76 | ]} //, | ||
77 | /* | ||
78 | {tag:'li', id:this.getId('otpOption'), children:[ | ||
79 | {tag:'label', html:'one-time password', 'for':this.getId('otpField_1')}, | ||
80 | {tag:'input', id:this.getId('otpField_1'), type:'text', cls:'otp', value:'abcd-efgh'}, | ||
81 | {tag:'input', id:this.getId('otpField_2'), type:'text', cls:'otp', value:'abcd-efgh'}, | ||
82 | {tag:'input', id:this.getId('otpField_3'), type:'text', cls:'otp', value:'abcd-efgh'}, | ||
83 | {tag:'input', id:this.getId('otpField_4'), type:'text', cls:'otp', value:'abcd-efgh'} | ||
84 | ]} | ||
85 | */ | ||
86 | ]}, | ||
87 | // {tag:'input', id:this.getId('otpCheckbox'), type:'checkbox', cls:'checkbox'}, | ||
88 | // {tag:'label', html:'use a one-time passphrase', 'for':this.getId('otpCheckbox'), cls:'checkbox'}, | ||
89 | |||
90 | {tag:'div', cls:'translations', children:[ | ||
91 | {tag:'h4', html:'choose your language'}, | ||
92 | {tag:'ul', children:[ | ||
93 | {tag:'li', cls:'selected', html:'english'}, | ||
94 | {tag:'li', html:'italiano'}, | ||
95 | {tag:'li', html:'dutch'}, | ||
96 | {tag:'li', html:'french'}, | ||
97 | {tag:'li', html:'spanish'}, | ||
98 | {tag:'li', html:'chinese'}, | ||
99 | {tag:'li', html:'japanese'}, | ||
100 | {tag:'li', html:'portugal'}, | ||
101 | {tag:'li', html:'arabic'} | ||
102 | ]} | ||
103 | ]}, | ||
104 | |||
105 | {tag:'input', id:this.getId('submitButton'), type:'submit', value:'login', cls:'submit'} | ||
106 | ]} | ||
107 | ]} | ||
108 | ]} | ||
109 | ]}, | ||
110 | {tag:'div', cls:'footer'} | ||
111 | ]}); | ||
112 | |||
113 | if (this.autocomplete() == 'off') { | ||
114 | MochiKit.DOM.updateNodeAttributes(this.getElement('form'), {autocomplete:'off'}); | ||
115 | } | ||
116 | |||
117 | // Clipperz.Style.setBackgroundGradient(this.getElement('body'), {from:"#ff9955", to:"#ff6622"}) | ||
118 | |||
119 | // this.setEntropyDisplay(new Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay(this.getElement('passphraseField'))); | ||
120 | |||
121 | // MochiKit.Signal.connect(this.getId('otpCheckbox'), 'onclick', this, 'togglePasswordFields'); | ||
122 | // this.showPassphraseField(); | ||
123 | |||
124 | this.getElement('usernameField').focus(); | ||
125 | |||
126 | MochiKit.Signal.connect(this.getElement('loginForm'), 'onsubmit', this, 'loginEventHandler'); | ||
127 | }, | ||
128 | |||
129 | //----------------------------------------------------------------------------- | ||
130 | /* | ||
131 | 'togglePasswordFields': function(anEvent) { | ||
132 | var shouldUseOTP; | ||
133 | |||
134 | shouldUseOTP = this.getElement('otpCheckbox').checked; | ||
135 | |||
136 | if (shouldUseOTP == false) { | ||
137 | this.showPassphraseField(); | ||
138 | } else { | ||
139 | this.showOTPFields(); | ||
140 | } | ||
141 | }, | ||
142 | */ | ||
143 | //----------------------------------------------------------------------------- | ||
144 | /* | ||
145 | 'showPassphraseField': function() { | ||
146 | this.showElement('passphraseOption'); | ||
147 | this.hideElement('otpOption'); | ||
148 | }, | ||
149 | */ | ||
150 | //----------------------------------------------------------------------------- | ||
151 | |||
152 | 'focusOnPassphraseField': function () { | ||
153 | this.getElement('passphraseField').focus(); | ||
154 | this.getElement('passphraseField').select(); | ||
155 | }, | ||
156 | |||
157 | //----------------------------------------------------------------------------- | ||
158 | /* | ||
159 | 'showOTPFields': function() { | ||
160 | this.hideElement('passphraseOption'); | ||
161 | this.showElement('otpOption'); | ||
162 | }, | ||
163 | */ | ||
164 | //------------------------------------------------------------------------- | ||
165 | |||
166 | 'loginEventHandler': function(anEvent) { | ||
167 | varusername; | ||
168 | var passphrase; | ||
169 | // var shouldUseOTP; | ||
170 | // var otp; | ||
171 | var signalArguments; | ||
172 | |||
173 | anEvent.preventDefault(); | ||
174 | |||
175 | username = this.getElement('usernameField').value; | ||
176 | passphrase = this.getElement('passphraseField').value; | ||
177 | // otp =this.getElement('otpField_1').value + | ||
178 | // this.getElement('otpField_2').value + | ||
179 | // this.getElement('otpField_3').value + | ||
180 | // this.getElement('otpField_4').value; | ||
181 | // shouldUseOTP = this.getElement('otpCheckbox').checked; | ||
182 | |||
183 | signalArguments = {username:username}; | ||
184 | |||
185 | // if (shouldUseOTP) { | ||
186 | // signalArguments.otp = otp; | ||
187 | // } else { | ||
188 | signalArguments.passphrase = passphrase; | ||
189 | // } | ||
190 | |||
191 | MochiKit.Signal.signal(this, 'doLogin', signalArguments); | ||
192 | }, | ||
193 | |||
194 | //------------------------------------------------------------------------- | ||
195 | |||
196 | 'submitButtonElement': function() { | ||
197 | return this.getElement('submitButton'); | ||
198 | }, | ||
199 | |||
200 | //------------------------------------------------------------------------- | ||
201 | |||
202 | __syntaxFix__: "syntax fix" | ||
203 | }); | ||