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

Unified Diff: chrome/browser/resources/ntp4/apps_page.js

Issue 7452008: Improve layout for bookmark-apps. Add a treatment for small icons. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Review adjustments. Set div class correctly. Created 9 years, 5 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/ntp4/apps_page.js
diff --git a/chrome/browser/resources/ntp4/apps_page.js b/chrome/browser/resources/ntp4/apps_page.js
index 702c751b33db0502ee4729f6d1dc326f296e9051..5c8460fc1cadd24d52970323377b2ca207aa474d 100644
--- a/chrome/browser/resources/ntp4/apps_page.js
+++ b/chrome/browser/resources/ntp4/apps_page.js
@@ -178,15 +178,25 @@ cr.define('ntp4', function() {
this.className = 'app';
+ if (!this.appData_.icon_big_exists && this.appData_.icon_small_exists)
+ this.useSmallIcon_ = true;
+
var appImg = this.ownerDocument.createElement('img');
- appImg.src = this.appData_.icon_big;
- // We use a mask of the same image so CSS rules can highlight just the
- // image when it's touched.
- appImg.style.WebkitMaskImage = url(this.appData_.icon_big);
+ appImg.src = this.useSmallIcon_ ? this.appData_.icon_small
+ : this.appData_.icon_big;
Evan Stade 2011/07/28 23:21:33 I think technically : goes at the end of the previ
Greg Billock 2011/07/29 16:55:57 OK.
// We put a click handler just on the app image - so clicking on the
// margins between apps doesn't do anything.
appImg.addEventListener('click', this.onClick_.bind(this));
- this.appendChild(appImg);
+ if (this.useSmallIcon_) {
+ var imgDiv = this.ownerDocument.createElement('div');
+ imgDiv.setAttribute('class', 'app-icon-div');
+ imgDiv.appendChild(appImg);
+ imgDiv.addEventListener('click', this.onClick_.bind(this));
+ this.imgDiv_ = imgDiv;
+ this.appendChild(imgDiv);
+ } else {
+ this.appendChild(appImg);
+ }
this.appImg_ = appImg;
var appSpan = this.ownerDocument.createElement('span');
@@ -206,8 +216,20 @@ cr.define('ntp4', function() {
* animate.
*/
setBounds: function(size, x, y) {
- this.appImg_.style.width = this.appImg_.style.height =
- (size * APP_IMG_SIZE_FRACTION) + 'px';
+ if (this.useSmallIcon_) {
+ this.imgDiv_.style.width = (size * APP_IMG_SIZE_FRACTION) + 'px';
+ this.imgDiv_.style.height = (size * APP_IMG_SIZE_FRACTION - 4) + 'px';
+ this.appImg_.style.width = this.appImg_.style.height = '32px';
+ var margin = (size - (size * APP_IMG_SIZE_FRACTION)) / 2;
+ this.imgDiv_.style['margin-left'] = margin + 'px';
+ this.imgDiv_.style['margin-right'] = margin + 'px';
+ this.imgDiv_.style['margin-bottom'] = '4px';
+ }
+ else {
+ this.appImg_.style.width = this.appImg_.style.height =
+ (size * APP_IMG_SIZE_FRACTION) + 'px';
+ }
+
this.style.width = this.style.height = size + 'px';
this.style.left = x + 'px';

Powered by Google App Engine
This is Rietveld 408576698