OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 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 cr.define('cr.ui', function() { | 5 cr.define('cr.ui', function() { |
6 /** | 6 /** |
7 * A class to manage focus between given horizontally arranged elements. | 7 * A class to manage focus between given horizontally arranged elements. |
8 * | 8 * |
9 * Pressing left cycles backward and pressing right cycles forward in item | 9 * Pressing left cycles backward and pressing right cycles forward in item |
10 * order. Pressing Home goes to the beginning of the list and End goes to the | 10 * order. Pressing Home goes to the beginning of the list and End goes to the |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 element.tabIndex = this.isActive() ? 0 : -1; | 119 element.tabIndex = this.isActive() ? 0 : -1; |
120 | 120 |
121 this.eventTracker.add(element, 'blur', this.onBlur_.bind(this)); | 121 this.eventTracker.add(element, 'blur', this.onBlur_.bind(this)); |
122 this.eventTracker.add(element, 'focus', this.onFocus_.bind(this)); | 122 this.eventTracker.add(element, 'focus', this.onFocus_.bind(this)); |
123 this.eventTracker.add(element, 'keydown', this.onKeydown_.bind(this)); | 123 this.eventTracker.add(element, 'keydown', this.onKeydown_.bind(this)); |
124 this.eventTracker.add(element, 'mousedown', this.onMousedown_.bind(this)); | 124 this.eventTracker.add(element, 'mousedown', this.onMousedown_.bind(this)); |
125 return true; | 125 return true; |
126 }, | 126 }, |
127 | 127 |
128 /** Dereferences nodes and removes event handlers. */ | 128 /** Dereferences nodes and removes event handlers. */ |
129 destroy: function() { this.eventTracker.removeAll(); }, | 129 destroy: function() { |
| 130 this.eventTracker.removeAll(); |
| 131 }, |
130 | 132 |
131 /** | 133 /** |
132 * @param {!Element} sampleElement An element for to find an equivalent for. | 134 * @param {!Element} sampleElement An element for to find an equivalent for. |
133 * @return {!Element} An equivalent element to focus for |sampleElement|. | 135 * @return {!Element} An equivalent element to focus for |sampleElement|. |
134 * @protected | 136 * @protected |
135 */ | 137 */ |
136 getCustomEquivalent: function(sampleElement) { | 138 getCustomEquivalent: function(sampleElement) { |
137 return assert(this.getFirstFocusable()); | 139 return assert(this.getFirstFocusable()); |
138 }, | 140 }, |
139 | 141 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 this.getEquivalentElement(elementToFocus).focus(); | 284 this.getEquivalentElement(elementToFocus).focus(); |
283 e.preventDefault(); | 285 e.preventDefault(); |
284 } | 286 } |
285 }, | 287 }, |
286 }; | 288 }; |
287 | 289 |
288 return { | 290 return { |
289 FocusRow: FocusRow, | 291 FocusRow: FocusRow, |
290 }; | 292 }; |
291 }); | 293 }); |
OLD | NEW |