OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 /** | 6 /** |
7 * @fileoverview Rendering for iframed most visited thumbnails. | 7 * @fileoverview Rendering for iframed most visited thumbnails. |
8 */ | 8 */ |
9 | 9 |
10 window.addEventListener('DOMContentLoaded', function() { | 10 window.addEventListener('DOMContentLoaded', function() { |
(...skipping 12 matching lines...) Expand all Loading... |
23 document.body.appendChild(link); | 23 document.body.appendChild(link); |
24 }; | 24 }; |
25 function createAndAppendThumbnail(isVisible) { | 25 function createAndAppendThumbnail(isVisible) { |
26 var image = new Image(); | 26 var image = new Image(); |
27 image.onload = function() { | 27 image.onload = function() { |
28 var shadow = document.createElement('span'); | 28 var shadow = document.createElement('span'); |
29 shadow.classList.add('shadow'); | 29 shadow.classList.add('shadow'); |
30 var link = createMostVisitedLink(params, data.url, data.title); | 30 var link = createMostVisitedLink(params, data.url, data.title); |
31 link.appendChild(shadow); | 31 link.appendChild(shadow); |
32 link.appendChild(image); | 32 link.appendChild(image); |
| 33 // We add 'position: absolute' in anticipation that there could be more |
| 34 // than one thumbnail. This will superpose the elements. |
| 35 link.style.position = 'absolute'; |
33 document.body.appendChild(link); | 36 document.body.appendChild(link); |
34 }; | 37 }; |
35 if (!isVisible) { | 38 if (!isVisible) { |
36 image.style.visibility = 'hidden'; | 39 image.style.visibility = 'hidden'; |
37 } | 40 } |
38 return image; | 41 return image; |
39 } | 42 } |
40 | 43 |
41 if (data.thumbnailUrl) { | 44 if (data.thumbnailUrl) { |
42 var image = createAndAppendThumbnail(true); | 45 var image = createAndAppendThumbnail(true); |
(...skipping 16 matching lines...) Expand all Loading... |
59 } else { | 62 } else { |
60 image.onerror = showDomainElement; | 63 image.onerror = showDomainElement; |
61 } | 64 } |
62 image.src = data.thumbnailUrl; | 65 image.src = data.thumbnailUrl; |
63 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_ATTEMPT); | 66 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_ATTEMPT); |
64 } else { | 67 } else { |
65 showDomainElement(); | 68 showDomainElement(); |
66 } | 69 } |
67 }); | 70 }); |
68 }); | 71 }); |
OLD | NEW |