Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: chrome/browser/resources/history/other_devices.js

Issue 807593005: Make downloads list keyboard shortcuts more consistent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 * @param {Element} rowElement The element representing this row.
433 * @param {Node} boundary Focus events are ignored outside of this node.
434 * @extends {cr.ui.FocusRow}
435 */
436 DevicesView.SingleColumnFocusRow = function(rowElement, boundary) {
437 rowElement.__proto__ = DevicesView.SingleColumnFocusRow.prototype;
438 rowElement.decorate(boundary);
439 return rowElement;
440 };
441
442 DevicesView.SingleColumnFocusRow.prototype = {
443 __proto__: cr.ui.FocusRow.prototype,
444
445 /** @override */
446 decorate: function(boundary, opt_delegate) {
447 cr.ui.FocusRow.prototype.decorate.apply(this, arguments);
448 this.addFocusableElement(this);
449 },
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
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)
Dan Beam 2015/01/24 02:37:08 nit: curlies
hcarmona 2015/01/27 18:30:40 Done.
518 grid.addRow(new DevicesView.SingleColumnFocusRow(rows[i], devices[i]));
492 this.focusGrids_.push(grid); 519 this.focusGrids_.push(grid);
493 } 520 }
494 }; 521 };
495 522
496 /** 523 /**
497 * Sets the menu model data. An empty list means that either there are no 524 * 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. 525 * foreign sessions, or tab sync is disabled for this profile.
499 * |isTabSyncEnabled| makes it possible to distinguish between the cases. 526 * |isTabSyncEnabled| makes it possible to distinguish between the cases.
500 * 527 *
501 * @param {Array} sessionList Array of objects describing the sessions 528 * @param {Array} sessionList Array of objects describing the sessions
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 577
551 var doSearch = function(e) { 578 var doSearch = function(e) {
552 devicesView.setSearchText($('search-field').value); 579 devicesView.setSearchText($('search-field').value);
553 }; 580 };
554 $('search-field').addEventListener('search', doSearch); 581 $('search-field').addEventListener('search', doSearch);
555 $('search-button').addEventListener('click', doSearch); 582 $('search-button').addEventListener('click', doSearch);
556 } 583 }
557 584
558 // Add handlers to HTML elements. 585 // Add handlers to HTML elements.
559 document.addEventListener('DOMContentLoaded', load); 586 document.addEventListener('DOMContentLoaded', load);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698