OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
6 * @fileoverview Network drop-down implementation. | 6 * @fileoverview Network drop-down implementation. |
7 */ | 7 */ |
8 | 8 |
9 cr.define('cr.ui', function() { | 9 cr.define('cr.ui', function() { |
10 /** | 10 /** |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 DropDown.KEYCODE_TAB = 9; | 86 DropDown.KEYCODE_TAB = 9; |
87 DropDown.KEYCODE_UP = 38; | 87 DropDown.KEYCODE_UP = 38; |
88 | 88 |
89 DropDown.prototype = { | 89 DropDown.prototype = { |
90 __proto__: HTMLDivElement.prototype, | 90 __proto__: HTMLDivElement.prototype, |
91 | 91 |
92 /** @override */ | 92 /** @override */ |
93 decorate: function() { | 93 decorate: function() { |
94 this.appendChild(this.createOverlay_()); | 94 this.appendChild(this.createOverlay_()); |
95 this.appendChild(this.title_ = this.createTitle_()); | 95 this.appendChild(this.title_ = this.createTitle_()); |
96 this.appendChild(new DropDownContainer()); | 96 var container = new DropDownContainer(); |
| 97 container.id = this.id + '-dropdown-container'; |
| 98 this.appendChild(container); |
97 | 99 |
98 this.addEventListener('keydown', this.keyDownHandler_); | 100 this.addEventListener('keydown', this.keyDownHandler_); |
99 | 101 |
100 this.title_.id = this.id + '-dropdown'; | 102 this.title_.id = this.id + '-dropdown'; |
101 this.title_.setAttribute('role', 'button'); | 103 this.title_.setAttribute('role', 'button'); |
102 this.title_.setAttribute('aria-haspopup', 'true'); | 104 this.title_.setAttribute('aria-haspopup', 'true'); |
| 105 this.title_.setAttribute('aria-owns', container.id); |
103 }, | 106 }, |
104 | 107 |
105 /** | 108 /** |
106 * Returns true if dropdown menu is shown. | 109 * Returns true if dropdown menu is shown. |
107 * @type {bool} Whether menu element is shown. | 110 * @type {bool} Whether menu element is shown. |
108 */ | 111 */ |
109 get isShown() { | 112 get isShown() { |
110 return !this.container.hidden; | 113 return !this.container.hidden; |
111 }, | 114 }, |
112 | 115 |
113 /** | 116 /** |
114 * Sets dropdown menu visibility. | 117 * Sets dropdown menu visibility. |
115 * @param {bool} show New visibility state for dropdown menu. | 118 * @param {bool} show New visibility state for dropdown menu. |
116 */ | 119 */ |
117 set isShown(show) { | 120 set isShown(show) { |
118 this.firstElementChild.hidden = !show; | 121 this.firstElementChild.hidden = !show; |
119 this.container.hidden = !show; | 122 this.container.hidden = !show; |
120 if (show) { | 123 if (show) { |
121 this.container.selectItem(this.container.firstItem, false); | 124 this.container.selectItem(this.container.firstItem, false); |
122 this.title_.setAttribute('aria-pressed', 'true'); | |
123 } else { | 125 } else { |
124 this.title_.setAttribute('aria-pressed', 'false'); | |
125 this.title_.removeAttribute('aria-activedescendant'); | 126 this.title_.removeAttribute('aria-activedescendant'); |
126 } | 127 } |
127 }, | 128 }, |
128 | 129 |
129 /** | 130 /** |
130 * Returns title button. | 131 * Returns title button. |
131 */ | 132 */ |
132 get titleButton() { | 133 get titleButton() { |
133 return this.children[1]; | 134 return this.children[1]; |
134 }, | 135 }, |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 * Refreshes network drop-down. Should be called on language change. | 412 * Refreshes network drop-down. Should be called on language change. |
412 */ | 413 */ |
413 DropDown.refresh = function() { | 414 DropDown.refresh = function() { |
414 chrome.send('networkDropdownRefresh'); | 415 chrome.send('networkDropdownRefresh'); |
415 }; | 416 }; |
416 | 417 |
417 return { | 418 return { |
418 DropDown: DropDown | 419 DropDown: DropDown |
419 }; | 420 }; |
420 }); | 421 }); |
OLD | NEW |