Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* Copyright 2015 The Chromium Authors. All rights reserved. | 1 /* Copyright 2015 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 // Single iframe for NTP tiles. | 5 // Single iframe for NTP tiles. |
| 6 (function() { | 6 (function() { |
| 7 'use strict'; | 7 'use strict'; |
| 8 | 8 |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 // Unused here. | 32 // Unused here. |
| 33 NTP_EXTERNAL_TILE: 5, | 33 NTP_EXTERNAL_TILE: 5, |
| 34 // There was an error in loading both the thumbnail image and the fallback | 34 // There was an error in loading both the thumbnail image and the fallback |
| 35 // (if it was provided), resulting in a gray tile. | 35 // (if it was provided), resulting in a gray tile. |
| 36 NTP_THUMBNAIL_ERROR: 6, | 36 NTP_THUMBNAIL_ERROR: 6, |
| 37 // Used a gray tile with the domain as the fallback for a failed thumbnail. | 37 // Used a gray tile with the domain as the fallback for a failed thumbnail. |
| 38 // Unused here. | 38 // Unused here. |
| 39 NTP_GRAY_TILE_FALLBACK: 7, | 39 NTP_GRAY_TILE_FALLBACK: 7, |
| 40 // The visuals of that tile's fallback are handled externally. Unused here. | 40 // The visuals of that tile's fallback are handled externally. Unused here. |
| 41 NTP_EXTERNAL_TILE_FALLBACK: 8, | 41 NTP_EXTERNAL_TILE_FALLBACK: 8, |
| 42 // The user moused over an NTP tile. | |
| 43 NTP_MOUSEOVER: 9, | |
|
Marc Treib
2016/07/05 08:07:31
Hm, there's a few other ones here that say "unused
sfiera
2016/07/05 18:24:40
Done.
| |
| 44 // A NTP Tile has finished loading (successfully or failing). | 42 // A NTP Tile has finished loading (successfully or failing). |
| 45 NTP_TILE_LOADED: 10, | 43 NTP_TILE_LOADED: 10, |
| 46 }; | 44 }; |
| 47 | 45 |
| 48 | 46 |
| 49 /** | 47 /** |
| 50 * Total number of tiles to show at any time. If the host page doesn't send | 48 * Total number of tiles to show at any time. If the host page doesn't send |
| 51 * enough tiles, we fill them blank. | 49 * enough tiles, we fill them blank. |
| 52 * @const {number} | 50 * @const {number} |
| 53 */ | 51 */ |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 460 if (inArrowDirection(this, nonEmptyTiles[i]) && | 458 if (inArrowDirection(this, nonEmptyTiles[i]) && |
| 461 (!nextTile || inArrowDirection(nonEmptyTiles[i], nextTile))) { | 459 (!nextTile || inArrowDirection(nonEmptyTiles[i], nextTile))) { |
| 462 nextTile = nonEmptyTiles[i]; | 460 nextTile = nonEmptyTiles[i]; |
| 463 } | 461 } |
| 464 } | 462 } |
| 465 if (nextTile) { | 463 if (nextTile) { |
| 466 nextTile.focus(); | 464 nextTile.focus(); |
| 467 } | 465 } |
| 468 } | 466 } |
| 469 }); | 467 }); |
| 470 // TODO(fserb): remove this or at least change to mouseenter. | |
| 471 tile.addEventListener('mouseover', function() { | |
| 472 logEvent(LOG_TYPE.NTP_MOUSEOVER); | |
| 473 }); | |
| 474 | 468 |
| 475 var title = tile.querySelector('.mv-title'); | 469 var title = tile.querySelector('.mv-title'); |
| 476 title.innerText = data.title; | 470 title.innerText = data.title; |
| 477 title.style.direction = data.direction || 'ltr'; | 471 title.style.direction = data.direction || 'ltr'; |
| 478 if (NUM_TITLE_LINES > 1) { | 472 if (NUM_TITLE_LINES > 1) { |
| 479 title.classList.add('multiline'); | 473 title.classList.add('multiline'); |
| 480 } | 474 } |
| 481 | 475 |
| 482 if (USE_ICONS) { | 476 if (USE_ICONS) { |
| 483 var thumb = tile.querySelector('.mv-thumb'); | 477 var thumb = tile.querySelector('.mv-thumb'); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 var html = document.querySelector('html'); | 639 var html = document.querySelector('html'); |
| 646 html.dir = 'rtl'; | 640 html.dir = 'rtl'; |
| 647 } | 641 } |
| 648 | 642 |
| 649 window.addEventListener('message', handlePostMessage); | 643 window.addEventListener('message', handlePostMessage); |
| 650 }; | 644 }; |
| 651 | 645 |
| 652 | 646 |
| 653 window.addEventListener('DOMContentLoaded', init); | 647 window.addEventListener('DOMContentLoaded', init); |
| 654 })(); | 648 })(); |
| OLD | NEW |