Commit 224b1832 authored by estade@chromium.org's avatar estade@chromium.org

ntp4: respect non-default apps promo logo

BUG=none
TEST=manual (set logo to something else in preferences file)


Review URL: http://codereview.chromium.org/7602017

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96688 0039d316-1c4b-4281-b951-d872f2087c98
parent cc73fb3f
...@@ -26,15 +26,19 @@ ...@@ -26,15 +26,19 @@
white-space: nowrap; white-space: nowrap;
} }
.app-contents > img { .app-img-container {
cursor: pointer; cursor: pointer;
display: block;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
/* -webkit-mask-image set by JavaScript to the image source */ /* -webkit-mask-image set by JavaScript to the image source */
-webkit-mask-size: 100% 100%; -webkit-mask-size: 100% 100%;
} }
.app-img-container > * {
height: 100%;
width: 100%;
}
.app-icon-div { .app-icon-div {
/* TODO(gbillock): find a better style for this div. Better border color? */ /* TODO(gbillock): find a better style for this div. Better border color? */
border: 1px solid gray; border: 1px solid gray;
...@@ -68,6 +72,22 @@ ...@@ -68,6 +72,22 @@
display: none; display: none;
} }
.tile:only-of-type > .has-promo .app-img-container > .apps-promo-logo {
display: block;
}
.apps-promo-logo {
display: none;
}
.tile:only-of-type > .has-promo .app-img-container > img:first-child {
display: none;
}
.app-img-container > img:first-child {
display: block;
}
/* TODO(estade): animation? */ /* TODO(estade): animation? */
.tile:only-of-type > .has-promo > .apps-promo-extras { .tile:only-of-type > .has-promo > .apps-promo-extras {
display: block; display: block;
......
...@@ -181,22 +181,28 @@ cr.define('ntp4', function() { ...@@ -181,22 +181,28 @@ cr.define('ntp4', function() {
var appContents = this.ownerDocument.createElement('div'); var appContents = this.ownerDocument.createElement('div');
appContents.className = 'app-contents'; appContents.className = 'app-contents';
var appImgContainer = this.ownerDocument.createElement('div');
appImgContainer.className = 'app-img-container';
this.appImgContainer_ = appImgContainer;
if (!this.appData_.icon_big_exists && this.appData_.icon_small_exists) if (!this.appData_.icon_big_exists && this.appData_.icon_small_exists)
this.useSmallIcon_ = true; this.useSmallIcon_ = true;
var appImg = this.ownerDocument.createElement('img'); var appImg = this.ownerDocument.createElement('img');
appImg.src = this.useSmallIcon_ ? this.appData_.icon_small : appImg.src = this.useSmallIcon_ ? this.appData_.icon_small :
this.appData_.icon_big; this.appData_.icon_big;
appImgContainer.appendChild(appImg);
if (this.useSmallIcon_) { if (this.useSmallIcon_) {
var imgDiv = this.ownerDocument.createElement('div'); var imgDiv = this.ownerDocument.createElement('div');
imgDiv.className = 'app-icon-div'; imgDiv.className = 'app-icon-div';
imgDiv.appendChild(appImg); imgDiv.appendChild(appImgContainer);
imgDiv.addEventListener('click', this.onClick_.bind(this)); imgDiv.addEventListener('click', this.onClick_.bind(this));
this.imgDiv_ = imgDiv; this.imgDiv_ = imgDiv;
appContents.appendChild(imgDiv); appContents.appendChild(imgDiv);
} else { } else {
appImg.addEventListener('click', this.onClick_.bind(this)); appImgContainer.addEventListener('click', this.onClick_.bind(this));
appContents.appendChild(appImg); appContents.appendChild(appImgContainer);
} }
this.appImg_ = appImg; this.appImg_ = appImg;
...@@ -205,6 +211,7 @@ cr.define('ntp4', function() { ...@@ -205,6 +211,7 @@ cr.define('ntp4', function() {
appSpan.addEventListener('click', this.onClick_.bind(this)); appSpan.addEventListener('click', this.onClick_.bind(this));
appContents.appendChild(appSpan); appContents.appendChild(appSpan);
this.appendChild(appContents); this.appendChild(appContents);
this.appContents_ = appContents;
this.addEventListener('keydown', cr.ui.contextMenuHandler); this.addEventListener('keydown', cr.ui.contextMenuHandler);
this.addEventListener('keyup', cr.ui.contextMenuHandler); this.addEventListener('keyup', cr.ui.contextMenuHandler);
...@@ -239,12 +246,15 @@ cr.define('ntp4', function() { ...@@ -239,12 +246,15 @@ cr.define('ntp4', function() {
this.appsPromoHide_ = this.appsPromoHide_ =
this.appsPromoExtras_.querySelector('.apps-promo-hide'); this.appsPromoExtras_.querySelector('.apps-promo-hide');
this.appsPromoLogo_ = this.ownerDocument.createElement('img');
this.appsPromoLogo_.className = 'apps-promo-logo';
this.appImgContainer_.appendChild(this.appsPromoLogo_);
this.appsPromoHide_.addEventListener('click', this.appsPromoHide_.addEventListener('click',
this.onHidePromoClicked_.bind(this)); this.onHidePromoClicked_.bind(this));
this.appendChild(this.appsPromoExtras_); this.appendChild(this.appsPromoExtras_);
this.appsPromoExtras_.hidden = false; this.appsPromoExtras_.hidden = false;
// TODO(estade): A ping url needs to be set for the app icon.
}, },
/** /**
...@@ -274,6 +284,7 @@ cr.define('ntp4', function() { ...@@ -274,6 +284,7 @@ cr.define('ntp4', function() {
this.appsPromoLink_.href = data.promoLink; this.appsPromoLink_.href = data.promoLink;
this.appsPromoLink_.textContent = data.promoButton; this.appsPromoLink_.textContent = data.promoButton;
this.appsPromoHide_.textContent = data.promoExpire; this.appsPromoHide_.textContent = data.promoExpire;
this.appsPromoLogo_.src = data.promoLogo;
}, },
/** /**
...@@ -285,10 +296,9 @@ cr.define('ntp4', function() { ...@@ -285,10 +296,9 @@ cr.define('ntp4', function() {
*/ */
setBounds: function(size, x, y) { setBounds: function(size, x, y) {
var imgSize = size * APP_IMG_SIZE_FRACTION; var imgSize = size * APP_IMG_SIZE_FRACTION;
this.appImg_.style.width = this.appImg_.style.height = this.appImgContainer_.style.width = this.appImgContainer_.style.height =
this.useSmallIcon_ ? '32px' : imgSize + 'px'; this.useSmallIcon_ ? '32px' : imgSize + 'px';
this.style.width = this.style.height = size + 'px'; this.style.width = this.style.height = size + 'px';
if (this.isStore_) if (this.isStore_)
this.appsPromoExtras_.style.left = size + (imgSize - size) / 2 + 'px'; this.appsPromoExtras_.style.left = size + (imgSize - size) / 2 + 'px';
......
...@@ -198,8 +198,10 @@ cr.define('ntp4', function() { ...@@ -198,8 +198,10 @@ cr.define('ntp4', function() {
*/ */
doDrop: function(e) { doDrop: function(e) {
e.stopPropagation(); e.stopPropagation();
if (ntp4.getCurrentlyDraggingTile) if (ntp4.getCurrentlyDraggingTile) {
this.page_.appendDraggingTile(); this.page_.appendDraggingTile();
this.page_.cleanupDrag();
}
// TODO(estade): handle non-tile drags. // TODO(estade): handle non-tile drags.
this.cancelDelayedSwitch_(); this.cancelDelayedSwitch_();
......
...@@ -901,8 +901,9 @@ cr.define('ntp4', function() { ...@@ -901,8 +901,9 @@ cr.define('ntp4', function() {
this.tileElements_[adjustedIndex]); this.tileElements_[adjustedIndex]);
this.tileMoved(currentlyDraggingTile); this.tileMoved(currentlyDraggingTile);
} else { } else {
var originalPage = currentlyDraggingTile.tilePage;
this.addDragData(e.dataTransfer, adjustedIndex); this.addDragData(e.dataTransfer, adjustedIndex);
currentlyDraggingTile.tilePage.cleanupDrag(); originalPage.cleanupDrag();
} }
// Dropping the icon may cause topMargin to change, but changing it // Dropping the icon may cause topMargin to change, but changing it
...@@ -924,7 +925,7 @@ cr.define('ntp4', function() { ...@@ -924,7 +925,7 @@ cr.define('ntp4', function() {
if (originalPage == this) if (originalPage == this)
return; return;
this.addDragData(null, this.tileElements_.length - 1); this.addDragData(null, this.tileElements_.length);
originalPage.cleanupDrag(); originalPage.cleanupDrag();
}, },
......
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