OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 The section of the history page that shows tabs from sessions | 6 * @fileoverview The section of the history page that shows tabs from sessions |
7 on other devices. | 7 on other devices. |
8 */ | 8 */ |
9 | 9 |
10 /////////////////////////////////////////////////////////////////////////////// | 10 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 DevicesView.prototype.increaseRowHeight = function(row, height) { | 420 DevicesView.prototype.increaseRowHeight = function(row, height) { |
421 for (var i = this.rowHeights_.length; i <= row; i++) | 421 for (var i = this.rowHeights_.length; i <= row; i++) |
422 this.rowHeights_.push(NB_ENTRIES_OTHER_ROWS_COLUMN); | 422 this.rowHeights_.push(NB_ENTRIES_OTHER_ROWS_COLUMN); |
423 this.rowHeights_[row] += height; | 423 this.rowHeights_[row] += height; |
424 this.displayResults_(); | 424 this.displayResults_(); |
425 }; | 425 }; |
426 | 426 |
427 // DevicesView, Private ------------------------------------------------------- | 427 // DevicesView, Private ------------------------------------------------------- |
428 | 428 |
429 /** | 429 /** |
| 430 * Provides an implementation for a single column grid. |
| 431 * @constructor |
| 432 * @implements {cr.ui.FocusRow.Observer} |
| 433 */ |
| 434 DevicesView.SingleColumnObserver = function() {}; |
| 435 |
| 436 DevicesView.SingleColumnObserver.prototype = { |
| 437 /** @override */ |
| 438 onActivate: function(row) {}, |
| 439 |
| 440 /** @override */ |
| 441 onDeactivate: function(row) {}, |
| 442 |
| 443 /** @override */ |
| 444 getRowElement: function(rowItem) { return rowItem; }, |
| 445 |
| 446 /** @override */ |
| 447 onElementIdMiss: function(row, expectedId) { return null; }, |
| 448 }; |
| 449 |
| 450 /** |
430 * Update the page with results. | 451 * Update the page with results. |
431 * @private | 452 * @private |
432 */ | 453 */ |
433 DevicesView.prototype.displayResults_ = function() { | 454 DevicesView.prototype.displayResults_ = function() { |
434 this.clearDOM(); | 455 this.clearDOM(); |
435 var resultsFragment = document.createDocumentFragment(); | 456 var resultsFragment = document.createDocumentFragment(); |
436 if (this.devices_.length == 0) | 457 if (this.devices_.length == 0) |
437 return; | 458 return; |
438 | 459 |
439 // We'll increase to 0 as we create the first row. | 460 // We'll increase to 0 as we create the first row. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 if (tabs[i].scrollWidth <= tabs[i].clientWidth) | 493 if (tabs[i].scrollWidth <= tabs[i].clientWidth) |
473 tabs[i].title = ''; | 494 tabs[i].title = ''; |
474 } | 495 } |
475 | 496 |
476 this.resultDiv_.appendChild( | 497 this.resultDiv_.appendChild( |
477 createElementWithClassName('div', 'other-devices-bottom')); | 498 createElementWithClassName('div', 'other-devices-bottom')); |
478 | 499 |
479 this.focusGrids_.forEach(function(grid) { grid.destroy(); }); | 500 this.focusGrids_.forEach(function(grid) { grid.destroy(); }); |
480 this.focusGrids_.length = 0; | 501 this.focusGrids_.length = 0; |
481 | 502 |
482 var singleColumn = function(e) { return [e]; }; | |
483 | |
484 var devices = this.resultDiv_.querySelectorAll('.device-contents'); | 503 var devices = this.resultDiv_.querySelectorAll('.device-contents'); |
485 for (var i = 0; i < devices.length; ++i) { | 504 for (var i = 0; i < devices.length; ++i) { |
486 var rows = devices[i].querySelectorAll('.device-tab-entry, button'); | 505 var rows = devices[i].querySelectorAll('.device-tab-entry, button'); |
487 if (!rows.length) | 506 if (!rows.length) |
488 continue; | 507 continue; |
489 | 508 |
490 var grid = new cr.ui.FocusGrid(devices[i]); | 509 var grid = new cr.ui.FocusGrid(devices[i], |
491 grid.setGrid(Array.prototype.map.call(rows, singleColumn)); | 510 new DevicesView.SingleColumnObserver()); |
| 511 for (var j = 0; j < rows.length; ++j) { |
| 512 var row = grid.createRow(); |
| 513 row.setFocusableElementId(rows[j], 'single-column'); |
| 514 grid.addRow(row); |
| 515 } |
492 this.focusGrids_.push(grid); | 516 this.focusGrids_.push(grid); |
493 } | 517 } |
494 }; | 518 }; |
495 | 519 |
496 /** | 520 /** |
497 * Sets the menu model data. An empty list means that either there are no | 521 * Sets the menu model data. An empty list means that either there are no |
498 * foreign sessions, or tab sync is disabled for this profile. | 522 * foreign sessions, or tab sync is disabled for this profile. |
499 * |isTabSyncEnabled| makes it possible to distinguish between the cases. | 523 * |isTabSyncEnabled| makes it possible to distinguish between the cases. |
500 * | 524 * |
501 * @param {Array} sessionList Array of objects describing the sessions | 525 * @param {Array} sessionList Array of objects describing the sessions |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 | 574 |
551 var doSearch = function(e) { | 575 var doSearch = function(e) { |
552 devicesView.setSearchText($('search-field').value); | 576 devicesView.setSearchText($('search-field').value); |
553 }; | 577 }; |
554 $('search-field').addEventListener('search', doSearch); | 578 $('search-field').addEventListener('search', doSearch); |
555 $('search-button').addEventListener('click', doSearch); | 579 $('search-button').addEventListener('click', doSearch); |
556 } | 580 } |
557 | 581 |
558 // Add handlers to HTML elements. | 582 // Add handlers to HTML elements. |
559 document.addEventListener('DOMContentLoaded', load); | 583 document.addEventListener('DOMContentLoaded', load); |
OLD | NEW |