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

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: Improve CSS 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.
188 appImg.style.WebkitMaskImage = url(this.appData_.icon_big);
189 // We put a click handler just on the app image - so clicking on the 190 // We put a click handler just on the app image - so clicking on the
190 // margins between apps doesn't do anything. 191 // margins between apps doesn't do anything.
191 appImg.addEventListener('click', this.onClick_.bind(this)); 192 appImg.addEventListener('click', this.onClick_.bind(this));
Evan Stade 2011/08/03 19:17:15 I think this is redundant in the useSmallIcon_ cas
Greg Billock 2011/08/03 21:15:50 Moved inside non-small-icon case and removed the c
192 appContents.appendChild(appImg); 193 if (this.useSmallIcon_) {
194 var imgDiv = this.ownerDocument.createElement('div');
195 imgDiv.className = 'app-icon-div';
196 imgDiv.appendChild(appImg);
197 imgDiv.addEventListener('click', this.onClick_.bind(this));
198 this.imgDiv_ = imgDiv;
199 appContents.appendChild(imgDiv);
200 } else {
201 appContents.appendChild(appImg);
202 }
193 this.appImg_ = appImg; 203 this.appImg_ = appImg;
194 204
195 var appSpan = this.ownerDocument.createElement('span'); 205 var appSpan = this.ownerDocument.createElement('span');
196 appSpan.textContent = this.appData_.name; 206 appSpan.textContent = this.appData_.name;
197 appContents.appendChild(appSpan); 207 appContents.appendChild(appSpan);
198 this.appendChild(appContents); 208 this.appendChild(appContents);
199 209
200 this.addEventListener('keydown', cr.ui.contextMenuHandler); 210 this.addEventListener('keydown', cr.ui.contextMenuHandler);
201 this.addEventListener('keyup', cr.ui.contextMenuHandler); 211 this.addEventListener('keyup', cr.ui.contextMenuHandler);
202 212
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 267
258 /** 268 /**
259 * Set the size and position of the app tile. 269 * Set the size and position of the app tile.
260 * @param {number} size The total size of |this|. 270 * @param {number} size The total size of |this|.
261 * @param {number} x The x-position. 271 * @param {number} x The x-position.
262 * @param {number} y The y-position. 272 * @param {number} y The y-position.
263 * animate. 273 * animate.
264 */ 274 */
265 setBounds: function(size, x, y) { 275 setBounds: function(size, x, y) {
266 var imgSize = size * APP_IMG_SIZE_FRACTION; 276 var imgSize = size * APP_IMG_SIZE_FRACTION;
267 this.appImg_.style.width = this.appImg_.style.height = imgSize + 'px'; 277 if (this.useSmallIcon_) {
Evan Stade 2011/08/03 19:17:15 yay reduced complexity. now you can use ternary op
Greg Billock 2011/08/03 21:15:50 Done.
278 this.appImg_.style.width = this.appImg_.style.height = '32px';
279 } else {
280 this.appImg_.style.width = this.appImg_.style.height = imgSize + 'px';
281 }
282
268 this.style.width = this.style.height = size + 'px'; 283 this.style.width = this.style.height = size + 'px';
269 if (this.isStore_) 284 if (this.isStore_)
270 this.appsPromoExtras_.style.left = size + (imgSize - size) / 2 + 'px'; 285 this.appsPromoExtras_.style.left = size + (imgSize - size) / 2 + 'px';
271 286
272 this.style.left = x + 'px'; 287 this.style.left = x + 'px';
273 this.style.right = x + 'px'; 288 this.style.right = x + 'px';
274 this.style.top = y + 'px'; 289 this.style.top = y + 'px';
275 }, 290 },
276 291
277 /** 292 /**
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 AppsPage.setPromo = function(data) { 447 AppsPage.setPromo = function(data) {
433 var store = document.querySelector('.webstore'); 448 var store = document.querySelector('.webstore');
434 if (store) 449 if (store)
435 store.setAppsPromoData(data); 450 store.setAppsPromoData(data);
436 }; 451 };
437 452
438 return { 453 return {
439 AppsPage: AppsPage, 454 AppsPage: AppsPage,
440 }; 455 };
441 }); 456 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698