Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js index 8f8696d..507ee31 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js | |||
@@ -1,881 +1,871 @@ | |||
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.DataModel'); | 24 | Clipperz.Base.module('Clipperz.PM.DataModel'); |
27 | 25 | ||
28 | Clipperz.PM.DataModel.DirectLogin = function(args) { | 26 | Clipperz.PM.DataModel.DirectLogin = function(args) { |
29 | args = args || {}; | 27 | args = args || {}; |
30 | 28 | ||
31 | Clipperz.PM.DataModel.DirectLogin.superclass.constructor.apply(this, arguments); | 29 | Clipperz.PM.DataModel.DirectLogin.superclass.constructor.apply(this, arguments); |
32 | 30 | ||
33 | this._reference =args.reference | 31 | this._reference =args.reference |
34 | ||Clipperz.PM.Crypto.randomKey(); | 32 | ||Clipperz.PM.Crypto.randomKey(); |
35 | this._record =args.record | 33 | this._record =args.record |
36 | ||Clipperz.Base.exception.raise('MandatoryParameter'); | 34 | ||Clipperz.Base.exception.raise('MandatoryParameter'); |
37 | 35 | ||
38 | this._retrieveIndexDataFunction = args.retrieveIndexDataFunction | 36 | this._retrieveIndexDataFunction = args.retrieveIndexDataFunction |
39 | ||this.record().retrieveDirectLoginIndexDataFunction() | 37 | ||this.record().retrieveDirectLoginIndexDataFunction() |
40 | ||Clipperz.Base.exception.raise('MandatoryParameter'); | 38 | ||Clipperz.Base.exception.raise('MandatoryParameter'); |
41 | this._setIndexDataFunction = args.setIndexDataFunction | 39 | this._setIndexDataFunction = args.setIndexDataFunction |
42 | ||this.record().setDirectLoginIndexDataFunction() | 40 | ||this.record().setDirectLoginIndexDataFunction() |
43 | ||Clipperz.Base.exception.raise('MandatoryParameter'); | 41 | ||Clipperz.Base.exception.raise('MandatoryParameter'); |
44 | this._removeIndexDataFunction =args.removeIndexDataFunction | 42 | this._removeIndexDataFunction =args.removeIndexDataFunction |
45 | ||this.record().removeDirectLoginIndexDataFunction() | 43 | ||this.record().removeDirectLoginIndexDataFunction() |
46 | ||Clipperz.Base.exception.raise('MandatoryParameter'); | 44 | ||Clipperz.Base.exception.raise('MandatoryParameter'); |
47 | 45 | ||
48 | this._inputs = null; | 46 | this._inputs = null; |
49 | this._bindings = null; | 47 | this._bindings = null; |
50 | this._formValues = null; | 48 | this._formValues = null; |
51 | 49 | ||
52 | // this._inputsDeferredLock = new MochiKit.Async.DeferredLock(); | 50 | // this._inputsDeferredLock = new MochiKit.Async.DeferredLock(); |
53 | // this._bindingsDeferredLock = new MochiKit.Async.DeferredLock(); | 51 | // this._bindingsDeferredLock = new MochiKit.Async.DeferredLock(); |
54 | // this._formValuesDeferredLock = new MochiKit.Async.DeferredLock(); | 52 | // this._formValuesDeferredLock = new MochiKit.Async.DeferredLock(); |
55 | 53 | ||
56 | this._transientState = null; | 54 | this._transientState = null; |
57 | 55 | ||
58 | this._isBrandNew = MochiKit.Base.isUndefinedOrNull(args.reference); | 56 | this._isBrandNew = MochiKit.Base.isUndefinedOrNull(args.reference); |
59 | 57 | ||
60 | this.record().addDirectLogin(this); | 58 | this.record().addDirectLogin(this); |
61 | 59 | ||
62 | return this; | 60 | return this; |
63 | } | 61 | } |
64 | 62 | ||
65 | Clipperz.Base.extend(Clipperz.PM.DataModel.DirectLogin, Object, { | 63 | Clipperz.Base.extend(Clipperz.PM.DataModel.DirectLogin, Object, { |
66 | 64 | ||
67 | 'toString': function() { | 65 | 'toString': function() { |
68 | return "DirectLogin (" + this.reference() + ")"; | 66 | return "DirectLogin (" + this.reference() + ")"; |
69 | }, | 67 | }, |
70 | 68 | ||
71 | //========================================================================= | 69 | //========================================================================= |
72 | 70 | ||
73 | 'reference': function () { | 71 | 'reference': function () { |
74 | return this._reference; | 72 | return this._reference; |
75 | }, | 73 | }, |
76 | 74 | ||
77 | //------------------------------------------------------------------------- | 75 | //------------------------------------------------------------------------- |
78 | 76 | ||
79 | 'record': function () { | 77 | 'record': function () { |
80 | return this._record; | 78 | return this._record; |
81 | }, | 79 | }, |
82 | 80 | ||
83 | //========================================================================= | 81 | //========================================================================= |
84 | 82 | ||
85 | 'isBrandNew': function () { | 83 | 'isBrandNew': function () { |
86 | return this._isBrandNew; | 84 | return this._isBrandNew; |
87 | }, | 85 | }, |
88 | 86 | ||
89 | //========================================================================= | 87 | //========================================================================= |
90 | 88 | ||
91 | 'removeIndexDataFunction': function () { | 89 | 'removeIndexDataFunction': function () { |
92 | return this._removeIndexDataFunction; | 90 | return this._removeIndexDataFunction; |
93 | }, | 91 | }, |
94 | 92 | ||
95 | 'remove': function () { | 93 | 'remove': function () { |
96 | return Clipperz.Async.callbacks("DirectLogin.remove", [ | 94 | return Clipperz.Async.callbacks("DirectLogin.remove", [ |
97 | MochiKit.Base.partial(this.removeIndexDataFunction(), this.reference()), | 95 | MochiKit.Base.partial(this.removeIndexDataFunction(), this.reference()), |
98 | MochiKit.Base.method(this.record(), 'removeDirectLogin', this) | 96 | MochiKit.Base.method(this.record(), 'removeDirectLogin', this) |
99 | ], {trace:false}); | 97 | ], {trace:false}); |
100 | }, | 98 | }, |
101 | 99 | ||
102 | //========================================================================= | 100 | //========================================================================= |
103 | /* | 101 | /* |
104 | 'inputsDeferredLock': function () { | 102 | 'inputsDeferredLock': function () { |
105 | return this._inputsDeferredLock; | 103 | return this._inputsDeferredLock; |
106 | }, | 104 | }, |
107 | 105 | ||
108 | 'bindingsDeferredLock': function () { | 106 | 'bindingsDeferredLock': function () { |
109 | return this._bindingsDeferredLock; | 107 | return this._bindingsDeferredLock; |
110 | }, | 108 | }, |
111 | 109 | ||
112 | 'formValuesDeferredLock': function () { | 110 | 'formValuesDeferredLock': function () { |
113 | return this._formValuesDeferredLock; | 111 | return this._formValuesDeferredLock; |
114 | }, | 112 | }, |
115 | */ | 113 | */ |
116 | //========================================================================= | 114 | //========================================================================= |
117 | 115 | ||
118 | 'label': function () { | 116 | 'label': function () { |
119 | return this.getIndexDataForKey('label'); | 117 | return this.getIndexDataForKey('label'); |
120 | }, | 118 | }, |
121 | 119 | ||
122 | 'setLabelKeepingBackwardCompatibilityWithBeta': function (aValue) { | 120 | 'setLabelKeepingBackwardCompatibilityWithBeta': function (aValue) { |
123 | return Clipperz.Async.callbacks("DirectLogin.setLabelKeepingBackwardCompatibilityWithBeta", [ | 121 | return Clipperz.Async.callbacks("DirectLogin.setLabelKeepingBackwardCompatibilityWithBeta", [ |
124 | MochiKit.Base.method(this, 'setIndexDataForKey', 'label', aValue), | 122 | MochiKit.Base.method(this, 'setIndexDataForKey', 'label', aValue), |
125 | MochiKit.Base.method(this, 'setValue', 'label', aValue) | 123 | MochiKit.Base.method(this, 'setValue', 'label', aValue) |
126 | ], {trace:false}); | 124 | ], {trace:false}); |
127 | }, | 125 | }, |
128 | 126 | ||
129 | 'setLabel': function (aValue) { | 127 | 'setLabel': function (aValue) { |
130 | return this.setLabelKeepingBackwardCompatibilityWithBeta(aValue); | 128 | return this.setLabelKeepingBackwardCompatibilityWithBeta(aValue); |
131 | // return this.setIndexDataForKey('label', aValue); | 129 | // return this.setIndexDataForKey('label', aValue); |
132 | }, | 130 | }, |
133 | 131 | ||
134 | //========================================================================= | 132 | //========================================================================= |
135 | 133 | ||
136 | 'favicon': function () { | 134 | 'favicon': function () { |
137 | return this.getIndexDataForKey('favicon'); | 135 | return this.getIndexDataForKey('favicon'); |
138 | }, | 136 | }, |
139 | 137 | ||
140 | 'setFavicon': function (aValue) { | 138 | 'setFavicon': function (aValue) { |
141 | return this.setIndexDataForKey('favicon', aValue); | 139 | return this.setIndexDataForKey('favicon', aValue); |
142 | }, | 140 | }, |
143 | 141 | ||
144 | 'faviconUrlWithBookmarkletConfiguration': function (aBookmarkletConfiguration) { | 142 | 'faviconUrlWithBookmarkletConfiguration': function (aBookmarkletConfiguration) { |
145 | varresult; | 143 | varresult; |
146 | 144 | ||
147 | if (! MochiKit.Base.isUndefinedOrNull(aBookmarkletConfiguration['page']['favicon'])) { | 145 | if (! MochiKit.Base.isUndefinedOrNull(aBookmarkletConfiguration['page']['favicon'])) { |
148 | result = aBookmarkletConfiguration['page']['favicon']; | 146 | result = aBookmarkletConfiguration['page']['favicon']; |
149 | } else if (! MochiKit.Base.isUndefinedOrNull(aBookmarkletConfiguration['form']['attributes']['action'])) { | 147 | } else if (! MochiKit.Base.isUndefinedOrNull(aBookmarkletConfiguration['form']['attributes']['action'])) { |
150 | var actionUrl; | 148 | var actionUrl; |
151 | var hostname; | 149 | var hostname; |
152 | 150 | ||
153 | actionUrl = aBookmarkletConfiguration['form']['attributes']['action']; | 151 | actionUrl = aBookmarkletConfiguration['form']['attributes']['action']; |
154 | hostname = actionUrl.replace(/^https?:\/\/([^\/]*)\/.*/, '$1'); | 152 | hostname = actionUrl.replace(/^https?:\/\/([^\/]*)\/.*/, '$1'); |
155 | result = "http://" + hostname + "/favicon.ico"; | 153 | result = "http://" + hostname + "/favicon.ico"; |
156 | } else { | 154 | } else { |
157 | result = null; | 155 | result = null; |
158 | } | 156 | } |
159 | 157 | ||
160 | 158 | ||
161 | return result; | 159 | return result; |
162 | }, | 160 | }, |
163 | 161 | ||
164 | //------------------------------------------------------------------------- | 162 | //------------------------------------------------------------------------- |
165 | /* | 163 | /* |
166 | 'faviconData': function () { | 164 | 'faviconData': function () { |
167 | var regexp = new RegExp('^data\:\/\/.*', 'i'); | 165 | var regexp = new RegExp('^data\:\/\/.*', 'i'); |
168 | 166 | ||
169 | return Clipperz.Async.callbacks("DirectLogin.favicon", [ | 167 | return Clipperz.Async.callbacks("DirectLogin.favicon", [ |
170 | MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon'), | 168 | MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon'), |
171 | MochiKit.Base.method(regexp, 'test'), | 169 | MochiKit.Base.method(regexp, 'test'), |
172 | Clipperz.Async.deferredIf("is data URL", [ | 170 | Clipperz.Async.deferredIf("is data URL", [ |
173 | MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon') | 171 | MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon') |
174 | ], [ | 172 | ], [ |
175 | MochiKit.Base.method(this, 'transientState'), | 173 | MochiKit.Base.method(this, 'transientState'), |
176 | MochiKit.Base.itemgetter('faviconData'), | 174 | MochiKit.Base.itemgetter('faviconData'), |
177 | Clipperz.Async.deferredIf('has a chaced value for the favicon data', [ | 175 | Clipperz.Async.deferredIf('has a chaced value for the favicon data', [ |
178 | MochiKit.Base.operator.identity | 176 | MochiKit.Base.operator.identity |
179 | ], [ | 177 | ], [ |
180 | MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon'), | 178 | MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon'), |
181 | MochiKit.Base.method(this, 'loadFaviconDataFromURL') | 179 | MochiKit.Base.method(this, 'loadFaviconDataFromURL') |
182 | ]) | 180 | ]) |
183 | 181 | ||
184 | ]) | 182 | ]) |
185 | ], {trace:false}); | 183 | ], {trace:false}); |
186 | }, | 184 | }, |
187 | 185 | ||
188 | //------------------------------------------------------------------------- | 186 | //------------------------------------------------------------------------- |
189 | 187 | ||
190 | 'loadFaviconDataFromURL': function (anURL) { | 188 | 'loadFaviconDataFromURL': function (anURL) { |
191 | var deferredResult; | 189 | var deferredResult; |
192 | var image; | 190 | var image; |
193 | 191 | ||
194 | deferredResult = new Clipperz.Async.Deferred("DirectLogin.loadFaviconDataFromURL", {trace:false}); | 192 | deferredResult = new Clipperz.Async.Deferred("DirectLogin.loadFaviconDataFromURL", {trace:false}); |
195 | deferredResult.addCallback(function (anEvent) { | 193 | deferredResult.addCallback(function (anEvent) { |
196 | var image = anEvent.src(); | 194 | var image = anEvent.src(); |
197 | var canvas = document.createElement("canvas"); | 195 | var canvas = document.createElement("canvas"); |
198 | var result; | 196 | var result; |
199 | 197 | ||
200 | canvas.width = image.width; | 198 | canvas.width = image.width; |
201 | canvas.height = image.height; | 199 | canvas.height = image.height; |
202 | 200 | ||
203 | var ctx = canvas.getContext("2d"); | 201 | var ctx = canvas.getContext("2d"); |
204 | ctx.drawImage(image, 0, 0); | 202 | ctx.drawImage(image, 0, 0); |
205 | 203 | ||
206 | result = canvas.toDataURL(/*"image/png"* /); | 204 | result = canvas.toDataURL(/*"image/png"* /); |
207 | 205 | ||
208 | return result; | 206 | return result; |
209 | }); | 207 | }); |
210 | deferredResult.addErrback(MochiKit.Async.succeed, Clipperz.PM.Strings.getValue('defaultFaviconUrl')); | 208 | deferredResult.addErrback(MochiKit.Async.succeed, Clipperz.PM.Strings.getValue('defaultFaviconUrl')); |
211 | deferredResult.addBoth(MochiKit.Base.bind(function (aDataUrl) { | 209 | deferredResult.addBoth(MochiKit.Base.bind(function (aDataUrl) { |
212 | this.transientState()['faviconData'] = aDataUrl; | 210 | this.transientState()['faviconData'] = aDataUrl; |
213 | 211 | ||
214 | return aDataUrl; | 212 | return aDataUrl; |
215 | }, this)); | 213 | }, this)); |
216 | 214 | ||
217 | image = new Image(); | 215 | image = new Image(); |
218 | MochiKit.Signal.connect(image, 'onload', MochiKit.Base.method(deferredResult, 'callback')); | 216 | MochiKit.Signal.connect(image, 'onload', MochiKit.Base.method(deferredResult, 'callback')); |
219 | MochiKit.Signal.connect(image, 'onerror', MochiKit.Base.method(deferredResult, 'errback')); | 217 | MochiKit.Signal.connect(image, 'onerror', MochiKit.Base.method(deferredResult, 'errback')); |
220 | MochiKit.Signal.connect(image, 'onabort', MochiKit.Base.method(deferredResult, 'errback')); | 218 | MochiKit.Signal.connect(image, 'onabort', MochiKit.Base.method(deferredResult, 'errback')); |
221 | 219 | ||
222 | image.src = anURL; | 220 | image.src = anURL; |
223 | 221 | ||
224 | return deferredResult; | 222 | return deferredResult; |
225 | }, | 223 | }, |
226 | */ | 224 | */ |
227 | 225 | ||
228 | //========================================================================= | 226 | //========================================================================= |
229 | 227 | ||
230 | 'type': function () { | 228 | 'type': function () { |
231 | return this.getValue('formData.attributes.type') | 229 | return this.getValue('formData.attributes.type') |
232 | }, | 230 | }, |
233 | 231 | ||
234 | //========================================================================= | 232 | //========================================================================= |
235 | 233 | ||
236 | 'serializedData': function () { | 234 | 'serializedData': function () { |
237 | return Clipperz.Async.collectResults("DirectLogin.serializedData", { | 235 | return Clipperz.Async.collectResults("DirectLogin.serializedData", { |
238 | 'bookmarkletVersion': MochiKit.Base.method(this, 'getValue', 'bookmarkletVersion'), | 236 | 'bookmarkletVersion': MochiKit.Base.method(this, 'getValue', 'bookmarkletVersion'), |
239 | 'formData': MochiKit.Base.method(this, 'getValue', 'formData'), | 237 | 'formData': MochiKit.Base.method(this, 'getValue', 'formData'), |
240 | 'formValues': MochiKit.Base.method(this, 'getValue', 'formValues'), | 238 | 'formValues': MochiKit.Base.method(this, 'getValue', 'formValues'), |
241 | 'bindingData': [ | 239 | 'bindingData': [ |
242 | MochiKit.Base.method(this, 'bindings'), | 240 | MochiKit.Base.method(this, 'bindings'), |
243 | function (someBindings) { | 241 | function (someBindings) { |
244 | var result; | 242 | var result; |
245 | var bindingKey; | 243 | var bindingKey; |
246 | 244 | ||
247 | result = {} | 245 | result = {} |
248 | for (bindingKey in someBindings) { | 246 | for (bindingKey in someBindings) { |
249 | result[bindingKey] = someBindings[bindingKey].serializedData(); | 247 | result[bindingKey] = someBindings[bindingKey].serializedData(); |
250 | } | 248 | } |
251 | 249 | ||
252 | return result; | 250 | return result; |
253 | } | 251 | } |
254 | ] | 252 | ] |
255 | }, {trace:false})() | 253 | }, {trace:false})() |
256 | }, | 254 | }, |
257 | 255 | ||
258 | //========================================================================= | 256 | //========================================================================= |
259 | /* | 257 | /* |
260 | 'fixFormDataFromBookmarkletVersion_0_1': function(aValue) { | 258 | 'fixFormDataFromBookmarkletVersion_0_1': function(aValue) { |
261 | //{"type":"radio", "name":"action", "value":"new-user", "checked":false }, { "type":"radio", "name":"action", "value":"sign-in", "checked":true } | 259 | //{"type":"radio", "name":"action", "value":"new-user", "checked":false }, { "type":"radio", "name":"action", "value":"sign-in", "checked":true } |
262 | // || | 260 | // || |
263 | // \ / | 261 | // \ / |
264 | // \/ | 262 | // \/ |
265 | //{"name":"dominio", "type":"radio", "options":[{"value":"@alice.it", "checked":true}, {"value":"@tin.it", "checked":false}, {"value":"@virgilio.it", "checked":false}, {"value":"@tim.it", "checked":false}]} | 263 | //{"name":"dominio", "type":"radio", "options":[{"value":"@alice.it", "checked":true}, {"value":"@tin.it", "checked":false}, {"value":"@virgilio.it", "checked":false}, {"value":"@tim.it", "checked":false}]} |
266 | var result; | 264 | var result; |
267 | var inputs; | 265 | var inputs; |
268 | var updatedInputs; | 266 | var updatedInputs; |
269 | var radios; | 267 | var radios; |
270 | 268 | ||
271 | result = aValue; | 269 | result = aValue; |
272 | inputs = aValue['inputs']; | 270 | inputs = aValue['inputs']; |
273 | 271 | ||
274 | updatedInputs = MochiKit.Base.filter(function(anInput) { | 272 | updatedInputs = MochiKit.Base.filter(function(anInput) { |
275 | varresult; | 273 | varresult; |
276 | var type; | 274 | var type; |
277 | 275 | ||
278 | type = anInput['type'] || 'text'; | 276 | type = anInput['type'] || 'text'; |
279 | result = type.toLowerCase() != 'radio'; | 277 | result = type.toLowerCase() != 'radio'; |
280 | 278 | ||
281 | return result; | 279 | return result; |
282 | }, inputs); | 280 | }, inputs); |
283 | radios = MochiKit.Base.filter(function(anInput) { | 281 | radios = MochiKit.Base.filter(function(anInput) { |
284 | varresult; | 282 | varresult; |
285 | var type; | 283 | var type; |
286 | 284 | ||
287 | type = anInput['type'] || 'text'; | 285 | type = anInput['type'] || 'text'; |
288 | result = type.toLowerCase() == 'radio'; | 286 | result = type.toLowerCase() == 'radio'; |
289 | 287 | ||
290 | return result; | 288 | return result; |
291 | }, inputs); | 289 | }, inputs); |
292 | 290 | ||
293 | if (radios.length > 0) { | 291 | if (radios.length > 0) { |
294 | var updatedRadios; | 292 | var updatedRadios; |
295 | 293 | ||
296 | updatedRadios = {}; | 294 | updatedRadios = {}; |
297 | MochiKit.Iter.forEach(radios, MochiKit.Base.bind(function(aRadio) { | 295 | MochiKit.Iter.forEach(radios, MochiKit.Base.bind(function(aRadio) { |
298 | varradioConfiguration; | 296 | varradioConfiguration; |
299 | 297 | ||
300 | radioConfiguration = updatedRadios[aRadio['name']]; | 298 | radioConfiguration = updatedRadios[aRadio['name']]; |
301 | if (radioConfiguration == null) { | 299 | if (radioConfiguration == null) { |
302 | radioConfiguration = {type:'radio', name:aRadio['name'], options:[]}; | 300 | radioConfiguration = {type:'radio', name:aRadio['name'], options:[]}; |
303 | updatedRadios[aRadio['name']] = radioConfiguration; | 301 | updatedRadios[aRadio['name']] = radioConfiguration; |
304 | } | 302 | } |
305 | 303 | ||
306 | //TODO: remove the value: field and replace it with element.dom.value = <some value> | 304 | //TODO: remove the value: field and replace it with element.dom.value = <some value> |
307 | radioConfiguration.options.push({value:aRadio['value'], checked:aRadio['checked']}); | 305 | radioConfiguration.options.push({value:aRadio['value'], checked:aRadio['checked']}); |
308 | 306 | ||
309 | //TODO: shoud remove the 'formValues' call, as it is now deferred | 307 | //TODO: shoud remove the 'formValues' call, as it is now deferred |
310 | // if ((aRadio['checked'] == true) && (this.formValues()[aRadio['name']] == null)) { | 308 | // if ((aRadio['checked'] == true) && (this.formValues()[aRadio['name']] == null)) { |
311 | // this.formValues()[aRadio['name']] = aRadio['value']; | 309 | // this.formValues()[aRadio['name']] = aRadio['value']; |
312 | // } | 310 | // } |
313 | }, this)) | 311 | }, this)) |
314 | 312 | ||
315 | updatedInputs = MochiKit.Base.concat(updatedInputs, MochiKit.Base.values(updatedRadios)); | 313 | updatedInputs = MochiKit.Base.concat(updatedInputs, MochiKit.Base.values(updatedRadios)); |
316 | } | 314 | } |
317 | 315 | ||
318 | delete result.inputs; | 316 | delete result.inputs; |
319 | result.inputs = updatedInputs; | 317 | result.inputs = updatedInputs; |
320 | 318 | ||
321 | return result; | 319 | return result; |
322 | }, | 320 | }, |
323 | 321 | ||
324 | '_fixConfiguration': function (aConfiguration) { | 322 | '_fixConfiguration': function (aConfiguration) { |
325 | var fixedConfiguration; | 323 | var fixedConfiguration; |
326 | // var inputs; | 324 | // var inputs; |
327 | // var bindings; | 325 | // var bindings; |
328 | // var i,c; | 326 | // var i,c; |
329 | 327 | ||
330 | fixedConfiguration = Clipperz.Base.deepClone(aConfiguration); | 328 | fixedConfiguration = Clipperz.Base.deepClone(aConfiguration); |
331 | 329 | ||
332 | //console.log("PROCESS CONFIGURATION", aConfiguration); | 330 | //Clipperz.log("PROCESS CONFIGURATION", aConfiguration); |
333 | switch (aConfiguration['bookmarkletVersion']) { | 331 | switch (aConfiguration['bookmarkletVersion']) { |
334 | case '0.1': | 332 | case '0.1': |
335 | fixedConfiguration['formData'] = this.fixFormDataFromBookmarkletVersion_0_1(aConfiguration['formData']); | 333 | fixedConfiguration['formData'] = this.fixFormDataFromBookmarkletVersion_0_1(aConfiguration['formData']); |
336 | break; | 334 | break; |
337 | case '0.2': | 335 | case '0.2': |
338 | fixedConfiguration['formData'] = aConfiguration['formData']; | 336 | fixedConfiguration['formData'] = aConfiguration['formData']; |
339 | break; | 337 | break; |
340 | } | 338 | } |
341 | 339 | ||
342 | / * | 340 | / * |
343 | aConfiguration['_inputs'] = []; | 341 | aConfiguration['_inputs'] = []; |
344 | c = formData['inputs'].length; | 342 | c = formData['inputs'].length; |
345 | for (i=0; i<c; i++) { | 343 | for (i=0; i<c; i++) { |
346 | aConfiguration['_inputs'].push(new Clipperz.PM.DataModel.DirectLoginInput(formData['inputs'][i])); | 344 | aConfiguration['_inputs'].push(new Clipperz.PM.DataModel.DirectLoginInput(formData['inputs'][i])); |
347 | } | 345 | } |
348 | * / | 346 | * / |
349 | / * | 347 | / * |
350 | aConfiguration['_bindings'] = {}; | 348 | aConfiguration['_bindings'] = {}; |
351 | if (aConfiguration['legacyBindingData'] == null) { | 349 | if (aConfiguration['legacyBindingData'] == null) { |
352 | if (aConfiguration['bindingData'] != null) { | 350 | if (aConfiguration['bindingData'] != null) { |
353 | var bindingKey; | 351 | var bindingKey; |
354 | 352 | ||
355 | for (bindingKey in aConfiguration['bindingData']) { | 353 | for (bindingKey in aConfiguration['bindingData']) { |
356 | var newBinding; | 354 | var newBinding; |
357 | 355 | ||
358 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(bindingKey, {fieldKey:aConfiguration['bindingData'][bindingKey]}); | 356 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(bindingKey, {fieldKey:aConfiguration['bindingData'][bindingKey]}); |
359 | aConfiguration['_bindings'][newBinding.key()] = newBinding; | 357 | aConfiguration['_bindings'][newBinding.key()] = newBinding; |
360 | } | 358 | } |
361 | } else { | 359 | } else { |
362 | var editableFields; | 360 | var editableFields; |
363 | 361 | ||
364 | editableFields = MochiKit.Base.filter(function(aField) { | 362 | editableFields = MochiKit.Base.filter(function(aField) { |
365 | var result; | 363 | var result; |
366 | var type; | 364 | var type; |
367 | 365 | ||
368 | type = aField['type'].toLowerCase(); | 366 | type = aField['type'].toLowerCase(); |
369 | result = ((type != 'hidden') && (type != 'submit') && (type != 'checkbox') && (type != 'radio') && (type != 'select')); | 367 | result = ((type != 'hidden') && (type != 'submit') && (type != 'checkbox') && (type != 'radio') && (type != 'select')); |
370 | 368 | ||
371 | return result; | 369 | return result; |
372 | }, aConfiguration['_inputs']); | 370 | }, aConfiguration['_inputs']); |
373 | 371 | ||
374 | MochiKit.Iter.forEach(editableFields, MochiKit.Base.bind(function(anEditableField) { | 372 | MochiKit.Iter.forEach(editableFields, MochiKit.Base.bind(function(anEditableField) { |
375 | var newBinding; | 373 | var newBinding; |
376 | 374 | ||
377 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(anEditableField['name']); | 375 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(anEditableField['name']); |
378 | aConfiguration['_bindings'][newBinding.key()] = newBinding; | 376 | aConfiguration['_bindings'][newBinding.key()] = newBinding; |
379 | }, this)); | 377 | }, this)); |
380 | } | 378 | } |
381 | 379 | ||
382 | } else { | 380 | } else { |
383 | var bindingKey; | 381 | var bindingKey; |
384 | 382 | ||
385 | for (bindingKey in aConfiguration['legacyBindingData']) { | 383 | for (bindingKey in aConfiguration['legacyBindingData']) { |
386 | var newBinding; | 384 | var newBinding; |
387 | 385 | ||
388 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(bindingKey, {fieldName:aConfiguration['legacyBindingData'][bindingKey]}); | 386 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(bindingKey, {fieldName:aConfiguration['legacyBindingData'][bindingKey]}); |
389 | aConfiguration['_bindings'][newBinding.key()] = newBinding; | 387 | aConfiguration['_bindings'][newBinding.key()] = newBinding; |
390 | } | 388 | } |
391 | } | 389 | } |
392 | * / | 390 | * / |
393 | 391 | ||
394 | return fixedConfiguration; | 392 | return fixedConfiguration; |
395 | }, | 393 | }, |
396 | 394 | ||
397 | //------------------------------------------------------------------------- | 395 | //------------------------------------------------------------------------- |
398 | 396 | ||
399 | 'getObjectDataStore': function () { | 397 | 'getObjectDataStore': function () { |
400 | var deferredResult; | 398 | var deferredResult; |
401 | 399 | ||
402 | deferredResult = new Clipperz.Async.Deferred("DirectLogin.getObjectDataStore", {trace:false}); | 400 | deferredResult = new Clipperz.Async.Deferred("DirectLogin.getObjectDataStore", {trace:false}); |
403 | deferredResult.acquireLock(this.objectDataStoreDeferredLock()); | 401 | deferredResult.acquireLock(this.objectDataStoreDeferredLock()); |
404 | deferredResult.addCallback(MochiKit.Base.bind(function () { | 402 | deferredResult.addCallback(MochiKit.Base.bind(function () { |
405 | var innerDeferredResult; | 403 | var innerDeferredResult; |
406 | 404 | ||
407 | if (this._objectDataStore == null) { | 405 | if (this._objectDataStore == null) { |
408 | this._objectDataStore = new Clipperz.KeyValueObjectStore(); | 406 | this._objectDataStore = new Clipperz.KeyValueObjectStore(); |
409 | 407 | ||
410 | innerDeferredResult = new Clipperz.Async.Deferred("DirectLogin.getObjectDataStore <inner deferred>", {trace:false}); | 408 | innerDeferredResult = new Clipperz.Async.Deferred("DirectLogin.getObjectDataStore <inner deferred>", {trace:false}); |
411 | // innerDeferredResult.addMethod(this.record(), 'getValue', 'directLogins' + '.' + this.reference()); | 409 | // innerDeferredResult.addMethod(this.record(), 'getValue', 'directLogins' + '.' + this.reference()); |
412 | innerDeferredResult.addMethod(this, 'getValue', ''), | 410 | innerDeferredResult.addMethod(this, 'getValue', ''), |
413 | innerDeferredResult.addMethod(this, 'setOriginalState'); | 411 | innerDeferredResult.addMethod(this, 'setOriginalState'); |
414 | innerDeferredResult.addMethod(this, '_fixConfiguration'); | 412 | innerDeferredResult.addMethod(this, '_fixConfiguration'); |
415 | innerDeferredResult.addMethod(this._objectDataStore, 'initWithValues'); | 413 | innerDeferredResult.addMethod(this._objectDataStore, 'initWithValues'); |
416 | // innerDeferredResult.addMethod(this._objectDataStore, 'setValues'); | 414 | // innerDeferredResult.addMethod(this._objectDataStore, 'setValues'); |
417 | innerDeferredResult.callback(); | 415 | innerDeferredResult.callback(); |
418 | } else { | 416 | } else { |
419 | innerDeferredResult = MochiKit.Async.succeed(this._objectDataStore); | 417 | innerDeferredResult = MochiKit.Async.succeed(this._objectDataStore); |
420 | } | 418 | } |
421 | 419 | ||
422 | return innerDeferredResult; | 420 | return innerDeferredResult; |
423 | }, this)); | 421 | }, this)); |
424 | deferredResult.releaseLock(this.objectDataStoreDeferredLock()); | 422 | deferredResult.releaseLock(this.objectDataStoreDeferredLock()); |
425 | deferredResult.callback(); | 423 | deferredResult.callback(); |
426 | 424 | ||
427 | return deferredResult; | 425 | return deferredResult; |
428 | }, | 426 | }, |
429 | 427 | ||
430 | //------------------------------------------------------------------------- | 428 | //------------------------------------------------------------------------- |
431 | 429 | ||
432 | 'hasInitiatedObjectDataStore': function () { | 430 | 'hasInitiatedObjectDataStore': function () { |
433 | return (this._objectDataStore != null); | 431 | return (this._objectDataStore != null); |
434 | }, | 432 | }, |
435 | 433 | ||
436 | //------------------------------------------------------------------------- | 434 | //------------------------------------------------------------------------- |
437 | 435 | ||
438 | 'resetObjectDataStore': function () { | 436 | 'resetObjectDataStore': function () { |
439 | this._objectDataStore.removeAllData(); | 437 | this._objectDataStore.removeAllData(); |
440 | this._objectDataStore = null; | 438 | this._objectDataStore = null; |
441 | }, | 439 | }, |
442 | */ | 440 | */ |
443 | //========================================================================= | 441 | //========================================================================= |
444 | 442 | ||
445 | 'bookmarkletConfiguration': function () { | 443 | 'bookmarkletConfiguration': function () { |
446 | return Clipperz.Async.callbacks("DirectLogin.bookmarkletConfiguration", [ | 444 | return Clipperz.Async.callbacks("DirectLogin.bookmarkletConfiguration", [ |
447 | Clipperz.Async.collectResults("DirectLogin.bookmarkletConfiguration <inner results>", { | 445 | Clipperz.Async.collectResults("DirectLogin.bookmarkletConfiguration <inner results>", { |
448 | 'label': MochiKit.Base.method(this, 'label'), | 446 | 'label': MochiKit.Base.method(this, 'label'), |
449 | 'configuration': MochiKit.Base.method(this, 'getValue', '') | 447 | 'configuration': MochiKit.Base.method(this, 'getValue', '') |
450 | }, {trace:false}), | 448 | }, {trace:false}), |
451 | function (someValues) { | 449 | function (someValues) { |
452 | var result; | 450 | var result; |
453 | 451 | ||
454 | if (someValues['configuration'] != null) { | 452 | if (someValues['configuration'] != null) { |
455 | varconfiguration; | 453 | varconfiguration; |
456 | 454 | ||
457 | configuration = { | 455 | configuration = { |
458 | 'page': { | 456 | 'page': { |
459 | 'title': someValues['label'] | 457 | 'title': someValues['label'] |
460 | //'favicon' | 458 | //'favicon' |
461 | // 'url' | 459 | // 'url' |
462 | }, | 460 | }, |
463 | 'form': someValues['configuration']['formData'], | 461 | 'form': someValues['configuration']['formData'], |
464 | 'version':someValues['configuration']['bookmarkletVersion'] | 462 | 'version':someValues['configuration']['bookmarkletVersion'] |
465 | } | 463 | } |
466 | 464 | ||
467 | result = Clipperz.Base.formatJSON(configuration); | 465 | result = Clipperz.Base.formatJSON(configuration); |
468 | } else { | 466 | } else { |
469 | result = ''; | 467 | result = ''; |
470 | } | 468 | } |
471 | 469 | ||
472 | return result; | 470 | return result; |
473 | } | 471 | } |
474 | ], {trace:false}); | 472 | ], {trace:false}); |
475 | 473 | ||
476 | }, | 474 | }, |
477 | 475 | ||
478 | //------------------------------------------------------------------------- | 476 | //------------------------------------------------------------------------- |
479 | 477 | ||
480 | 'setBookmarkletConfiguration': function (aValue) { | 478 | 'setBookmarkletConfiguration': function (aValue) { |
481 | var bookmarkletConfiguration; | 479 | var bookmarkletConfiguration; |
482 | 480 | ||
483 | bookmarkletConfiguration = Clipperz.PM.DataModel.DirectLogin.checkBookmarkletConfiguration(aValue); | 481 | bookmarkletConfiguration = Clipperz.PM.DataModel.DirectLogin.checkBookmarkletConfiguration(aValue); |
484 | //console.log("BOOKMARKLET CONFIGURATION", bookmarkletConfiguration); | 482 | |
485 | return Clipperz.Async.callbacks("DirectLogin.setBookmarkletConfiguration", [ | 483 | return Clipperz.Async.callbacks("DirectLogin.setBookmarkletConfiguration", [ |
486 | MochiKit.Base.method(this, 'setValue', 'formData', bookmarkletConfiguration['form']), | 484 | MochiKit.Base.method(this, 'setValue', 'formData', bookmarkletConfiguration['form']), |
487 | //function (aValue) { console.log("SET VALUE - formData", aValue); return aValue; }, | ||
488 | MochiKit.Base.method(this, 'setValue', 'bookmarkletVersion', bookmarkletConfiguration['version']), | 485 | MochiKit.Base.method(this, 'setValue', 'bookmarkletVersion', bookmarkletConfiguration['version']), |
489 | 486 | ||
490 | MochiKit.Base.method(this, 'favicon'), | 487 | MochiKit.Base.method(this, 'favicon'), |
491 | Clipperz.Async.deferredIf("the favicon is not set", [ | 488 | Clipperz.Async.deferredIf("the favicon is not set", [ |
492 | ], [ | 489 | ], [ |
493 | MochiKit.Base.method(this, 'faviconUrlWithBookmarkletConfiguration', bookmarkletConfiguration), | 490 | MochiKit.Base.method(this, 'faviconUrlWithBookmarkletConfiguration', bookmarkletConfiguration), |
494 | MochiKit.Base.method(this, 'setFavicon') | 491 | MochiKit.Base.method(this, 'setFavicon') |
495 | ]), | 492 | ]), |
496 | 493 | ||
497 | MochiKit.Base.method(this, 'updateInputsAfterChangingBookmarkletConfiguration'), | 494 | MochiKit.Base.method(this, 'updateInputsAfterChangingBookmarkletConfiguration'), |
498 | MochiKit.Base.method(this, 'updateFormValuesAfterChangingBookmarkletConfiguration'), | 495 | MochiKit.Base.method(this, 'updateFormValuesAfterChangingBookmarkletConfiguration'), |
499 | MochiKit.Base.method(this, 'updateBindingsAfterChangingBookmarkletConfiguration'), | 496 | MochiKit.Base.method(this, 'updateBindingsAfterChangingBookmarkletConfiguration'), |
500 | 497 | ||
501 | MochiKit.Base.noop | 498 | MochiKit.Base.noop |
502 | ], {trace:false}); | 499 | ], {trace:false}); |
503 | }, | 500 | }, |
504 | 501 | ||
505 | //========================================================================= | 502 | //========================================================================= |
506 | 503 | ||
507 | 'formAttributes': function () { | 504 | 'formAttributes': function () { |
508 | return this.getValue('formData.attributes'); | 505 | return this.getValue('formData.attributes'); |
509 | }, | 506 | }, |
510 | 507 | ||
511 | //========================================================================= | 508 | //========================================================================= |
512 | 509 | ||
513 | 'inputs': function () { | 510 | 'inputs': function () { |
514 | return Clipperz.Async.callbacks("DirectLogin.inputs", [ | 511 | return Clipperz.Async.callbacks("DirectLogin.inputs", [ |
515 | Clipperz.Async.deferredIf("this._inputs is defined", [ | 512 | Clipperz.Async.deferredIf("this._inputs is defined", [ |
516 | ], [ | 513 | ], [ |
517 | MochiKit.Base.method(this, 'updateInputsAfterChangingBookmarkletConfiguration') | 514 | MochiKit.Base.method(this, 'updateInputsAfterChangingBookmarkletConfiguration') |
518 | ]) | 515 | ]) |
519 | ], {trace:false}, this._inputs); | 516 | ], {trace:false}, this._inputs); |
520 | }, | 517 | }, |
521 | 518 | ||
522 | 'setInputWithFormDataConfiguration': function (aFormDataConfiguration) { | 519 | 'setInputWithFormDataConfiguration': function (aFormDataConfiguration) { |
523 | this._inputs = {}; | 520 | this._inputs = {}; |
524 | 521 | ||
525 | if (aFormDataConfiguration != null) { | 522 | if (aFormDataConfiguration != null) { |
526 | MochiKit.Iter.forEach(aFormDataConfiguration['inputs'], MochiKit.Base.bind(function (anInputData) { | 523 | MochiKit.Iter.forEach(aFormDataConfiguration['inputs'], MochiKit.Base.bind(function (anInputData) { |
527 | var newInput; | 524 | var newInput; |
528 | 525 | ||
529 | newInput = new Clipperz.PM.DataModel.DirectLoginInput(anInputData); | 526 | newInput = new Clipperz.PM.DataModel.DirectLoginInput(anInputData); |
530 | this._inputs[newInput.name()] = newInput; | 527 | this._inputs[newInput.name()] = newInput; |
531 | }, this)); | 528 | }, this)); |
532 | } | 529 | } |
533 | 530 | ||
534 | return this._inputs; | 531 | return this._inputs; |
535 | }, | 532 | }, |
536 | 533 | ||
537 | 'updateInputsAfterChangingBookmarkletConfiguration': function () { | 534 | 'updateInputsAfterChangingBookmarkletConfiguration': function () { |
538 | return Clipperz.Async.callbacks("DirectLogin.updateInputsAfterChangingBookmarkletConfiguration", [ | 535 | return Clipperz.Async.callbacks("DirectLogin.updateInputsAfterChangingBookmarkletConfiguration", [ |
539 | // MochiKit.Base.method(this, 'getValue', ''), | ||
540 | //function (aValue) { console.log("VALUE", aValue); return aValue }, | ||
541 | MochiKit.Base.method(this, 'getValue', 'formData'), | 536 | MochiKit.Base.method(this, 'getValue', 'formData'), |
542 | //function (aValue) { console.log("FORM DATA", aValue); return aValue }, | ||
543 | MochiKit.Base.method(this, 'setInputWithFormDataConfiguration') | 537 | MochiKit.Base.method(this, 'setInputWithFormDataConfiguration') |
544 | ], {trace:false}); | 538 | ], {trace:false}); |
545 | }, | 539 | }, |
546 | 540 | ||
547 | //========================================================================= | 541 | //========================================================================= |
548 | 542 | ||
549 | 'inputValues': function () { | 543 | 'inputValues': function () { |
550 | return Clipperz.Async.callbacks("DirectLogin.inputValues", [ | 544 | return Clipperz.Async.callbacks("DirectLogin.inputValues", [ |
551 | MochiKit.Base.method(this, 'inputs'), | 545 | MochiKit.Base.method(this, 'inputs'), |
552 | MochiKit.Base.values, | 546 | MochiKit.Base.values, |
553 | //function (aValue) { console.log("INPUTS", aValue); return aValue; }, | ||
554 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.partial(MochiKit.Base.method(this, 'inputValue'))), | 547 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.partial(MochiKit.Base.method(this, 'inputValue'))), |
555 | Clipperz.Async.collectAll, | 548 | Clipperz.Async.collectAll, |
556 | Clipperz.Base.mergeItems | 549 | Clipperz.Base.mergeItems |
557 | ], {trace:false}); | 550 | ], {trace:false}); |
558 | }, | 551 | }, |
559 | 552 | ||
560 | 'inputValue': function (anInput) { | 553 | 'inputValue': function (anInput) { |
561 | vardeferredResult; | 554 | vardeferredResult; |
562 | 555 | ||
563 | deferredResult = new Clipperz.Async.Deferred("DirectLogin.inputValue", {trace:false}); | 556 | deferredResult = new Clipperz.Async.Deferred("DirectLogin.inputValue", {trace:false}); |
564 | 557 | ||
565 | if (anInput.needsFormValue()) { | 558 | if (anInput.needsFormValue()) { |
566 | deferredResult.addMethod(this, 'formValues'); | 559 | deferredResult.addMethod(this, 'formValues'); |
567 | deferredResult.addCallback(MochiKit.Base.itemgetter(anInput.name())); | 560 | deferredResult.addCallback(MochiKit.Base.itemgetter(anInput.name())); |
568 | deferredResult.addMethodcaller('value'); | 561 | deferredResult.addMethodcaller('value'); |
569 | } else if (anInput.needsBinding()) { | 562 | } else if (anInput.needsBinding()) { |
570 | deferredResult.addMethod(this, 'bindings'); | 563 | deferredResult.addMethod(this, 'bindings'); |
571 | deferredResult.addCallback(MochiKit.Base.itemgetter(anInput.name())); | 564 | deferredResult.addCallback(MochiKit.Base.itemgetter(anInput.name())); |
572 | deferredResult.addMethodcaller('field'); | 565 | deferredResult.addMethodcaller('field'); |
573 | deferredResult.addMethodcaller('value'); | 566 | deferredResult.addMethodcaller('value'); |
574 | } else { | 567 | } else { |
575 | deferredResult.addCallback(MochiKit.Async.succeed, anInput.value()); | 568 | deferredResult.addCallback(MochiKit.Async.succeed, anInput.value()); |
576 | } | 569 | } |
577 | deferredResult.addCallback(function (anActualValue) { | 570 | deferredResult.addCallback(function (anActualValue) { |
578 | return [anInput.name(), anActualValue]; | 571 | return [anInput.name(), anActualValue]; |
579 | }); | 572 | }); |
580 | 573 | ||
581 | deferredResult.callback(); | 574 | deferredResult.callback(); |
582 | 575 | ||
583 | return deferredResult; | 576 | return deferredResult; |
584 | }, | 577 | }, |
585 | 578 | ||
586 | //========================================================================= | 579 | //========================================================================= |
587 | 580 | ||
588 | 'bindings': function () { | 581 | 'bindings': function () { |
589 | return Clipperz.Async.callbacks("DirectLogin.bindings", [ | 582 | return Clipperz.Async.callbacks("DirectLogin.bindings", [ |
590 | Clipperz.Async.deferredIf("this._bindings is defined", [ | 583 | Clipperz.Async.deferredIf("this._bindings is defined", [ |
591 | ], [ | 584 | ], [ |
592 | MochiKit.Base.method(this, 'updateBindingsAfterChangingBookmarkletConfiguration'), | 585 | MochiKit.Base.method(this, 'updateBindingsAfterChangingBookmarkletConfiguration'), |
593 | MochiKit.Base.bind(function () { return this._bindings;}, this) | 586 | MochiKit.Base.bind(function () { return this._bindings;}, this) |
594 | ]) | 587 | ]) |
595 | ], {trace:false}, this._bindings); | 588 | ], {trace:false}, this._bindings); |
596 | }, | 589 | }, |
597 | 590 | ||
598 | 'bindFormFieldWithLabelToRecordFieldWithLabel': function (aFormFieldLabel, aRecordFieldLabel) { | 591 | 'bindFormFieldWithLabelToRecordFieldWithLabel': function (aFormFieldLabel, aRecordFieldLabel) { |
599 | return Clipperz.Async.callbacks("DirectLogin.bindFormFieldWithLabelToCardFieldWithLabel", [ | 592 | return Clipperz.Async.callbacks("DirectLogin.bindFormFieldWithLabelToCardFieldWithLabel", [ |
600 | Clipperz.Async.collectResults("DirectLogin.bindFormFieldWithLabelToCardFieldWithLabel - collect results", { | 593 | Clipperz.Async.collectResults("DirectLogin.bindFormFieldWithLabelToCardFieldWithLabel - collect results", { |
601 | 'binding': [ | 594 | 'binding': [ |
602 | MochiKit.Base.method(this, 'bindings'), | 595 | MochiKit.Base.method(this, 'bindings'), |
603 | MochiKit.Base.itemgetter(aFormFieldLabel) | 596 | MochiKit.Base.itemgetter(aFormFieldLabel) |
604 | ], | 597 | ], |
605 | 'field': [ | 598 | 'field': [ |
606 | MochiKit.Base.method(this.record(), 'fieldWithLabel', aRecordFieldLabel) | 599 | MochiKit.Base.method(this.record(), 'fieldWithLabel', aRecordFieldLabel) |
607 | ] | 600 | ] |
608 | }), | 601 | }), |
609 | function (someValues) { | 602 | function (someValues) { |
610 | someValues['binding'].setField(someValues['field']) | 603 | someValues['binding'].setField(someValues['field']) |
611 | } | 604 | } |
612 | ], {trace:false}); | 605 | ], {trace:false}); |
613 | }, | 606 | }, |
614 | 607 | ||
615 | //------------------------------------------------------------------------- | 608 | //------------------------------------------------------------------------- |
616 | /* | 609 | /* |
617 | 'bindingValues': function () { | 610 | 'bindingValues': function () { |
618 | return Clipperz.Async.callbacks("DirectLogin.bindingValues", [ | 611 | return Clipperz.Async.callbacks("DirectLogin.bindingValues", [ |
619 | Clipperz.Async.collectResults("DirectLogin.bindingValues [collectResults]", { | 612 | Clipperz.Async.collectResults("DirectLogin.bindingValues [collectResults]", { |
620 | 'fieldValues': [ | 613 | 'fieldValues': [ |
621 | MochiKit.Base.method(this, 'record'), | 614 | MochiKit.Base.method(this, 'record'), |
622 | MochiKit.Base.methodcaller('getFieldsValues') | 615 | MochiKit.Base.methodcaller('getFieldsValues') |
623 | ], | 616 | ], |
624 | 'bindings': MochiKit.Base.method(this, 'bindings') | 617 | 'bindings': MochiKit.Base.method(this, 'bindings') |
625 | }, {trace:false}), | 618 | }, {trace:false}), |
626 | function (someData) { | 619 | function (someData) { |
627 | var result; | 620 | var result; |
628 | varbindingKey; | 621 | varbindingKey; |
629 | 622 | ||
630 | result = {}; | 623 | result = {}; |
631 | for (bindingKey in someData['bindings']) { | 624 | for (bindingKey in someData['bindings']) { |
632 | result[bindingKey] = someData['fieldValues'][someData['bindings'][bindingKey].fieldKey()]['value']; | 625 | result[bindingKey] = someData['fieldValues'][someData['bindings'][bindingKey].fieldKey()]['value']; |
633 | } | 626 | } |
634 | 627 | ||
635 | return result; | 628 | return result; |
636 | } | 629 | } |
637 | ], {trace:false}); | 630 | ], {trace:false}); |
638 | }, | 631 | }, |
639 | */ | 632 | */ |
640 | //------------------------------------------------------------------------- | 633 | //------------------------------------------------------------------------- |
641 | 634 | ||
642 | 'updateBindingsAfterChangingBookmarkletConfiguration': function () { | 635 | 'updateBindingsAfterChangingBookmarkletConfiguration': function () { |
643 | return Clipperz.Async.callbacks("DirectLogin.updateBindingsAfterChangingBookmarkletConfiguration", [ | 636 | return Clipperz.Async.callbacks("DirectLogin.updateBindingsAfterChangingBookmarkletConfiguration", [ |
644 | Clipperz.Async.collectResults("DirectLogin.updateBindingsAfterChangingBookmarkletConfiguration<collect results>", { | 637 | Clipperz.Async.collectResults("DirectLogin.updateBindingsAfterChangingBookmarkletConfiguration<collect results>", { |
645 | 'currentValues':MochiKit.Base.method(this, 'getValue', ''), | 638 | 'currentValues':MochiKit.Base.method(this, 'getValue', ''), |
646 | 'originalValues':MochiKit.Base.method(this, 'originalConfiguration'), | 639 | 'originalValues':MochiKit.Base.method(this, 'originalConfiguration'), |
647 | 'inputs': MochiKit.Base.method(this, 'inputs') | 640 | 'inputs': MochiKit.Base.method(this, 'inputs') |
648 | }, {trace:false}), | 641 | }, {trace:false}), |
649 | MochiKit.Base.bind(function (someValues) { | 642 | MochiKit.Base.bind(function (someValues) { |
650 | var availableBindingValues; | 643 | var availableBindingValues; |
651 | var inputRequiringBindingValues; | 644 | var inputRequiringBindingValues; |
652 | var newBindingValues; | 645 | var newBindingValues; |
653 | 646 | ||
654 | if (MochiKit.Base.isUndefinedOrNull(someValues['originalValues']) || MochiKit.Base.isUndefinedOrNull(someValues['originalValues']['bindingData'])) { | 647 | if (MochiKit.Base.isUndefinedOrNull(someValues['originalValues']) || MochiKit.Base.isUndefinedOrNull(someValues['originalValues']['bindingData'])) { |
655 | availableBindingValues = {}; | 648 | availableBindingValues = {}; |
656 | } else { | 649 | } else { |
657 | availableBindingValues = Clipperz.Base.deepClone(someValues['originalValues']['bindingData']) | 650 | availableBindingValues = Clipperz.Base.deepClone(someValues['originalValues']['bindingData']) |
658 | } | 651 | } |
659 | 652 | ||
660 | if (someValues['currentValues'] != null) { | 653 | if (someValues['currentValues'] != null) { |
661 | MochiKit.Base.update(availableBindingValues, someValues['currentValues']['bindingData']); | 654 | MochiKit.Base.update(availableBindingValues, someValues['currentValues']['bindingData']); |
662 | } | 655 | } |
663 | 656 | ||
664 | this._bindings = {}; | 657 | this._bindings = {}; |
665 | newBindingValues = {} | 658 | newBindingValues = {} |
666 | MochiKit.Iter.forEach(MochiKit.Base.filter(MochiKit.Base.methodcaller('needsBinding'), MochiKit.Base.values(someValues['inputs'])), MochiKit.Base.bind(function (anInput) { | 659 | MochiKit.Iter.forEach(MochiKit.Base.filter(MochiKit.Base.methodcaller('needsBinding'), MochiKit.Base.values(someValues['inputs'])), MochiKit.Base.bind(function (anInput) { |
667 | varnewBinding; | 660 | varnewBinding; |
668 | 661 | ||
669 | newBindingValues[anInput.name()] = availableBindingValues[anInput.name()]; | 662 | newBindingValues[anInput.name()] = availableBindingValues[anInput.name()]; |
670 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, { | 663 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, { |
671 | 'key': anInput.name(), | 664 | 'key': anInput.name(), |
672 | 'field':availableBindingValues[anInput.name()] | 665 | 'field':availableBindingValues[anInput.name()] |
673 | }); | 666 | }); |
674 | 667 | ||
675 | this._bindings[anInput.name()] = newBinding; | 668 | this._bindings[anInput.name()] = newBinding; |
676 | }, this)) | 669 | }, this)) |
677 | //console.log("THIS._BINDINGS", this._bindings); | ||
678 | 670 | ||
679 | return newBindingValues; | 671 | return newBindingValues; |
680 | 672 | ||
681 | /* | 673 | /* |
682 | this._bindings = {}; | 674 | this._bindings = {}; |
683 | //console.log("CONFIGURATION", aConfiguration); | ||
684 | 675 | ||
685 | if (someValues['currentValues'] != null) { | 676 | if (someValues['currentValues'] != null) { |
686 | if (someValues['currentValues']['bindingData'] != null) { | 677 | if (someValues['currentValues']['bindingData'] != null) { |
687 | var bindingKey; | 678 | var bindingKey; |
688 | 679 | ||
689 | //console.log("BINDING DATA", someValues['currentValues']['bindingData']); | ||
690 | for (bindingKey in someValues['currentValues']['bindingData']) { | 680 | for (bindingKey in someValues['currentValues']['bindingData']) { |
691 | var newBinding; | 681 | var newBinding; |
692 | 682 | ||
693 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, { | 683 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, { |
694 | 'key': bindingKey, | 684 | 'key': bindingKey, |
695 | 'field':someValues['currentValues']['bindingData'][bindingKey] | 685 | 'field':someValues['currentValues']['bindingData'][bindingKey] |
696 | }); | 686 | }); |
697 | this._bindings[newBinding.key()] = newBinding; | 687 | this._bindings[newBinding.key()] = newBinding; |
698 | } | 688 | } |
699 | } else if (someValues['currentValues']['legacyBindingData'] == null) { | 689 | } else if (someValues['currentValues']['legacyBindingData'] == null) { |
700 | var bindingKey; | 690 | var bindingKey; |
701 | 691 | ||
702 | for (bindingKey in someValues['currentValues']['legacyBindingData']) { | 692 | for (bindingKey in someValues['currentValues']['legacyBindingData']) { |
703 | var newBinding; | 693 | var newBinding; |
704 | 694 | ||
705 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, { | 695 | newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, { |
706 | 'key': bindingKey, | 696 | 'key': bindingKey, |
707 | 'field':someValues['currentValues']['legacyBindingData'][bindingKey] | 697 | 'field':someValues['currentValues']['legacyBindingData'][bindingKey] |
708 | }); | 698 | }); |
709 | this._bindings[newBinding.key()] = newBinding; | 699 | this._bindings[newBinding.key()] = newBinding; |
710 | } | 700 | } |
711 | } else { | 701 | } else { |
712 | WTF = TODO; | 702 | WTF = TODO; |
713 | } | 703 | } |
714 | } | 704 | } |
715 | 705 | ||
716 | return this._bindings; | 706 | return this._bindings; |
717 | */ | 707 | */ |
718 | }, this), | 708 | }, this), |
719 | MochiKit.Base.method(this, 'setValue', 'bindingData') | 709 | MochiKit.Base.method(this, 'setValue', 'bindingData') |
720 | ], {trace:false}); | 710 | ], {trace:false}); |
721 | }, | 711 | }, |
722 | 712 | ||
723 | //========================================================================= | 713 | //========================================================================= |
724 | 714 | ||
725 | 'formValues': function () { | 715 | 'formValues': function () { |
726 | return Clipperz.Async.callbacks("DirectLogin.formValues", [ | 716 | return Clipperz.Async.callbacks("DirectLogin.formValues", [ |
727 | Clipperz.Async.deferredIf("this._formValues is defined", [ | 717 | Clipperz.Async.deferredIf("this._formValues is defined", [ |
728 | ], [ | 718 | ], [ |
729 | MochiKit.Base.method(this, 'updateFormValuesAfterChangingBookmarkletConfiguration'), | 719 | MochiKit.Base.method(this, 'updateFormValuesAfterChangingBookmarkletConfiguration'), |
730 | MochiKit.Base.bind(function () { return this._formValues;}, this) | 720 | MochiKit.Base.bind(function () { return this._formValues;}, this) |
731 | ]) | 721 | ]) |
732 | ], {trace:false}, this._formValues); | 722 | ], {trace:false}, this._formValues); |
733 | }, | 723 | }, |
734 | 724 | ||
735 | //------------------------------------------------------------------------- | 725 | //------------------------------------------------------------------------- |
736 | 726 | ||
737 | 'updateFormValuesAfterChangingBookmarkletConfiguration': function () { | 727 | 'updateFormValuesAfterChangingBookmarkletConfiguration': function () { |
738 | return Clipperz.Async.callbacks("DirectLogin.updateFormValuesAfterChangingBookmarkletConfiguration", [ | 728 | return Clipperz.Async.callbacks("DirectLogin.updateFormValuesAfterChangingBookmarkletConfiguration", [ |
739 | Clipperz.Async.collectResults("DirectLogin.updateFormValuesAfterChangingBookmarkletConfiguration <collect results>", { | 729 | Clipperz.Async.collectResults("DirectLogin.updateFormValuesAfterChangingBookmarkletConfiguration <collect results>", { |
740 | 'currentValues':MochiKit.Base.method(this, 'getValue', ''), | 730 | 'currentValues':MochiKit.Base.method(this, 'getValue', ''), |
741 | 'originalValues':MochiKit.Base.method(this, 'originalConfiguration'), | 731 | 'originalValues':MochiKit.Base.method(this, 'originalConfiguration'), |
742 | 'inputs': MochiKit.Base.method(this, 'inputs') | 732 | 'inputs': MochiKit.Base.method(this, 'inputs') |
743 | }, {trace:false}), | 733 | }, {trace:false}), |
744 | MochiKit.Base.bind(function (someValues) { | 734 | MochiKit.Base.bind(function (someValues) { |
745 | var availableFormValues; | 735 | var availableFormValues; |
746 | var inputRequiringFormValues; | 736 | var inputRequiringFormValues; |
747 | var newFormValues; | 737 | var newFormValues; |
748 | 738 | ||
749 | if (MochiKit.Base.isUndefinedOrNull(someValues['originalValues']) || MochiKit.Base.isUndefinedOrNull(someValues['originalValues']['formValues'])) { | 739 | if (MochiKit.Base.isUndefinedOrNull(someValues['originalValues']) || MochiKit.Base.isUndefinedOrNull(someValues['originalValues']['formValues'])) { |
750 | availableFormValues = {}; | 740 | availableFormValues = {}; |
751 | } else { | 741 | } else { |
752 | availableFormValues = Clipperz.Base.deepClone(someValues['originalValues']['formValues']) | 742 | availableFormValues = Clipperz.Base.deepClone(someValues['originalValues']['formValues']) |
753 | } | 743 | } |
754 | 744 | ||
755 | MochiKit.Base.update(availableFormValues, someValues['currentValues']['formValues']); | 745 | MochiKit.Base.update(availableFormValues, someValues['currentValues']['formValues']); |
756 | 746 | ||
757 | this._formValues = {}; | 747 | this._formValues = {}; |
758 | newFormValues = {}; | 748 | newFormValues = {}; |
759 | MochiKit.Iter.forEach(MochiKit.Base.filter(MochiKit.Base.methodcaller('needsFormValue'), MochiKit.Base.values(someValues['inputs'])), MochiKit.Base.bind(function (anInput) { | 749 | MochiKit.Iter.forEach(MochiKit.Base.filter(MochiKit.Base.methodcaller('needsFormValue'), MochiKit.Base.values(someValues['inputs'])), MochiKit.Base.bind(function (anInput) { |
760 | varnewFormValue; | 750 | varnewFormValue; |
761 | var fieldOptions; | 751 | var fieldOptions; |
762 | 752 | ||
763 | fieldOptions = { | 753 | fieldOptions = { |
764 | 'type': anInput.type(), | 754 | 'type': anInput.type(), |
765 | 'options':anInput.options() | 755 | 'options':anInput.options() |
766 | }; | 756 | }; |
767 | 757 | ||
768 | newFormValues[anInput.name()] = availableFormValues[anInput.name()] | 758 | newFormValues[anInput.name()] = availableFormValues[anInput.name()] |
769 | newFormValue = new Clipperz.PM.DataModel.DirectLoginFormValue(this, { | 759 | newFormValue = new Clipperz.PM.DataModel.DirectLoginFormValue(this, { |
770 | 'key': anInput.name(), | 760 | 'key': anInput.name(), |
771 | 'fieldOptions':fieldOptions, | 761 | 'fieldOptions':fieldOptions, |
772 | 'value': availableFormValues[anInput.name()] | 762 | 'value': availableFormValues[anInput.name()] |
773 | }); | 763 | }); |
774 | 764 | ||
775 | this._formValues[anInput.name()] = newFormValue; | 765 | this._formValues[anInput.name()] = newFormValue; |
776 | }, this)) | 766 | }, this)) |
777 | 767 | ||
778 | return newFormValues; | 768 | return newFormValues; |
779 | }, this), | 769 | }, this), |
780 | MochiKit.Base.method(this, 'setValue', 'formValues') | 770 | MochiKit.Base.method(this, 'setValue', 'formValues') |
781 | ], {trace:false}); | 771 | ], {trace:false}); |
782 | }, | 772 | }, |
783 | 773 | ||
784 | //========================================================================= | 774 | //========================================================================= |
785 | 775 | ||
786 | 'retrieveIndexDataFunction': function () { | 776 | 'retrieveIndexDataFunction': function () { |
787 | return this._retrieveIndexDataFunction; | 777 | return this._retrieveIndexDataFunction; |
788 | }, | 778 | }, |
789 | 779 | ||
790 | 'getIndexDataForKey': function (aKey) { | 780 | 'getIndexDataForKey': function (aKey) { |
791 | return Clipperz.Async.callbacks("DirectLogin.getIndexDataForKey", [ | 781 | return Clipperz.Async.callbacks("DirectLogin.getIndexDataForKey", [ |
792 | MochiKit.Base.partial(this.retrieveIndexDataFunction(), this.reference()), | 782 | MochiKit.Base.partial(this.retrieveIndexDataFunction(), this.reference()), |
793 | Clipperz.Async.deferredIf("DirectLogin.getIndexDataForKey - index data not null", [ | 783 | Clipperz.Async.deferredIf("DirectLogin.getIndexDataForKey - index data not null", [ |
794 | MochiKit.Base.itemgetter(aKey) | 784 | MochiKit.Base.itemgetter(aKey) |
795 | ],[ | 785 | ],[ |
796 | MochiKit.Async.succeed | 786 | MochiKit.Async.succeed |
797 | ]) | 787 | ]) |
798 | ], {trace:false}); | 788 | ], {trace:false}); |
799 | }, | 789 | }, |
800 | 790 | ||
801 | //------------------------------------------------------------------------- | 791 | //------------------------------------------------------------------------- |
802 | 792 | ||
803 | 'setIndexDataForKey': function (aKey, aValue) { | 793 | 'setIndexDataForKey': function (aKey, aValue) { |
804 | return Clipperz.Async.callbacks("DirectLogin.setValueForKey", [ | 794 | return Clipperz.Async.callbacks("DirectLogin.setValueForKey", [ |
805 | MochiKit.Base.method(this, 'getIndexDataForKey', aKey), | 795 | MochiKit.Base.method(this, 'getIndexDataForKey', aKey), |
806 | MochiKit.Base.bind(function (anActualValue) { | 796 | MochiKit.Base.bind(function (anActualValue) { |
807 | var transientStateKey; | 797 | var transientStateKey; |
808 | 798 | ||
809 | transientStateKey = 'original_' + aKey; | 799 | transientStateKey = 'original_' + aKey; |
810 | if (MochiKit.Base.isUndefinedOrNull(this.transientState()[transientStateKey])) { | 800 | if (MochiKit.Base.isUndefinedOrNull(this.transientState()[transientStateKey])) { |
811 | if (anActualValue != aValue) { | 801 | if (anActualValue != aValue) { |
812 | this.transientState()[transientStateKey] = anActualValue; | 802 | this.transientState()[transientStateKey] = anActualValue; |
813 | } | 803 | } |
814 | } else if (this.transientState()[transientStateKey] == aValue) { | 804 | } else if (this.transientState()[transientStateKey] == aValue) { |
815 | this.transientState()[transientStateKey] = null; | 805 | this.transientState()[transientStateKey] = null; |
816 | } | 806 | } |
817 | }, this), | 807 | }, this), |
818 | MochiKit.Base.partial(this._setIndexDataFunction, this.reference(), aKey, aValue) | 808 | MochiKit.Base.partial(this._setIndexDataFunction, this.reference(), aKey, aValue) |
819 | ], {trace:false}) | 809 | ], {trace:false}) |
820 | }, | 810 | }, |
821 | 811 | ||
822 | //------------------------------------------------------------------------- | 812 | //------------------------------------------------------------------------- |
823 | /* | 813 | /* |
824 | 'setValueForKey': function (aKey, aValue) { | 814 | 'setValueForKey': function (aKey, aValue) { |
825 | return Clipperz.Async.callbacks("DirectLogin.setValueForKey", [ | 815 | return Clipperz.Async.callbacks("DirectLogin.setValueForKey", [ |
826 | MochiKit.Base.method(this, 'getIndexDataForKey', aKey), | 816 | MochiKit.Base.method(this, 'getIndexDataForKey', aKey), |
827 | MochiKit.Base.bind(function (anActualValue) { | 817 | MochiKit.Base.bind(function (anActualValue) { |
828 | var transientStateKey; | 818 | var transientStateKey; |
829 | 819 | ||
830 | transientStateKey = 'original_' + aKey; | 820 | transientStateKey = 'original_' + aKey; |
831 | if (MochiKit.Base.isUndefinedOrNull(this.transientState()[transientStateKey])) { | 821 | if (MochiKit.Base.isUndefinedOrNull(this.transientState()[transientStateKey])) { |
832 | if (anActualValue != aValue) { | 822 | if (anActualValue != aValue) { |
833 | this.transientState()[transientStateKey] = anActualValue; | 823 | this.transientState()[transientStateKey] = anActualValue; |
834 | } | 824 | } |
835 | } else if (this.transientState()[transientStateKey] == aValue) { | 825 | } else if (this.transientState()[transientStateKey] == aValue) { |
836 | this.transientState()[transientStateKey] = null; | 826 | this.transientState()[transientStateKey] = null; |
837 | } | 827 | } |
838 | }, this), | 828 | }, this), |
839 | MochiKit.Base.method(this, 'setIndexDataForKey', aKey, aValue) | 829 | MochiKit.Base.method(this, 'setIndexDataForKey', aKey, aValue) |
840 | ], {trace:false}) | 830 | ], {trace:false}) |
841 | }, | 831 | }, |
842 | */ | 832 | */ |
843 | //========================================================================= | 833 | //========================================================================= |
844 | /* | 834 | /* |
845 | 'storedConfiguration': function () { | 835 | 'storedConfiguration': function () { |
846 | return this.record().getValue('directLogins' + '.' + this.reference()); | 836 | return this.record().getValue('directLogins' + '.' + this.reference()); |
847 | }, | 837 | }, |
848 | 838 | ||
849 | //'setStoredConfiguration': function (aValue) { | 839 | //'setStoredConfiguration': function (aValue) { |
850 | // return this.record().setValue('directLogins' + '.' + this.reference(), aValue); | 840 | // return this.record().setValue('directLogins' + '.' + this.reference(), aValue); |
851 | //}, | 841 | //}, |
852 | */ | 842 | */ |
853 | //========================================================================= | 843 | //========================================================================= |
854 | 844 | ||
855 | 'hasPendingChanges': function () { | 845 | 'hasPendingChanges': function () { |
856 | varresult; | 846 | varresult; |
857 | var deferredResult; | 847 | var deferredResult; |
858 | 848 | ||
859 | result = false; | 849 | result = false; |
860 | result = result || this.isBrandNew(); | 850 | result = result || this.isBrandNew(); |
861 | result = result || (! MochiKit.Base.isUndefinedOrNull(this.transientState()['original_label'])); | 851 | result = result || (! MochiKit.Base.isUndefinedOrNull(this.transientState()['original_label'])); |
862 | result = result || (! MochiKit.Base.isUndefinedOrNull(this.transientState()['original_favicon'])); | 852 | result = result || (! MochiKit.Base.isUndefinedOrNull(this.transientState()['original_favicon'])); |
863 | 853 | ||
864 | if ((result == false) && (this.originalConfiguration() != null)) { | 854 | if ((result == false) && (this.originalConfiguration() != null)) { |
865 | deferredResult = Clipperz.Async.callbacks("DirectLogin.hasPendingChanges", [ | 855 | deferredResult = Clipperz.Async.callbacks("DirectLogin.hasPendingChanges", [ |
866 | MochiKit.Base.method(this, 'serializedData'), | 856 | MochiKit.Base.method(this, 'serializedData'), |
867 | MochiKit.Base.bind(function (aCurrentConfiguration) { | 857 | MochiKit.Base.bind(function (aCurrentConfiguration) { |
868 | varoriginalConfiguration; | 858 | varoriginalConfiguration; |
869 | var currentConfiguration; | 859 | var currentConfiguration; |
870 | var result; | 860 | var result; |
871 | 861 | ||
872 | originalConfiguration = this.originalConfiguration(); | 862 | originalConfiguration = this.originalConfiguration(); |
873 | currentConfiguration = aCurrentConfiguration; | 863 | currentConfiguration = aCurrentConfiguration; |
874 | 864 | ||
875 | result = false; | 865 | result = false; |
876 | result = result || (MochiKit.Base.compare(originalConfiguration['bookmarkletVersion'], currentConfiguration['bookmarkletVersion'])!= 0); | 866 | result = result || (MochiKit.Base.compare(originalConfiguration['bookmarkletVersion'], currentConfiguration['bookmarkletVersion'])!= 0); |
877 | result = result || (MochiKit.Base.compare(originalConfiguration['formData'], currentConfiguration['formData']) != 0); | 867 | result = result || (MochiKit.Base.compare(originalConfiguration['formData'], currentConfiguration['formData']) != 0); |
878 | result = result || (MochiKit.Base.compare(originalConfiguration['formValues'], currentConfiguration['formValues']) != 0); | 868 | result = result || (MochiKit.Base.compare(originalConfiguration['formValues'], currentConfiguration['formValues']) != 0); |
879 | result = result || (MochiKit.Base.compare(originalConfiguration['bindingData'], currentConfiguration['bindingData']) != 0); | 869 | result = result || (MochiKit.Base.compare(originalConfiguration['bindingData'], currentConfiguration['bindingData']) != 0); |
880 | 870 | ||
881 | return result; | 871 | return result; |