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