| 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 } | 349 } |
| 350 }; | 350 }; |
| 351 | 351 |
| 352 /** | 352 /** |
| 353 * Updates networks list with the new data. | 353 * Updates networks list with the new data. |
| 354 * @param {!Object} data Networks list. | 354 * @param {!Object} data Networks list. |
| 355 */ | 355 */ |
| 356 DropDown.updateNetworks = function(data) { | 356 DropDown.updateNetworks = function(data) { |
| 357 var elementId = DropDown.activeElementId_; | 357 if (DropDown.activeElementId_) |
| 358 $(elementId).setItems(data); | 358 $(DropDown.activeElementId_).setItems(data); |
| 359 }; | 359 }; |
| 360 | 360 |
| 361 /** | 361 /** |
| 362 * Updates network title, which is shown by the drop-down. | 362 * Updates network title, which is shown by the drop-down. |
| 363 * @param {string} title Title to be displayed. | 363 * @param {string} title Title to be displayed. |
| 364 * @param {!Object} icon Icon to be displayed. | 364 * @param {!Object} icon Icon to be displayed. |
| 365 */ | 365 */ |
| 366 DropDown.updateNetworkTitle = function(title, icon) { | 366 DropDown.updateNetworkTitle = function(title, icon) { |
| 367 var elementId = DropDown.activeElementId_; | 367 if (DropDown.activeElementId_) |
| 368 $(elementId).setTitle(title, icon); | 368 $(DropDown.activeElementId_).setTitle(title, icon); |
| 369 }; | 369 }; |
| 370 | 370 |
| 371 /** | 371 /** |
| 372 * Activates or deactivates network drop-down. Only one network drop-down | 372 * Activates or deactivates network drop-down. Only one network drop-down |
| 373 * 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 |
| 374 * the previous one. Deactivating not active drop-down does nothing. | 374 * the previous one. Deactivating not active drop-down does nothing. |
| 375 * @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. |
| 376 * @param {boolean} isActive Is drop-down active? | 376 * @param {boolean} isActive Is drop-down active? |
| 377 * @param {boolean} isOobe Is dropdown placed on an OOBE screen. | 377 * @param {boolean} isOobe Is dropdown placed on an OOBE screen. |
| 378 */ | 378 */ |
| 379 DropDown.setActive = function(elementId, isActive, isOobe) { | 379 DropDown.setActive = function(elementId, isActive, isOobe) { |
| 380 if (isActive) { | 380 if (isActive) { |
| 381 DropDown.activeElementId_ = elementId; | |
| 382 $(elementId).isShown = false; | 381 $(elementId).isShown = false; |
| 383 chrome.send('networkDropdownShow', [elementId, isOobe]); | 382 if (DropDown.activeElementId_ != elementId) { |
| 383 DropDown.activeElementId_ = elementId; |
| 384 chrome.send('networkDropdownShow', [elementId, isOobe]); |
| 385 } |
| 384 } else { | 386 } else { |
| 385 if (DropDown.activeElementId_ == elementId) { | 387 if (DropDown.activeElementId_ == elementId) { |
| 386 DropDown.activeElementId_ = ''; | 388 DropDown.activeElementId_ = ''; |
| 387 chrome.send('networkDropdownHide', []); | 389 chrome.send('networkDropdownHide', []); |
| 388 } | 390 } |
| 389 } | 391 } |
| 390 }; | 392 }; |
| 391 | 393 |
| 392 /** | 394 /** |
| 393 * Refreshes network drop-down. Should be called on language change. | 395 * Refreshes network drop-down. Should be called on language change. |
| 394 */ | 396 */ |
| 395 DropDown.refresh = function() { | 397 DropDown.refresh = function() { |
| 396 chrome.send('networkDropdownRefresh', []); | 398 chrome.send('networkDropdownRefresh', []); |
| 397 }; | 399 }; |
| 398 | 400 |
| 399 return { | 401 return { |
| 400 DropDown: DropDown | 402 DropDown: DropDown |
| 401 }; | 403 }; |
| 402 }); | 404 }); |
| OLD | NEW |