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