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

Side by Side Diff: chrome/browser/resources/ntp_search/new_tab.js

Issue 11445009: NTP5: Reuse insertion/removal animations for Apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing Dan's comment Created 8 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 /** 5 /**
6 * @fileoverview New tab page 6 * @fileoverview New tab page
7 * This is the main code for the new tab page. NewTabView manages page list, 7 * This is the main code for the new tab page. NewTabView manages page list,
8 * dot list and handles apps pages callbacks from backend. It also handles 8 * dot list and handles apps pages callbacks from backend. It also handles
9 * the layout of the Bottom Panel and the global UI states of the New Tab Page. 9 * the layout of the Bottom Panel and the global UI states of the New Tab Page.
10 */ 10 */
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 * 420 *
421 * Note that calls to this function can occur at any time, not just in 421 * Note that calls to this function can occur at any time, not just in
422 * response to a getApps request. For example, when a user 422 * response to a getApps request. For example, when a user
423 * installs/uninstalls an app on another synchronized devices. 423 * installs/uninstalls an app on another synchronized devices.
424 * @param {Object} data An object with all the data on available 424 * @param {Object} data An object with all the data on available
425 * applications. 425 * applications.
426 */ 426 */
427 getAppsCallback: function(data) { 427 getAppsCallback: function(data) {
428 assert(loadTimeData.getBoolean('showApps')); 428 assert(loadTimeData.getBoolean('showApps'));
429 429
430 var page = this.appsPage;
431 var state = page && page.getTileRepositioningState();
Dan Beam 2012/12/05 18:40:44 ^ so why is all this logic being removed?
pedro (no code reviews) 2012/12/05 20:03:55 This logic was placed in the wrong spot. It has be
432 if (state) {
433 if (state.isRemoving)
434 page.animateTileRemoval(state.index, data);
435 else
436 page.animateTileRestoration(state.index, data);
437
438 page.resetTileRepositioningState();
439 return;
440 }
441
442 var startTime = Date.now(); 430 var startTime = Date.now();
443 431
444 if (page)
445 page.removeAllTiles();
446
447 // Get the array of apps and add any special synthesized entries. 432 // Get the array of apps and add any special synthesized entries.
448 var apps = data.apps; 433 var apps = data.apps;
449 434
450 // Sort alphabetically. 435 // Sort alphabetically.
451 apps.sort(function(a, b) { 436 apps.sort(function(a, b) {
452 return a.title.toLocaleLowerCase() > b.title.toLocaleLowerCase() ? 1 : 437 return a.title.toLocaleLowerCase() > b.title.toLocaleLowerCase() ? 1 :
453 a.title.toLocaleLowerCase() < b.title.toLocaleLowerCase() ? -1 : 0; 438 a.title.toLocaleLowerCase() < b.title.toLocaleLowerCase() ? -1 : 0;
454 }); 439 });
455 440
456 // An app to animate (in case it was just installed). 441 // An app to animate (in case it was just installed).
457 var highlightApp; 442 var highlightApp;
458 443
459 // Add the apps, creating pages as necessary. 444 // Add the apps, creating pages as necessary.
460 this.appendTilePage(new ntp.AppsPage(), 445 var page = new ntp.AppsPage();
461 loadTimeData.getString('appDefaultPageName')); 446 page.setDataList(apps, false);
447
448 this.appendTilePage(page, loadTimeData.getString('appDefaultPageName'));
462 for (var i = 0; i < apps.length; i++) { 449 for (var i = 0; i < apps.length; i++) {
463 var app = apps[i]; 450 var app = apps[i];
464 if (app.id == this.highlightAppId) 451 if (app.id == this.highlightAppId)
465 highlightApp = app; 452 highlightApp = app;
466 else 453 else
467 this.appsPage.insertApp(app, false); 454 this.appsPage.insertApp(app, false);
468 } 455 }
469 456
470 if (highlightApp) 457 if (highlightApp)
471 this.appAdded(highlightApp, true); 458 this.appAdded(highlightApp, true);
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 setMostVisitedPages: setMostVisitedPages, 1143 setMostVisitedPages: setMostVisitedPages,
1157 setRecentlyClosedTabs: setRecentlyClosedTabs, 1144 setRecentlyClosedTabs: setRecentlyClosedTabs,
1158 showNotification: showNotification, 1145 showNotification: showNotification,
1159 themeChanged: themeChanged, 1146 themeChanged: themeChanged,
1160 }; 1147 };
1161 }); 1148 });
1162 1149
1163 document.addEventListener('DOMContentLoaded', ntp.onLoad); 1150 document.addEventListener('DOMContentLoaded', ntp.onLoad);
1164 1151
1165 var toCssPx = cr.ui.toCssPx; 1152 var toCssPx = cr.ui.toCssPx;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698