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

Unified Diff: chrome/browser/resources/local_ntp/most_visited_util.js

Issue 1061163003: [New Tab Page] Reset default parameters for NTP title.html, adding param for multiline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adapting style to local file. Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/local_ntp/most_visited_util.js
diff --git a/chrome/browser/resources/local_ntp/most_visited_util.js b/chrome/browser/resources/local_ntp/most_visited_util.js
index a88ae20416114cc3bcde2a09cb5beb4d59f5a89e..dfa9c235def3290a714bda5eedc45383304b8d94 100644
--- a/chrome/browser/resources/local_ntp/most_visited_util.js
+++ b/chrome/browser/resources/local_ntp/most_visited_util.js
@@ -118,10 +118,11 @@ function createMostVisitedLink(params, href, title, text, direction, provider) {
// The fading length in pixels is passed by the caller.
var mask = 'linear-gradient(' + dir + ', rgba(0,0,0,1), rgba(0,0,0,1) ' +
styles.textFadePos + 'px, rgba(0,0,0,0))';
- link.style.lineHeight = 'auto';
link.style.textOverflow = 'clip';
link.style.webkitMask = mask;
- link.style.whiteSpace = 'nowrap';
+ }
+ if (styles.numTitleLines && styles.numTitleLines > 1) {
+ link.classList.add('multiline');
}
link.href = href;
@@ -130,8 +131,12 @@ function createMostVisitedLink(params, href, title, text, direction, provider) {
// Include links in the tab order. The tabIndex is necessary for
// accessibility.
link.tabIndex = '0';
- if (text)
- link.textContent = text;
+ if (text) {
+ // Wrap text with span so ellipsis will appear at the end of multiline.
+ var spanWrap = document.createElement('span');
+ spanWrap.textContent = text;
+ link.appendChild(spanWrap);
+ }
link.addEventListener('mouseover', function() {
var ntpApiHandle = chrome.embeddedSearch.newTabPage;
ntpApiHandle.logEvent(NTP_LOGGING_EVENT_TYPE.NTP_MOUSEOVER);
@@ -224,7 +229,8 @@ function getTextColor(params, isTitle) {
* - f: font-family.
* - fs: font-size as a number in pixels.
* - ta: text-align property, as a string.
- * - tf: specifying a text fade starting position, in pixels.
+ * - tf: text fade starting position, in pixels.
+ * - ntl: number of lines in the title.
* @param {Object<string, string>} params URL parameters specifying style.
* @param {boolean} isTitle if the style is for the Most Visited Title.
* @return {Object} Styles suitable for CSS interpolation.
@@ -246,6 +252,11 @@ function getMostVisitedStyles(params, isTitle) {
if (isFinite(tf))
styles.textFadePos = tf;
}
+ if ('ntl' in params) {
+ var ntl = parseInt(params.ntl, 10);
+ if (isFinite(ntl))
+ styles.numTitleLines = ntl;
+ }
return styles;
}

Powered by Google App Engine
This is Rietveld 408576698