summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UnlockPasswordComponent.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Web/Components/UnlockPasswordComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Components/UnlockPasswordComponent.js184
1 files changed, 184 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UnlockPasswordComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UnlockPasswordComponent.js
new file mode 100644
index 0000000..5b9d522
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UnlockPasswordComponent.js
@@ -0,0 +1,184 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer 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
29Clipperz.Base.module('Clipperz.PM.UI.Web.Components');
30
31Clipperz.PM.UI.Web.Components.UnlockPasswordComponent = function(args) {
32 args = args || {};
33
34 Clipperz.PM.UI.Web.Components.UnlockPasswordComponent.superclass.constructor.apply(this, arguments);
35
36 this._openFromElement = args.openFromElement || null;
37 this._onOkCloseToElement = args.onOkCloseToElement || null;
38 this._onCancelCloseToElement = args.onCancelCloseToElement|| null;
39
40 this._progressBarComponent = null;
41
42 return this;
43}
44
45//=============================================================================
46
47Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.UnlockPasswordComponent, Clipperz.PM.UI.Common.Components.SimpleMessagePanel, {
48
49 //-------------------------------------------------------------------------
50
51 'toString': function () {
52 return "Clipperz.PM.UI.Web.Components.UnlockPasswordComponent component";
53 },
54
55 //-------------------------------------------------------------------------
56
57 'getPassphrase': function () {
58 /* var deferredResult;
59
60 if (this.passphrase() == null) {
61 this.deferredShowModal({'openFromElement': this.openFromElement()});
62 deferredResult = this.deferred();
63 } else {
64 deferredResult = MochiKit.Async.succeed(this.passphrase());
65 }
66
67 return deferredResult;
68*/
69
70 this.deferredShowModal({'openFromElement': this.openFromElement()});
71
72 return this.deferred();
73 },
74
75 //-------------------------------------------------------------------------
76
77 'deferredShowModal': function (someParameters) {
78 return Clipperz.Async.callbacks("UnlockPasswordComponent.deferredShowModal", [
79 MochiKit.Base.bind(Clipperz.PM.UI.Web.Components.UnlockPasswordComponent.superclass.deferredShowModal, this, someParameters),
80 MochiKit.Base.method(this, 'getElement', 'passphrase'),
81 MochiKit.Base.methodcaller('focus')
82 ], {trace:false})
83 },
84
85 //-------------------------------------------------------------------------
86
87 'openFromElement': function () {
88 return this._openFromElement;
89 },
90
91 'onOkCloseToElement': function () {
92 return this._onOkCloseToElement;
93 },
94
95 'onCancelCloseToElement': function () {
96 return this._onCancelCloseToElement;
97 },
98
99 //-------------------------------------------------------------------------
100
101 'renderSelf': function() {
102 Clipperz.PM.UI.Web.Components.UnlockPasswordComponent.superclass.renderSelf.apply(this, arguments);
103
104 this.append(this.getElement('container'), {tag:'div', cls:'passphrase', children: [
105 // {tag:'form', id:this.getId('passphraseForm'), children:[
106 {tag:'input', id:this.getId('passphrase'), type:'password', name:'passphrase', value:''}
107 // ]}
108 ]});
109
110 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'userSuccessfullyLoggedIn', this, 'userSuccessfullyLoggedInHandler');
111 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'userLoginFailed', this, 'userLoginFailedHandler');
112
113
114 // MochiKit.Async.callLater(0.1, MochiKit.Base.method(this.getElement('passphrase'), 'focus'));
115 // this.getElement('passphrase').select();
116 },
117
118 //-------------------------------------------------------------------------
119
120 'showProgressBar': function () {
121 varprogressBarElement;
122
123 this.getElement('container').innerHTML = '';
124
125 progressBarElement = this.append(this.getElement('container'), {tag:'div', cls:'progressBarWrapper'});
126 this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':progressBarElement}));
127
128 this.setButtons([{text:"Cancel", result:'CANCEL'}]);
129 },
130
131 //-------------------------------------------------------------------------
132
133 'showFailure': function () {
134 this.setType('ALERT');
135 this.setTitle("Login failed");
136 this.setText("Wrong passphrase; the unlock has failed.");
137 this.getElement('container').innerHTML = '';
138 this.setButtons([{text:"Close", result:'CANCEL', isDefault:true}]);
139 },
140
141 //-------------------------------------------------------------------------
142
143 'closeOk': function () {
144 var passphrase;
145
146 passphrase = this.getElement('passphrase').value;
147 this.showProgressBar();
148 // this.deferred().callback(passphrase);
149 MochiKit.Async.callLater(0.5, MochiKit.Base.method(this.deferred(), 'callback', passphrase));
150 this._deferred = null;
151 },
152
153 'closeCancel': function () {
154 this.deferredHideModal({closeToElement:this.onCancelCloseToElement()});
155 this.deferred().cancel();
156 this._deferred = null;
157 },
158
159 //-------------------------------------------------------------------------
160
161 'userSuccessfullyLoggedInHandler': function (anEvent) {
162 this.deferredHideModal({closeToElement:this.onOkCloseToElement()});
163 },
164
165 'userLoginFailedHandler': function (anEvent) {
166//console.log("############### FAILED LOGIN ################");
167 this.showFailure();
168 },
169
170 //-------------------------------------------------------------------------
171/*
172 'deferredShow': function (someArgs, aResult) {
173 this.deferredShowModal(someArgs);
174
175 // this.deferred().addMethod(this, 'deferredHideModal', {closeToElement:someArgs.onOkCloseToElement });
176 // this.deferred().addErrback (MochiKit.Base.method(this, 'deferredHideModal', {closeToElement:someArgs.onCancelCloseToElement }));
177 // this.deferred().addCallback(MochiKit.Async.succeed, aResult);
178
179 return this.deferred();
180 },
181*/
182 //-------------------------------------------------------------------------
183 __syntaxFix__: "syntax fix"
184});