Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js new file mode 100644 index 0000000..eec83b0 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js | |||
@@ -0,0 +1,181 @@ | |||
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.iPhone.Components'); | ||
30 | |||
31 | Clipperz.PM.UI.iPhone.Components.LoginForm = function(args) { | ||
32 | args = args || {}; | ||
33 | |||
34 | Clipperz.PM.UI.iPhone.Components.LoginForm.superclass.constructor.apply(this, arguments); | ||
35 | |||
36 | return this; | ||
37 | } | ||
38 | |||
39 | //============================================================================= | ||
40 | |||
41 | Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.LoginForm, Clipperz.PM.UI.Common.Components.BaseComponent, { | ||
42 | |||
43 | //------------------------------------------------------------------------- | ||
44 | |||
45 | 'toString': function () { | ||
46 | return "Clipperz.PM.UI.iPhone.Components.LoginForm component"; | ||
47 | }, | ||
48 | |||
49 | //------------------------------------------------------------------------- | ||
50 | |||
51 | 'focusOnUsername': function () { | ||
52 | this.getElement('username').focus(); | ||
53 | }, | ||
54 | |||
55 | //------------------------------------------------------------------------- | ||
56 | |||
57 | 'username': function () { | ||
58 | return this.getElement('username').value; | ||
59 | }, | ||
60 | |||
61 | 'passphrase': function () { | ||
62 | return this.getElement('passphrase').value; | ||
63 | }, | ||
64 | |||
65 | //------------------------------------------------------------------------- | ||
66 | |||
67 | 'renderSelf': function(/*aContainer, aPosition*/) { | ||
68 | this.append(this.element(), [ | ||
69 | {tag:'div', cls:'toolbar iPhoneClipperzToolbar', children:[ | ||
70 | {tag:'h1', id:'pageTitle', html:'Clipperz'}, | ||
71 | {tag:'a', id:'backButton', cls:'button', href:'#', html:"back"} | ||
72 | ]}, | ||
73 | {tag:'form', title:'Theaters', cls:'panel toolbarlessPanel loginForm', id:this.getId('loginFormPanel'), children:[ | ||
74 | {tag:'fieldset', id:this.getId('fieldset'), children:[ | ||
75 | {tag:'div', cls:'row', children:[ | ||
76 | {tag:'label', html:"username"}, | ||
77 | {tag:'input', type:'text', name:'username', value:"", autocorrect:'off', autocapitalize:'off', id:this.getId('username')} | ||
78 | ]}, | ||
79 | {tag:'div', cls:'row', children:[ | ||
80 | {tag:'label', html:"passphrase"}, | ||
81 | {tag:'input', type:'password', name:'passphrase', value:"", id:this.getId('passphrase')} | ||
82 | ]} | ||
83 | ]}, | ||
84 | {tag:'a', cls:'whiteButton', type:'submit', href:'#', html:"Login", id:this.getId('submit')} | ||
85 | ]}, | ||
86 | {tag:'div', cls:'panel toolbarlessPanel loginProgressPanel', id:this.getId('loginProgressPanel'), children:[ | ||
87 | {tag:'div', id:this.getId('progressBar')} //, | ||
88 | // {tag:'a', cls:'whiteButton', type:'submit', href:'#', html:"Cancel", id:this.getId('cancel')} | ||
89 | ]}, | ||
90 | {tag:'div', cls:'panel loginErrorPanel', id:this.getId('loginErrorPanel'), children:[ | ||
91 | {tag:'div', cls:'errorMessage', id:this.getId('errorMessageBox'), children:[ | ||
92 | {tag:'h2', id:this.getId('errorMessage'), html:"Login failed"} | ||
93 | ]} | ||
94 | ]} | ||
95 | ]); | ||
96 | |||
97 | MochiKit.Signal.connect(this.getElement('submit'), 'onclick',this, 'submitHandler'); | ||
98 | MochiKit.Signal.connect(this.getElement('loginFormPanel'), 'onsubmit',this, 'submitHandler'); | ||
99 | |||
100 | // MochiKit.Signal.connect(this.getElement('cancel'), 'onclick',this, 'cancelHandler'); | ||
101 | MochiKit.Signal.connect('backButton', 'onclick',this, 'backHandler'); | ||
102 | |||
103 | this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':this.getElement('progressBar')})); | ||
104 | |||
105 | // MochiKit.Style.hideElement(this.getElement('errorMessage')); | ||
106 | |||
107 | this.showLoginForm(); | ||
108 | // MochiKit.Async.callLater(0.2, MochiKit.Base.method(this, 'focusOnUsername')); | ||
109 | }, | ||
110 | |||
111 | //------------------------------------------------------------------------- | ||
112 | |||
113 | 'showLoginForm': function () { | ||
114 | MochiKit.Style.showElement(this.getElement('loginFormPanel')); | ||
115 | MochiKit.Style.hideElement(this.getElement('loginProgressPanel')); | ||
116 | MochiKit.Style.hideElement(this.getElement('loginErrorPanel')); | ||
117 | MochiKit.Style.hideElement('backButton'); | ||
118 | }, | ||
119 | |||
120 | 'slideInLoginForm': function () { | ||
121 | varoffset; | ||
122 | |||
123 | offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480); | ||
124 | |||
125 | MochiKit.Style.showElement(this.getElement('loginFormPanel')); | ||
126 | MochiKit.Style.setElementPosition(this.getElement('loginFormPanel'), {x:-offset, y:0}); | ||
127 | |||
128 | new MochiKit.Visual.Sequence([ | ||
129 | new MochiKit.Visual.Parallel([ | ||
130 | new MochiKit.Visual.Move(this.getElement('loginErrorPanel'), {x:offset, y:0, mode:'relative',transition:MochiKit.Visual.Transitions.linear, sync:true}), | ||
131 | new MochiKit.Visual.Move(this.getElement('loginFormPanel'), {x:0, y:0, mode:'absolute',transition:MochiKit.Visual.Transitions.linear, sync:true}), | ||
132 | MochiKit.Visual.fade ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true}) | ||
133 | ], {duration:0.5, sync:true}), | ||
134 | MochiKit.Visual.fade(this.getElement('loginErrorPanel'), {duration:0, sync:true}) | ||
135 | ], {}) | ||
136 | }, | ||
137 | |||
138 | 'showLoginProgress': function () { | ||
139 | MochiKit.Style.hideElement(this.getElement('loginFormPanel')); | ||
140 | MochiKit.Style.showElement(this.getElement('loginProgressPanel')); | ||
141 | }, | ||
142 | |||
143 | 'showLoginError': function (anError) { | ||
144 | this.getElement('errorMessage').innerHTML = "Login error"; | ||
145 | |||
146 | MochiKit.Style.showElement('backButton'); | ||
147 | MochiKit.Style.hideElement(this.getElement('loginProgressPanel')); | ||
148 | MochiKit.Style.showElement(this.getElement('loginErrorPanel')); | ||
149 | MochiKit.Style.setElementPosition(this.getElement('loginErrorPanel'), {x:0, y:45}); | ||
150 | }, | ||
151 | |||
152 | //------------------------------------------------------------------------- | ||
153 | /* | ||
154 | 'disableCancelButton': function () { | ||
155 | MochiKit.DOM.hideElement(this.getElement('cancel')); | ||
156 | }, | ||
157 | */ | ||
158 | //------------------------------------------------------------------------- | ||
159 | |||
160 | 'submitHandler': function (anEvent) { | ||
161 | anEvent.preventDefault(); | ||
162 | |||
163 | MochiKit.Signal.signal(this, 'doLogin', {'username':this.username(), 'passphrase':this.passphrase()}); | ||
164 | }, | ||
165 | |||
166 | 'cancelHandler': function (anEvent) { | ||
167 | anEvent.preventDefault(); | ||
168 | |||
169 | //console.log("CANCEL"); | ||
170 | }, | ||
171 | |||
172 | 'backHandler': function (anEvent) { | ||
173 | anEvent.preventDefault(); | ||
174 | |||
175 | this.slideInLoginForm(); | ||
176 | }, | ||
177 | |||
178 | //------------------------------------------------------------------------- | ||
179 | |||
180 | __syntaxFix__: "syntax fix" | ||
181 | }); | ||