Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js index c025a51..92ed6e3 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js | |||
@@ -1,262 +1,259 @@ | |||
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.Controllers'); | 24 | Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers'); |
27 | 25 | ||
28 | Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController = function(args) { | 26 | Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController = function(args) { |
29 | this._directLoginEditingComponent = args.directLoginEditingComponent|| Clipperz.Base.exception.raise('MandatoryParameter'); | 27 | this._directLoginEditingComponent = args.directLoginEditingComponent|| Clipperz.Base.exception.raise('MandatoryParameter'); |
30 | this._cardLabel = args.cardLabel || Clipperz.Base.exception.raise('MandatoryParameter'); | 28 | this._cardLabel = args.cardLabel || Clipperz.Base.exception.raise('MandatoryParameter'); |
31 | 29 | ||
32 | MochiKit.Signal.connect(this._directLoginEditingComponent, 'changedValue',this, 'handleChangedValue'); | 30 | MochiKit.Signal.connect(this._directLoginEditingComponent, 'changedValue',this, 'handleChangedValue'); |
33 | MochiKit.Signal.connect(this._directLoginEditingComponent, 'moveForward',this, 'handleMoveForward'); | 31 | MochiKit.Signal.connect(this._directLoginEditingComponent, 'moveForward',this, 'handleMoveForward'); |
34 | MochiKit.Signal.connect(this._directLoginEditingComponent, 'keyPressed',this, 'handleDirectLoginEditingComponentKeyPressed'); | 32 | MochiKit.Signal.connect(this._directLoginEditingComponent, 'keyPressed',this, 'handleDirectLoginEditingComponentKeyPressed'); |
35 | 33 | ||
36 | this._directLogin = null; | 34 | this._directLogin = null; |
37 | this._directLoginHasJustBeenAdded = false; | 35 | this._directLoginHasJustBeenAdded = false; |
38 | 36 | ||
39 | this._rulerComponent = null; | 37 | this._rulerComponent = null; |
40 | 38 | ||
41 | this._steps = null; | 39 | this._steps = null; |
42 | this._currentStepIndex = 0; | 40 | this._currentStepIndex = 0; |
43 | this._isNextEnabled = false; | 41 | this._isNextEnabled = false; |
44 | 42 | ||
45 | this._recordFields = null; | 43 | this._recordFields = null; |
46 | this._originalBindings = null; | 44 | this._originalBindings = null; |
47 | 45 | ||
48 | this._bindingComponents = []; | 46 | this._bindingComponents = []; |
49 | this._formValueComponents = []; | 47 | this._formValueComponents = []; |
50 | 48 | ||
51 | return this; | 49 | return this; |
52 | } | 50 | } |
53 | 51 | ||
54 | MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController.prototype, { | 52 | MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController.prototype, { |
55 | 53 | ||
56 | 'toString': function() { | 54 | 'toString': function() { |
57 | return "Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController"; | 55 | return "Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController"; |
58 | }, | 56 | }, |
59 | 57 | ||
60 | //------------------------------------------------------------------------- | 58 | //------------------------------------------------------------------------- |
61 | 59 | ||
62 | 'directLogin': function () { | 60 | 'directLogin': function () { |
63 | return this._directLogin; | 61 | return this._directLogin; |
64 | }, | 62 | }, |
65 | 63 | ||
66 | //------------------------------------------------------------------------- | 64 | //------------------------------------------------------------------------- |
67 | 65 | ||
68 | 'directLoginHasJustBeenAdded': function () { | 66 | 'directLoginHasJustBeenAdded': function () { |
69 | return this._directLoginHasJustBeenAdded; | 67 | return this._directLoginHasJustBeenAdded; |
70 | }, | 68 | }, |
71 | 69 | ||
72 | 'setDirectLoginHasJustBeenAdded': function (aValue) { | 70 | 'setDirectLoginHasJustBeenAdded': function (aValue) { |
73 | this._directLoginHasJustBeenAdded = aValue; | 71 | this._directLoginHasJustBeenAdded = aValue; |
74 | }, | 72 | }, |
75 | 73 | ||
76 | //------------------------------------------------------------------------- | 74 | //------------------------------------------------------------------------- |
77 | 75 | ||
78 | 'directLoginEditingComponent': function () { | 76 | 'directLoginEditingComponent': function () { |
79 | return this._directLoginEditingComponent; | 77 | return this._directLoginEditingComponent; |
80 | }, | 78 | }, |
81 | 79 | ||
82 | //============================================================================= | 80 | //============================================================================= |
83 | 81 | ||
84 | 'cardLabel': function () { | 82 | 'cardLabel': function () { |
85 | return this._cardLabel; | 83 | return this._cardLabel; |
86 | }, | 84 | }, |
87 | 85 | ||
88 | //============================================================================= | 86 | //============================================================================= |
89 | 87 | ||
90 | 'resetCurrentStepIndex': function () { | 88 | 'resetCurrentStepIndex': function () { |
91 | this._currentStepIndex = 0; | 89 | this._currentStepIndex = 0; |
92 | this.rulerComponent().resetStatus(); | 90 | this.rulerComponent().resetStatus(); |
93 | }, | 91 | }, |
94 | 92 | ||
95 | //----------------------------------------------------------------------------- | 93 | //----------------------------------------------------------------------------- |
96 | 94 | ||
97 | 'enableNext': function (aValue) { | 95 | 'enableNext': function (aValue) { |
98 | this.rulerComponent().enableNext(aValue); | 96 | this.rulerComponent().enableNext(aValue); |
99 | this._isNextEnabled = aValue; | 97 | this._isNextEnabled = aValue; |
100 | }, | 98 | }, |
101 | 99 | ||
102 | 'isNextEnabled': function () { | 100 | 'isNextEnabled': function () { |
103 | return this._isNextEnabled; | 101 | return this._isNextEnabled; |
104 | }, | 102 | }, |
105 | 103 | ||
106 | //----------------------------------------------------------------------------- | 104 | //----------------------------------------------------------------------------- |
107 | 105 | ||
108 | 'enablePrevious': function (aValue) { | 106 | 'enablePrevious': function (aValue) { |
109 | this.rulerComponent().enablePrevious(aValue); | 107 | this.rulerComponent().enablePrevious(aValue); |
110 | }, | 108 | }, |
111 | 109 | ||
112 | //============================================================================= | 110 | //============================================================================= |
113 | 111 | ||
114 | 'bindingComponents': function () { | 112 | 'bindingComponents': function () { |
115 | return this._bindingComponents; | 113 | return this._bindingComponents; |
116 | }, | 114 | }, |
117 | 115 | ||
118 | 'resetBindingComponents': function () { | 116 | 'resetBindingComponents': function () { |
119 | this.directLoginEditingComponent().clearAllBindingsComponents(); | 117 | this.directLoginEditingComponent().clearAllBindingsComponents(); |
120 | this._bindingComponents = []; | 118 | this._bindingComponents = []; |
121 | }, | 119 | }, |
122 | 120 | ||
123 | //============================================================================= | 121 | //============================================================================= |
124 | 122 | ||
125 | 'formValueComponents': function () { | 123 | 'formValueComponents': function () { |
126 | return this._formValueComponents; | 124 | return this._formValueComponents; |
127 | }, | 125 | }, |
128 | 126 | ||
129 | 'resetFormValueComponents': function () { | 127 | 'resetFormValueComponents': function () { |
130 | this.directLoginEditingComponent().clearAllFormValueComponents(); | 128 | this.directLoginEditingComponent().clearAllFormValueComponents(); |
131 | this._formValueComponents = []; | 129 | this._formValueComponents = []; |
132 | }, | 130 | }, |
133 | 131 | ||
134 | //============================================================================= | 132 | //============================================================================= |
135 | 133 | ||
136 | 'recordFields': function () { | 134 | 'recordFields': function () { |
137 | return this._recordFields; | 135 | return this._recordFields; |
138 | }, | 136 | }, |
139 | 137 | ||
140 | 'setRecordFields': function (aValue) { | 138 | 'setRecordFields': function (aValue) { |
141 | this._recordFields = aValue; | 139 | this._recordFields = aValue; |
142 | }, | 140 | }, |
143 | 141 | ||
144 | 'recordFieldWithReference': function (aReference) { | 142 | 'recordFieldWithReference': function (aReference) { |
145 | var matchingValues; | 143 | var matchingValues; |
146 | var result; | 144 | var result; |
147 | 145 | ||
148 | matchingValues = MochiKit.Base.filter(function (aField) { return aField['reference'] == aReference; }, this.recordFields()); | 146 | matchingValues = MochiKit.Base.filter(function (aField) { return aField['reference'] == aReference; }, this.recordFields()); |
149 | 147 | ||
150 | if (matchingValues.length == 0) { | 148 | if (matchingValues.length == 0) { |
151 | result = null; | 149 | result = null; |
152 | } else { | 150 | } else { |
153 | result = matchingValues[0]; | 151 | result = matchingValues[0]; |
154 | } | 152 | } |
155 | 153 | ||
156 | return result; | 154 | return result; |
157 | }, | 155 | }, |
158 | 156 | ||
159 | //----------------------------------------------------------------------------- | 157 | //----------------------------------------------------------------------------- |
160 | 158 | ||
161 | 'originalBindings': function () { | 159 | 'originalBindings': function () { |
162 | return this._originalBindings; | 160 | return this._originalBindings; |
163 | }, | 161 | }, |
164 | 162 | ||
165 | 'setOriginalBindings': function (aValue) { | 163 | 'setOriginalBindings': function (aValue) { |
166 | //console.log("BINDINGS", aValue); | ||
167 | this._originalBindings = aValue; | 164 | this._originalBindings = aValue; |
168 | }, | 165 | }, |
169 | 166 | ||
170 | //============================================================================= | 167 | //============================================================================= |
171 | 168 | ||
172 | 'rulerComponent': function () { | 169 | 'rulerComponent': function () { |
173 | if (this._rulerComponent == null) { | 170 | if (this._rulerComponent == null) { |
174 | this._rulerComponent = new Clipperz.PM.UI.Web.Components.RulerComponent({ | 171 | this._rulerComponent = new Clipperz.PM.UI.Web.Components.RulerComponent({ |
175 | translationContext:'Wizards.DirectLoginWizard' | 172 | translationContext:'Wizards.DirectLoginWizard' |
176 | }); | 173 | }); |
177 | this._rulerComponent.render(); | 174 | this._rulerComponent.render(); |
178 | 175 | ||
179 | MochiKit.Signal.connect(this._rulerComponent, 'exit', this, 'handleExit'); | 176 | MochiKit.Signal.connect(this._rulerComponent, 'exit', this, 'handleExit'); |
180 | MochiKit.Signal.connect(this._rulerComponent, 'done', this, 'done'); | 177 | MochiKit.Signal.connect(this._rulerComponent, 'done', this, 'done'); |
181 | MochiKit.Signal.connect(this._rulerComponent, 'moveForward',this, 'handleMoveForward'); | 178 | MochiKit.Signal.connect(this._rulerComponent, 'moveForward',this, 'handleMoveForward'); |
182 | MochiKit.Signal.connect(this._rulerComponent, 'moveBackward',this, 'handleMoveBackward'); | 179 | MochiKit.Signal.connect(this._rulerComponent, 'moveBackward',this, 'handleMoveBackward'); |
183 | MochiKit.Signal.connect(this._rulerComponent, 'cursorMoved',this, 'handleCursorMoved'); | 180 | MochiKit.Signal.connect(this._rulerComponent, 'cursorMoved',this, 'handleCursorMoved'); |
184 | } | 181 | } |
185 | 182 | ||
186 | return this._rulerComponent; | 183 | return this._rulerComponent; |
187 | }, | 184 | }, |
188 | 185 | ||
189 | //----------------------------------------------------------------------------- | 186 | //----------------------------------------------------------------------------- |
190 | 187 | ||
191 | 'showRuler': function (someSteps) { | 188 | 'showRuler': function (someSteps) { |
192 | var rulerElement; | 189 | var rulerElement; |
193 | 190 | ||
194 | this.setSteps(someSteps); | 191 | this.setSteps(someSteps); |
195 | 192 | ||
196 | rulerElement = this.rulerComponent().element(); | 193 | rulerElement = this.rulerComponent().element(); |
197 | this.directLoginEditingComponent().disableAllPanels(); | 194 | this.directLoginEditingComponent().disableAllPanels(); |
198 | 195 | ||
199 | MochiKit.Style.showElement(rulerElement); | 196 | MochiKit.Style.showElement(rulerElement); |
200 | MochiKit.Style.setElementPosition(rulerElement, {x:-1000, y:this.directLoginEditingComponent().bottomMargin()}); | 197 | MochiKit.Style.setElementPosition(rulerElement, {x:-1000, y:this.directLoginEditingComponent().bottomMargin()}); |
201 | new MochiKit.Visual.Move(rulerElement, { | 198 | new MochiKit.Visual.Move(rulerElement, { |
202 | x:0, y:this.directLoginEditingComponent().bottomMargin(), | 199 | x:0, y:this.directLoginEditingComponent().bottomMargin(), |
203 | mode:'absolute', | 200 | mode:'absolute', |
204 | duration:1, | 201 | duration:1, |
205 | afterFinish:MochiKit.Base.method(this, 'handleCursorMoved') | 202 | afterFinish:MochiKit.Base.method(this, 'handleCursorMoved') |
206 | }); | 203 | }); |
207 | }, | 204 | }, |
208 | 205 | ||
209 | 'fixRulerRendering': function (aValue) { | 206 | 'fixRulerRendering': function (aValue) { |
210 | this.rulerComponent().setDisplayMode(aValue); | 207 | this.rulerComponent().setDisplayMode(aValue); |
211 | }, | 208 | }, |
212 | 209 | ||
213 | //----------------------------------------------------------------------------- | 210 | //----------------------------------------------------------------------------- |
214 | 211 | ||
215 | 'hideRuler': function () { | 212 | 'hideRuler': function () { |
216 | new MochiKit.Visual.Move(this.rulerComponent().element(), {x:-1000, mode:'relative', duration:1}); | 213 | new MochiKit.Visual.Move(this.rulerComponent().element(), {x:-1000, mode:'relative', duration:1}); |
217 | }, | 214 | }, |
218 | 215 | ||
219 | 'doneWithRuler': function () { | 216 | 'doneWithRuler': function () { |
220 | var rulerComponentElement; | 217 | var rulerComponentElement; |
221 | 218 | ||
222 | rulerComponentElement = this.rulerComponent().element(); | 219 | rulerComponentElement = this.rulerComponent().element(); |
223 | new MochiKit.Visual.Move(this.rulerComponent().element(), { | 220 | new MochiKit.Visual.Move(this.rulerComponent().element(), { |
224 | x:1000, | 221 | x:1000, |
225 | mode:'relative', | 222 | mode:'relative', |
226 | duration:1, | 223 | duration:1, |
227 | // afterFinish:MochiKit.Base.partial(MochiKit.Style.hideElement, rulerComponentElement) | 224 | // afterFinish:MochiKit.Base.partial(MochiKit.Style.hideElement, rulerComponentElement) |
228 | afterFinish:function () { MochiKit.Style.hideElement(rulerComponentElement); } | 225 | afterFinish:function () { MochiKit.Style.hideElement(rulerComponentElement); } |
229 | }); | 226 | }); |
230 | }, | 227 | }, |
231 | 228 | ||
232 | //============================================================================= | 229 | //============================================================================= |
233 | 230 | ||
234 | 'addNewDirectLoginRulerSteps': function () { | 231 | 'addNewDirectLoginRulerSteps': function () { |
235 | return MochiKit.Base.concat([ 'LABEL'], this.editDirectLoginRulerSteps()); | 232 | return MochiKit.Base.concat([ 'LABEL'], this.editDirectLoginRulerSteps()); |
236 | 233 | ||
237 | }, | 234 | }, |
238 | 235 | ||
239 | 'editDirectLoginRulerSteps': function () { | 236 | 'editDirectLoginRulerSteps': function () { |
240 | return [ /*'TYPE',*/ 'CONFIGURATION', 'BINDINGS','FAVICON', 'DONE']; | 237 | return [ /*'TYPE',*/ 'CONFIGURATION', 'BINDINGS','FAVICON', 'DONE']; |
241 | }, | 238 | }, |
242 | 239 | ||
243 | //------------------------------------------------------------------------- | 240 | //------------------------------------------------------------------------- |
244 | 241 | ||
245 | 'runWithDirectLogin': function (aDirectLogin, hasJustBeenAdded) { | 242 | 'runWithDirectLogin': function (aDirectLogin, hasJustBeenAdded) { |
246 | this._directLogin = aDirectLogin; | 243 | this._directLogin = aDirectLogin; |
247 | this.setDirectLoginHasJustBeenAdded(hasJustBeenAdded); | 244 | this.setDirectLoginHasJustBeenAdded(hasJustBeenAdded); |
248 | 245 | ||
249 | return Clipperz.Async.callbacks("DirectLoginWizardController.runWithDirectLogin", [ | 246 | return Clipperz.Async.callbacks("DirectLoginWizardController.runWithDirectLogin", [ |
250 | MochiKit.Base.method(aDirectLogin, 'label'), | 247 | MochiKit.Base.method(aDirectLogin, 'label'), |
251 | MochiKit.Base.method(this.directLoginEditingComponent(), 'setLabel'), | 248 | MochiKit.Base.method(this.directLoginEditingComponent(), 'setLabel'), |
252 | 249 | ||
253 | MochiKit.Base.method(aDirectLogin, 'favicon'), | 250 | MochiKit.Base.method(aDirectLogin, 'favicon'), |
254 | MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginFavicon'), | 251 | MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginFavicon'), |
255 | 252 | ||
256 | MochiKit.Base.method(aDirectLogin, 'bookmarkletConfiguration'), | 253 | MochiKit.Base.method(aDirectLogin, 'bookmarkletConfiguration'), |
257 | MochiKit.Base.method(this.directLoginEditingComponent(), 'setBookmarkletConfiguration'), | 254 | MochiKit.Base.method(this.directLoginEditingComponent(), 'setBookmarkletConfiguration'), |
258 | 255 | ||
259 | MochiKit.Base.method(aDirectLogin, 'bindings'), | 256 | MochiKit.Base.method(aDirectLogin, 'bindings'), |
260 | MochiKit.Base.method(this, 'setOriginalBindings'), | 257 | MochiKit.Base.method(this, 'setOriginalBindings'), |
261 | 258 | ||
262 | MochiKit.Base.method(aDirectLogin, 'record'), | 259 | MochiKit.Base.method(aDirectLogin, 'record'), |
@@ -314,194 +311,192 @@ MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController. | |||
314 | if (enableNext == true) { | 311 | if (enableNext == true) { |
315 | try { | 312 | try { |
316 | Clipperz.PM.DataModel.DirectLogin.checkBookmarkletConfiguration(this.directLoginEditingComponent().bookmarkletConfiguration()); | 313 | Clipperz.PM.DataModel.DirectLogin.checkBookmarkletConfiguration(this.directLoginEditingComponent().bookmarkletConfiguration()); |
317 | this.directLoginEditingComponent().removeHighlightConfigurationSyntaxError(); | 314 | this.directLoginEditingComponent().removeHighlightConfigurationSyntaxError(); |
318 | } catch (e) { | 315 | } catch (e) { |
319 | this.directLoginEditingComponent().highlightConfigurationSyntaxError(); | 316 | this.directLoginEditingComponent().highlightConfigurationSyntaxError(); |
320 | enableNext = false; | 317 | enableNext = false; |
321 | } | 318 | } |
322 | } | 319 | } |
323 | break; | 320 | break; |
324 | case 'BINDINGS': | 321 | case 'BINDINGS': |
325 | enableNext = MochiKit.Iter.every(this.bindingComponents(), function (aBindingComponent) { return aBindingComponent.selectedValue() != null; }) | 322 | enableNext = MochiKit.Iter.every(this.bindingComponents(), function (aBindingComponent) { return aBindingComponent.selectedValue() != null; }) |
326 | this.directLoginEditingComponent().enableBindingFields(); | 323 | this.directLoginEditingComponent().enableBindingFields(); |
327 | break; | 324 | break; |
328 | case 'FAVICON': | 325 | case 'FAVICON': |
329 | enableNext = true; | 326 | enableNext = true; |
330 | this.directLoginEditingComponent().enableFaviconField(); | 327 | this.directLoginEditingComponent().enableFaviconField(); |
331 | break; | 328 | break; |
332 | case 'DONE': | 329 | case 'DONE': |
333 | enableNext = true; | 330 | enableNext = true; |
334 | this.directLoginEditingComponent().enableDonePanel(); | 331 | this.directLoginEditingComponent().enableDonePanel(); |
335 | break; | 332 | break; |
336 | } | 333 | } |
337 | 334 | ||
338 | if (this.currentStepIndex() > 0) { | 335 | if (this.currentStepIndex() > 0) { |
339 | this.enablePrevious(enablePrevious); | 336 | this.enablePrevious(enablePrevious); |
340 | } else { | 337 | } else { |
341 | this.enablePrevious(false); | 338 | this.enablePrevious(false); |
342 | } | 339 | } |
343 | this.enableNext(enableNext); | 340 | this.enableNext(enableNext); |
344 | }, | 341 | }, |
345 | 342 | ||
346 | //----------------------------------------------------------------------------- | 343 | //----------------------------------------------------------------------------- |
347 | 344 | ||
348 | 'setFocus': function () { | 345 | 'setFocus': function () { |
349 | switch(this.currentStep()) { | 346 | switch(this.currentStep()) { |
350 | case 'LABEL': | 347 | case 'LABEL': |
351 | this.directLoginEditingComponent().focusOnLabelElement(); | 348 | this.directLoginEditingComponent().focusOnLabelElement(); |
352 | break; | 349 | break; |
353 | case 'TYPE': | 350 | case 'TYPE': |
354 | break; | 351 | break; |
355 | case 'CONFIGURATION': | 352 | case 'CONFIGURATION': |
356 | this.directLoginEditingComponent().focusOnBookmarkletConfigurationElement(); | 353 | this.directLoginEditingComponent().focusOnBookmarkletConfigurationElement(); |
357 | break; | 354 | break; |
358 | case 'BINDINGS': | 355 | case 'BINDINGS': |
359 | // this.directLoginEditingComponent().getElement('???').focus(); | 356 | // this.directLoginEditingComponent().getElement('???').focus(); |
360 | break; | 357 | break; |
361 | case 'FAVICON': | 358 | case 'FAVICON': |
362 | this.directLoginEditingComponent().focusOnFaviconElement(); | 359 | this.directLoginEditingComponent().focusOnFaviconElement(); |
363 | break; | 360 | break; |
364 | case 'DONE': | 361 | case 'DONE': |
365 | break; | 362 | break; |
366 | } | 363 | } |
367 | }, | 364 | }, |
368 | 365 | ||
369 | //============================================================================= | 366 | //============================================================================= |
370 | 367 | ||
371 | 'steps': function () { | 368 | 'steps': function () { |
372 | return this._steps; | 369 | return this._steps; |
373 | }, | 370 | }, |
374 | 371 | ||
375 | 'setSteps': function (aValue) { | 372 | 'setSteps': function (aValue) { |
376 | this._steps = aValue; | 373 | this._steps = aValue; |
377 | 374 | ||
378 | this.rulerComponent().setSteps(aValue); | 375 | this.rulerComponent().setSteps(aValue); |
379 | this.resetCurrentStepIndex(); | 376 | this.resetCurrentStepIndex(); |
380 | }, | 377 | }, |
381 | 378 | ||
382 | 'currentStepIndex': function () { | 379 | 'currentStepIndex': function () { |
383 | return this._currentStepIndex; | 380 | return this._currentStepIndex; |
384 | }, | 381 | }, |
385 | 382 | ||
386 | 'currentStep': function () { | 383 | 'currentStep': function () { |
387 | return this.steps()[this.currentStepIndex()]; | 384 | return this.steps()[this.currentStepIndex()]; |
388 | }, | 385 | }, |
389 | 386 | ||
390 | //============================================================================= | 387 | //============================================================================= |
391 | 388 | ||
392 | 'handleExit': function () { | 389 | 'handleExit': function () { |
393 | MochiKit.Signal.signal(this, 'exit'); | 390 | MochiKit.Signal.signal(this, 'exit'); |
394 | }, | 391 | }, |
395 | 392 | ||
396 | 'done': function () { | 393 | 'done': function () { |
397 | this.doneWithRuler(); | 394 | this.doneWithRuler(); |
398 | 395 | ||
399 | Clipperz.Async.callbacks("DirectLoginWizardController.done", [ | 396 | Clipperz.Async.callbacks("DirectLoginWizardController.done", [ |
400 | MochiKit.Base.method(this.directLoginEditingComponent(), 'label'), | 397 | MochiKit.Base.method(this.directLoginEditingComponent(), 'label'), |
401 | MochiKit.Base.method(this.directLogin(), 'setLabel'), | 398 | MochiKit.Base.method(this.directLogin(), 'setLabel'), |
402 | 399 | ||
403 | MochiKit.Base.method(this.directLoginEditingComponent(), 'bookmarkletConfiguration'), | 400 | MochiKit.Base.method(this.directLoginEditingComponent(), 'bookmarkletConfiguration'), |
404 | MochiKit.Base.method(this.directLogin(), 'setBookmarkletConfiguration'), | 401 | MochiKit.Base.method(this.directLogin(), 'setBookmarkletConfiguration'), |
405 | 402 | ||
406 | //Bindings | 403 | //Bindings |
407 | MochiKit.Base.method(this.directLoginEditingComponent(), 'bindingComponents'), | 404 | MochiKit.Base.method(this.directLoginEditingComponent(), 'bindingComponents'), |
408 | // MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.bind(function (aBindingComponent) { | 405 | // MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.bind(function (aBindingComponent) { |
409 | Clipperz.Async.forEach(MochiKit.Base.bind(function (aBindingComponent) { | 406 | Clipperz.Async.forEach(MochiKit.Base.bind(function (aBindingComponent) { |
410 | //console.log("aBindingComponent", aBindingComponent); | ||
411 | // this.directLogin(). | ||
412 | return Clipperz.Async.callbacks("DirectLoginWizardController.done - update directLogin bindings", [ | 407 | return Clipperz.Async.callbacks("DirectLoginWizardController.done - update directLogin bindings", [ |
413 | MochiKit.Base.method(this.directLogin(), 'bindings'), | 408 | MochiKit.Base.method(this.directLogin(), 'bindings'), |
414 | MochiKit.Base.itemgetter(aBindingComponent.formFieldName()), | 409 | MochiKit.Base.itemgetter(aBindingComponent.formFieldName()), |
415 | MochiKit.Base.methodcaller('setFieldKey', aBindingComponent.selectedValue()) | 410 | MochiKit.Base.methodcaller('setFieldKey', aBindingComponent.selectedValue()) |
416 | ], {trace:false}); | 411 | ], {trace:false}); |
417 | }, this)), | 412 | }, this)), |
418 | 413 | ||
419 | MochiKit.Base.method(this.directLoginEditingComponent(), 'favicon'), | 414 | MochiKit.Base.method(this.directLoginEditingComponent(), 'favicon'), |
420 | MochiKit.Base.method(this.directLogin(), 'setFavicon'), | 415 | MochiKit.Base.method(this.directLogin(), 'setFavicon'), |
421 | 416 | ||
422 | MochiKit.Base.partial(MochiKit.Signal.signal, this, 'done', { | 417 | MochiKit.Base.partial(MochiKit.Signal.signal, this, 'done', { |
423 | 'directLogin': this.directLogin(), | 418 | 'directLogin': this.directLogin(), |
424 | 'hasJustBeenAdded':this.directLoginHasJustBeenAdded() | 419 | 'hasJustBeenAdded':this.directLoginHasJustBeenAdded() |
425 | }) | 420 | }) |
426 | ], {trace:false}); | 421 | ], {trace:false}); |
427 | }, | 422 | }, |
428 | 423 | ||
429 | //============================================================================= | 424 | //============================================================================= |
430 | 425 | ||
431 | 'handleMoveBackward': function () { | 426 | 'handleMoveBackward': function () { |
432 | if (this._currentStepIndex > 0) { | 427 | if (this._currentStepIndex > 0) { |
433 | varafterMoveAction; | 428 | varafterMoveAction; |
434 | 429 | ||
435 | this._currentStepIndex --; | 430 | this._currentStepIndex --; |
436 | afterMoveAction = MochiKit.Base.noop; | 431 | afterMoveAction = MochiKit.Base.noop; |
437 | 432 | ||
438 | switch(this.currentStep()) { | 433 | switch(this.currentStep()) { |
439 | case 'LABEL': | 434 | case 'LABEL': |
440 | break; | 435 | break; |
441 | case 'TYPE': | 436 | case 'TYPE': |
442 | break; | 437 | break; |
443 | case 'CONFIGURATION': | 438 | case 'CONFIGURATION': |
444 | break; | 439 | break; |
445 | case 'BINDINGS': | 440 | case 'BINDINGS': |
446 | break; | 441 | break; |
447 | case 'FAVICON': | 442 | case 'FAVICON': |
448 | break; | 443 | break; |
449 | case 'DONE': | 444 | case 'DONE': |
450 | break; | 445 | break; |
451 | }; | 446 | }; |
452 | 447 | ||
453 | this.rulerComponent().moveBackward(afterMoveAction); | 448 | this.rulerComponent().moveBackward(afterMoveAction); |
454 | } | 449 | } |
455 | 450 | ||
456 | if (this._currentStepIndex == 0) { | 451 | if (this._currentStepIndex == 0) { |
457 | this.enablePrevious(false); | 452 | this.enablePrevious(false); |
458 | } | 453 | } |
459 | }, | 454 | }, |
460 | 455 | ||
461 | 'handleMoveForward': function () { | 456 | 'handleMoveForward': function () { |
462 | if (this.isNextEnabled()) { | 457 | if (this.isNextEnabled()) { |
463 | varafterMoveAction; | 458 | varafterMoveAction; |
464 | 459 | ||
465 | this._currentStepIndex ++; | 460 | this._currentStepIndex ++; |
466 | afterMoveAction = MochiKit.Base.noop; | 461 | afterMoveAction = MochiKit.Base.noop; |
467 | 462 | ||
468 | switch(this.currentStep()) { | 463 | switch(this.currentStep()) { |
469 | case 'LABEL': | 464 | case 'LABEL': |
470 | break; | 465 | break; |
471 | case 'TYPE': | 466 | case 'TYPE': |
472 | break; | 467 | break; |
473 | case 'CONFIGURATION': | 468 | case 'CONFIGURATION': |
474 | break; | 469 | break; |
475 | case 'BINDINGS': | 470 | case 'BINDINGS': |
476 | this.resetBindingComponents(); | 471 | this.resetBindingComponents(); |
477 | this.resetFormValueComponents(); | 472 | this.resetFormValueComponents(); |
478 | 473 | ||
479 | afterMoveAction = MochiKit.Base.partial(Clipperz.Async.callbacks, "DirectLoginWizardController.handleMoveForward - BINDINGS", [ | 474 | afterMoveAction = MochiKit.Base.partial(Clipperz.Async.callbacks, "DirectLoginWizardController.handleMoveForward - BINDINGS", [ |
480 | MochiKit.Base.method(this.directLogin(), 'setBookmarkletConfiguration', this.directLoginEditingComponent().bookmarkletConfiguration()), | 475 | MochiKit.Base.method(this.directLogin(), 'setBookmarkletConfiguration', this.directLoginEditingComponent().bookmarkletConfiguration()), |
481 | 476 | ||
482 | MochiKit.Base.method(this.directLogin(), 'favicon'), | 477 | MochiKit.Base.method(this.directLogin(), 'favicon'), |
483 | MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginFavicon'), | 478 | MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginFavicon'), |
484 | 479 | ||
485 | MochiKit.Base.method(this.directLogin(), 'bindings'), | 480 | MochiKit.Base.method(this.directLogin(), 'bindings'), |
486 | MochiKit.Base.values, | 481 | MochiKit.Base.values, |
487 | Clipperz.Async.forEach(MochiKit.Base.bind(function (aBinding) { | 482 | Clipperz.Async.forEach(MochiKit.Base.bind(function (aBinding) { |
488 | var bindingComponent; | 483 | var bindingComponent; |
489 | 484 | ||
490 | bindingComponent = new Clipperz.PM.UI.Web.Components.DirectLoginEditingBindingComponent({ | 485 | bindingComponent = new Clipperz.PM.UI.Web.Components.DirectLoginEditingBindingComponent({ |
491 | formFieldName: aBinding.key(), | 486 | formFieldName: aBinding.key(), |
492 | fields: this.recordFields(), | 487 | fields: this.recordFields(), |
493 | selectedFieldKey: aBinding.fieldKey() | 488 | selectedFieldKey: aBinding.fieldKey() |
494 | }); | 489 | }); |
495 | 490 | ||
496 | this.bindingComponents().push(bindingComponent); | 491 | this.bindingComponents().push(bindingComponent); |
497 | 492 | ||
498 | MochiKit.Signal.connect(bindingComponent, 'bindChange', this, 'handleBindChange', bindingComponent); | 493 | MochiKit.Signal.connect(bindingComponent, 'bindChange', this, 'handleBindChange', bindingComponent); |
499 | this.directLoginEditingComponent().addBindingComponent(bindingComponent); | 494 | this.directLoginEditingComponent().addBindingComponent(bindingComponent); |
500 | 495 | ||
501 | }, this)), | 496 | }, this)), |
502 | 497 | ||
503 | MochiKit.Base.method(this.directLogin(), 'formValues'), | 498 | MochiKit.Base.method(this.directLogin(), 'formValues'), |
504 | MochiKit.Base.values, | 499 | MochiKit.Base.values, |
505 | Clipperz.Async.forEach(MochiKit.Base.bind(function (aFormValue) { | 500 | Clipperz.Async.forEach(MochiKit.Base.bind(function (aFormValue) { |
506 | var formValueComponent; | 501 | var formValueComponent; |
507 | 502 | ||