| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 DropDown.prototype = { | 82 DropDown.prototype = { |
| 83 __proto__: HTMLDivElement.prototype, | 83 __proto__: HTMLDivElement.prototype, |
| 84 | 84 |
| 85 /** @inheritDoc */ | 85 /** @inheritDoc */ |
| 86 decorate: function() { | 86 decorate: function() { |
| 87 this.appendChild(this.createOverlay_()); | 87 this.appendChild(this.createOverlay_()); |
| 88 this.appendChild(this.title_ = this.createTitle_()); | 88 this.appendChild(this.title_ = this.createTitle_()); |
| 89 this.appendChild(new DropDownContainer()); | 89 this.appendChild(new DropDownContainer()); |
| 90 | 90 |
| 91 this.isShown = false; | |
| 92 this.addEventListener('keydown', this.keyDownHandler_); | 91 this.addEventListener('keydown', this.keyDownHandler_); |
| 93 | 92 |
| 94 this.title_.id = this.id + '-dropdown'; | 93 this.title_.id = this.id + '-dropdown'; |
| 95 this.title_.setAttribute('role', 'button'); | 94 this.title_.setAttribute('role', 'button'); |
| 96 this.title_.setAttribute('aria-haspopup', 'true'); | 95 this.title_.setAttribute('aria-haspopup', 'true'); |
| 97 }, | 96 }, |
| 98 | 97 |
| 99 /** | 98 /** |
| 100 * Returns true if dropdown menu is shown. | 99 * Returns true if dropdown menu is shown. |
| 101 * @type {bool} Whether menu element is shown. | 100 * @type {bool} Whether menu element is shown. |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 /** | 371 /** |
| 373 * Activates or deactivates network drop-down. Only one network drop-down | 372 * Activates or deactivates network drop-down. Only one network drop-down |
| 374 * can be active at the same time. So activating new drop-down deactivates | 373 * can be active at the same time. So activating new drop-down deactivates |
| 375 * the previous one. Deactivating not active drop-down does nothing. | 374 * the previous one. Deactivating not active drop-down does nothing. |
| 376 * @param {string} element_id Id of the element which is network drop-down. | 375 * @param {string} element_id Id of the element which is network drop-down. |
| 377 * @param {boolean} is_active Is drop-down active? | 376 * @param {boolean} is_active Is drop-down active? |
| 378 */ | 377 */ |
| 379 DropDown.setActive = function(elementId, isActive) { | 378 DropDown.setActive = function(elementId, isActive) { |
| 380 if (isActive) { | 379 if (isActive) { |
| 381 DropDown.activeElementId_ = elementId; | 380 DropDown.activeElementId_ = elementId; |
| 381 $(elementId).isShown = false; |
| 382 chrome.send('networkDropdownShow', [elementId]); | 382 chrome.send('networkDropdownShow', [elementId]); |
| 383 } else { | 383 } else { |
| 384 if (DropDown.activeElementId_ == elementId) { | 384 if (DropDown.activeElementId_ == elementId) { |
| 385 DropDown.activeElementId_ = ''; | 385 DropDown.activeElementId_ = ''; |
| 386 chrome.send('networkDropdownHide', []); | 386 chrome.send('networkDropdownHide', []); |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 }; | 389 }; |
| 390 | 390 |
| 391 /** | 391 /** |
| 392 * Refreshes network drop-down. Should be called on language change. | 392 * Refreshes network drop-down. Should be called on language change. |
| 393 */ | 393 */ |
| 394 DropDown.refresh = function() { | 394 DropDown.refresh = function() { |
| 395 chrome.send('networkDropdownRefresh', []); | 395 chrome.send('networkDropdownRefresh', []); |
| 396 }; | 396 }; |
| 397 | 397 |
| 398 return { | 398 return { |
| 399 DropDown: DropDown | 399 DropDown: DropDown |
| 400 }; | 400 }; |
| 401 }); | 401 }); |
| OLD | NEW |