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 Utilities for rendering most visited thumbnails and titles. | 7 * @fileoverview Utilities for rendering most visited thumbnails and titles. |
8 */ | 8 */ |
9 | 9 |
10 <include src="instant_iframe_validation.js"> | 10 <include src="instant_iframe_validation.js"> |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 ntpApiHandle.logMostVisitedNavigation(parseInt(params.pos, 10), | 149 ntpApiHandle.logMostVisitedNavigation(parseInt(params.pos, 10), |
150 provider || ''); | 150 provider || ''); |
151 } | 151 } |
152 | 152 |
153 if (!isServerSuggestion) { | 153 if (!isServerSuggestion) { |
154 e.preventDefault(); | 154 e.preventDefault(); |
155 ntpApiHandle.navigateContentWindow(href, getDispositionFromEvent(e)); | 155 ntpApiHandle.navigateContentWindow(href, getDispositionFromEvent(e)); |
156 } | 156 } |
157 // Else follow <a> normally, so transition type would be LINK. | 157 // Else follow <a> normally, so transition type would be LINK. |
158 }); | 158 }); |
| 159 link.addEventListener('mousedown', function(e) { |
| 160 e.preventDefault(); // Prevent drag-select. |
| 161 }); |
159 | 162 |
160 return link; | 163 return link; |
161 } | 164 } |
162 | 165 |
163 | 166 |
164 /** | 167 /** |
165 * Decodes most visited styles from URL parameters. | 168 * Decodes most visited styles from URL parameters. |
| 169 * - c: A hexadecimal number interpreted as a hex color code. |
166 * - f: font-family. | 170 * - f: font-family. |
167 * - fs: font-size as a number in pixels. | 171 * - fs: font-size as a number in pixels. |
168 * - ta: text-align property, as a string. | 172 * - ta: text-align property, as a string. |
169 * - tf: specifying a text fade starting position, in pixels. | 173 * - tf: specifying a text fade starting position, in pixels. |
170 * - c: A hexadecimal number interpreted as a hex color code. | |
171 * @param {Object.<string, string>} params URL parameters specifying style. | 174 * @param {Object.<string, string>} params URL parameters specifying style. |
172 * @param {boolean} isTitle if the style is for the Most Visited Title. | 175 * @param {boolean} isTitle if the style is for the Most Visited Title. |
173 * @return {Object} Styles suitable for CSS interpolation. | 176 * @return {Object} Styles suitable for CSS interpolation. |
174 */ | 177 */ |
175 function getMostVisitedStyles(params, isTitle) { | 178 function getMostVisitedStyles(params, isTitle) { |
176 var styles = { | 179 var styles = { |
177 color: '#777', | 180 color: '#777', |
178 fontFamily: '', | 181 fontFamily: '', |
179 fontSize: 11 | 182 fontSize: 11 |
180 }; | 183 }; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 if (navigator.sendBeacon) { | 257 if (navigator.sendBeacon) { |
255 navigator.sendBeacon(url); | 258 navigator.sendBeacon(url); |
256 } else { | 259 } else { |
257 // if sendBeacon is not enabled, we fallback for "a ping". | 260 // if sendBeacon is not enabled, we fallback for "a ping". |
258 var a = document.createElement('a'); | 261 var a = document.createElement('a'); |
259 a.href = '#'; | 262 a.href = '#'; |
260 a.ping = url; | 263 a.ping = url; |
261 a.click(); | 264 a.click(); |
262 } | 265 } |
263 } | 266 } |
OLD | NEW |