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

Side by Side Diff: chrome/browser/resources/ntp4/apps_page.js

Issue 7553020: Revert 94715 - Revert 94714 - Improve layout for bookmark-apps. Add treatment for small icons. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix up CSS, string, JS. Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 cr.define('ntp4', function() { 5 cr.define('ntp4', function() {
6 'use strict'; 6 'use strict';
7 7
8 var localStrings = new LocalStrings; 8 var localStrings = new LocalStrings;
9 9
10 var APP_LAUNCH = { 10 var APP_LAUNCH = {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 initialize: function() { 175 initialize: function() {
176 assert(this.appData_.id, 'Got an app without an ID'); 176 assert(this.appData_.id, 'Got an app without an ID');
177 this.id = this.appData_.id; 177 this.id = this.appData_.id;
178 178
179 this.className = 'app'; 179 this.className = 'app';
180 180
181 var appContents = this.ownerDocument.createElement('div'); 181 var appContents = this.ownerDocument.createElement('div');
182 appContents.className = 'app-contents'; 182 appContents.className = 'app-contents';
183 183
184 if (!this.appData_.icon_big_exists && this.appData_.icon_small_exists)
185 this.useSmallIcon_ = true;
186
184 var appImg = this.ownerDocument.createElement('img'); 187 var appImg = this.ownerDocument.createElement('img');
185 appImg.src = this.appData_.icon_big; 188 appImg.src = this.useSmallIcon_ ? this.appData_.icon_small :
186 // We use a mask of the same image so CSS rules can highlight just the 189 this.appData_.icon_big;
187 // image when it's touched. 190 if (this.useSmallIcon_) {
188 appImg.style.WebkitMaskImage = url(this.appData_.icon_big); 191 var imgDiv = this.ownerDocument.createElement('div');
189 // We put a click handler just on the app image - so clicking on the 192 imgDiv.className = 'app-icon-div';
190 // margins between apps doesn't do anything. 193 imgDiv.appendChild(appImg);
191 appImg.addEventListener('click', this.onClick_.bind(this)); 194 imgDiv.addEventListener('click', this.onClick_.bind(this));
192 appContents.appendChild(appImg); 195 this.imgDiv_ = imgDiv;
196 appContents.appendChild(imgDiv);
197 } else {
198 appImg.addEventListener('click', this.onClick_.bind(this));
199 appContents.appendChild(appImg);
200 }
193 this.appImg_ = appImg; 201 this.appImg_ = appImg;
194 202
195 var appSpan = this.ownerDocument.createElement('span'); 203 var appSpan = this.ownerDocument.createElement('span');
196 appSpan.textContent = this.appData_.name; 204 appSpan.textContent = this.appData_.name;
197 appContents.appendChild(appSpan); 205 appContents.appendChild(appSpan);
198 this.appendChild(appContents); 206 this.appendChild(appContents);
199 207
200 this.addEventListener('keydown', cr.ui.contextMenuHandler); 208 this.addEventListener('keydown', cr.ui.contextMenuHandler);
201 this.addEventListener('keyup', cr.ui.contextMenuHandler); 209 this.addEventListener('keyup', cr.ui.contextMenuHandler);
202 210
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 265
258 /** 266 /**
259 * Set the size and position of the app tile. 267 * Set the size and position of the app tile.
260 * @param {number} size The total size of |this|. 268 * @param {number} size The total size of |this|.
261 * @param {number} x The x-position. 269 * @param {number} x The x-position.
262 * @param {number} y The y-position. 270 * @param {number} y The y-position.
263 * animate. 271 * animate.
264 */ 272 */
265 setBounds: function(size, x, y) { 273 setBounds: function(size, x, y) {
266 var imgSize = size * APP_IMG_SIZE_FRACTION; 274 var imgSize = size * APP_IMG_SIZE_FRACTION;
267 this.appImg_.style.width = this.appImg_.style.height = imgSize + 'px'; 275 this.appImg_.style.width = this.appImg_.style.height =
276 this.useSmallIcon_ ? '32px' : imgSize + 'px';
277
278
268 this.style.width = this.style.height = size + 'px'; 279 this.style.width = this.style.height = size + 'px';
269 if (this.isStore_) 280 if (this.isStore_)
270 this.appsPromoExtras_.style.left = size + (imgSize - size) / 2 + 'px'; 281 this.appsPromoExtras_.style.left = size + (imgSize - size) / 2 + 'px';
271 282
272 this.style.left = x + 'px'; 283 this.style.left = x + 'px';
273 this.style.right = x + 'px'; 284 this.style.right = x + 'px';
274 this.style.top = y + 'px'; 285 this.style.top = y + 'px';
275 }, 286 },
276 287
277 /** 288 /**
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 AppsPage.setPromo = function(data) { 443 AppsPage.setPromo = function(data) {
433 var store = document.querySelector('.webstore'); 444 var store = document.querySelector('.webstore');
434 if (store) 445 if (store)
435 store.setAppsPromoData(data); 446 store.setAppsPromoData(data);
436 }; 447 };
437 448
438 return { 449 return {
439 AppsPage: AppsPage, 450 AppsPage: AppsPage,
440 }; 451 };
441 }); 452 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698