Commit 1e1b2a25 authored by Weilun Shi's avatar Weilun Shi Committed by Commit Bot

[NTP] Enlarge link icon size when there is only one line attribution

Link icon will be enlarged when there is only one line of attribution.
The size of the link icon will still correspond to the text size when
there are two lines of attribution.

Screencast:
https://screencast.googleplex.com/cast/NTQwNTYzNTc2NDAyNzM5Mnw1ZjlmZGVjNC04Yg

Bug: 878917
Change-Id: I351569a1c260b4e5d0524c44bebdcdc8f67a4522
Reviewed-on: https://chromium-review.googlesource.com/1197425Reviewed-by: default avatarKristi Park <kristipark@chromium.org>
Commit-Queue: Weilun Shi <sweilun@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587884}
parent 5ca87ba8
...@@ -611,7 +611,13 @@ html[dir=rtl] #custom-bg-attr { ...@@ -611,7 +611,13 @@ html[dir=rtl] #custom-bg-attr {
width: 10px; width: 10px;
} }
#link-icon.single-attr {
background-size: 16px 16px;
height: 18px;
width: 16px;
}
html[dir=rtl] #link-icon { html[dir=rtl] #link-icon {
margin-right: auto;
margin-left: 8px; margin-left: 8px;
} margin-right: auto;
}
\ No newline at end of file
...@@ -125,6 +125,7 @@ customBackgrounds.CLASSES = { ...@@ -125,6 +125,7 @@ customBackgrounds.CLASSES = {
SELECTED_BORDER: 'selected-border', SELECTED_BORDER: 'selected-border',
SELECTED_CHECK: 'selected-check', SELECTED_CHECK: 'selected-check',
SELECTED_CIRCLE: 'selected-circle', SELECTED_CIRCLE: 'selected-circle',
SINGLE_ATTR: 'single-attr'
}; };
/** /**
...@@ -236,24 +237,27 @@ customBackgrounds.setAttribution = function( ...@@ -236,24 +237,27 @@ customBackgrounds.setAttribution = function(
var attributionBox = $(customBackgrounds.IDS.ATTRIBUTIONS); var attributionBox = $(customBackgrounds.IDS.ATTRIBUTIONS);
var attr1 = document.createElement('div'); var attr1 = document.createElement('div');
var attr2 = document.createElement('div'); var attr2 = document.createElement('div');
if (attributionLine1 != '') { if (attributionLine1 !== '') {
// Shouldn't be changed from textContent for security assurances. // Shouldn't be changed from textContent for security assurances.
attr1.textContent = attributionLine1; attr1.textContent = attributionLine1;
attr1.classList.add(customBackgrounds.CLASSES.ATTR_1); attr1.classList.add(customBackgrounds.CLASSES.ATTR_1);
$(customBackgrounds.IDS.ATTRIBUTIONS).appendChild(attr1); $(customBackgrounds.IDS.ATTRIBUTIONS).appendChild(attr1);
} }
if (attributionLine2 != '') { if (attributionLine2 !== '') {
// Shouldn't be changed from textContent for security assurances. // Shouldn't be changed from textContent for security assurances.
attr2.textContent = attributionLine2; attr2.textContent = attributionLine2;
attr2.classList.add(customBackgrounds.CLASSES.ATTR_2); attr2.classList.add(customBackgrounds.CLASSES.ATTR_2);
attributionBox.appendChild(attr2); attributionBox.appendChild(attr2);
} }
if (attributionActionUrl != '') { if (attributionActionUrl !== '') {
var attr = (attributionLine2 != '' ? attr2 : attr1); var attr = (attributionLine2 !== '' ? attr2 : attr1);
attr.classList.add(customBackgrounds.CLASSES.ATTR_LINK); attr.classList.add(customBackgrounds.CLASSES.ATTR_LINK);
var linkIcon = document.createElement('div'); var linkIcon = document.createElement('div');
linkIcon.id = customBackgrounds.IDS.LINK_ICON; linkIcon.id = customBackgrounds.IDS.LINK_ICON;
// Enlarge link-icon when there is only one line of attribution
if (attributionLine2 === '')
linkIcon.classList.add(customBackgrounds.CLASSES.SINGLE_ATTR);
attr.insertBefore(linkIcon, attr.firstChild); attr.insertBefore(linkIcon, attr.firstChild);
attributionBox.classList.add(customBackgrounds.CLASSES.ATTR_LINK); attributionBox.classList.add(customBackgrounds.CLASSES.ATTR_LINK);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment