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

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: Rebase to head. 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));
192 appContents.appendChild(appImg); 193 if (this.useSmallIcon_) {
194 var imgDiv = this.ownerDocument.createElement('div');
195 imgDiv.setAttribute('class', 'app-icon-div');
Evan Stade 2011/08/02 21:47:14 imgDiv.class =
Greg Billock 2011/08/03 19:05:50 Done. (className)
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_) {
278 this.imgDiv_.style.width = imgSize + 'px';
279 this.imgDiv_.style.height = (imgSize - 4) + 'px';
280 this.appImg_.style.width = this.appImg_.style.height = '32px';
Evan Stade 2011/08/02 21:47:14 define in css file
Greg Billock 2011/08/03 19:05:50 These should really come from the icon size we cho
281 var margin = (size - imgSize) / 2;
282 this.imgDiv_.style['margin-left'] = margin + 'px';
Evan Stade 2011/08/02 21:47:14 marginLeft but I feel like you should be able to
Greg Billock 2011/08/03 19:05:50 Yeah, I moved these and got it looking better with
283 this.imgDiv_.style['margin-right'] = margin + 'px';
284 this.imgDiv_.style['margin-bottom'] = '4px';
Evan Stade 2011/08/02 21:47:14 define in css file
Greg Billock 2011/08/03 19:05:50 Done.
285 }
Evan Stade 2011/08/02 21:47:14 else on same line
Greg Billock 2011/08/03 19:05:50 Done.
286 else {
287 this.appImg_.style.width = this.appImg_.style.height = imgSize + 'px';
288 }
289
268 this.style.width = this.style.height = size + 'px'; 290 this.style.width = this.style.height = size + 'px';
269 if (this.isStore_) 291 if (this.isStore_)
270 this.appsPromoExtras_.style.left = size + (imgSize - size) / 2 + 'px'; 292 this.appsPromoExtras_.style.left = size + (imgSize - size) / 2 + 'px';
271 293
272 this.style.left = x + 'px'; 294 this.style.left = x + 'px';
273 this.style.right = x + 'px'; 295 this.style.right = x + 'px';
274 this.style.top = y + 'px'; 296 this.style.top = y + 'px';
275 }, 297 },
276 298
277 /** 299 /**
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 AppsPage.setPromo = function(data) { 454 AppsPage.setPromo = function(data) {
433 var store = document.querySelector('.webstore'); 455 var store = document.querySelector('.webstore');
434 if (store) 456 if (store)
435 store.setAppsPromoData(data); 457 store.setAppsPromoData(data);
436 }; 458 };
437 459
438 return { 460 return {
439 AppsPage: AppsPage, 461 AppsPage: AppsPage,
440 }; 462 };
441 }); 463 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp4/apps_page.css ('k') | chrome/browser/ui/webui/extension_icon_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698