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 * @extends {cr.ui.FocusRow} |
| 433 */ |
| 434 function DevicesViewFocusRow() {} |
| 435 |
| 436 /** |
| 437 * Decorates |rowElement| so that it can be treated as a DevicesViewFocusRow. |
| 438 * @param {Element} rowElement The element representing this row. |
| 439 * @param {Node} boundary Focus events are ignored outside of this node. |
| 440 */ |
| 441 DevicesViewFocusRow.decorate = function(rowElement, boundary) { |
| 442 rowElement.__proto__ = DevicesViewFocusRow.prototype; |
| 443 rowElement.decorate(boundary); |
| 444 rowElement.addFocusableElement(rowElement); |
| 445 }; |
| 446 |
| 447 DevicesViewFocusRow.prototype = { |
| 448 __proto__: cr.ui.FocusRow.prototype, |
| 449 |
| 450 /** @override */ |
| 451 getEquivalentElement: function(element) { |
| 452 return this; |
| 453 }, |
| 454 }; |
| 455 |
| 456 /** |
430 * Update the page with results. | 457 * Update the page with results. |
431 * @private | 458 * @private |
432 */ | 459 */ |
433 DevicesView.prototype.displayResults_ = function() { | 460 DevicesView.prototype.displayResults_ = function() { |
434 this.clearDOM(); | 461 this.clearDOM(); |
435 var resultsFragment = document.createDocumentFragment(); | 462 var resultsFragment = document.createDocumentFragment(); |
436 if (this.devices_.length == 0) | 463 if (this.devices_.length == 0) |
437 return; | 464 return; |
438 | 465 |
439 // We'll increase to 0 as we create the first row. | 466 // 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) | 499 if (tabs[i].scrollWidth <= tabs[i].clientWidth) |
473 tabs[i].title = ''; | 500 tabs[i].title = ''; |
474 } | 501 } |
475 | 502 |
476 this.resultDiv_.appendChild( | 503 this.resultDiv_.appendChild( |
477 createElementWithClassName('div', 'other-devices-bottom')); | 504 createElementWithClassName('div', 'other-devices-bottom')); |
478 | 505 |
479 this.focusGrids_.forEach(function(grid) { grid.destroy(); }); | 506 this.focusGrids_.forEach(function(grid) { grid.destroy(); }); |
480 this.focusGrids_.length = 0; | 507 this.focusGrids_.length = 0; |
481 | 508 |
482 var singleColumn = function(e) { return [e]; }; | |
483 | |
484 var devices = this.resultDiv_.querySelectorAll('.device-contents'); | 509 var devices = this.resultDiv_.querySelectorAll('.device-contents'); |
485 for (var i = 0; i < devices.length; ++i) { | 510 for (var i = 0; i < devices.length; ++i) { |
486 var rows = devices[i].querySelectorAll('.device-tab-entry, button'); | 511 var rows = devices[i].querySelectorAll('.device-tab-entry, button'); |
487 if (!rows.length) | 512 if (!rows.length) |
488 continue; | 513 continue; |
489 | 514 |
490 var grid = new cr.ui.FocusGrid(devices[i]); | 515 var grid = new cr.ui.FocusGrid(); |
491 grid.setGrid(Array.prototype.map.call(rows, singleColumn)); | 516 for (var i = 0; i < rows.length; ++i) { |
| 517 DevicesViewFocusRow.decorate(rows[i], devices[i]); |
| 518 grid.addRow(rows[i]); |
| 519 } |
492 this.focusGrids_.push(grid); | 520 this.focusGrids_.push(grid); |
493 } | 521 } |
494 }; | 522 }; |
495 | 523 |
496 /** | 524 /** |
497 * Sets the menu model data. An empty list means that either there are no | 525 * 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. | 526 * foreign sessions, or tab sync is disabled for this profile. |
499 * |isTabSyncEnabled| makes it possible to distinguish between the cases. | 527 * |isTabSyncEnabled| makes it possible to distinguish between the cases. |
500 * | 528 * |
501 * @param {Array} sessionList Array of objects describing the sessions | 529 * @param {Array} sessionList Array of objects describing the sessions |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 | 578 |
551 var doSearch = function(e) { | 579 var doSearch = function(e) { |
552 devicesView.setSearchText($('search-field').value); | 580 devicesView.setSearchText($('search-field').value); |
553 }; | 581 }; |
554 $('search-field').addEventListener('search', doSearch); | 582 $('search-field').addEventListener('search', doSearch); |
555 $('search-button').addEventListener('click', doSearch); | 583 $('search-button').addEventListener('click', doSearch); |
556 } | 584 } |
557 | 585 |
558 // Add handlers to HTML elements. | 586 // Add handlers to HTML elements. |
559 document.addEventListener('DOMContentLoaded', load); | 587 document.addEventListener('DOMContentLoaded', load); |
OLD | NEW |