OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 Polymer('oobe-screen', (function() { | 5 Polymer('oobe-screen', (function() { |
6 /** @const */ var CALLBACK_USER_ACTED = 'userActed'; | 6 /** @const */ var CALLBACK_USER_ACTED = 'userActed'; |
7 | 7 |
8 function doNothing() {}; | 8 function doNothing() {}; |
9 | 9 |
10 return { | 10 return { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 initialize: doNothing, | 44 initialize: doNothing, |
45 | 45 |
46 ready: function() { | 46 ready: function() { |
47 if (this.decorate_) { | 47 if (this.decorate_) { |
48 this.initialize(); | 48 this.initialize(); |
49 } else { | 49 } else { |
50 this.ready_ = true; | 50 this.ready_ = true; |
51 } | 51 } |
52 }, | 52 }, |
53 | 53 |
| 54 userActed: function(_, _, source) { |
| 55 this.send(CALLBACK_USER_ACTED, source.getAttribute('action')); |
| 56 }, |
| 57 |
54 i18n: function(args) { | 58 i18n: function(args) { |
55 if (!(args instanceof Array)) | 59 if (!(args instanceof Array)) |
56 args = [args]; | 60 args = [args]; |
57 args[0] = 'login_' + this.name + '_' + args[0]; | 61 args[0] = 'login_' + this.name + '_' + args[0]; |
58 return loadTimeData.getStringF.apply(loadTimeData, args); | 62 return loadTimeData.getStringF.apply(loadTimeData, args); |
59 }, | 63 }, |
60 | 64 |
61 /** | 65 /** |
62 * Called by login.Screen when the screen is beeing registered. | 66 * Called by login.Screen when the screen is beeing registered. |
63 */ | 67 */ |
64 decorate: function(screen) { | 68 decorate: function(screen) { |
65 this.screen_ = screen; | 69 this.screen_ = screen; |
66 screen.initialize(); | 70 screen.initialize(); |
67 this.context = screen.screenContext_; | 71 this.context = screen.screenContext_; |
68 this.C = this.context.storage_; | 72 this.C = this.context.storage_; |
69 this.contextObservers_ = {}; | 73 this.contextObservers_ = {}; |
70 var self = this; | 74 var self = this; |
71 this.querySelectorAllImpl_('button[action]').forEach(function(button) { | |
72 button.addEventListener('click', function(e) { | |
73 var action = this.getAttribute('action'); | |
74 self.send(CALLBACK_USER_ACTED, action); | |
75 e.stopPropagation(); | |
76 }); | |
77 }); | |
78 if (this.ready_) { | 75 if (this.ready_) { |
79 this.initialize(); | 76 this.initialize(); |
80 } else { | 77 } else { |
81 this.decorate_ = true; | 78 this.decorate_ = true; |
82 } | 79 } |
83 }, | 80 }, |
84 | 81 |
85 /** | 82 /** |
86 * @final | 83 * @final |
87 */ | 84 */ |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 */ | 207 */ |
211 getPropertyNameOf_: function(value) { | 208 getPropertyNameOf_: function(value) { |
212 for (var key in this) | 209 for (var key in this) |
213 if (this[key] === value) | 210 if (this[key] === value) |
214 return key; | 211 return key; |
215 return ''; | 212 return ''; |
216 } | 213 } |
217 }; | 214 }; |
218 })()); | 215 })()); |
219 | 216 |
OLD | NEW |